]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/debian/missing-sources/framework/Web/Javascripts/source/tinymce-405/classes/ui/TabPanel.js
baculum: Add missing-sources directory in debian metadata structure
[bacula/bacula] / gui / baculum / debian / missing-sources / framework / Web / Javascripts / source / tinymce-405 / classes / ui / TabPanel.js
1 /**
2  * TabPanel.js
3  *
4  * Copyright, Moxiecode Systems AB
5  * Released under LGPL License.
6  *
7  * License: http://www.tinymce.com/license
8  * Contributing: http://www.tinymce.com/contributing
9  */
10
11 /**
12  * Creates a tab panel control.
13  *
14  * @-x-less TabPanel.less
15  * @class tinymce.ui.TabPanel
16  * @extends tinymce.ui.Panel
17  *
18  * @setting {Number} activeTab Active tab index.
19  */
20 define("tinymce/ui/TabPanel", [
21         "tinymce/ui/Panel",
22         "tinymce/ui/DomUtils"
23 ], function(Panel, DomUtils) {
24         "use stict";
25
26         return Panel.extend({
27                 lastIdx: 0,
28
29                 Defaults: {
30                         layout: 'absolute',
31                         defaults: {
32                                 type: 'panel'
33                         }
34                 },
35
36                 /**
37                  * Activates the specified tab by index.
38                  *
39                  * @method activateTab
40                  * @param {Number} idx Index of the tab to activate.
41                  */
42                 activateTab: function(idx) {
43                         if (this.activeTabId) {
44                                 DomUtils.removeClass(this.getEl(this.activeTabId), this.classPrefix + 'active');
45                         }
46
47                         this.activeTabId = 't' + idx;
48
49                         DomUtils.addClass(this.getEl('t' + idx), this.classPrefix + 'active');
50
51                         if (idx != this.lastIdx) {
52                                 this.items()[this.lastIdx].hide();
53                                 this.lastIdx = idx;
54                         }
55
56                         this.items()[idx].show().fire('showtab');
57                         this.reflow();
58                 },
59
60                 /**
61                  * Renders the control as a HTML string.
62                  *
63                  * @method renderHtml
64                  * @return {String} HTML representing the control.
65                  */
66                 renderHtml: function() {
67                         var self = this, layout = self._layout, tabsHtml = '', prefix = self.classPrefix;
68
69                         self.preRender();
70                         layout.preRender(self);
71
72                         self.items().each(function(ctrl, i) {
73                                 tabsHtml += (
74                                         '<div id="' + self._id + '-t' + i + '" class="' + prefix + 'tab" unselectable="on">' +
75                                                 self.encode(ctrl.settings.title) +
76                                         '</div>'
77                                 );
78                         });
79
80                         return (
81                                 '<div id="' + self._id + '" class="' + self.classes() + '" hideFocus="1" tabIndex="-1">' +
82                                         '<div id="' + self._id + '-head" class="' + prefix + 'tabs">' +
83                                                 tabsHtml +
84                                         '</div>' +
85                                         '<div id="' + self._id + '-body" class="' + self.classes('body') + '">' +
86                                                 layout.renderHtml(self) +
87                                         '</div>' +
88                                 '</div>'
89                         );
90                 },
91
92                 /**
93                  * Called after the control has been rendered.
94                  *
95                  * @method postRender
96                  */
97                 postRender: function() {
98                         var self = this;
99
100                         self._super();
101
102                         self.settings.activeTab = self.settings.activeTab || 0;
103                         self.activateTab(self.settings.activeTab);
104
105                         this.on('click', function(e) {
106                                 var targetParent = e.target.parentNode;
107
108                                 if (e.target.parentNode.id == self._id + '-head') {
109                                         var i = targetParent.childNodes.length;
110
111                                         while (i--) {
112                                                 if (targetParent.childNodes[i] == e.target) {
113                                                         self.activateTab(i);
114                                                 }
115                                         }
116                                 }
117                         });
118                 },
119
120                 /**
121                  * Initializes the current controls layout rect.
122                  * This will be executed by the layout managers to determine the
123                  * default minWidth/minHeight etc.
124                  *
125                  * @method initLayoutRect
126                  * @return {Object} Layout rect instance.
127                  */
128                 initLayoutRect: function() {
129                         var self = this, rect, minW, minH;
130
131                         minW = minH = 0;
132                         self.items().each(function(item, i) {
133                                 minW = Math.max(minW, item.layoutRect().minW);
134                                 minH = Math.max(minH, item.layoutRect().minH);
135                                 if (self.settings.activeTab != i) {
136                                         item.hide();
137                                 }
138                         });
139
140                         self.items().each(function(ctrl) {
141                                 ctrl.settings.x = 0;
142                                 ctrl.settings.y = 0;
143                                 ctrl.settings.w = minW;
144                                 ctrl.settings.h = minH;
145
146                                 ctrl.layoutRect({
147                                         x: 0,
148                                         y: 0,
149                                         w: minW,
150                                         h: minH
151                                 });
152                         });
153
154                         var headH = self.getEl('head').offsetHeight;
155
156                         self.settings.minWidth = minW;
157                         self.settings.minHeight = minH + headH;
158
159                         rect = self._super();
160                         rect.deltaH += self.getEl('head').offsetHeight;
161                         rect.innerH = rect.h - rect.deltaH;
162
163                         return rect;
164                 }
165         });
166 });