- */
- setMenuPrefixText : function(t) {
- this.menuPrefixText = t;
- },
- // private && applied to the tab panel itself.
- parentOverrides : {
- // all execute within the scope of the tab panel
- // private
- showTabsMenu : function(e) {
- if (this.tabsMenu) {
- this.tabsMenu.destroy();
- this.un('destroy', this.tabsMenu.destroy, this.tabsMenu);
- this.tabsMenu = null;
- }
- this.tabsMenu = new Ext.menu.Menu();
- this.on('destroy', this.tabsMenu.destroy, this.tabsMenu);
-
- this.generateTabMenuItems();
-
- var target = Ext.get(e.getTarget());
- var xy = target.getXY();
-//
- //Y param + 24 pixels
- xy[1] += 24;
-
- this.tabsMenu.showAt(xy);
- },
- // private
- generateTabMenuItems : function() {
- var curActive = this.getActiveTab();
- var totalItems = this.items.getCount();
- var pageSize = this.tabScrollerMenu.getPageSize();
-
-
- if (totalItems > pageSize) {
- var numSubMenus = Math.floor(totalItems / pageSize);
- var remainder = totalItems % pageSize;
-
- // Loop through all of the items and create submenus in chunks of 10
- for (var i = 0 ; i < numSubMenus; i++) {
- var curPage = (i + 1) * pageSize;
- var menuItems = [];
-
-
- for (var x = 0; x < pageSize; x++) {
- index = x + curPage - pageSize;
- var item = this.items.get(index);
- menuItems.push(this.autoGenMenuItem(item));
- }
-
- this.tabsMenu.add({
- text : this.tabScrollerMenu.getMenuPrefixText() + ' ' + (curPage - pageSize + 1) + ' - ' + curPage,
- menu : menuItems
- });
-
- }
- // remaining items
- if (remainder > 0) {
- var start = numSubMenus * pageSize;
- menuItems = [];
- for (var i = start ; i < totalItems; i ++ ) {
- var item = this.items.get(i);
- menuItems.push(this.autoGenMenuItem(item));
- }
-
- this.tabsMenu.add({
- text : this.tabScrollerMenu.menuPrefixText + ' ' + (start + 1) + ' - ' + (start + menuItems.length),
- menu : menuItems
- });
-
- }
- }
- else {
- this.items.each(function(item) {
- if (item.id != curActive.id && !item.hidden) {
- this.tabsMenu.add(this.autoGenMenuItem(item));
- }
- }, this);
- }
- },
- // private
- autoGenMenuItem : function(item) {
- var maxText = this.tabScrollerMenu.getMaxText();
- var text = Ext.util.Format.ellipsis(item.title, maxText);
-
- return {
- text : text,
- handler : this.showTabFromMenu,
- scope : this,
- disabled : item.disabled,
- tabToShow : item,
- iconCls : item.iconCls
- }
-
- },
- // private
- showTabFromMenu : function(menuItem) {
- this.setActiveTab(menuItem.tabToShow);
- }
- }
+ */
+ setMenuPrefixText: function(t) {
+ this.menuPrefixText = t;
+ },
+
+ showTabsMenu: function(e) {
+ var me = this;
+
+ if (me.tabsMenu) {
+ me.tabsMenu.removeAll();
+ } else {
+ me.tabsMenu = Ext.create('Ext.menu.Menu');
+ me.tabPanel.on('destroy', me.tabsMenu.destroy, me.tabsMenu);
+ }
+
+ me.generateTabMenuItems();
+
+ var target = Ext.get(e.getTarget());
+ var xy = target.getXY();
+
+ //Y param + 24 pixels
+ xy[1] += 24;
+
+ me.tabsMenu.showAt(xy);
+ },
+
+ // private
+ generateTabMenuItems: function() {
+ var me = this,
+ tabPanel = me.tabPanel,
+ curActive = tabPanel.getActiveTab(),
+ totalItems = tabPanel.items.getCount(),
+ pageSize = me.getPageSize(),
+ numSubMenus = Math.floor(totalItems / pageSize),
+ remainder = totalItems % pageSize,
+ i, curPage, menuItems, x, item, start, index;
+
+ if (totalItems > pageSize) {
+
+ // Loop through all of the items and create submenus in chunks of 10
+ for (i = 0; i < numSubMenus; i++) {
+ curPage = (i + 1) * pageSize;
+ menuItems = [];
+
+ for (x = 0; x < pageSize; x++) {
+ index = x + curPage - pageSize;
+ item = tabPanel.items.get(index);
+ menuItems.push(me.autoGenMenuItem(item));
+ }
+
+ me.tabsMenu.add({
+ text: me.getMenuPrefixText() + ' ' + (curPage - pageSize + 1) + ' - ' + curPage,
+ menu: menuItems
+ });
+ }
+ // remaining items
+ if (remainder > 0) {
+ start = numSubMenus * pageSize;
+ menuItems = [];
+ for (i = start; i < totalItems; i++) {
+ item = tabPanel.items.get(i);
+ menuItems.push(me.autoGenMenuItem(item));
+ }
+
+ me.tabsMenu.add({
+ text: me.menuPrefixText + ' ' + (start + 1) + ' - ' + (start + menuItems.length),
+ menu: menuItems
+ });
+
+ }
+ }
+ else {
+ tabPanel.items.each(function(item) {
+ if (item.id != curActive.id && !item.hidden) {
+ me.tabsMenu.add(me.autoGenMenuItem(item));
+ }
+ });
+ }
+ },
+
+ // private
+ autoGenMenuItem: function(item) {
+ var maxText = this.getMaxText(),
+ text = Ext.util.Format.ellipsis(item.title, maxText);
+
+ return {
+ text: text,
+ handler: this.showTabFromMenu,
+ scope: this,
+ disabled: item.disabled,
+ tabToShow: item,
+ iconCls: item.iconCls
+ };
+ },
+
+ // private
+ showTabFromMenu: function(menuItem) {
+ this.tabPanel.setActiveTab(menuItem.tabToShow);
+ }