3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
4 <title>The source code</title>
\r
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
8 <body onload="prettyPrint();">
\r
9 <pre class="prettyprint lang-js"><div id="cls-Ext.layout.ToolbarLayout"></div>/**
10 * @class Ext.layout.ToolbarLayout
11 * @extends Ext.layout.ContainerLayout
12 * Layout manager implicitly used by Ext.Toolbar.
14 Ext.layout.ToolbarLayout = Ext.extend(Ext.layout.ContainerLayout, {
19 noItemsMenuText : '<div class="x-toolbar-no-items">(None)</div>',
22 onLayout : function(ct, target){
24 var align = ct.buttonAlign == 'center' ? 'center' : 'left';
25 target.addClass('x-toolbar-layout-ct');
26 target.insertHtml('beforeEnd',
27 '<table cellspacing="0" class="x-toolbar-ct"><tbody><tr><td class="x-toolbar-left" align="' + align + '"><table cellspacing="0"><tbody><tr class="x-toolbar-left-row"></tr></tbody></table></td><td class="x-toolbar-right" align="right"><table cellspacing="0" class="x-toolbar-right-ct"><tbody><tr><td><table cellspacing="0"><tbody><tr class="x-toolbar-right-row"></tr></tbody></table></td><td><table cellspacing="0"><tbody><tr class="x-toolbar-extras-row"></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table>');
28 this.leftTr = target.child('tr.x-toolbar-left-row', true);
29 this.rightTr = target.child('tr.x-toolbar-right-row', true);
30 this.extrasTr = target.child('tr.x-toolbar-extras-row', true);
33 var side = ct.buttonAlign == 'right' ? this.rightTr : this.leftTr,
35 items = ct.items.items;
37 for(var i = 0, len = items.length, c; i < len; i++, pos++) {
42 }else if(!c.rendered){
43 c.render(this.insertCell(c, side, pos));
45 if(!c.xtbHidden && !this.isValidParent(c, side.childNodes[pos])){
46 var td = this.insertCell(c, side, pos);
47 td.appendChild(c.getPositionEl().dom);
48 c.container = Ext.get(td);
52 //strip extra empty cells
53 this.cleanup(this.leftTr);
54 this.cleanup(this.rightTr);
55 this.cleanup(this.extrasTr);
56 this.fitToSize(target);
59 cleanup : function(row){
60 var cn = row.childNodes, i, c;
61 for(i = cn.length-1; i >= 0 && (c = cn[i]); i--){
68 insertCell : function(c, side, pos){
69 var td = document.createElement('td');
70 td.className='x-toolbar-cell';
71 side.insertBefore(td, side.childNodes[pos]||null);
75 hideItem : function(item){
76 var h = (this.hiddens = this.hiddens || []);
78 item.xtbHidden = true;
79 item.xtbWidth = item.getPositionEl().dom.parentNode.offsetWidth;
83 unhideItem : function(item){
85 item.xtbHidden = false;
86 this.hiddens.remove(item);
87 if(this.hiddens.length < 1){
92 getItemWidth : function(c){
93 return c.hidden ? (c.xtbWidth || 0) : c.getPositionEl().dom.parentNode.offsetWidth;
96 fitToSize : function(t){
97 if(this.container.enableOverflow === false){
100 var w = t.dom.clientWidth,
101 lw = this.lastWidth || 0,
102 iw = t.dom.firstChild.offsetWidth,
103 clipWidth = w - this.triggerWidth,
108 if(iw > w || (this.hiddens && w >= lw)){
109 var i, items = this.container.items.items,
110 len = items.length, c,
113 for(i = 0; i < len; i++) {
116 loopWidth += this.getItemWidth(c);
117 if(loopWidth > clipWidth){
118 if(!(c.hidden || c.xtbHidden)){
121 }else if(c.xtbHidden){
129 if(!this.lastOverflow){
130 this.container.fireEvent('overflowchange', this.container, true);
131 this.lastOverflow = true;
137 if(this.lastOverflow){
138 this.container.fireEvent('overflowchange', this.container, false);
139 this.lastOverflow = false;
144 createMenuConfig : function(c, hideOnClick){
145 var cfg = Ext.apply({}, c.initialConfig),
146 group = c.toggleGroup;
149 text: c.overflowText || c.text,
153 disabled: c.disabled,
157 hideOnClick: hideOnClick
159 if(group || c.enableToggle){
164 checkchange: function(item, checked){
177 addComponentToMenu : function(m, c){
178 if(c instanceof Ext.Toolbar.Separator){
180 }else if(Ext.isFunction(c.isXType)){
181 if(c.isXType('splitbutton')){
182 m.add(this.createMenuConfig(c, true));
183 }else if(c.isXType('button')){
184 m.add(this.createMenuConfig(c, !c.menu));
185 }else if(c.isXType('buttongroup')){
186 c.items.each(function(item){
187 this.addComponentToMenu(m, item);
193 clearMenu : function(){
194 var m = this.moreMenu;
196 m.items.each(function(item){
203 beforeMoreShow : function(m){
204 var h = this.container.items.items,
208 needsSep = function(group, item){
209 return group.isXType('buttongroup') && !(item instanceof Ext.Toolbar.Separator);
214 for(var i = 0; i < len; i++){
217 if(prev && (needsSep(c, prev) || needsSep(prev, c))){
220 this.addComponentToMenu(m, c);
224 // put something so the menu isn't empty
225 // if no compatible items found
226 if(m.items.length < 1){
227 m.add(this.noItemsMenuText);
231 initMore : function(){
233 this.moreMenu = new Ext.menu.Menu({
234 ownerCt : this.container,
236 beforeshow: this.beforeMoreShow,
241 this.more = new Ext.Button({
242 iconCls : 'x-toolbar-more-icon',
243 cls : 'x-toolbar-more',
244 menu : this.moreMenu,
245 ownerCt : this.container
247 var td = this.insertCell(this.more, this.extrasTr, 100);
248 this.more.render(td);
252 destroy : function(){
253 Ext.destroy(this.more, this.moreMenu);
256 delete this.extrasTr;
257 Ext.layout.ToolbarLayout.superclass.destroy.call(this);
261 Ext.Container.LAYOUTS.toolbar = Ext.layout.ToolbarLayout;</pre>
\r