Bienvenue sur PostGIS.fr

Bienvenue sur PostGIS.fr , le site de la communauté des utilisateurs francophones de PostGIS.

PostGIS ajoute le support d'objets géographique à la base de données PostgreSQL. En effet, PostGIS "spatialise" le serverur PostgreSQL, ce qui permet de l'utiliser comme une base de données SIG.

Maintenu à jour, en fonction de nos disponibilités et des diverses sorties des outils que nous testons, nous vous proposons l'ensemble de nos travaux publiés en langue française.

source: trunk/workshop-routing-foss4g/web/ext/src/widgets/Button.js @ 76

Revision 76, 27.4 KB checked in by djay, 12 years ago (diff)

Ajout du répertoire web

  • Property svn:executable set to *
Line 
1/*!
2 * Ext JS Library 3.4.0
3 * Copyright(c) 2006-2011 Sencha Inc.
4 * licensing@sencha.com
5 * http://www.sencha.com/license
6 */
7/**
8 * @class Ext.Button
9 * @extends Ext.BoxComponent
10 * Simple Button class
11 * @cfg {String} text The button text to be used as innerHTML (html tags are accepted)
12 * @cfg {String} icon The path to an image to display in the button (the image will be set as the background-image
13 * CSS property of the button by default, so if you want a mixed icon/text button, set cls:'x-btn-text-icon')
14 * @cfg {Function} handler A function called when the button is clicked (can be used instead of click event).
15 * The handler is passed the following parameters:<div class="mdetail-params"><ul>
16 * <li><code>b</code> : Button<div class="sub-desc">This Button.</div></li>
17 * <li><code>e</code> : EventObject<div class="sub-desc">The click event.</div></li>
18 * </ul></div>
19 * @cfg {Number} minWidth The minimum width for this button (used to give a set of buttons a common width).
20 * See also {@link Ext.Panel}.<tt>{@link Ext.Panel#minButtonWidth minButtonWidth}</tt>.
21 * @cfg {String/Object} tooltip The tooltip for the button - can be a string to be used as innerHTML (html tags are accepted) or QuickTips config object
22 * @cfg {Boolean} hidden True to start hidden (defaults to false)
23 * @cfg {Boolean} disabled True to start disabled (defaults to false)
24 * @cfg {Boolean} pressed True to start pressed (only if enableToggle = true)
25 * @cfg {String} toggleGroup The group this toggle button is a member of (only 1 per group can be pressed)
26 * @cfg {Boolean/Object} repeat True to repeat fire the click event while the mouse is down. This can also be
27 * a {@link Ext.util.ClickRepeater ClickRepeater} config object (defaults to false).
28 * @constructor
29 * Create a new button
30 * @param {Object} config The config object
31 * @xtype button
32 */
33Ext.Button = Ext.extend(Ext.BoxComponent, {
34    /**
35     * Read-only. True if this button is hidden
36     * @type Boolean
37     */
38    hidden : false,
39    /**
40     * Read-only. True if this button is disabled
41     * @type Boolean
42     */
43    disabled : false,
44    /**
45     * Read-only. True if this button is pressed (only if enableToggle = true)
46     * @type Boolean
47     */
48    pressed : false,
49
50    /**
51     * @cfg {Number} tabIndex Set a DOM tabIndex for this button (defaults to undefined)
52     */
53
54    /**
55     * @cfg {Boolean} allowDepress
56     * False to not allow a pressed Button to be depressed (defaults to undefined). Only valid when {@link #enableToggle} is true.
57     */
58
59    /**
60     * @cfg {Boolean} enableToggle
61     * True to enable pressed/not pressed toggling (defaults to false)
62     */
63    enableToggle : false,
64    /**
65     * @cfg {Function} toggleHandler
66     * Function called when a Button with {@link #enableToggle} set to true is clicked. Two arguments are passed:<ul class="mdetail-params">
67     * <li><b>button</b> : Ext.Button<div class="sub-desc">this Button object</div></li>
68     * <li><b>state</b> : Boolean<div class="sub-desc">The next state of the Button, true means pressed.</div></li>
69     * </ul>
70     */
71    /**
72     * @cfg {Mixed} menu
73     * Standard menu attribute consisting of a reference to a menu object, a menu id or a menu config blob (defaults to undefined).
74     */
75    /**
76     * @cfg {String} menuAlign
77     * The position to align the menu to (see {@link Ext.Element#alignTo} for more details, defaults to 'tl-bl?').
78     */
79    menuAlign : 'tl-bl?',
80
81    /**
82     * @cfg {String} overflowText If used in a {@link Ext.Toolbar Toolbar}, the
83     * text to be used if this item is shown in the overflow menu. See also
84     * {@link Ext.Toolbar.Item}.<code>{@link Ext.Toolbar.Item#overflowText overflowText}</code>.
85     */
86    /**
87     * @cfg {String} iconCls
88     * A css class which sets a background image to be used as the icon for this button
89     */
90    /**
91     * @cfg {String} type
92     * submit, reset or button - defaults to 'button'
93     */
94    type : 'button',
95
96    // private
97    menuClassTarget : 'tr:nth(2)',
98
99    /**
100     * @cfg {String} clickEvent
101     * The DOM event that will fire the handler of the button. This can be any valid event name (dblclick, contextmenu).
102     * Defaults to <tt>'click'</tt>.
103     */
104    clickEvent : 'click',
105
106    /**
107     * @cfg {Boolean} handleMouseEvents
108     * False to disable visual cues on mouseover, mouseout and mousedown (defaults to true)
109     */
110    handleMouseEvents : true,
111
112    /**
113     * @cfg {String} tooltipType
114     * The type of tooltip to use. Either 'qtip' (default) for QuickTips or 'title' for title attribute.
115     */
116    tooltipType : 'qtip',
117
118    /**
119     * @cfg {String} buttonSelector
120     * <p>(Optional) A {@link Ext.DomQuery DomQuery} selector which is used to extract the active, clickable element from the
121     * DOM structure created.</p>
122     * <p>When a custom {@link #template} is used, you  must ensure that this selector results in the selection of
123     * a focussable element.</p>
124     * <p>Defaults to <b><tt>'button:first-child'</tt></b>.</p>
125     */
126    buttonSelector : 'button:first-child',
127
128    /**
129     * @cfg {String} scale
130     * <p>(Optional) The size of the Button. Three values are allowed:</p>
131     * <ul class="mdetail-params">
132     * <li>'small'<div class="sub-desc">Results in the button element being 16px high.</div></li>
133     * <li>'medium'<div class="sub-desc">Results in the button element being 24px high.</div></li>
134     * <li>'large'<div class="sub-desc">Results in the button element being 32px high.</div></li>
135     * </ul>
136     * <p>Defaults to <b><tt>'small'</tt></b>.</p>
137     */
138    scale : 'small',
139
140    /**
141     * @cfg {Object} scope The scope (<tt><b>this</b></tt> reference) in which the
142     * <code>{@link #handler}</code> and <code>{@link #toggleHandler}</code> is
143     * executed. Defaults to this Button.
144     */
145
146    /**
147     * @cfg {String} iconAlign
148     * <p>(Optional) The side of the Button box to render the icon. Four values are allowed:</p>
149     * <ul class="mdetail-params">
150     * <li>'top'<div class="sub-desc"></div></li>
151     * <li>'right'<div class="sub-desc"></div></li>
152     * <li>'bottom'<div class="sub-desc"></div></li>
153     * <li>'left'<div class="sub-desc"></div></li>
154     * </ul>
155     * <p>Defaults to <b><tt>'left'</tt></b>.</p>
156     */
157    iconAlign : 'left',
158
159    /**
160     * @cfg {String} arrowAlign
161     * <p>(Optional) The side of the Button box to render the arrow if the button has an associated {@link #menu}.
162     * Two values are allowed:</p>
163     * <ul class="mdetail-params">
164     * <li>'right'<div class="sub-desc"></div></li>
165     * <li>'bottom'<div class="sub-desc"></div></li>
166     * </ul>
167     * <p>Defaults to <b><tt>'right'</tt></b>.</p>
168     */
169    arrowAlign : 'right',
170
171    /**
172     * @cfg {Ext.Template} template (Optional)
173     * <p>A {@link Ext.Template Template} used to create the Button's DOM structure.</p>
174     * Instances, or subclasses which need a different DOM structure may provide a different
175     * template layout in conjunction with an implementation of {@link #getTemplateArgs}.
176     * @type Ext.Template
177     * @property template
178     */
179    /**
180     * @cfg {String} cls
181     * A CSS class string to apply to the button's main element.
182     */
183    /**
184     * @property menu
185     * @type Menu
186     * The {@link Ext.menu.Menu Menu} object associated with this Button when configured with the {@link #menu} config option.
187     */
188    /**
189     * @cfg {Boolean} autoWidth
190     * By default, if a width is not specified the button will attempt to stretch horizontally to fit its content.
191     * If the button is being managed by a width sizing layout (hbox, fit, anchor), set this to false to prevent
192     * the button from doing this automatic sizing.
193     * Defaults to <tt>undefined</tt>.
194     */
195
196    initComponent : function(){
197        if(this.menu){
198            // If array of items, turn it into an object config so we
199            // can set the ownerCt property in the config
200            if (Ext.isArray(this.menu)){
201                this.menu = { items: this.menu };
202            }
203           
204            // An object config will work here, but an instance of a menu
205            // will have already setup its ref's and have no effect
206            if (Ext.isObject(this.menu)){
207                this.menu.ownerCt = this;
208            }
209           
210            this.menu = Ext.menu.MenuMgr.get(this.menu);
211            this.menu.ownerCt = undefined;
212        }
213       
214        Ext.Button.superclass.initComponent.call(this);
215
216        this.addEvents(
217            /**
218             * @event click
219             * Fires when this button is clicked
220             * @param {Button} this
221             * @param {EventObject} e The click event
222             */
223            'click',
224            /**
225             * @event toggle
226             * Fires when the 'pressed' state of this button changes (only if enableToggle = true)
227             * @param {Button} this
228             * @param {Boolean} pressed
229             */
230            'toggle',
231            /**
232             * @event mouseover
233             * Fires when the mouse hovers over the button
234             * @param {Button} this
235             * @param {Event} e The event object
236             */
237            'mouseover',
238            /**
239             * @event mouseout
240             * Fires when the mouse exits the button
241             * @param {Button} this
242             * @param {Event} e The event object
243             */
244            'mouseout',
245            /**
246             * @event menushow
247             * If this button has a menu, this event fires when it is shown
248             * @param {Button} this
249             * @param {Menu} menu
250             */
251            'menushow',
252            /**
253             * @event menuhide
254             * If this button has a menu, this event fires when it is hidden
255             * @param {Button} this
256             * @param {Menu} menu
257             */
258            'menuhide',
259            /**
260             * @event menutriggerover
261             * If this button has a menu, this event fires when the mouse enters the menu triggering element
262             * @param {Button} this
263             * @param {Menu} menu
264             * @param {EventObject} e
265             */
266            'menutriggerover',
267            /**
268             * @event menutriggerout
269             * If this button has a menu, this event fires when the mouse leaves the menu triggering element
270             * @param {Button} this
271             * @param {Menu} menu
272             * @param {EventObject} e
273             */
274            'menutriggerout'
275        );
276       
277        if(Ext.isString(this.toggleGroup)){
278            this.enableToggle = true;
279        }
280    },
281
282/**
283  * <p>This method returns an Array which provides substitution parameters for the {@link #template Template} used
284  * to create this Button's DOM structure.</p>
285  * <p>Instances or subclasses which use a different Template to create a different DOM structure may need to provide their
286  * own implementation of this method.</p>
287  * <p>The default implementation which provides data for the default {@link #template} returns an Array containing the
288  * following items:</p><div class="mdetail-params"><ul>
289  * <li>The &lt;button&gt;'s {@link #type}</li>
290  * <li>A CSS class name applied to the Button's main &lt;tbody&gt; element which determines the button's scale and icon alignment.</li>
291  * <li>A CSS class to determine the presence and position of an arrow icon. (<code>'x-btn-arrow'</code> or <code>'x-btn-arrow-bottom'</code> or <code>''</code>)</li>
292  * <li>The {@link #cls} CSS class name applied to the button's wrapping &lt;table&gt; element.</li>
293  * <li>The Component id which is applied to the button's wrapping &lt;table&gt; element.</li>
294  * </ul></div>
295  * @return {Array} Substitution data for a Template.
296 */
297    getTemplateArgs : function(){
298        return [this.type, 'x-btn-' + this.scale + ' x-btn-icon-' + this.scale + '-' + this.iconAlign, this.getMenuClass(), this.cls, this.id];
299    },
300
301    // private
302    setButtonClass : function(){
303        if(this.useSetClass){
304            if(!Ext.isEmpty(this.oldCls)){
305                this.el.removeClass([this.oldCls, 'x-btn-pressed']);
306            }
307            this.oldCls = (this.iconCls || this.icon) ? (this.text ? 'x-btn-text-icon' : 'x-btn-icon') : 'x-btn-noicon';
308            this.el.addClass([this.oldCls, this.pressed ? 'x-btn-pressed' : null]);
309        }
310    },
311
312    // protected
313    getMenuClass : function(){
314        return this.menu ? (this.arrowAlign != 'bottom' ? 'x-btn-arrow' : 'x-btn-arrow-bottom') : '';
315    },
316
317    // private
318    onRender : function(ct, position){
319        if(!this.template){
320            if(!Ext.Button.buttonTemplate){
321                // hideous table template
322                Ext.Button.buttonTemplate = new Ext.Template(
323                    '<table id="{4}" cellspacing="0" class="x-btn {3}"><tbody class="{1}">',
324                    '<tr><td class="x-btn-tl"><i>&#160;</i></td><td class="x-btn-tc"></td><td class="x-btn-tr"><i>&#160;</i></td></tr>',
325                    '<tr><td class="x-btn-ml"><i>&#160;</i></td><td class="x-btn-mc"><em class="{2}" unselectable="on"><button type="{0}"></button></em></td><td class="x-btn-mr"><i>&#160;</i></td></tr>',
326                    '<tr><td class="x-btn-bl"><i>&#160;</i></td><td class="x-btn-bc"></td><td class="x-btn-br"><i>&#160;</i></td></tr>',
327                    '</tbody></table>');
328                Ext.Button.buttonTemplate.compile();
329            }
330            this.template = Ext.Button.buttonTemplate;
331        }
332
333        var btn, targs = this.getTemplateArgs();
334
335        if(position){
336            btn = this.template.insertBefore(position, targs, true);
337        }else{
338            btn = this.template.append(ct, targs, true);
339        }
340        /**
341         * An {@link Ext.Element Element} encapsulating the Button's clickable element. By default,
342         * this references a <tt>&lt;button&gt;</tt> element. Read only.
343         * @type Ext.Element
344         * @property btnEl
345         */
346        this.btnEl = btn.child(this.buttonSelector);
347        this.mon(this.btnEl, {
348            scope: this,
349            focus: this.onFocus,
350            blur: this.onBlur
351        });
352
353        this.initButtonEl(btn, this.btnEl);
354
355        Ext.ButtonToggleMgr.register(this);
356    },
357
358    // private
359    initButtonEl : function(btn, btnEl){
360        this.el = btn;
361        this.setIcon(this.icon);
362        this.setText(this.text);
363        this.setIconClass(this.iconCls);
364        if(Ext.isDefined(this.tabIndex)){
365            btnEl.dom.tabIndex = this.tabIndex;
366        }
367        if(this.tooltip){
368            this.setTooltip(this.tooltip, true);
369        }
370
371        if(this.handleMouseEvents){
372            this.mon(btn, {
373                scope: this,
374                mouseover: this.onMouseOver,
375                mousedown: this.onMouseDown
376            });
377
378            // new functionality for monitoring on the document level
379            //this.mon(btn, 'mouseout', this.onMouseOut, this);
380        }
381
382        if(this.menu){
383            this.mon(this.menu, {
384                scope: this,
385                show: this.onMenuShow,
386                hide: this.onMenuHide
387            });
388        }
389
390        if(this.repeat){
391            var repeater = new Ext.util.ClickRepeater(btn, Ext.isObject(this.repeat) ? this.repeat : {});
392            this.mon(repeater, 'click', this.onRepeatClick, this);
393        }else{
394            this.mon(btn, this.clickEvent, this.onClick, this);
395        }
396    },
397
398    // private
399    afterRender : function(){
400        Ext.Button.superclass.afterRender.call(this);
401        this.useSetClass = true;
402        this.setButtonClass();
403        this.doc = Ext.getDoc();
404        this.doAutoWidth();
405    },
406
407    /**
408     * Sets the CSS class that provides a background image to use as the button's icon.  This method also changes
409     * the value of the {@link iconCls} config internally.
410     * @param {String} cls The CSS class providing the icon image
411     * @return {Ext.Button} this
412     */
413    setIconClass : function(cls){
414        this.iconCls = cls;
415        if(this.el){
416            this.btnEl.dom.className = '';
417            this.btnEl.addClass(['x-btn-text', cls || '']);
418            this.setButtonClass();
419        }
420        return this;
421    },
422
423    /**
424     * Sets the tooltip for this Button.
425     * @param {String/Object} tooltip. This may be:<div class="mdesc-details"><ul>
426     * <li><b>String</b> : A string to be used as innerHTML (html tags are accepted) to show in a tooltip</li>
427     * <li><b>Object</b> : A configuration object for {@link Ext.QuickTips#register}.</li>
428     * </ul></div>
429     * @return {Ext.Button} this
430     */
431    setTooltip : function(tooltip, /* private */ initial){
432        if(this.rendered){
433            if(!initial){
434                this.clearTip();
435            }
436            if(Ext.isObject(tooltip)){
437                Ext.QuickTips.register(Ext.apply({
438                      target: this.btnEl.id
439                }, tooltip));
440                this.tooltip = tooltip;
441            }else{
442                this.btnEl.dom[this.tooltipType] = tooltip;
443            }
444        }else{
445            this.tooltip = tooltip;
446        }
447        return this;
448    },
449
450    // private
451    clearTip : function(){
452        if(Ext.isObject(this.tooltip)){
453            Ext.QuickTips.unregister(this.btnEl);
454        }
455    },
456
457    // private
458    beforeDestroy : function(){
459        if(this.rendered){
460            this.clearTip();
461        }
462        if(this.menu && this.destroyMenu !== false) {
463            Ext.destroy(this.btnEl, this.menu);
464        }
465        Ext.destroy(this.repeater);
466    },
467
468    // private
469    onDestroy : function(){
470        if(this.rendered){
471            this.doc.un('mouseover', this.monitorMouseOver, this);
472            this.doc.un('mouseup', this.onMouseUp, this);
473            delete this.doc;
474            delete this.btnEl;
475            Ext.ButtonToggleMgr.unregister(this);
476        }
477        Ext.Button.superclass.onDestroy.call(this);
478    },
479
480    // private
481    doAutoWidth : function(){
482        if(this.autoWidth !== false && this.el && this.text && this.width === undefined){
483            this.el.setWidth('auto');
484            if(Ext.isIE7 && Ext.isStrict){
485                var ib = this.btnEl;
486                if(ib && ib.getWidth() > 20){
487                    ib.clip();
488                    ib.setWidth(Ext.util.TextMetrics.measure(ib, this.text).width+ib.getFrameWidth('lr'));
489                }
490            }
491            if(this.minWidth){
492                if(this.el.getWidth() < this.minWidth){
493                    this.el.setWidth(this.minWidth);
494                }
495            }
496        }
497    },
498
499    /**
500     * Assigns this Button's click handler
501     * @param {Function} handler The function to call when the button is clicked
502     * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the handler function is executed.
503     * Defaults to this Button.
504     * @return {Ext.Button} this
505     */
506    setHandler : function(handler, scope){
507        this.handler = handler;
508        this.scope = scope;
509        return this;
510    },
511
512    /**
513     * Sets this Button's text
514     * @param {String} text The button text
515     * @return {Ext.Button} this
516     */
517    setText : function(text){
518        this.text = text;
519        if(this.el){
520            this.btnEl.update(text || '&#160;');
521            this.setButtonClass();
522        }
523        this.doAutoWidth();
524        return this;
525    },
526
527    /**
528     * Sets the background image (inline style) of the button.  This method also changes
529     * the value of the {@link icon} config internally.
530     * @param {String} icon The path to an image to display in the button
531     * @return {Ext.Button} this
532     */
533    setIcon : function(icon){
534        this.icon = icon;
535        if(this.el){
536            this.btnEl.setStyle('background-image', icon ? 'url(' + icon + ')' : '');
537            this.setButtonClass();
538        }
539        return this;
540    },
541
542    /**
543     * Gets the text for this Button
544     * @return {String} The button text
545     */
546    getText : function(){
547        return this.text;
548    },
549
550    /**
551     * If a state it passed, it becomes the pressed state otherwise the current state is toggled.
552     * @param {Boolean} state (optional) Force a particular state
553     * @param {Boolean} supressEvent (optional) True to stop events being fired when calling this method.
554     * @return {Ext.Button} this
555     */
556    toggle : function(state, suppressEvent){
557        state = state === undefined ? !this.pressed : !!state;
558        if(state != this.pressed){
559            if(this.rendered){
560                this.el[state ? 'addClass' : 'removeClass']('x-btn-pressed');
561            }
562            this.pressed = state;
563            if(!suppressEvent){
564                this.fireEvent('toggle', this, state);
565                if(this.toggleHandler){
566                    this.toggleHandler.call(this.scope || this, this, state);
567                }
568            }
569        }
570        return this;
571    },
572
573    // private
574    onDisable : function(){
575        this.onDisableChange(true);
576    },
577
578    // private
579    onEnable : function(){
580        this.onDisableChange(false);
581    },
582
583    onDisableChange : function(disabled){
584        if(this.el){
585            if(!Ext.isIE6 || !this.text){
586                this.el[disabled ? 'addClass' : 'removeClass'](this.disabledClass);
587            }
588            this.el.dom.disabled = disabled;
589        }
590        this.disabled = disabled;
591    },
592
593    /**
594     * Show this button's menu (if it has one)
595     */
596    showMenu : function(){
597        if(this.rendered && this.menu){
598            if(this.tooltip){
599                Ext.QuickTips.getQuickTip().cancelShow(this.btnEl);
600            }
601            if(this.menu.isVisible()){
602                this.menu.hide();
603            }
604            this.menu.ownerCt = this;
605            this.menu.show(this.el, this.menuAlign);
606        }
607        return this;
608    },
609
610    /**
611     * Hide this button's menu (if it has one)
612     */
613    hideMenu : function(){
614        if(this.hasVisibleMenu()){
615            this.menu.hide();
616        }
617        return this;
618    },
619
620    /**
621     * Returns true if the button has a menu and it is visible
622     * @return {Boolean}
623     */
624    hasVisibleMenu : function(){
625        return this.menu && this.menu.ownerCt == this && this.menu.isVisible();
626    },
627   
628    // private
629    onRepeatClick : function(repeat, e){
630        this.onClick(e);
631    },
632
633    // private
634    onClick : function(e){
635        if(e){
636            e.preventDefault();
637        }
638        if(e.button !== 0){
639            return;
640        }
641        if(!this.disabled){
642            this.doToggle();
643            if(this.menu && !this.hasVisibleMenu() && !this.ignoreNextClick){
644                this.showMenu();
645            }
646            this.fireEvent('click', this, e);
647            if(this.handler){
648                //this.el.removeClass('x-btn-over');
649                this.handler.call(this.scope || this, this, e);
650            }
651        }
652    },
653   
654    // private
655    doToggle: function(){
656        if (this.enableToggle && (this.allowDepress !== false || !this.pressed)) {
657            this.toggle();
658        }
659    },
660
661    // private
662    isMenuTriggerOver : function(e, internal){
663        return this.menu && !internal;
664    },
665
666    // private
667    isMenuTriggerOut : function(e, internal){
668        return this.menu && !internal;
669    },
670
671    // private
672    onMouseOver : function(e){
673        if(!this.disabled){
674            var internal = e.within(this.el,  true);
675            if(!internal){
676                this.el.addClass('x-btn-over');
677                if(!this.monitoringMouseOver){
678                    this.doc.on('mouseover', this.monitorMouseOver, this);
679                    this.monitoringMouseOver = true;
680                }
681                this.fireEvent('mouseover', this, e);
682            }
683            if(this.isMenuTriggerOver(e, internal)){
684                this.fireEvent('menutriggerover', this, this.menu, e);
685            }
686        }
687    },
688
689    // private
690    monitorMouseOver : function(e){
691        if(e.target != this.el.dom && !e.within(this.el)){
692            if(this.monitoringMouseOver){
693                this.doc.un('mouseover', this.monitorMouseOver, this);
694                this.monitoringMouseOver = false;
695            }
696            this.onMouseOut(e);
697        }
698    },
699
700    // private
701    onMouseOut : function(e){
702        var internal = e.within(this.el) && e.target != this.el.dom;
703        this.el.removeClass('x-btn-over');
704        this.fireEvent('mouseout', this, e);
705        if(this.isMenuTriggerOut(e, internal)){
706            this.fireEvent('menutriggerout', this, this.menu, e);
707        }
708    },
709
710    focus : function() {
711        this.btnEl.focus();
712    },
713
714    blur : function() {
715        this.btnEl.blur();
716    },
717
718    // private
719    onFocus : function(e){
720        if(!this.disabled){
721            this.el.addClass('x-btn-focus');
722        }
723    },
724    // private
725    onBlur : function(e){
726        this.el.removeClass('x-btn-focus');
727    },
728
729    // private
730    getClickEl : function(e, isUp){
731       return this.el;
732    },
733
734    // private
735    onMouseDown : function(e){
736        if(!this.disabled && e.button === 0){
737            this.getClickEl(e).addClass('x-btn-click');
738            this.doc.on('mouseup', this.onMouseUp, this);
739        }
740    },
741    // private
742    onMouseUp : function(e){
743        if(e.button === 0){
744            this.getClickEl(e, true).removeClass('x-btn-click');
745            this.doc.un('mouseup', this.onMouseUp, this);
746        }
747    },
748    // private
749    onMenuShow : function(e){
750        if(this.menu.ownerCt == this){
751            this.menu.ownerCt = this;
752            this.ignoreNextClick = 0;
753            this.el.addClass('x-btn-menu-active');
754            this.fireEvent('menushow', this, this.menu);
755        }
756    },
757    // private
758    onMenuHide : function(e){
759        if(this.menu.ownerCt == this){
760            this.el.removeClass('x-btn-menu-active');
761            this.ignoreNextClick = this.restoreClick.defer(250, this);
762            this.fireEvent('menuhide', this, this.menu);
763            delete this.menu.ownerCt;
764        }
765    },
766
767    // private
768    restoreClick : function(){
769        this.ignoreNextClick = 0;
770    }
771
772    /**
773     * @cfg {String} autoEl @hide
774     */
775    /**
776     * @cfg {String/Object} html @hide
777     */
778    /**
779     * @cfg {String} contentEl  @hide
780     */
781    /**
782     * @cfg {Mixed} data  @hide
783     */
784    /**
785     * @cfg {Mixed} tpl  @hide
786     */
787    /**
788     * @cfg {String} tplWriteMode  @hide
789     */
790});
791Ext.reg('button', Ext.Button);
792
793// Private utility class used by Button
794Ext.ButtonToggleMgr = function(){
795   var groups = {};
796
797   function toggleGroup(btn, state){
798       if(state){
799           var g = groups[btn.toggleGroup];
800           for(var i = 0, l = g.length; i < l; i++){
801               if(g[i] != btn){
802                   g[i].toggle(false);
803               }
804           }
805       }
806   }
807
808   return {
809       register : function(btn){
810           if(!btn.toggleGroup){
811               return;
812           }
813           var g = groups[btn.toggleGroup];
814           if(!g){
815               g = groups[btn.toggleGroup] = [];
816           }
817           g.push(btn);
818           btn.on('toggle', toggleGroup);
819       },
820
821       unregister : function(btn){
822           if(!btn.toggleGroup){
823               return;
824           }
825           var g = groups[btn.toggleGroup];
826           if(g){
827               g.remove(btn);
828               btn.un('toggle', toggleGroup);
829           }
830       },
831
832       /**
833        * Gets the pressed button in the passed group or null
834        * @param {String} group
835        * @return Button
836        */
837       getPressed : function(group){
838           var g = groups[group];
839           if(g){
840               for(var i = 0, len = g.length; i < len; i++){
841                   if(g[i].pressed === true){
842                       return g[i];
843                   }
844               }
845           }
846           return null;
847       }
848   };
849}();
Note: See TracBrowser for help on using the repository browser.