744 lines
No EOL
30 KiB
HTML
744 lines
No EOL
30 KiB
HTML
<html><head><title>TabPanel.js</title><link rel="stylesheet" type="text/css" href="../resources/style.css" media="screen"/></head><body><h1>TabPanel.js</h1><pre class="highlighted"><code><i>/**
|
|
* @class Ext.TabPanel
|
|
* @extends Ext.util.Observable
|
|
* Creates a lightweight TabPanel component using Yahoo! UI.
|
|
* <br><br>
|
|
* Usage:
|
|
* <pre><code>
|
|
<font color="#008000"><i>// basic tabs 1, built from existing content</font></i>
|
|
<b>var</b> tabs = <b>new</b> Ext.TabPanel("tabs1");
|
|
tabs.addTab("script", "View Script");
|
|
tabs.addTab("markup", "View Markup");
|
|
tabs.activate("script");
|
|
|
|
<font color="#008000"><i>// more advanced tabs, built from javascript</font></i>
|
|
<b>var</b> jtabs = <b>new</b> Ext.TabPanel("jtabs");
|
|
jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
|
|
|
|
<font color="#008000"><i>// set up the UpdateManager</font></i>
|
|
<b>var</b> tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
|
|
<b>var</b> updater = tab2.getUpdateManager();
|
|
updater.setDefaultUrl("ajax1.htm");
|
|
tab2.on('activate', updater.refresh, updater, true);
|
|
|
|
<font color="#008000"><i>// Use setUrl <b>for</b> Ajax loading</font></i>
|
|
<b>var</b> tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
|
|
tab3.setUrl("ajax2.htm", null, true);
|
|
|
|
<font color="#008000"><i>// Disabled tab</font></i>
|
|
<b>var</b> tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can"t see me cause I"m disabled");
|
|
tab4.disable();
|
|
|
|
jtabs.activate("jtabs-1");
|
|
}
|
|
* </code></pre>
|
|
* @constructor
|
|
* Create <b>new</b> TabPanel.
|
|
* @param {String/HTMLElement/Element} container The id, DOM element or Ext.Element container where <b>this</b> TabPanel is to be rendered.
|
|
* @param {Boolean} config Config object to set any properties <b>for</b> this TabPanel or true to render the tabs on the bottom.
|
|
*/</i>
|
|
Ext.TabPanel = <b>function</b>(container, config){
|
|
<i>/**
|
|
* The container element <b>for</b> this TabPanel.
|
|
* @type Ext.Element
|
|
*/</i>
|
|
<b>this</b>.el = Ext.get(container, true);
|
|
<b>if</b>(config){
|
|
<b>if</b>(typeof config == "boolean"){
|
|
<b>this</b>.tabPosition = config ? "bottom" : "top";
|
|
}<b>else</b>{
|
|
Ext.apply(<b>this</b>, config);
|
|
}
|
|
}
|
|
<b>if</b>(this.tabPosition == "bottom"){
|
|
<b>this</b>.bodyEl = Ext.get(<b>this</b>.createBody(<b>this</b>.el.dom));
|
|
<b>this</b>.el.addClass("x-tabs-bottom");
|
|
}
|
|
<b>this</b>.stripWrap = Ext.get(<b>this</b>.createStrip(<b>this</b>.el.dom), true);
|
|
<b>this</b>.stripEl = Ext.get(<b>this</b>.createStripList(<b>this</b>.stripWrap.dom), true);
|
|
<b>this</b>.stripBody = Ext.get(<b>this</b>.stripWrap.dom.firstChild.firstChild, true);
|
|
<b>if</b>(Ext.isIE){
|
|
Ext.fly(<b>this</b>.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
|
|
}
|
|
<b>if</b>(this.tabPosition != "bottom"){
|
|
<i>/** The body element that contains TabPaneItem bodies.
|
|
* @type Ext.Element
|
|
*/</i>
|
|
<b>this</b>.bodyEl = Ext.get(<b>this</b>.createBody(<b>this</b>.el.dom));
|
|
<b>this</b>.el.addClass("x-tabs-top");
|
|
}
|
|
<b>this</b>.items = [];
|
|
|
|
<b>this</b>.bodyEl.setStyle("position", "relative");
|
|
|
|
<b>this</b>.active = null;
|
|
<b>this</b>.activateDelegate = <b>this</b>.activate.createDelegate(<b>this</b>);
|
|
|
|
<b>this</b>.addEvents({
|
|
<i>/**
|
|
* @event tabchange
|
|
* Fires when the active tab changes
|
|
* @param {Ext.TabPanel} <b>this</b>
|
|
* @param {Ext.TabPanelItem} activePanel The <b>new</b> active tab
|
|
*/</i>
|
|
"tabchange": true,
|
|
<i>/**
|
|
* @event beforetabchange
|
|
* Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
|
|
* @param {Ext.TabPanel} <b>this</b>
|
|
* @param {Object} e Set cancel to true on <b>this</b> object to cancel the tab change
|
|
* @param {Ext.TabPanelItem} tab The tab being changed to
|
|
*/</i>
|
|
"beforetabchange" : true
|
|
});
|
|
|
|
Ext.EventManager.onWindowResize(<b>this</b>.onResize, <b>this</b>);
|
|
<b>this</b>.cpad = <b>this</b>.el.getPadding("lr");
|
|
<b>this</b>.hiddenCount = 0;
|
|
|
|
Ext.TabPanel.superclass.constructor.call(<b>this</b>);
|
|
};
|
|
|
|
Ext.extend(Ext.TabPanel, Ext.util.Observable, {
|
|
<i>/** The position of the tabs. Can be "top" or "bottom" @type String */</i>
|
|
tabPosition : "top",
|
|
currentTabWidth : 0,
|
|
<i>/** The minimum width of a tab (ignored <b>if</b> resizeTabs is not true). @type Number */</i>
|
|
minTabWidth : 40,
|
|
<i>/** The maximum width of a tab (ignored <b>if</b> resizeTabs is not true). @type Number */</i>
|
|
maxTabWidth : 250,
|
|
<i>/** The preferred (<b>default</b>) width of a tab (ignored <b>if</b> resizeTabs is not true). @type Number */</i>
|
|
preferredTabWidth : 175,
|
|
<i>/** Set <b>this</b> to true to enable dynamic tab resizing. @type Boolean */</i>
|
|
resizeTabs : false,
|
|
<i>/** Set <b>this</b> to true to turn on window resizing monitoring (ignored <b>if</b> resizeTabs is not true). @type Boolean */</i>
|
|
monitorResize : true,
|
|
|
|
<i>/**
|
|
* Creates a <b>new</b> TabPanelItem by looking <b>for</b> an existing element <b>with</b> the provided id - <b>if</b> it's not found it creates one.
|
|
* @param {String} id The id of the div to use <b>or create</b>
|
|
* @param {String} text The text <b>for</b> the tab
|
|
* @param {String} content (optional) Content to put <b>in</b> the TabPanelItem body
|
|
* @param {Boolean} closable (optional) True to create a close icon on the tab
|
|
* @<b>return</b> {Ext.TabPanelItem} The created TabPanelItem
|
|
*/</i>
|
|
addTab : <b>function</b>(id, text, content, closable){
|
|
<b>var</b> item = <b>new</b> Ext.TabPanelItem(<b>this</b>, id, text, closable);
|
|
<b>this</b>.addTabItem(item);
|
|
<b>if</b>(content){
|
|
item.setContent(content);
|
|
}
|
|
<b>return</b> item;
|
|
},
|
|
|
|
<i>/**
|
|
* Returns the TabPanelItem <b>with</b> the specified id/index
|
|
* @param {String/Number} id The id or index of the TabPanelItem to fetch.
|
|
* @<b>return</b> {Ext.TabPanelItem}
|
|
*/</i>
|
|
getTab : <b>function</b>(id){
|
|
<b>return</b> this.items[id];
|
|
},
|
|
|
|
<i>/**
|
|
* Hides the TabPanelItem <b>with</b> the specified id/index
|
|
* @param {String/Number} id The id or index of the TabPanelItem to hide.
|
|
*/</i>
|
|
hideTab : <b>function</b>(id){
|
|
<b>var</b> t = <b>this</b>.items[id];
|
|
<b>if</b>(!t.isHidden()){
|
|
t.setHidden(true);
|
|
<b>this</b>.hiddenCount++;
|
|
<b>this</b>.autoSizeTabs();
|
|
}
|
|
},
|
|
|
|
<i>/**
|
|
* "Unhides" the TabPanelItem <b>with</b> the specified id/index
|
|
* @param {String/Number} id The id or index of the TabPanelItem to unhide.
|
|
*/</i>
|
|
unhideTab : <b>function</b>(id){
|
|
<b>var</b> t = <b>this</b>.items[id];
|
|
<b>if</b>(t.isHidden()){
|
|
t.setHidden(false);
|
|
<b>this</b>.hiddenCount--;
|
|
<b>this</b>.autoSizeTabs();
|
|
}
|
|
},
|
|
|
|
<i>/**
|
|
* Add an existing TabPanelItem.
|
|
* @param {Ext.TabPanelItem} item The TabPanelItem to add
|
|
*/</i>
|
|
addTabItem : <b>function</b>(item){
|
|
<b>this</b>.items[item.id] = item;
|
|
<b>this</b>.items.push(item);
|
|
<b>if</b>(this.resizeTabs){
|
|
item.setWidth(<b>this</b>.currentTabWidth || <b>this</b>.preferredTabWidth);
|
|
<b>this</b>.autoSizeTabs();
|
|
}<b>else</b>{
|
|
item.autoSize();
|
|
}
|
|
},
|
|
|
|
<i>/**
|
|
* Remove a TabPanelItem.
|
|
* @param {String/Number} id The id or index of the TabPanelItem to remove.
|
|
*/</i>
|
|
removeTab : <b>function</b>(id){
|
|
<b>var</b> items = <b>this</b>.items;
|
|
<b>var</b> tab = items[id];
|
|
<b>if</b>(!tab) <b>return</b>;
|
|
<b>var</b> index = items.indexOf(tab);
|
|
<b>if</b>(this.active == tab && items.length > 1){
|
|
<b>var</b> newTab = <b>this</b>.getNextAvailable(index);
|
|
<b>if</b>(newTab)newTab.activate();
|
|
}
|
|
<b>this</b>.stripEl.dom.removeChild(tab.pnode.dom);
|
|
<b>if</b>(tab.bodyEl.dom.parentNode == <b>this</b>.bodyEl.dom){ <i>// <b>if</b> it was moved already prevent error</i>
|
|
<b>this</b>.bodyEl.dom.removeChild(tab.bodyEl.dom);
|
|
}
|
|
items.splice(index, 1);
|
|
<b>delete</b> this.items[tab.id];
|
|
tab.fireEvent("close", tab);
|
|
tab.purgeListeners();
|
|
<b>this</b>.autoSizeTabs();
|
|
},
|
|
|
|
getNextAvailable : <b>function</b>(start){
|
|
<b>var</b> items = <b>this</b>.items;
|
|
<b>var</b> index = start;
|
|
<i>// look <b>for</b> a next tab that will slide over to</i>
|
|
<i>// replace the one being removed</i>
|
|
<b>while</b>(index < items.length){
|
|
<b>var</b> item = items[++index];
|
|
<b>if</b>(item && !item.isHidden()){
|
|
<b>return</b> item;
|
|
}
|
|
}
|
|
<i>// <b>if</b> one isn't found select the previous tab (on the left)</i>
|
|
index = start;
|
|
<b>while</b>(index >= 0){
|
|
<b>var</b> item = items[--index];
|
|
<b>if</b>(item && !item.isHidden()){
|
|
<b>return</b> item;
|
|
}
|
|
}
|
|
<b>return</b> null;
|
|
},
|
|
|
|
<i>/**
|
|
* Disable a TabPanelItem. <b>It cannot be the active tab, <b>if</b> it is <b>this</b> call is ignored.</b>.
|
|
* @param {String/Number} id The id or index of the TabPanelItem to disable.
|
|
*/</i>
|
|
disableTab : <b>function</b>(id){
|
|
<b>var</b> tab = <b>this</b>.items[id];
|
|
<b>if</b>(tab && <b>this</b>.active != tab){
|
|
tab.disable();
|
|
}
|
|
},
|
|
|
|
<i>/**
|
|
* Enable a TabPanelItem that is disabled.
|
|
* @param {String/Number} id The id or index of the TabPanelItem to enable.
|
|
*/</i>
|
|
enableTab : <b>function</b>(id){
|
|
<b>var</b> tab = <b>this</b>.items[id];
|
|
tab.enable();
|
|
},
|
|
|
|
<i>/**
|
|
* Activate a TabPanelItem. The currently active will be deactivated.
|
|
* @param {String/Number} id The id or index of the TabPanelItem to activate.
|
|
*/</i>
|
|
activate : <b>function</b>(id){
|
|
<b>var</b> tab = <b>this</b>.items[id];
|
|
<b>if</b>(!tab){
|
|
<b>return</b> null;
|
|
}
|
|
<b>if</b>(tab == <b>this</b>.active){
|
|
<b>return</b> tab;
|
|
}
|
|
<b>var</b> e = {};
|
|
<b>this</b>.fireEvent("beforetabchange", <b>this</b>, e, tab);
|
|
<b>if</b>(e.cancel !== true && !tab.disabled){
|
|
<b>if</b>(this.active){
|
|
<b>this</b>.active.hide();
|
|
}
|
|
<b>this</b>.active = <b>this</b>.items[id];
|
|
<b>this</b>.active.show();
|
|
<b>this</b>.fireEvent("tabchange", <b>this</b>, <b>this</b>.active);
|
|
}
|
|
<b>return</b> tab;
|
|
},
|
|
|
|
<i>/**
|
|
* Get the active TabPanelItem
|
|
* @<b>return</b> {Ext.TabPanelItem} The active TabPanelItem or null <b>if</b> none are active.
|
|
*/</i>
|
|
getActiveTab : <b>function</b>(){
|
|
<b>return</b> this.active;
|
|
},
|
|
|
|
<i>/**
|
|
* Updates the tab body element to fit the height of the container element
|
|
* <b>for</b> overflow scrolling
|
|
* @param {Number} targetHeight (optional) Override the starting height from the elements height
|
|
*/</i>
|
|
syncHeight : <b>function</b>(targetHeight){
|
|
<b>var</b> height = (targetHeight || <b>this</b>.el.getHeight())-<b>this</b>.el.getBorderWidth("tb")-<b>this</b>.el.getPadding("tb");
|
|
<b>var</b> bm = <b>this</b>.bodyEl.getMargins();
|
|
<b>var</b> newHeight = height-(<b>this</b>.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
|
|
<b>this</b>.bodyEl.setHeight(newHeight);
|
|
<b>return</b> newHeight;
|
|
},
|
|
|
|
onResize : <b>function</b>(){
|
|
<b>if</b>(this.monitorResize){
|
|
<b>this</b>.autoSizeTabs();
|
|
}
|
|
},
|
|
|
|
<i>/**
|
|
* Disables tab resizing <b>while</b> tabs are being added (<b>if</b> resizeTabs is false <b>this</b> does nothing)
|
|
*/</i>
|
|
beginUpdate : <b>function</b>(){
|
|
<b>this</b>.updating = true;
|
|
},
|
|
|
|
<i>/**
|
|
* Stops an update and resizes the tabs (<b>if</b> resizeTabs is false <b>this</b> does nothing)
|
|
*/</i>
|
|
endUpdate : <b>function</b>(){
|
|
<b>this</b>.updating = false;
|
|
<b>this</b>.autoSizeTabs();
|
|
},
|
|
|
|
<i>/**
|
|
* Manual call to resize the tabs (<b>if</b> resizeTabs is false <b>this</b> does nothing)
|
|
*/</i>
|
|
autoSizeTabs : <b>function</b>(){
|
|
<b>var</b> count = <b>this</b>.items.length;
|
|
<b>var</b> vcount = count - <b>this</b>.hiddenCount;
|
|
<b>if</b>(!<b>this</b>.resizeTabs || count < 1 || vcount < 1 || <b>this</b>.updating) <b>return</b>;
|
|
<b>var</b> w = Math.max(<b>this</b>.el.getWidth() - <b>this</b>.cpad, 10);
|
|
<b>var</b> availWidth = Math.floor(w / vcount);
|
|
<b>var</b> b = <b>this</b>.stripBody;
|
|
<b>if</b>(b.getWidth() > w){
|
|
<b>var</b> tabs = <b>this</b>.items;
|
|
<b>this</b>.setTabWidth(Math.max(availWidth, <b>this</b>.minTabWidth)-2);
|
|
<b>if</b>(availWidth < <b>this</b>.minTabWidth){
|
|
<i>/*<b>if</b>(!<b>this</b>.sleft){ <i>// incomplete scrolling code</i>
|
|
<b>this</b>.createScrollButtons();
|
|
}
|
|
<b>this</b>.showScroll();
|
|
<b>this</b>.stripClip.setWidth(w - (<b>this</b>.sleft.getWidth()+<b>this</b>.sright.getWidth()));*/</i>
|
|
}
|
|
}<b>else</b>{
|
|
<b>if</b>(this.currentTabWidth < <b>this</b>.preferredTabWidth){
|
|
<b>this</b>.setTabWidth(Math.min(availWidth, <b>this</b>.preferredTabWidth)-2);
|
|
}
|
|
}
|
|
},
|
|
|
|
<i>/**
|
|
* Returns the number of tabs
|
|
* @<b>return</b> {Number}
|
|
*/</i>
|
|
getCount : <b>function</b>(){
|
|
<b>return</b> this.items.length;
|
|
},
|
|
|
|
<i>/**
|
|
* Resizes all the tabs to the passed width
|
|
* @param {Number} The <b>new</b> width
|
|
*/</i>
|
|
setTabWidth : <b>function</b>(width){
|
|
<b>this</b>.currentTabWidth = width;
|
|
<b>for</b>(var i = 0, len = <b>this</b>.items.length; i < len; i++) {
|
|
<b>if</b>(!<b>this</b>.items[i].isHidden())<b>this</b>.items[i].setWidth(width);
|
|
}
|
|
},
|
|
|
|
<i>/**
|
|
* Destroys <b>this</b> TabPanel
|
|
* @param {Boolean} removeEl (optional) True to remove the element from the DOM as well
|
|
*/</i>
|
|
destroy : <b>function</b>(removeEl){
|
|
Ext.EventManager.removeResizeListener(<b>this</b>.onResize, <b>this</b>);
|
|
<b>for</b>(var i = 0, len = <b>this</b>.items.length; i < len; i++){
|
|
<b>this</b>.items[i].purgeListeners();
|
|
}
|
|
<b>if</b>(removeEl === true){
|
|
<b>this</b>.el.update("");
|
|
<b>this</b>.el.remove();
|
|
}
|
|
}
|
|
});
|
|
|
|
<i>/**
|
|
* @class Ext.TabPanelItem
|
|
* @extends Ext.util.Observable
|
|
*/</i>
|
|
Ext.TabPanelItem = <b>function</b>(tabPanel, id, text, closable){
|
|
<i>/**
|
|
* The TabPanel <b>this</b> TabPanelItem belongs to
|
|
* @type Ext.TabPanel
|
|
*/</i>
|
|
<b>this</b>.tabPanel = tabPanel;
|
|
<i>/**
|
|
* The id <b>for</b> this TabPanelItem
|
|
* @type String
|
|
*/</i>
|
|
<b>this</b>.id = id;
|
|
<i>/** @private */</i>
|
|
<b>this</b>.disabled = false;
|
|
<i>/** @private */</i>
|
|
<b>this</b>.text = text;
|
|
<i>/** @private */</i>
|
|
<b>this</b>.loaded = false;
|
|
<b>this</b>.closable = closable;
|
|
|
|
<i>/**
|
|
* The body element <b>for</b> this TabPanelItem
|
|
* @type Ext.Element
|
|
*/</i>
|
|
<b>this</b>.bodyEl = Ext.get(tabPanel.createItemBody(tabPanel.bodyEl.dom, id));
|
|
<b>this</b>.bodyEl.setVisibilityMode(Ext.Element.VISIBILITY);
|
|
<b>this</b>.bodyEl.setStyle("display", "block");
|
|
<b>this</b>.bodyEl.setStyle("zoom", "1");
|
|
<b>this</b>.hideAction();
|
|
|
|
<b>var</b> els = tabPanel.createStripElements(tabPanel.stripEl.dom, text, closable);
|
|
<i>/** @private */</i>
|
|
<b>this</b>.el = Ext.get(els.el, true);
|
|
<b>this</b>.inner = Ext.get(els.inner, true);
|
|
<b>this</b>.textEl = Ext.get(<b>this</b>.el.dom.firstChild.firstChild.firstChild, true);
|
|
<b>this</b>.pnode = Ext.get(els.el.parentNode, true);
|
|
<b>this</b>.el.on("mousedown", <b>this</b>.onTabMouseDown, <b>this</b>);
|
|
<b>this</b>.el.on("click", <b>this</b>.onTabClick, <b>this</b>);
|
|
<i>/** @private */</i>
|
|
<b>if</b>(closable){
|
|
<b>var</b> c = Ext.get(els.close, true);
|
|
c.dom.title = <b>this</b>.closeText;
|
|
c.addClassOnOver("close-over");
|
|
c.on("click", <b>this</b>.closeClick, <b>this</b>);
|
|
}
|
|
|
|
<b>this</b>.addEvents({
|
|
<i>/**
|
|
* @event activate
|
|
* Fires when <b>this</b> tab becomes the active tab
|
|
* @param {Ext.TabPanel} tabPanel
|
|
* @param {Ext.TabPanelItem} <b>this</b>
|
|
*/</i>
|
|
"activate": true,
|
|
<i>/**
|
|
* @event beforeclose
|
|
* Fires before <b>this</b> tab is closed. To cancal the close, set cancel to true on e. (e.cancel = true)
|
|
* @param {Ext.TabPanelItem} <b>this</b>
|
|
* @param {Object} e Set cancel to true on <b>this</b> object to cancel the close.
|
|
*/</i>
|
|
"beforeclose": true,
|
|
<i>/**
|
|
* @event close
|
|
* Fires when <b>this</b> tab is closed
|
|
* @param {Ext.TabPanelItem} <b>this</b>
|
|
*/</i>
|
|
"close": true,
|
|
<i>/**
|
|
* @event deactivate
|
|
* Fires when <b>this</b> tab is no longer the active tab
|
|
* @param {Ext.TabPanel} tabPanel
|
|
* @param {Ext.TabPanelItem} <b>this</b>
|
|
*/</i>
|
|
"deactivate" : true
|
|
});
|
|
<b>this</b>.hidden = false;
|
|
|
|
Ext.TabPanelItem.superclass.constructor.call(<b>this</b>);
|
|
};
|
|
|
|
Ext.extend(Ext.TabPanelItem, Ext.util.Observable, {
|
|
purgeListeners : <b>function</b>(){
|
|
Ext.util.Observable.prototype.purgeListeners.call(<b>this</b>);
|
|
<b>this</b>.el.removeAllListeners();
|
|
},
|
|
<i>/**
|
|
* Show <b>this</b> TabPanelItem - <b>this</b> <b>does not</b> deactivate the currently active TabPanelItem.
|
|
*/</i>
|
|
show : <b>function</b>(){
|
|
<b>this</b>.pnode.addClass("on");
|
|
<b>this</b>.showAction();
|
|
<b>if</b>(Ext.isOpera){
|
|
<b>this</b>.tabPanel.stripWrap.repaint();
|
|
}
|
|
<b>this</b>.fireEvent("activate", <b>this</b>.tabPanel, <b>this</b>);
|
|
},
|
|
|
|
<i>/**
|
|
* Returns true <b>if</b> this tab is the active tab
|
|
* @<b>return</b> {Boolean}
|
|
*/</i>
|
|
isActive : <b>function</b>(){
|
|
<b>return</b> this.tabPanel.getActiveTab() == <b>this</b>;
|
|
},
|
|
|
|
<i>/**
|
|
* Hide <b>this</b> TabPanelItem - <b>if</b> you don't activate another TabPanelItem <b>this</b> could look odd.
|
|
*/</i>
|
|
hide : <b>function</b>(){
|
|
<b>this</b>.pnode.removeClass("on");
|
|
<b>this</b>.hideAction();
|
|
<b>this</b>.fireEvent("deactivate", <b>this</b>.tabPanel, <b>this</b>);
|
|
},
|
|
|
|
hideAction : <b>function</b>(){
|
|
<b>this</b>.bodyEl.hide();
|
|
<b>this</b>.bodyEl.setStyle("position", "absolute");
|
|
<b>this</b>.bodyEl.setLeft("-20000px");
|
|
<b>this</b>.bodyEl.setTop("-20000px");
|
|
},
|
|
|
|
showAction : <b>function</b>(){
|
|
<b>this</b>.bodyEl.setStyle("position", "relative");
|
|
<b>this</b>.bodyEl.setTop("");
|
|
<b>this</b>.bodyEl.setLeft("");
|
|
<b>this</b>.bodyEl.show();
|
|
},
|
|
|
|
<i>/**
|
|
* Set the tooltip <b>for</b> the tab
|
|
* @param {String} tooltip
|
|
*/</i>
|
|
setTooltip : <b>function</b>(text){
|
|
<b>if</b>(Ext.QuickTips && Ext.QuickTips.isEnabled()){
|
|
<b>this</b>.textEl.dom.qtip = text;
|
|
<b>this</b>.textEl.dom.removeAttribute('title');
|
|
}<b>else</b>{
|
|
<b>this</b>.textEl.dom.title = text;
|
|
}
|
|
},
|
|
|
|
onTabClick : <b>function</b>(e){
|
|
e.preventDefault();
|
|
<b>this</b>.tabPanel.activate(<b>this</b>.id);
|
|
},
|
|
|
|
onTabMouseDown : <b>function</b>(e){
|
|
e.preventDefault();
|
|
<b>this</b>.tabPanel.activate(<b>this</b>.id);
|
|
},
|
|
|
|
getWidth : <b>function</b>(){
|
|
<b>return</b> this.inner.getWidth();
|
|
},
|
|
|
|
setWidth : <b>function</b>(width){
|
|
<b>var</b> iwidth = width - <b>this</b>.pnode.getPadding("lr");
|
|
<b>this</b>.inner.setWidth(iwidth);
|
|
<b>this</b>.textEl.setWidth(iwidth-<b>this</b>.inner.getPadding("lr"));
|
|
<b>this</b>.pnode.setWidth(width);
|
|
},
|
|
|
|
setHidden : <b>function</b>(hidden){
|
|
<b>this</b>.hidden = hidden;
|
|
<b>this</b>.pnode.setStyle("display", hidden ? "none" : "");
|
|
},
|
|
|
|
<i>/**
|
|
* Returns true <b>if</b> this tab is "hidden"
|
|
* @<b>return</b> {Boolean}
|
|
*/</i>
|
|
isHidden : <b>function</b>(){
|
|
<b>return</b> this.hidden;
|
|
},
|
|
|
|
<i>/**
|
|
* Returns the text <b>for</b> this tab
|
|
* @<b>return</b> {String}
|
|
*/</i>
|
|
getText : <b>function</b>(){
|
|
<b>return</b> this.text;
|
|
},
|
|
|
|
autoSize : <b>function</b>(){
|
|
<i>//<b>this</b>.el.beginMeasure();</i>
|
|
<b>this</b>.textEl.setWidth(1);
|
|
<b>this</b>.setWidth(<b>this</b>.textEl.dom.scrollWidth+<b>this</b>.pnode.getPadding("lr")+<b>this</b>.inner.getPadding("lr"));
|
|
<i>//<b>this</b>.el.endMeasure();</i>
|
|
},
|
|
|
|
<i>/**
|
|
* Sets the text <b>for</b> the tab (Note: <b>this</b> also sets the tooltip)
|
|
* @param {String} text
|
|
*/</i>
|
|
setText : <b>function</b>(text){
|
|
<b>this</b>.text = text;
|
|
<b>this</b>.textEl.update(text);
|
|
<b>this</b>.setTooltip(text);
|
|
<b>if</b>(!<b>this</b>.tabPanel.resizeTabs){
|
|
<b>this</b>.autoSize();
|
|
}
|
|
},
|
|
<i>/**
|
|
* Activate <b>this</b> TabPanelItem - <b>this</b> <b>does</b> deactivate the currently active TabPanelItem.
|
|
*/</i>
|
|
activate : <b>function</b>(){
|
|
<b>this</b>.tabPanel.activate(<b>this</b>.id);
|
|
},
|
|
|
|
<i>/**
|
|
* Disable <b>this</b> TabPanelItem - <b>this</b> call is ignore <b>if</b> this is the active TabPanelItem.
|
|
*/</i>
|
|
disable : <b>function</b>(){
|
|
<b>if</b>(this.tabPanel.active != <b>this</b>){
|
|
<b>this</b>.disabled = true;
|
|
<b>this</b>.pnode.addClass("disabled");
|
|
}
|
|
},
|
|
|
|
<i>/**
|
|
* Enable <b>this</b> TabPanelItem <b>if</b> it was previously disabled.
|
|
*/</i>
|
|
enable : <b>function</b>(){
|
|
<b>this</b>.disabled = false;
|
|
<b>this</b>.pnode.removeClass("disabled");
|
|
},
|
|
|
|
<i>/**
|
|
* Set the content <b>for</b> this TabPanelItem.
|
|
* @param {String} content The content
|
|
* @param {Boolean} loadScripts true to look <b>for</b> and load scripts
|
|
*/</i>
|
|
setContent : <b>function</b>(content, loadScripts){
|
|
<b>this</b>.bodyEl.update(content, loadScripts);
|
|
},
|
|
|
|
<i>/**
|
|
* Get the {@link Ext.UpdateManager} <b>for</b> the body of <b>this</b> TabPanelItem. Enables you to perform Ajax updates.
|
|
* @<b>return</b> {Ext.UpdateManager} The UpdateManager
|
|
*/</i>
|
|
getUpdateManager : <b>function</b>(){
|
|
<b>return</b> this.bodyEl.getUpdateManager();
|
|
},
|
|
|
|
<i>/**
|
|
* Set a URL to be used to load the content <b>for</b> this TabPanelItem.
|
|
* @param {String/Function} url The url to load the content from or a <b>function</b> to call to get the url
|
|
* @param {String/Object} params (optional) The string params <b>for</b> the update call or an object of the params. See {@link Ext.UpdateManager#update} <b>for</b> more details. (Defaults to null)
|
|
* @param {Boolean} loadOnce (optional) Whether to only load the content once. If <b>this</b> is false it makes the Ajax call every time <b>this</b> TabPanelItem is activated. (Defaults to false)
|
|
* @<b>return</b> {Ext.UpdateManager} The UpdateManager
|
|
*/</i>
|
|
setUrl : <b>function</b>(url, params, loadOnce){
|
|
<b>if</b>(this.refreshDelegate){
|
|
<b>this</b>.un('activate', <b>this</b>.refreshDelegate);
|
|
}
|
|
<b>this</b>.refreshDelegate = <b>this</b>._handleRefresh.createDelegate(<b>this</b>, [url, params, loadOnce]);
|
|
<b>this</b>.on("activate", <b>this</b>.refreshDelegate);
|
|
<b>return</b> this.bodyEl.getUpdateManager();
|
|
},
|
|
|
|
<i>/** @private */</i>
|
|
_handleRefresh : <b>function</b>(url, params, loadOnce){
|
|
<b>if</b>(!loadOnce || !<b>this</b>.loaded){
|
|
<b>var</b> updater = <b>this</b>.bodyEl.getUpdateManager();
|
|
updater.update(url, params, <b>this</b>._setLoaded.createDelegate(<b>this</b>));
|
|
}
|
|
},
|
|
|
|
<i>/**
|
|
* Force a content refresh from the URL specified <b>in</b> the setUrl() method.
|
|
* Will fail silently <b>if</b> the setUrl method has not been called.
|
|
* This does not activate the panel, just updates its content.
|
|
*/</i>
|
|
refresh : <b>function</b>(){
|
|
<b>if</b>(this.refreshDelegate){
|
|
<b>this</b>.loaded = false;
|
|
<b>this</b>.refreshDelegate();
|
|
}
|
|
},
|
|
|
|
<i>/** @private */</i>
|
|
_setLoaded : <b>function</b>(){
|
|
<b>this</b>.loaded = true;
|
|
},
|
|
|
|
<i>/** @private */</i>
|
|
closeClick : <b>function</b>(e){
|
|
<b>var</b> o = {};
|
|
e.stopEvent();
|
|
<b>this</b>.fireEvent("beforeclose", <b>this</b>, o);
|
|
<b>if</b>(o.cancel !== true){
|
|
<b>this</b>.tabPanel.removeTab(<b>this</b>.id);
|
|
}
|
|
},
|
|
<i>/**
|
|
* The text displayed <b>in</b> the tooltip <b>for</b> the close icon.
|
|
* @type String
|
|
*/</i>
|
|
closeText : "Close <b>this</b> tab"
|
|
});
|
|
|
|
<i>/** @private */</i>
|
|
Ext.TabPanel.prototype.createStrip = <b>function</b>(container){
|
|
<b>var</b> strip = document.createElement("div");
|
|
strip.className = "x-tabs-wrap";
|
|
container.appendChild(strip);
|
|
<b>return</b> strip;
|
|
};
|
|
<i>/** @private */</i>
|
|
Ext.TabPanel.prototype.createStripList = <b>function</b>(strip){
|
|
<i>// div wrapper <b>for</b> retard IE</i>
|
|
strip.innerHTML = '<div class="x-tabs-strip-wrap"><table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr></tr></tbody></table></div>';
|
|
<b>return</b> strip.firstChild.firstChild.firstChild.firstChild;
|
|
};
|
|
<i>/** @private */</i>
|
|
Ext.TabPanel.prototype.createBody = <b>function</b>(container){
|
|
<b>var</b> body = document.createElement("div");
|
|
Ext.id(body, "tab-body");
|
|
Ext.fly(body).addClass("x-tabs-body");
|
|
container.appendChild(body);
|
|
<b>return</b> body;
|
|
};
|
|
<i>/** @private */</i>
|
|
Ext.TabPanel.prototype.createItemBody = <b>function</b>(bodyEl, id){
|
|
<b>var</b> body = Ext.getDom(id);
|
|
<b>if</b>(!body){
|
|
body = document.createElement("div");
|
|
body.id = id;
|
|
}
|
|
Ext.fly(body).addClass("x-tabs-item-body");
|
|
bodyEl.insertBefore(body, bodyEl.firstChild);
|
|
<b>return</b> body;
|
|
};
|
|
<i>/** @private */</i>
|
|
Ext.TabPanel.prototype.createStripElements = <b>function</b>(stripEl, text, closable){
|
|
<b>var</b> td = document.createElement("td");
|
|
stripEl.appendChild(td);
|
|
<b>if</b>(closable){
|
|
td.className = "x-tabs-closable";
|
|
<b>if</b>(!<b>this</b>.closeTpl){
|
|
<b>this</b>.closeTpl = <b>new</b> Ext.Template(
|
|
'<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
|
|
'<span unselectable="on"' + (<b>this</b>.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
|
|
'<div unselectable="on" class="close-icon">&#160;</div></em></span></a>'
|
|
);
|
|
}
|
|
<b>var</b> el = <b>this</b>.closeTpl.overwrite(td, {"text": text});
|
|
<b>var</b> close = el.getElementsByTagName("div")[0];
|
|
<b>var</b> inner = el.getElementsByTagName("em")[0];
|
|
<b>return</b> {"el": el, "close": close, "inner": inner};
|
|
} <b>else</b> {
|
|
<b>if</b>(!<b>this</b>.tabTpl){
|
|
<b>this</b>.tabTpl = <b>new</b> Ext.Template(
|
|
'<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
|
|
'<span unselectable="on"' + (<b>this</b>.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
|
|
);
|
|
}
|
|
<b>var</b> el = <b>this</b>.tabTpl.overwrite(td, {"text": text});
|
|
<b>var</b> inner = el.getElementsByTagName("em")[0];
|
|
<b>return</b> {"el": el, "inner": inner};
|
|
}
|
|
};</code></pre><hr><div style="font-size:10px;text-align:center;color:gray;">Ext - Copyright © 2006-2007 Ext JS, LLC<br />All rights reserved.</div>
|
|
</body></html> |