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