~ubuntu-branches/ubuntu/raring/maas/raring-updates

« back to all changes in this revision

Viewing changes to src/maasserver/static/jslibs/yui/3.4.1/build/widget-uievents/widget-uievents-debug.js

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-07-03 17:42:37 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20120703174237-p8l0keuuznfg721k
Tags: 0.1+bzr709+dfsg-0ubuntu1
* New Upstream release
* debian/control:
  - Depends on python-celery, python-tempita, libjs-yui3-{full,min},
    libjs-raphael
* debian/maas.install:
  - Install apiclient, celeryconfig.py, maas-import-pxe-files, preseeds_v2.
  - Update to install various files from chroot, rather tha manually copy
    them from the source.
* debian/maas.links: symlink celeryconfig.py
* debian/maas.maas-celery.upstart: Add job.
* debian/rules:
  - Install celery upstart job.
  - Do not install jslibs as packages are now used.
  - Drop copying of maas_local_settings_sample.py as source now ships
    a maas_local_settings.py
* debian/patches:
  - 04-maas-http-fix.patch: Drop. Merged upstream.
  - 01-fix-database-settings.patch: Refreshed.
  - 99_enums_js.patch: Added until creation of enum.js / build process
    is fixed.
* debian/maas.postinst: Update bzr version to correctly handle upgrades.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
YUI 3.4.1 (build 4118)
3
 
Copyright 2011 Yahoo! Inc. All rights reserved.
4
 
Licensed under the BSD License.
5
 
http://yuilibrary.com/license/
6
 
*/
7
 
YUI.add('widget-uievents', function(Y) {
8
 
 
9
 
/**
10
 
 * Support for Widget UI Events (Custom Events fired by the widget, which wrap the underlying DOM events - e.g. widget:click, widget:mousedown)
11
 
 *
12
 
 * @module widget
13
 
 * @submodule widget-uievents
14
 
 */
15
 
 
16
 
var BOUNDING_BOX = "boundingBox",
17
 
    Widget = Y.Widget,
18
 
    RENDER = "render",
19
 
    L = Y.Lang,
20
 
    EVENT_PREFIX_DELIMITER = ":",
21
 
 
22
 
    //  Map of Node instances serving as a delegation containers for a specific
23
 
    //  event type to Widget instances using that delegation container.
24
 
    _uievts = Y.Widget._uievts = Y.Widget._uievts || {};
25
 
 
26
 
Y.mix(Widget.prototype, {
27
 
 
28
 
    /**
29
 
     * Destructor logic for UI event infrastructure,
30
 
     * invoked during Widget destruction.
31
 
     *
32
 
     * @method _destroyUIEvents
33
 
     * @for Widget
34
 
     * @private
35
 
     */
36
 
    _destroyUIEvents: function() {
37
 
 
38
 
        var widgetGuid = Y.stamp(this, true);
39
 
 
40
 
        Y.each(_uievts, function (info, key) {
41
 
            if (info.instances[widgetGuid]) {
42
 
                //  Unregister this Widget instance as needing this delegated
43
 
                //  event listener.
44
 
                delete info.instances[widgetGuid];
45
 
 
46
 
                //  There are no more Widget instances using this delegated 
47
 
                //  event listener, so detach it.
48
 
 
49
 
                if (Y.Object.isEmpty(info.instances)) {
50
 
                    info.handle.detach();
51
 
 
52
 
                    if (_uievts[key]) {
53
 
                        delete _uievts[key];
54
 
                    }
55
 
                }
56
 
            }
57
 
        });
58
 
    },
59
 
 
60
 
    /**
61
 
     * Map of DOM events that should be fired as Custom Events by the  
62
 
     * Widget instance.
63
 
     *
64
 
     * @property UI_EVENTS
65
 
     * @for Widget
66
 
     * @type Object
67
 
     */
68
 
    UI_EVENTS: Y.Node.DOM_EVENTS,
69
 
 
70
 
    /**
71
 
     * Returns the node on which to bind delegate listeners.
72
 
     *
73
 
     * @method _getUIEventNode
74
 
     * @for Widget
75
 
     * @protected
76
 
     */
77
 
    _getUIEventNode: function () {
78
 
        return this.get(BOUNDING_BOX);
79
 
    },
80
 
 
81
 
    /**
82
 
     * Binds a delegated DOM event listener of the specified type to the 
83
 
     * Widget's outtermost DOM element to facilitate the firing of a Custom
84
 
     * Event of the same type for the Widget instance.  
85
 
     *
86
 
     * @method _createUIEvent
87
 
     * @for Widget 
88
 
     * @param type {String} String representing the name of the event
89
 
     * @private
90
 
     */
91
 
    _createUIEvent: function (type) {
92
 
 
93
 
        var uiEvtNode = this._getUIEventNode(),
94
 
            key = (Y.stamp(uiEvtNode) + type),
95
 
            info = _uievts[key],
96
 
            handle;
97
 
 
98
 
        //  For each Node instance: Ensure that there is only one delegated
99
 
        //  event listener used to fire Widget UI events.
100
 
 
101
 
        if (!info) {
102
 
 
103
 
            handle = uiEvtNode.delegate(type, function (evt) {
104
 
 
105
 
                var widget = Widget.getByNode(this);
106
 
 
107
 
                // Widget could be null if node instance belongs to
108
 
                // another Y instance.
109
 
 
110
 
                if (widget) {
111
 
                    if (widget._filterUIEvent(evt)) {
112
 
                        widget.fire(evt.type, { domEvent: evt });
113
 
                    }
114
 
                }
115
 
 
116
 
            }, "." + Y.Widget.getClassName());
117
 
 
118
 
            _uievts[key] = info = { instances: {}, handle: handle };
119
 
        }
120
 
 
121
 
        //  Register this Widget as using this Node as a delegation container.
122
 
        info.instances[Y.stamp(this)] = 1;
123
 
    },
124
 
 
125
 
    /**
126
 
     * This method is used to determine if we should fire
127
 
     * the UI Event or not. The default implementation makes sure
128
 
     * that for nested delegates (nested unrelated widgets), we don't 
129
 
     * fire the UI event listener more than once at each level.
130
 
     *
131
 
     * <p>For example, without the additional filter, if you have nested 
132
 
     * widgets, each widget will have a delegate listener. If you 
133
 
     * click on the inner widget, the inner delegate listener's 
134
 
     * filter will match once, but the outer will match twice 
135
 
     * (based on delegate's design) - once for the inner widget, 
136
 
     * and once for the outer.</p>
137
 
     *
138
 
     * @method _filterUIEvent
139
 
     * @for Widget 
140
 
     * @param {DOMEventFacade} evt
141
 
     * @return {boolean} true if it's OK to fire the custom UI event, false if not.
142
 
     * @private
143
 
     * 
144
 
     */
145
 
    _filterUIEvent: function(evt) {
146
 
        // Either it's hitting this widget's delegate container (and not some other widget's), 
147
 
        // or the container it's hitting is handling this widget's ui events.
148
 
        return (evt.currentTarget.compareTo(evt.container) || evt.container.compareTo(this._getUIEventNode()));        
149
 
    },
150
 
 
151
 
    /**
152
 
     * Determines if the specified event is a UI event.
153
 
     *
154
 
     * @private
155
 
     * @method _isUIEvent
156
 
     * @for Widget 
157
 
     * @param type {String} String representing the name of the event
158
 
     * @return {String} Event Returns the name of the UI Event, otherwise 
159
 
     * undefined.
160
 
     */
161
 
    _getUIEvent: function (type) {
162
 
 
163
 
        if (L.isString(type)) {
164
 
            var sType = this.parseType(type)[1],
165
 
                iDelim,
166
 
                returnVal;
167
 
 
168
 
            if (sType) {
169
 
                // TODO: Get delimiter from ET, or have ET support this.
170
 
                iDelim = sType.indexOf(EVENT_PREFIX_DELIMITER);
171
 
                if (iDelim > -1) {
172
 
                    sType = sType.substring(iDelim + EVENT_PREFIX_DELIMITER.length);
173
 
                }
174
 
 
175
 
                if (this.UI_EVENTS[sType]) {
176
 
                    returnVal = sType;
177
 
                }
178
 
            }
179
 
 
180
 
            return returnVal;
181
 
        }
182
 
    },
183
 
 
184
 
    /**
185
 
     * Sets up infrastructure required to fire a UI event.
186
 
     * 
187
 
     * @private
188
 
     * @method _initUIEvent
189
 
     * @for Widget
190
 
     * @param type {String} String representing the name of the event
191
 
     * @return {String}     
192
 
     */
193
 
    _initUIEvent: function (type) {
194
 
        var sType = this._getUIEvent(type),
195
 
            queue = this._uiEvtsInitQueue || {};
196
 
 
197
 
        if (sType && !queue[sType]) {
198
 
            Y.log("Deferring creation of " + type + " delegate until render.", "info", "widget");
199
 
 
200
 
            this._uiEvtsInitQueue = queue[sType] = 1;
201
 
 
202
 
            this.after(RENDER, function() { 
203
 
                this._createUIEvent(sType);
204
 
                delete this._uiEvtsInitQueue[sType];
205
 
            });
206
 
        }
207
 
    },
208
 
 
209
 
    //  Override of "on" from Base to facilitate the firing of Widget events
210
 
    //  based on DOM events of the same name/type (e.g. "click", "mouseover").
211
 
    //  Temporary solution until we have the ability to listen to when 
212
 
    //  someone adds an event listener (bug 2528230)
213
 
    on: function (type) {
214
 
        this._initUIEvent(type);
215
 
        return Widget.superclass.on.apply(this, arguments);
216
 
    },
217
 
 
218
 
    //  Override of "publish" from Base to facilitate the firing of Widget events
219
 
    //  based on DOM events of the same name/type (e.g. "click", "mouseover").    
220
 
    //  Temporary solution until we have the ability to listen to when 
221
 
    //  someone publishes an event (bug 2528230)     
222
 
    publish: function (type, config) {
223
 
        var sType = this._getUIEvent(type);
224
 
        if (sType && config && config.defaultFn) {
225
 
            this._initUIEvent(sType);
226
 
        }        
227
 
        return Widget.superclass.publish.apply(this, arguments);
228
 
    }
229
 
 
230
 
}, true); // overwrite existing EventTarget methods
231
 
 
232
 
 
233
 
}, '3.4.1' ,{requires:['widget-base', 'node-event-delegate']});