| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459 | 
							- <!DOCTYPE html>
 
- <html>
 
- <head>
 
-   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
-   <title>The source code</title>
 
-   <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
 
-   <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
 
-   <style type="text/css">
 
-     .highlight { display: block; background-color: #ddd; }
 
-   </style>
 
-   <script type="text/javascript">
 
-     function highlight() {
 
-       document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
 
-     }
 
-   </script>
 
- </head>
 
- <body onload="prettyPrint(); highlight();">
 
-   <pre class="prettyprint lang-js"><span id='Ext-toolbar-Toolbar-method-constructor'><span id='Ext-toolbar-Toolbar'>/**
 
- </span></span> * Basic Toolbar class. Although the {@link Ext.container.Container#defaultType defaultType} for
 
-  * Toolbar is {@link Ext.button.Button button}, Toolbar elements (child items for the Toolbar container)
 
-  * may be virtually any type of Component. Toolbar elements can be created explicitly via their
 
-  * constructors, or implicitly via their xtypes, and can be {@link #method-add}ed dynamically.
 
-  *
 
-  * ## Some items have shortcut strings for creation:
 
-  *
 
-  * | Shortcut | xtype         | Class                         | Description
 
-  * |:---------|:--------------|:------------------------------|:---------------------------------------------------
 
-  * | `->`     | `tbfill`      | {@link Ext.toolbar.Fill}      | begin using the right-justified button container
 
-  * | `-`      | `tbseparator` | {@link Ext.toolbar.Separator} | add a vertical separator bar between toolbar items
 
-  * | ` `      | `tbspacer`    | {@link Ext.toolbar.Spacer}    | add horiztonal space between elements
 
-  *
 
-  *     @example
 
-  *     Ext.create('Ext.toolbar.Toolbar', {
 
-  *         renderTo: document.body,
 
-  *         width   : 500,
 
-  *         items: [
 
-  *             {
 
-  *                 // xtype: 'button', // default for Toolbars
 
-  *                 text: 'Button'
 
-  *             },
 
-  *             {
 
-  *                 xtype: 'splitbutton',
 
-  *                 text : 'Split Button'
 
-  *             },
 
-  *             // begin using the right-justified button container
 
-  *             '->', // same as { xtype: 'tbfill' }
 
-  *             {
 
-  *                 xtype    : 'textfield',
 
-  *                 name     : 'field1',
 
-  *                 emptyText: 'enter search term'
 
-  *             },
 
-  *             // add a vertical separator bar between toolbar items
 
-  *             '-', // same as {xtype: 'tbseparator'} to create Ext.toolbar.Separator
 
-  *             'text 1', // same as {xtype: 'tbtext', text: 'text1'} to create Ext.toolbar.TextItem
 
-  *             { xtype: 'tbspacer' },// same as ' ' to create Ext.toolbar.Spacer
 
-  *             'text 2',
 
-  *             { xtype: 'tbspacer', width: 50 }, // add a 50px space
 
-  *             'text 3'
 
-  *         ]
 
-  *     });
 
-  *
 
-  * Toolbars have {@link #method-enable} and {@link #method-disable} methods which when called, will
 
-  * enable/disable all items within your toolbar.
 
-  *
 
-  *     @example
 
-  *     Ext.create('Ext.toolbar.Toolbar', {
 
-  *         renderTo: document.body,
 
-  *         width   : 400,
 
-  *         items: [
 
-  *             {
 
-  *                 text: 'Button'
 
-  *             },
 
-  *             {
 
-  *                 xtype: 'splitbutton',
 
-  *                 text : 'Split Button'
 
-  *             },
 
-  *             '->',
 
-  *             {
 
-  *                 xtype    : 'textfield',
 
-  *                 name     : 'field1',
 
-  *                 emptyText: 'enter search term'
 
-  *             }
 
-  *         ]
 
-  *     });
 
-  *
 
-  * Example
 
-  *
 
-  *     @example
 
-  *     var enableBtn = Ext.create('Ext.button.Button', {
 
-  *         text    : 'Enable All Items',
 
-  *         disabled: true,
 
-  *         scope   : this,
 
-  *         handler : function() {
 
-  *             //disable the enable button and enable the disable button
 
-  *             enableBtn.disable();
 
-  *             disableBtn.enable();
 
-  *
 
-  *             //enable the toolbar
 
-  *             toolbar.enable();
 
-  *         }
 
-  *     });
 
-  *
 
-  *     var disableBtn = Ext.create('Ext.button.Button', {
 
-  *         text    : 'Disable All Items',
 
-  *         scope   : this,
 
-  *         handler : function() {
 
-  *             //enable the enable button and disable button
 
-  *             disableBtn.disable();
 
-  *             enableBtn.enable();
 
-  *
 
-  *             //disable the toolbar
 
-  *             toolbar.disable();
 
-  *         }
 
-  *     });
 
-  *
 
-  *     var toolbar = Ext.create('Ext.toolbar.Toolbar', {
 
-  *         renderTo: document.body,
 
-  *         width   : 400,
 
-  *         margin  : '5 0 0 0',
 
-  *         items   : [enableBtn, disableBtn]
 
-  *     });
 
-  *
 
-  * Adding items to and removing items from a toolbar is as simple as calling the {@link #method-add}
 
-  * and {@link #method-remove} methods. There is also a {@link #removeAll} method
 
-  * which remove all items within the toolbar.
 
-  *
 
-  *     @example
 
-  *     var toolbar = Ext.create('Ext.toolbar.Toolbar', {
 
-  *         renderTo: document.body,
 
-  *         width   : 700,
 
-  *         items: [
 
-  *             {
 
-  *                 text: 'Example Button'
 
-  *             }
 
-  *         ]
 
-  *     });
 
-  *
 
-  *     var addedItems = [];
 
-  *
 
-  *     Ext.create('Ext.toolbar.Toolbar', {
 
-  *         renderTo: document.body,
 
-  *         width   : 700,
 
-  *         margin  : '5 0 0 0',
 
-  *         items   : [
 
-  *             {
 
-  *                 text   : 'Add a button',
 
-  *                 scope  : this,
 
-  *                 handler: function() {
 
-  *                     var text = prompt('Please enter the text for your button:');
 
-  *                     addedItems.push(toolbar.add({
 
-  *                         text: text
 
-  *                     }));
 
-  *                 }
 
-  *             },
 
-  *             {
 
-  *                 text   : 'Add a text item',
 
-  *                 scope  : this,
 
-  *                 handler: function() {
 
-  *                     var text = prompt('Please enter the text for your item:');
 
-  *                     addedItems.push(toolbar.add(text));
 
-  *                 }
 
-  *             },
 
-  *             {
 
-  *                 text   : 'Add a toolbar separator',
 
-  *                 scope  : this,
 
-  *                 handler: function() {
 
-  *                     addedItems.push(toolbar.add('-'));
 
-  *                 }
 
-  *             },
 
-  *             {
 
-  *                 text   : 'Add a toolbar spacer',
 
-  *                 scope  : this,
 
-  *                 handler: function() {
 
-  *                     addedItems.push(toolbar.add('->'));
 
-  *                 }
 
-  *             },
 
-  *             '->',
 
-  *             {
 
-  *                 text   : 'Remove last inserted item',
 
-  *                 scope  : this,
 
-  *                 handler: function() {
 
-  *                     if (addedItems.length) {
 
-  *                         toolbar.remove(addedItems.pop());
 
-  *                     } else if (toolbar.items.length) {
 
-  *                         toolbar.remove(toolbar.items.last());
 
-  *                     } else {
 
-  *                         alert('No items in the toolbar');
 
-  *                     }
 
-  *                 }
 
-  *             },
 
-  *             {
 
-  *                 text   : 'Remove all items',
 
-  *                 scope  : this,
 
-  *                 handler: function() {
 
-  *                     toolbar.removeAll();
 
-  *                 }
 
-  *             }
 
-  *         ]
 
-  *     });
 
-  *
 
-  * @constructor
 
-  * Creates a new Toolbar
 
-  * @param {Object/Object[]} config A config object or an array of buttons to {@link #method-add}
 
-  * @docauthor Robert Dougan <rob@sencha.com>
 
-  */
 
- Ext.define('Ext.toolbar.Toolbar', {
 
-     extend: 'Ext.container.Container',
 
-     requires: [
 
-         'Ext.toolbar.Fill',
 
-         'Ext.layout.container.HBox',
 
-         'Ext.layout.container.VBox'
 
-     ],
 
-     uses: [
 
-         'Ext.toolbar.Separator'
 
-     ],
 
-     alias: 'widget.toolbar',
 
-     alternateClassName: 'Ext.Toolbar',
 
- <span id='Ext-toolbar-Toolbar-property-isToolbar'>    /**
 
- </span>     * @property {Boolean} isToolbar
 
-      * `true` in this class to identify an object as an instantiated Toolbar, or subclass thereof.
 
-      */
 
-     isToolbar: true,
 
-     baseCls  : Ext.baseCSSPrefix + 'toolbar',
 
-     ariaRole : 'toolbar',
 
-     defaultType: 'button',
 
- <span id='Ext-toolbar-Toolbar-cfg-vertical'>    /**
 
- </span>     * @cfg {Boolean} vertical
 
-      * Set to `true` to make the toolbar vertical. The layout will become a `vbox`.
 
-      */
 
-     vertical: false,
 
- <span id='Ext-toolbar-Toolbar-cfg-layout'>    /**
 
- </span>     * @cfg {String/Object} layout
 
-      * This class assigns a default layout (`layout: 'hbox'`).
 
-      * Developers _may_ override this configuration option if another layout
 
-      * is required (the constructor must be passed a configuration object in this
 
-      * case instead of an array).
 
-      * See {@link Ext.container.Container#layout} for additional information.
 
-      */
 
- <span id='Ext-toolbar-Toolbar-cfg-enableOverflow'>    /**
 
- </span>     * @cfg {Boolean} enableOverflow
 
-      * Configure true to make the toolbar provide a button which activates a dropdown Menu to show
 
-      * items which overflow the Toolbar's width.
 
-      */
 
-     enableOverflow: false,
 
- <span id='Ext-toolbar-Toolbar-cfg-menuTriggerCls'>    /**
 
- </span>     * @cfg {String} menuTriggerCls
 
-      * Configure the icon class of the overflow button.
 
-      */
 
-     menuTriggerCls: Ext.baseCSSPrefix + 'toolbar-more-icon',
 
-     
 
-     // private
 
-     trackMenus: true,
 
-     itemCls: Ext.baseCSSPrefix + 'toolbar-item',
 
-     statics: {
 
-         shortcuts: {
 
-             '-' : 'tbseparator',
 
-             ' ' : 'tbspacer'
 
-         },
 
-         shortcutsHV: {
 
-             // horizontal
 
-             0: {
 
-                 '->': { xtype: 'tbfill', height: 0 }
 
-             },
 
-             // vertical
 
-             1: {
 
-                 '->': { xtype: 'tbfill', width: 0 }
 
-             }
 
-         }
 
-     },
 
-     initComponent: function() {
 
-         var me = this,
 
-             keys;
 
-         // check for simplified (old-style) overflow config:
 
-         if (!me.layout && me.enableOverflow) {
 
-             me.layout = { overflowHandler: 'Menu' };
 
-         }
 
-         if (me.dock === 'right' || me.dock === 'left') {
 
-             me.vertical = true;
 
-         }
 
-         me.layout = Ext.applyIf(Ext.isString(me.layout) ? {
 
-             type: me.layout
 
-         } : me.layout || {}, {
 
-             type: me.vertical ? 'vbox' : 'hbox',
 
-             align: me.vertical ? 'stretchmax' : 'middle'
 
-         });
 
-         if (me.vertical) {
 
-             me.addClsWithUI('vertical');
 
-         }
 
-         // @TODO: remove this hack and implement a more general solution
 
-         if (me.ui === 'footer') {
 
-             me.ignoreBorderManagement = true;
 
-         }
 
-         me.callParent();
 
- <span id='Ext-toolbar-Toolbar-event-overflowchange'>        /**
 
- </span>         * @event overflowchange
 
-          * Fires after the overflow state has changed.
 
-          * @param {Object} c The Container
 
-          * @param {Boolean} lastOverflow overflow state
 
-          */
 
-         me.addEvents('overflowchange');
 
-     },
 
-     getRefItems: function(deep) {
 
-         var me = this,
 
-             items = me.callParent(arguments),
 
-             layout = me.layout,
 
-             handler;
 
-         if (deep && me.enableOverflow) {
 
-             handler = layout.overflowHandler;
 
-             if (handler && handler.menu) {
 
-                 items = items.concat(handler.menu.getRefItems(deep));
 
-             }
 
-         }
 
-         return items;
 
-     },
 
- <span id='Ext-toolbar-Toolbar-method-add'>    /**
 
- </span>     * Adds element(s) to the toolbar -- this function takes a variable number of
 
-      * arguments of mixed type and adds them to the toolbar.
 
-      *
 
-      * **Note**: See the notes within {@link Ext.container.Container#method-add}.
 
-      *
 
-      * @param {Object...} args The following types of arguments are all valid:
 
-      *
 
-      *  - `{@link Ext.button.Button config}`: A valid button config object
 
-      *  - `HtmlElement`: Any standard HTML element
 
-      *  - `Field`: Any form field
 
-      *  - `Item`: Any subclass of {@link Ext.toolbar.Item}
 
-      *  - `String`: Any generic string (gets wrapped in a {@link Ext.toolbar.TextItem}).
 
-      *
 
-      *    Note that there are a few special strings that are treated differently as explained next:
 
-      *
 
-      *      - `'-'`: Creates a separator element
 
-      *      - `' '`: Creates a spacer element
 
-      *      - `'->'`: Creates a fill element
 
-      *
 
-      * @method add
 
-      */
 
-     // private
 
-     lookupComponent: function(c) {
 
-         if (typeof c == 'string') {
 
-             var T = Ext.toolbar.Toolbar,
 
-                 shortcut = T.shortcutsHV[this.vertical ? 1 : 0][c] || T.shortcuts[c];
 
-             if (typeof shortcut == 'string') {
 
-                 c = {
 
-                     xtype: shortcut
 
-                 };
 
-             } else if (shortcut) {
 
-                 c = Ext.apply({}, shortcut);
 
-             } else {
 
-                 c = {
 
-                     xtype: 'tbtext',
 
-                     text: c
 
-                 };
 
-             }
 
-             this.applyDefaults(c);
 
-         }
 
-         return this.callParent(arguments);
 
-     },
 
-     // private
 
-     applyDefaults: function(c) {
 
-         if (!Ext.isString(c)) {
 
-             c = this.callParent(arguments);
 
-         }
 
-         return c;
 
-     },
 
-     // private
 
-     trackMenu: function(item, remove) {
 
-         if (this.trackMenus && item.menu) {
 
-             var method = remove ? 'mun' : 'mon',
 
-                 me = this;
 
-             me[method](item, 'mouseover', me.onButtonOver, me);
 
-             me[method](item, 'menushow', me.onButtonMenuShow, me);
 
-             me[method](item, 'menuhide', me.onButtonMenuHide, me);
 
-         }
 
-     },
 
-     // private
 
-     constructButton: function(item) {
 
-         return item.events ? item
 
-                 : Ext.widget(item.split ? 'splitbutton' : this.defaultType, item);
 
-     },
 
-     // private
 
-     onBeforeAdd: function(component) {
 
-         if (component.is('field') || (component.is('button') && this.ui != 'footer')) {
 
-             component.ui = component.ui + '-toolbar';
 
-         }
 
-         // Any separators needs to know if is vertical or not
 
-         if (component instanceof Ext.toolbar.Separator) {
 
-             component.setUI((this.vertical) ? 'vertical' : 'horizontal');
 
-         }
 
-         this.callParent(arguments);
 
-     },
 
-     // private
 
-     onAdd: function(component) {
 
-         this.callParent(arguments);
 
-         this.trackMenu(component);
 
-     },
 
-     
 
-     // private
 
-     onRemove: function(c) {
 
-         this.callParent(arguments);
 
-         this.trackMenu(c, true);
 
-     },
 
-     
 
-     getChildItemsToDisable: function() {
 
-         return this.items.getRange();   
 
-     },
 
-     // private
 
-     onButtonOver: function(btn){
 
-         if (this.activeMenuBtn && this.activeMenuBtn != btn) {
 
-             this.activeMenuBtn.hideMenu();
 
-             btn.showMenu();
 
-             this.activeMenuBtn = btn;
 
-         }
 
-     },
 
-     // private
 
-     onButtonMenuShow: function(btn) {
 
-         this.activeMenuBtn = btn;
 
-     },
 
-     // private
 
-     onButtonMenuHide: function(btn) {
 
-         delete this.activeMenuBtn;
 
-     }
 
- });</pre>
 
- </body>
 
- </html>
 
 
  |