Upgrade to ExtJS 4.0.2 - Released 06/09/2011
[extjs.git] / examples / tabs / tabs.js
1 /*
2
3 This file is part of Ext JS 4
4
5 Copyright (c) 2011 Sencha Inc
6
7 Contact:  http://www.sencha.com/contact
8
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file.  Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
11
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
13
14 */
15 Ext.require('Ext.tab.*');
16
17 Ext.onReady(function(){
18     // basic tabs 1, built from existing content
19     var tabs = Ext.createWidget('tabpanel', {
20         renderTo: 'tabs1',
21         width: 450,
22         activeTab: 0,
23         defaults :{
24             bodyPadding: 10
25         },
26         items: [{
27             contentEl:'script', 
28             title: 'Short Text',
29             closable: true
30         },{
31             contentEl:'markup', 
32             title: 'Long Text'
33         }]
34     });
35     
36     // second tabs built from JS
37     var tabs2 = Ext.createWidget('tabpanel', {
38         renderTo: document.body,
39         activeTab: 0,
40         width: 600,
41         height: 250,
42         plain: true,
43         defaults :{
44             autoScroll: true,
45             bodyPadding: 10
46         },
47         items: [{
48                 title: 'Normal Tab',
49                 html: "My content was added during construction."
50             },{
51                 title: 'Ajax Tab 1',
52                 loader: {
53                     url: 'ajax1.htm',
54                     contentType: 'html',
55                     loadMask: true
56                 },
57                 listeners: {
58                     activate: function(tab) {
59                         tab.loader.load();
60                     }
61                 }
62             },{
63                 title: 'Ajax Tab 2',
64                 loader: {
65                     url: 'ajax2.htm',
66                     contentType: 'html',
67                     autoLoad: true,
68                     params: 'foo=123&bar=abc'
69                 }
70             },{
71                 title: 'Event Tab',
72                 listeners: {
73                     activate: function(tab){
74                         alert(tab.title + ' was activated.');
75                     }
76                 },
77                 html: "I am tab 4's content. I also have an event listener attached."
78             },{
79                 title: 'Disabled Tab',
80                 disabled: true,
81                 html: "Can't see me cause I'm disabled"
82             }
83         ]
84     });
85 });