📄 tabset.js
字号:
} return null;},// override draw to make sure we have a tab selected, and to fire 'tabSelected()' on the tabdraw : function (a,b,c,d) { if (this.tabs && this.tabs.length > 0) { var selectedTab = this.getSelectedTabNumber(); // Don't allow a bad selectedTab value to persist. if (!isc.isA.Number(selectedTab) || selectedTab < 0) selectedTab = this.selectedTab = 0; // Ensure it's selected in the tab-bar - will no op if already selected, otherwise // will perform selection and fire our handlers this._tabBar.selectTab(selectedTab); } this.invokeSuper(isc.TabSet, "draw", a,b,c,d); this.fixLayout();},//> @method tabSet.setTabTitle() (A)// Changes the title of a tab// @param tab (Tab | number | ID)// @param title (HTML) new title// @visibility external// @example titleChange//<setTabTitle : function (tab, title) { this.getTab(tab).setTitle(title);},//>@method tabSet.enableTab() // If the specified tab is disabled, enable it now.// @param tab (Tab | number | ID)// @see tab.disabled// @visibility external//<enableTab : function (tab) { this.setTabDisabled(tab, false);},//>@method tabSet.disableTab() // If the specified tab is enabled, disable it now.// @param tab (Tab | number | ID)// @see tab.disabled// @visibility external//<disableTab : function (tab) { this.setTabDisabled(tab, true);},// Actually set the disabled property on a tab. Handled by just disabling the button.setTabDisabled : function (tab, disabled) { var tab = this.getTab(tab); if (tab) { // disable the tab so you can't access it. tab.setDisabled(disabled); // Also disable the pane in case it's showing. // Alternative approach would be to deselect the tab, if selected. The problem with // this is we may only have one tab in the tabSet. var pane = tab.pane; if (pane) { if (isc.isA.Canvas(pane)) pane.setDisabled(disabled); else pane.disabled = disabled; } }},//> @method tabSet.addTab() (A)// Add a tab// @param tab (Tab) new tab// @param position (number) position where tab should be added// @see TabSet.addTabs// @visibility external// @example tabsAddAndRemove//<addTab : function (tab, position) { return this.addTabs(tab, position);},//> @method tabSet.addTabs() (A)// Add one or more tabs// @param tabs (Tab or Array of Tab) new tab or tabs// @param position (number) position where tab should be added (or array of positions)// @see TabSet.addTab// @visibility external//<addTabs : function (newTabs, position) { if (!isc.isAn.Array(newTabs)) newTabs = [newTabs]; var oldSelectedTab = this.getTab(this.getSelectedTabNumber()), forceSelection = (this.getSelectedTabNumber() == -1); if (position == null || position > this.tabs.length) position = this.tabs.length; for (var i = 0; i < newTabs.length; i++) { // use 'createPane' to turn the pane into a hidden, deparented canvas. newTabs[i].pane = this.createPane(newTabs[i].pane); // apply tabProperties (see comment in makeTabBar) var undef; for (var propName in this.tabProperties) { if (newTabs[i][propName] === undef) { newTabs[i][propName] = this.tabProperties[propName]; } } // Actually add the tab to the config this.tabs.addAt(newTabs[i], (position + i)) } this._tabBar.addTabs(newTabs, position); // If we have a pickerMenu, destroy it so it gets rebuilt when next required if (this._pickerMenu != null) { this._pickerMenu.destroy(); delete this._pickerMenu; } // call fixLayout on a delay // Necessary in case the new tabs introduced clipping of the tab-bar // Delay required as layout reflow is asynch this.delayCall("fixLayout"); if (forceSelection) { // If we didn't have a selected tab at the start of this method, ensure we select the // first of the new tabs this.selectTab(0); } else { // otherwise, update this.selectedTab (an index) in case tabs were added before the old // selected tab this.selectedTab = this.getTabNumber(oldSelectedTab); } return position;},//> @method tabSet.removeTab() (A)// Remove a tab.// <P>// The pane associated with the removed tab is automatically destroyed when you// call this method. To avoid this, call +link{updateTab()} with <code>null</code> as the new// pane immediately before removing the tab.// // @param tabs (Tab | ID | number | Array of Tab) list of tabs, tabIDs, or tab numbers// // @see TabSet.removeTabs// @visibility external// @example tabsAddAndRemove//<removeTab : function (tab, dontDestroy) { return this.removeTabs(tab, dontDestroy);},//> @method tabSet.removeTabs() (A)// Remove one or more tabs. The pane(s) associated with the removed tab(s) is automatically// destroyed when you call this method.//// @param tabs (Tab | ID | number) list of tabs, tabIDs, or tab numbers//// @see TabSet.removeTab// @visibility external//<removeTabs : function (tabs, dontDestroy) { if (!isc.isAn.Array(tabs)) tabs = [tabs]; // get the actual tab button object from whatever was passed in. // We can pass this to tabBar.removeTabs() tabs = this.map("getTab", tabs); var removedSelected = false, selectedTab = this.getSelectedTab(); for (var i = 0; i < tabs.length; i++) { // remove the tab from the config var tab = tabs[i], index = this.getTabNumber(tab), tabObject = this.tabs[index]; if (tabObject == selectedTab) removedSelected = true; this.tabs.removeAt(index); // remove the pane var pane = tabObject.pane; if (pane && pane.parentElement == this.paneContainer) { this.paneContainer.removeChild(pane); if (!dontDestroy && this.destroyPanes !== false) pane.destroy(); } // remove the tab button this._tabBar.removeTabs(tab); } // if the selected tab was removed, select the first tab if we have any if (removedSelected && this.tabs.length > 0) this.selectTab(0); // If we have a pickerMenu, destroy it so it gets rebuilt when next required if (this._pickerMenu != null) { this._pickerMenu.destroy(); delete this._pickerMenu; } // call fixLayout on a delay // Necessary in case the removed tabs get rid of clipping of the tab-bar // Delay required as layout reflow is asynch this.delayCall("fixLayout", 0);},//> @method tabSet.canCloseTab()// Returns true if this tab is closeable. Determined by checking +link{tab.canClose} and// +link{tabSet.canCloseTabs}.// @param tab (int | ID | Tab) tab to check// @return (boolean) true if tab is closeable//<canCloseTab : function (tab) { if (!isc.isAn.Object(tab)) tab = this.getTabObject(tab); if (tab && tab.canClose != null) return tab.canClose; return this.canCloseTabs;},_tabIconClick : function(tab) { var shouldClose = this.canCloseTab(tab); if (shouldClose) { this.removeTab(tab); return false; } else return this.tabIconClick(tab); },//> @method tabSet.closeClick()// Method fired when the user clicks the "close" icon for a tab.<br>// This icon will be visible if +link{tab.canClose} is true for the tab in question.<br>// Default implementation will remove the tab from the tabSet.// @param tab (Tab) tab to close// @visibility external//<closeClick : function (tab) { this.removeTab(tab);},//> @method tabSet.tabIconClick()// Method fired when the user clicks the icon for a tab, as specified via +link{tab.icon}.<br>// Default behavior will fire <code>icon.click()</code> if specified, with a single parameter "tab".// @param tab (Tab) with click handler being fired// @visibility external//<tabIconClick : function (tab) { var icon = tab.icon; if (icon && icon.click) return this.fireCallback(icon.click, 'tab', [tab]);},//> @method tabSet.getTabObject()// Get the tab Object originally passed to +link{tabSet.tabs}, by index or ID.// If passed a tab Object, just returns it.//// @param tab (int | ID | Tab)// @return (Tab) the tab, or null if not found// @visibility external//<// NOTE: this returns the tab configuration object, not the button, since there may not be a// Button.getTabObject : function (tab) { // passed the tab button - determine it's index (use this below) tab = this.getTabNumber(tab); return this.tabs[tab];},//> @method tabSet.getTab()// Get the live Canvas representing a tab by index or ID. // If passed a tab Canvas, just returns it.// <P>// Note that live Tab instances are not available until +link{Canvas.draw,draw()}.// <P>// The returned Tab is considered an internal component of the TabSet. In order to maximize// forward compatibility, manipulate tabs through APIs such as a +link{setTabTitle()} instead.// Also note that a super-lightweight TabSet implementation may not use a separate Canvas per// Tab, and code that accesses an manipulates Tabs as Canvases won't be compatible with that// implementation.//// @param tab (int | ID | Canvas)// @return (Tab) the tab Canvas, or null if not found or TabSet not drawn yet//// @visibility external//<getTab : function (tab) { // already the tab button, return it if (isc.isAn.Canvas(tab)) return tab; if (!this.tabs) return null; // if we have a tab-config block, convert it to an index, since the tabBar doesn't see our // 'tabs' array if (this.tabs.contains(tab)) tab = this.tabs.indexOf(tab); // getButton on the tabBar handles the various possible types of the tab identifier passed in tab = this.getTabBar().getButton(tab); return tab;},//> @method tabSet.getTabPane()// Returns the pane for a given tab.//// @param tab (object | number | ID | Tab)// @return (Canvas) the tab pane// @visibility external//<getTabPane : function (tab) { return this.getTabObject(tab).pane;},//> @method tabSet.findTab()// Returns a the first tab in the list that matches the user-passed property name/value pair.//// @param propertyName (String) name of the property to look for// @param propertyValue (Any) value of the property//<findTabObject : function (propertyName, propertyValue) { return this.tabs.find(propertyName, propertyValue);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -