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