Roo/TabPanel.js
[roojs1] / Roo / TabPanel.js
1         /*
2  * Based on:
3  * Ext JS Library 1.1.1
4  * Copyright(c) 2006-2007, Ext JS, LLC.
5  *
6  * Originally Released Under LGPL - original licence link has changed is not relivant.
7  *
8  * Fork - LGPL
9  * <script type="text/javascript">
10  */
11 /**
12  * @class Roo.TabPanel
13  * @extends Roo.util.Observable
14  * A lightweight tab container.
15  * <br><br>
16  * Usage:
17  * <pre><code>
18 // basic tabs 1, built from existing content
19 var tabs = new Roo.TabPanel("tabs1");
20 tabs.addTab("script", "View Script");
21 tabs.addTab("markup", "View Markup");
22 tabs.activate("script");
23
24 // more advanced tabs, built from javascript
25 var jtabs = new Roo.TabPanel("jtabs");
26 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
27
28 // set up the UpdateManager
29 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
30 var updater = tab2.getUpdateManager();
31 updater.setDefaultUrl("ajax1.htm");
32 tab2.on('activate', updater.refresh, updater, true);
33
34 // Use setUrl for Ajax loading
35 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
36 tab3.setUrl("ajax2.htm", null, true);
37
38 // Disabled tab
39 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
40 tab4.disable();
41
42 jtabs.activate("jtabs-1");
43  * </code></pre>
44  * @constructor
45  * Create a new TabPanel.
46  * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
47  * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
48  */
49 Roo.TabPanel = function(container, config){
50     /**
51     * The container element for this TabPanel.
52     * @type Roo.Element
53     */
54     this.el = Roo.get(container, true);
55     if(config){
56         if(typeof config == "boolean"){
57             this.tabPosition = config ? "bottom" : "top";
58         }else{
59             Roo.apply(this, config);
60         }
61     }
62     if(this.tabPosition == "bottom"){
63         this.bodyEl = Roo.get(this.createBody(this.el.dom));
64         this.el.addClass("x-tabs-bottom");
65     }
66     this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
67     this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
68     this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
69     if(Roo.isIE){
70         Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
71     }
72     if(this.tabPosition != "bottom"){
73     /** The body element that contains {@link Roo.TabPanelItem} bodies. +
74      * @type Roo.Element
75      */
76       this.bodyEl = Roo.get(this.createBody(this.el.dom));
77       this.el.addClass("x-tabs-top");
78     }
79     this.items = [];
80
81     this.bodyEl.setStyle("position", "relative");
82
83     this.active = null;
84     this.activateDelegate = this.activate.createDelegate(this);
85
86     this.addEvents({
87         /**
88          * @event tabchange
89          * Fires when the active tab changes
90          * @param {Roo.TabPanel} this
91          * @param {Roo.TabPanelItem} activePanel The new active tab
92          */
93         "tabchange": true,
94         /**
95          * @event beforetabchange
96          * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
97          * @param {Roo.TabPanel} this
98          * @param {Object} e Set cancel to true on this object to cancel the tab change
99          * @param {Roo.TabPanelItem} tab The tab being changed to
100          */
101         "beforetabchange" : true
102     });
103
104     Roo.EventManager.onWindowResize(this.onResize, this);
105     this.cpad = this.el.getPadding("lr");
106     this.hiddenCount = 0;
107
108
109     // toolbar on the tabbar support...
110     if (this.toolbar) { 
111         var se = this.stripEl;
112         var tbh = se.child('td.x-tab-strip-toolbar'); //createChild(  { tag: 'td', style: 'width:100%;'  });
113     
114     
115         var lotb = new Roo.Toolbar(tbh);
116     }
117    
118
119
120     Roo.TabPanel.superclass.constructor.call(this);
121 };
122
123 Roo.extend(Roo.TabPanel, Roo.util.Observable, {
124     /*
125      *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
126      */
127     tabPosition : "top",
128     /*
129      *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
130      */
131     currentTabWidth : 0,
132     /*
133      *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
134      */
135     minTabWidth : 40,
136     /*
137      *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
138      */
139     maxTabWidth : 250,
140     /*
141      *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
142      */
143     preferredTabWidth : 175,
144     /*
145      *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
146      */
147     resizeTabs : false,
148     /*
149      *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
150      */
151     monitorResize : true,
152     /*
153      *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar. 
154      */
155     toolbar : false,
156
157     /**
158      * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
159      * @param {String} id The id of the div to use <b>or create</b>
160      * @param {String} text The text for the tab
161      * @param {String} content (optional) Content to put in the TabPanelItem body
162      * @param {Boolean} closable (optional) True to create a close icon on the tab
163      * @return {Roo.TabPanelItem} The created TabPanelItem
164      */
165     addTab : function(id, text, content, closable){
166         var item = new Roo.TabPanelItem(this, id, text, closable);
167         this.addTabItem(item);
168         if(content){
169             item.setContent(content);
170         }
171         return item;
172     },
173
174     /**
175      * Returns the {@link Roo.TabPanelItem} with the specified id/index
176      * @param {String/Number} id The id or index of the TabPanelItem to fetch.
177      * @return {Roo.TabPanelItem}
178      */
179     getTab : function(id){
180         return this.items[id];
181     },
182
183     /**
184      * Hides the {@link Roo.TabPanelItem} with the specified id/index
185      * @param {String/Number} id The id or index of the TabPanelItem to hide.
186      */
187     hideTab : function(id){
188         var t = this.items[id];
189         if(!t.isHidden()){
190            t.setHidden(true);
191            this.hiddenCount++;
192            this.autoSizeTabs();
193         }
194     },
195
196     /**
197      * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
198      * @param {String/Number} id The id or index of the TabPanelItem to unhide.
199      */
200     unhideTab : function(id){
201         var t = this.items[id];
202         if(t.isHidden()){
203            t.setHidden(false);
204            this.hiddenCount--;
205            this.autoSizeTabs();
206         }
207     },
208
209     /**
210      * Adds an existing {@link Roo.TabPanelItem}.
211      * @param {Roo.TabPanelItem} item The TabPanelItem to add
212      */
213     addTabItem : function(item){
214         this.items[item.id] = item;
215         this.items.push(item);
216         if(this.resizeTabs){
217            item.setWidth(this.currentTabWidth || this.preferredTabWidth);
218            this.autoSizeTabs();
219         }else{
220             item.autoSize();
221         }
222     },
223
224     /**
225      * Removes a {@link Roo.TabPanelItem}.
226      * @param {String/Number} id The id or index of the TabPanelItem to remove.
227      */
228     removeTab : function(id){
229         var items = this.items;
230         var tab = items[id];
231         if(!tab) { return; }
232         var index = items.indexOf(tab);
233         if(this.active == tab && items.length > 1){
234             var newTab = this.getNextAvailable(index);
235             if(newTab) {
236                 newTab.activate();
237             }
238         }
239         this.stripEl.dom.removeChild(tab.pnode.dom);
240         if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
241             this.bodyEl.dom.removeChild(tab.bodyEl.dom);
242         }
243         items.splice(index, 1);
244         delete this.items[tab.id];
245         tab.fireEvent("close", tab);
246         tab.purgeListeners();
247         this.autoSizeTabs();
248     },
249
250     getNextAvailable : function(start){
251         var items = this.items;
252         var index = start;
253         // look for a next tab that will slide over to
254         // replace the one being removed
255         while(index < items.length){
256             var item = items[++index];
257             if(item && !item.isHidden()){
258                 return item;
259             }
260         }
261         // if one isn't found select the previous tab (on the left)
262         index = start;
263         while(index >= 0){
264             var item = items[--index];
265             if(item && !item.isHidden()){
266                 return item;
267             }
268         }
269         return null;
270     },
271
272     /**
273      * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
274      * @param {String/Number} id The id or index of the TabPanelItem to disable.
275      */
276     disableTab : function(id){
277         var tab = this.items[id];
278         if(tab && this.active != tab){
279             tab.disable();
280         }
281     },
282
283     /**
284      * Enables a {@link Roo.TabPanelItem} that is disabled.
285      * @param {String/Number} id The id or index of the TabPanelItem to enable.
286      */
287     enableTab : function(id){
288         var tab = this.items[id];
289         tab.enable();
290     },
291
292     /**
293      * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
294      * @param {String/Number} id The id or index of the TabPanelItem to activate.
295      * @return {Roo.TabPanelItem} The TabPanelItem.
296      */
297     activate : function(id){
298         var tab = this.items[id];
299         if(!tab){
300             return null;
301         }
302         if(tab == this.active || tab.disabled){
303             return tab;
304         }
305         var e = {};
306         this.fireEvent("beforetabchange", this, e, tab);
307         if(e.cancel !== true && !tab.disabled){
308             if(this.active){
309                 this.active.hide();
310             }
311             this.active = this.items[id];
312             this.active.show();
313             this.fireEvent("tabchange", this, this.active);
314         }
315         return tab;
316     },
317
318     /**
319      * Gets the active {@link Roo.TabPanelItem}.
320      * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
321      */
322     getActiveTab : function(){
323         return this.active;
324     },
325
326     /**
327      * Updates the tab body element to fit the height of the container element
328      * for overflow scrolling
329      * @param {Number} targetHeight (optional) Override the starting height from the elements height
330      */
331     syncHeight : function(targetHeight){
332         var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
333         var bm = this.bodyEl.getMargins();
334         var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
335         this.bodyEl.setHeight(newHeight);
336         return newHeight;
337     },
338
339     onResize : function(){
340         if(this.monitorResize){
341             this.autoSizeTabs();
342         }
343     },
344
345     /**
346      * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
347      */
348     beginUpdate : function(){
349         this.updating = true;
350     },
351
352     /**
353      * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
354      */
355     endUpdate : function(){
356         this.updating = false;
357         this.autoSizeTabs();
358     },
359
360     /**
361      * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
362      */
363     autoSizeTabs : function(){
364         var count = this.items.length;
365         var vcount = count - this.hiddenCount;
366         if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) return;
367         var w = Math.max(this.el.getWidth() - this.cpad, 10);
368         var availWidth = Math.floor(w / vcount);
369         var b = this.stripBody;
370         if(b.getWidth() > w){
371             var tabs = this.items;
372             this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
373             if(availWidth < this.minTabWidth){
374                 /*if(!this.sleft){    // incomplete scrolling code
375                     this.createScrollButtons();
376                 }
377                 this.showScroll();
378                 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
379             }
380         }else{
381             if(this.currentTabWidth < this.preferredTabWidth){
382                 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
383             }
384         }
385     },
386
387     /**
388      * Returns the number of tabs in this TabPanel.
389      * @return {Number}
390      */
391      getCount : function(){
392          return this.items.length;
393      },
394
395     /**
396      * Resizes all the tabs to the passed width
397      * @param {Number} The new width
398      */
399     setTabWidth : function(width){
400         this.currentTabWidth = width;
401         for(var i = 0, len = this.items.length; i < len; i++) {
402                 if(!this.items[i].isHidden())this.items[i].setWidth(width);
403         }
404     },
405
406     /**
407      * Destroys this TabPanel
408      * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
409      */
410     destroy : function(removeEl){
411         Roo.EventManager.removeResizeListener(this.onResize, this);
412         for(var i = 0, len = this.items.length; i < len; i++){
413             this.items[i].purgeListeners();
414         }
415         if(removeEl === true){
416             this.el.update("");
417             this.el.remove();
418         }
419     }
420 });
421
422 /**
423  * @class Roo.TabPanelItem
424  * @extends Roo.util.Observable
425  * Represents an individual item (tab plus body) in a TabPanel.
426  * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
427  * @param {String} id The id of this TabPanelItem
428  * @param {String} text The text for the tab of this TabPanelItem
429  * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
430  */
431 Roo.TabPanelItem = function(tabPanel, id, text, closable){
432     /**
433      * The {@link Roo.TabPanel} this TabPanelItem belongs to
434      * @type Roo.TabPanel
435      */
436     this.tabPanel = tabPanel;
437     /**
438      * The id for this TabPanelItem
439      * @type String
440      */
441     this.id = id;
442     /** @private */
443     this.disabled = false;
444     /** @private */
445     this.text = text;
446     /** @private */
447     this.loaded = false;
448     this.closable = closable;
449
450     /**
451      * The body element for this TabPanelItem.
452      * @type Roo.Element
453      */
454     this.bodyEl = Roo.get(tabPanel.createItemBody(tabPanel.bodyEl.dom, id));
455     this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
456     this.bodyEl.setStyle("display", "block");
457     this.bodyEl.setStyle("zoom", "1");
458     this.hideAction();
459
460     var els = tabPanel.createStripElements(tabPanel.stripEl.dom, text, closable);
461     /** @private */
462     this.el = Roo.get(els.el, true);
463     this.inner = Roo.get(els.inner, true);
464     this.textEl = Roo.get(this.el.dom.firstChild.firstChild.firstChild, true);
465     this.pnode = Roo.get(els.el.parentNode, true);
466     this.el.on("mousedown", this.onTabMouseDown, this);
467     this.el.on("click", this.onTabClick, this);
468     /** @private */
469     if(closable){
470         var c = Roo.get(els.close, true);
471         c.dom.title = this.closeText;
472         c.addClassOnOver("close-over");
473         c.on("click", this.closeClick, this);
474      }
475
476     this.addEvents({
477          /**
478          * @event activate
479          * Fires when this tab becomes the active tab.
480          * @param {Roo.TabPanel} tabPanel The parent TabPanel
481          * @param {Roo.TabPanelItem} this
482          */
483         "activate": true,
484         /**
485          * @event beforeclose
486          * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
487          * @param {Roo.TabPanelItem} this
488          * @param {Object} e Set cancel to true on this object to cancel the close.
489          */
490         "beforeclose": true,
491         /**
492          * @event close
493          * Fires when this tab is closed.
494          * @param {Roo.TabPanelItem} this
495          */
496          "close": true,
497         /**
498          * @event deactivate
499          * Fires when this tab is no longer the active tab.
500          * @param {Roo.TabPanel} tabPanel The parent TabPanel
501          * @param {Roo.TabPanelItem} this
502          */
503          "deactivate" : true
504     });
505     this.hidden = false;
506
507     Roo.TabPanelItem.superclass.constructor.call(this);
508 };
509
510 Roo.extend(Roo.TabPanelItem, Roo.util.Observable, {
511     purgeListeners : function(){
512        Roo.util.Observable.prototype.purgeListeners.call(this);
513        this.el.removeAllListeners();
514     },
515     /**
516      * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
517      */
518     show : function(){
519         this.pnode.addClass("on");
520         this.showAction();
521         if(Roo.isOpera){
522             this.tabPanel.stripWrap.repaint();
523         }
524         this.fireEvent("activate", this.tabPanel, this);
525     },
526
527     /**
528      * Returns true if this tab is the active tab.
529      * @return {Boolean}
530      */
531     isActive : function(){
532         return this.tabPanel.getActiveTab() == this;
533     },
534
535     /**
536      * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
537      */
538     hide : function(){
539         this.pnode.removeClass("on");
540         this.hideAction();
541         this.fireEvent("deactivate", this.tabPanel, this);
542     },
543
544     hideAction : function(){
545         this.bodyEl.hide();
546         this.bodyEl.setStyle("position", "absolute");
547         this.bodyEl.setLeft("-20000px");
548         this.bodyEl.setTop("-20000px");
549     },
550
551     showAction : function(){
552         this.bodyEl.setStyle("position", "relative");
553         this.bodyEl.setTop("");
554         this.bodyEl.setLeft("");
555         this.bodyEl.show();
556     },
557
558     /**
559      * Set the tooltip for the tab.
560      * @param {String} tooltip The tab's tooltip
561      */
562     setTooltip : function(text){
563         if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
564             this.textEl.dom.qtip = text;
565             this.textEl.dom.removeAttribute('title');
566         }else{
567             this.textEl.dom.title = text;
568         }
569     },
570
571     onTabClick : function(e){
572         e.preventDefault();
573         this.tabPanel.activate(this.id);
574     },
575
576     onTabMouseDown : function(e){
577         e.preventDefault();
578         this.tabPanel.activate(this.id);
579     },
580
581     getWidth : function(){
582         return this.inner.getWidth();
583     },
584
585     setWidth : function(width){
586         var iwidth = width - this.pnode.getPadding("lr");
587         this.inner.setWidth(iwidth);
588         this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
589         this.pnode.setWidth(width);
590     },
591
592     /**
593      * Show or hide the tab
594      * @param {Boolean} hidden True to hide or false to show.
595      */
596     setHidden : function(hidden){
597         this.hidden = hidden;
598         this.pnode.setStyle("display", hidden ? "none" : "");
599     },
600
601     /**
602      * Returns true if this tab is "hidden"
603      * @return {Boolean}
604      */
605     isHidden : function(){
606         return this.hidden;
607     },
608
609     /**
610      * Returns the text for this tab
611      * @return {String}
612      */
613     getText : function(){
614         return this.text;
615     },
616
617     autoSize : function(){
618         //this.el.beginMeasure();
619         this.textEl.setWidth(1);
620         this.setWidth(this.textEl.dom.scrollWidth+this.pnode.getPadding("lr")+this.inner.getPadding("lr"));
621         //this.el.endMeasure();
622     },
623
624     /**
625      * Sets the text for the tab (Note: this also sets the tooltip text)
626      * @param {String} text The tab's text and tooltip
627      */
628     setText : function(text){
629         this.text = text;
630         this.textEl.update(text);
631         this.setTooltip(text);
632         if(!this.tabPanel.resizeTabs){
633             this.autoSize();
634         }
635     },
636     /**
637      * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
638      */
639     activate : function(){
640         this.tabPanel.activate(this.id);
641     },
642
643     /**
644      * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
645      */
646     disable : function(){
647         if(this.tabPanel.active != this){
648             this.disabled = true;
649             this.pnode.addClass("disabled");
650         }
651     },
652
653     /**
654      * Enables this TabPanelItem if it was previously disabled.
655      */
656     enable : function(){
657         this.disabled = false;
658         this.pnode.removeClass("disabled");
659     },
660
661     /**
662      * Sets the content for this TabPanelItem.
663      * @param {String} content The content
664      * @param {Boolean} loadScripts true to look for and load scripts
665      */
666     setContent : function(content, loadScripts){
667         this.bodyEl.update(content, loadScripts);
668     },
669
670     /**
671      * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
672      * @return {Roo.UpdateManager} The UpdateManager
673      */
674     getUpdateManager : function(){
675         return this.bodyEl.getUpdateManager();
676     },
677
678     /**
679      * Set a URL to be used to load the content for this TabPanelItem.
680      * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
681      * @param {String/Object} params (optional) The string params for the update call or an object of the params. See {@link Roo.UpdateManager#update} for more details. (Defaults to null)
682      * @param {Boolean} loadOnce (optional) Whether to only load the content once. If this is false it makes the Ajax call every time this TabPanelItem is activated. (Defaults to false)
683      * @return {Roo.UpdateManager} The UpdateManager
684      */
685     setUrl : function(url, params, loadOnce){
686         if(this.refreshDelegate){
687             this.un('activate', this.refreshDelegate);
688         }
689         this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
690         this.on("activate", this.refreshDelegate);
691         return this.bodyEl.getUpdateManager();
692     },
693
694     /** @private */
695     _handleRefresh : function(url, params, loadOnce){
696         if(!loadOnce || !this.loaded){
697             var updater = this.bodyEl.getUpdateManager();
698             updater.update(url, params, this._setLoaded.createDelegate(this));
699         }
700     },
701
702     /**
703      *   Forces a content refresh from the URL specified in the {@link #setUrl} method.
704      *   Will fail silently if the setUrl method has not been called.
705      *   This does not activate the panel, just updates its content.
706      */
707     refresh : function(){
708         if(this.refreshDelegate){
709            this.loaded = false;
710            this.refreshDelegate();
711         }
712     },
713
714     /** @private */
715     _setLoaded : function(){
716         this.loaded = true;
717     },
718
719     /** @private */
720     closeClick : function(e){
721         var o = {};
722         e.stopEvent();
723         this.fireEvent("beforeclose", this, o);
724         if(o.cancel !== true){
725             this.tabPanel.removeTab(this.id);
726         }
727     },
728     /**
729      * The text displayed in the tooltip for the close icon.
730      * @type String
731      */
732     closeText : "Close this tab"
733 });
734
735 /** @private */
736 Roo.TabPanel.prototype.createStrip = function(container){
737     var strip = document.createElement("div");
738     strip.className = "x-tabs-wrap";
739     container.appendChild(strip);
740     return strip;
741 };
742 /** @private */
743 Roo.TabPanel.prototype.createStripList = function(strip){
744     // div wrapper for retard IE
745     // returns the "tr" element.
746     strip.innerHTML = '<div class="x-tabs-strip-wrap">'+
747         '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
748         '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
749     return strip.firstChild.firstChild.firstChild.firstChild;
750 };
751 /** @private */
752 Roo.TabPanel.prototype.createBody = function(container){
753     var body = document.createElement("div");
754     Roo.id(body, "tab-body");
755     Roo.fly(body).addClass("x-tabs-body");
756     container.appendChild(body);
757     return body;
758 };
759 /** @private */
760 Roo.TabPanel.prototype.createItemBody = function(bodyEl, id){
761     var body = Roo.getDom(id);
762     if(!body){
763         body = document.createElement("div");
764         body.id = id;
765     }
766     Roo.fly(body).addClass("x-tabs-item-body");
767     bodyEl.insertBefore(body, bodyEl.firstChild);
768     return body;
769 };
770 /** @private */
771 Roo.TabPanel.prototype.createStripElements = function(stripEl, text, closable){
772     var td = document.createElement("td");
773     stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
774     //stripEl.appendChild(td);
775     if(closable){
776         td.className = "x-tabs-closable";
777         if(!this.closeTpl){
778             this.closeTpl = new Roo.Template(
779                '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
780                '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
781                '<div unselectable="on" class="close-icon">&#160;</div></em></span></a>'
782             );
783         }
784         var el = this.closeTpl.overwrite(td, {"text": text});
785         var close = el.getElementsByTagName("div")[0];
786         var inner = el.getElementsByTagName("em")[0];
787         return {"el": el, "close": close, "inner": inner};
788     } else {
789         if(!this.tabTpl){
790             this.tabTpl = new Roo.Template(
791                '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
792                '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
793             );
794         }
795         var el = this.tabTpl.overwrite(td, {"text": text});
796         var inner = el.getElementsByTagName("em")[0];
797         return {"el": el, "inner": inner};
798     }
799 };