~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/event-base-ie/event-base-ie.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
 
(function() {
8
 
 
9
 
var stateChangeListener,
10
 
    GLOBAL_ENV   = YUI.Env,
11
 
    config       = YUI.config,
12
 
    doc          = config.doc,
13
 
    docElement   = doc && doc.documentElement,
14
 
    EVENT_NAME   = 'onreadystatechange',
15
 
    pollInterval = config.pollInterval || 40;
16
 
 
17
 
if (docElement.doScroll && !GLOBAL_ENV._ieready) {
18
 
    GLOBAL_ENV._ieready = function() {
19
 
        GLOBAL_ENV._ready();
20
 
    };
21
 
 
22
 
/*! DOMReady: based on work by: Dean Edwards/John Resig/Matthias Miller/Diego Perini */
23
 
// Internet Explorer: use the doScroll() method on the root element.
24
 
// This isolates what appears to be a safe moment to manipulate the
25
 
// DOM prior to when the document's readyState suggests it is safe to do so.
26
 
    if (self !== self.top) {
27
 
        stateChangeListener = function() {
28
 
            if (doc.readyState == 'complete') {
29
 
                GLOBAL_ENV.remove(doc, EVENT_NAME, stateChangeListener);
30
 
                GLOBAL_ENV.ieready();
31
 
            }
32
 
        };
33
 
        GLOBAL_ENV.add(doc, EVENT_NAME, stateChangeListener);
34
 
    } else {
35
 
        GLOBAL_ENV._dri = setInterval(function() {
36
 
            try {
37
 
                docElement.doScroll('left');
38
 
                clearInterval(GLOBAL_ENV._dri);
39
 
                GLOBAL_ENV._dri = null;
40
 
                GLOBAL_ENV._ieready();
41
 
            } catch (domNotReady) { }
42
 
        }, pollInterval);
43
 
    }
44
 
}
45
 
 
46
 
})();
47
 
YUI.add('event-base-ie', function(Y) {
48
 
 
49
 
/*
50
 
 * Custom event engine, DOM event listener abstraction layer, synthetic DOM
51
 
 * events.
52
 
 * @module event
53
 
 * @submodule event-base
54
 
 */
55
 
 
56
 
function IEEventFacade() {
57
 
    // IEEventFacade.superclass.constructor.apply(this, arguments);
58
 
    Y.DOM2EventFacade.apply(this, arguments);
59
 
}
60
 
 
61
 
/*
62
 
 * (intentially left out of API docs)
63
 
 * Alternate Facade implementation that is based on Object.defineProperty, which
64
 
 * is partially supported in IE8.  Properties that involve setup work are
65
 
 * deferred to temporary getters using the static _define method.
66
 
 */
67
 
function IELazyFacade(e) {
68
 
    var proxy = Y.config.doc.createEventObject(e),
69
 
        proto = IELazyFacade.prototype;
70
 
 
71
 
    // TODO: necessary?
72
 
    proxy.hasOwnProperty = function () { return true; };
73
 
 
74
 
    proxy.init = proto.init;
75
 
    proxy.halt = proto.halt;
76
 
    proxy.preventDefault           = proto.preventDefault;
77
 
    proxy.stopPropagation          = proto.stopPropagation;
78
 
    proxy.stopImmediatePropagation = proto.stopImmediatePropagation;
79
 
 
80
 
    Y.DOM2EventFacade.apply(proxy, arguments);
81
 
 
82
 
    return proxy;
83
 
}
84
 
 
85
 
 
86
 
var imp = Y.config.doc && Y.config.doc.implementation,
87
 
    useLazyFacade = Y.config.lazyEventFacade,
88
 
 
89
 
    buttonMap = {
90
 
        0: 1, // left click
91
 
        4: 2, // middle click
92
 
        2: 3  // right click
93
 
    },
94
 
    relatedTargetMap = {
95
 
        mouseout: 'toElement',
96
 
        mouseover: 'fromElement'
97
 
    },
98
 
 
99
 
    resolve = Y.DOM2EventFacade.resolve,
100
 
 
101
 
    proto = {
102
 
        init: function() {
103
 
 
104
 
            IEEventFacade.superclass.init.apply(this, arguments);
105
 
 
106
 
            var e = this._event,
107
 
                x, y, d, b, de, t;
108
 
 
109
 
            this.target = resolve(e.srcElement);
110
 
 
111
 
            if (('clientX' in e) && (!x) && (0 !== x)) {
112
 
                x = e.clientX;
113
 
                y = e.clientY;
114
 
 
115
 
                d = Y.config.doc;
116
 
                b = d.body;
117
 
                de = d.documentElement;
118
 
 
119
 
                x += (de.scrollLeft || (b && b.scrollLeft) || 0);
120
 
                y += (de.scrollTop  || (b && b.scrollTop)  || 0);
121
 
 
122
 
                this.pageX = x;
123
 
                this.pageY = y;
124
 
            }
125
 
 
126
 
            if (e.type == "mouseout") {
127
 
                t = e.toElement;
128
 
            } else if (e.type == "mouseover") {
129
 
                t = e.fromElement;
130
 
            }
131
 
 
132
 
            // fallback to t.relatedTarget to support simulated events.
133
 
            // IE doesn't support setting toElement or fromElement on generic
134
 
            // events, so Y.Event.simulate sets relatedTarget instead.
135
 
            this.relatedTarget = resolve(t || e.relatedTarget);
136
 
 
137
 
            // which should contain the unicode key code if this is a key event
138
 
            // if (e.charCode) {
139
 
            //     this.which = e.charCode;
140
 
            // }
141
 
 
142
 
            // for click events, which is normalized for which mouse button was
143
 
            // clicked.
144
 
            if (e.button !== undefined) {
145
 
                this.which = this.button = buttonMap[e.button] || e.button;
146
 
            }
147
 
 
148
 
        },
149
 
 
150
 
        stopPropagation: function() {
151
 
            this._event.cancelBubble = true;
152
 
            this._wrapper.stopped = 1;
153
 
            this.stopped = 1;
154
 
        },
155
 
 
156
 
        stopImmediatePropagation: function() {
157
 
            this.stopPropagation();
158
 
            this._wrapper.stopped = 2;
159
 
            this.stopped = 2;
160
 
        },
161
 
 
162
 
        preventDefault: function(returnValue) {
163
 
            this._event.returnValue = returnValue || false;
164
 
            this._wrapper.prevented = 1;
165
 
            this.prevented = 1;
166
 
        }
167
 
    };
168
 
 
169
 
Y.extend(IEEventFacade, Y.DOM2EventFacade, proto);
170
 
 
171
 
Y.extend(IELazyFacade, Y.DOM2EventFacade, proto);
172
 
IELazyFacade.prototype.init = function () {
173
 
    var e         = this._event,
174
 
        overrides = this._wrapper.overrides,
175
 
        define    = IELazyFacade._define,
176
 
        lazyProperties = IELazyFacade._lazyProperties,
177
 
        prop;
178
 
 
179
 
    this.altKey   = e.altKey;
180
 
    this.ctrlKey  = e.ctrlKey;
181
 
    this.metaKey  = e.metaKey;
182
 
    this.shiftKey = e.shiftKey;
183
 
    this.type     = (overrides && overrides.type) || e.type;
184
 
    this.clientX  = e.clientX;
185
 
    this.clientY  = e.clientY;
186
 
 
187
 
    for (prop in lazyProperties) {
188
 
        if (lazyProperties.hasOwnProperty(prop)) {
189
 
            define(this, prop, lazyProperties[prop]);
190
 
        }
191
 
    }
192
 
 
193
 
    if (this._touch) {
194
 
        this._touch(e, this._currentTarget, this._wrapper);
195
 
    }
196
 
};
197
 
 
198
 
IELazyFacade._lazyProperties = {
199
 
    charCode: function () {
200
 
        var e = this._event;
201
 
 
202
 
        return e.keyCode || e.charCode;
203
 
    },
204
 
    keyCode: function () { return this.charCode; },
205
 
 
206
 
    button: function () {
207
 
        var e = this._event;
208
 
 
209
 
        return (e.button !== undefined) ?
210
 
            (buttonMap[e.button] || e.button) :
211
 
            (e.which || e.charCode || this.charCode);
212
 
    },
213
 
    which: function () { return this.button; },
214
 
 
215
 
    target: function () {
216
 
        return resolve(this._event.srcElement);
217
 
    },
218
 
    relatedTarget: function () {
219
 
        var e = this._event,
220
 
            targetProp = relatedTargetMap[e.type] || 'relatedTarget';
221
 
 
222
 
        // fallback to t.relatedTarget to support simulated events.
223
 
        // IE doesn't support setting toElement or fromElement on generic
224
 
        // events, so Y.Event.simulate sets relatedTarget instead.
225
 
        return resolve(e[targetProp] || e.relatedTarget);
226
 
    },
227
 
    currentTarget: function () {
228
 
        return resolve(this._currentTarget);
229
 
    },
230
 
 
231
 
    wheelDelta: function () {
232
 
        var e = this._event;
233
 
 
234
 
        if (e.type === "mousewheel" || e.type === "DOMMouseScroll") {
235
 
            return (e.detail) ?
236
 
                (e.detail * -1) :
237
 
                // wheelDelta between -80 and 80 result in -1 or 1
238
 
                Math.round(e.wheelDelta / 80) || ((e.wheelDelta < 0) ? -1 : 1);
239
 
        }
240
 
    },
241
 
 
242
 
    pageX: function () {
243
 
        var e = this._event,
244
 
            val = e.pageX,
245
 
            doc, bodyScroll, docScroll;
246
 
                
247
 
        if (val === undefined) {
248
 
            doc = Y.config.doc;
249
 
            bodyScroll = doc.body && doc.body.scrollLeft;
250
 
            docScroll = doc.documentElement.scrollLeft;
251
 
 
252
 
            val = e.clientX + (docScroll || bodyScroll || 0);
253
 
        }
254
 
 
255
 
        return val;
256
 
    },
257
 
    pageY: function () {
258
 
        var e = this._event,
259
 
            val = e.pageY,
260
 
            doc, bodyScroll, docScroll;
261
 
                
262
 
        if (val === undefined) {
263
 
            doc = Y.config.doc;
264
 
            bodyScroll = doc.body && doc.body.scrollTop;
265
 
            docScroll = doc.documentElement.scrollTop;
266
 
 
267
 
            val = e.clientY + (docScroll || bodyScroll || 0);
268
 
        }
269
 
 
270
 
        return val;
271
 
    }
272
 
};
273
 
 
274
 
 
275
 
/**
276
 
 * Wrapper function for Object.defineProperty that creates a property whose
277
 
 * value will be calulated only when asked for.  After calculating the value,
278
 
 * the getter wll be removed, so it will behave as a normal property beyond that
279
 
 * point.  A setter is also assigned so assigning to the property will clear
280
 
 * the getter, so foo.prop = 'a'; foo.prop; won't trigger the getter,
281
 
 * overwriting value 'a'.
282
 
 *
283
 
 * Used only by the DOMEventFacades used by IE8 when the YUI configuration
284
 
 * <code>lazyEventFacade</code> is set to true.
285
 
 *
286
 
 * @method _define
287
 
 * @param o {DOMObject} A DOM object to add the property to
288
 
 * @param prop {String} The name of the new property
289
 
 * @param valueFn {Function} The function that will return the initial, default
290
 
 *                  value for the property.
291
 
 * @static
292
 
 * @private
293
 
 */
294
 
IELazyFacade._define = function (o, prop, valueFn) {
295
 
    function val(v) {
296
 
        var ret = (arguments.length) ? v : valueFn.call(this);
297
 
 
298
 
        delete o[prop];
299
 
        Object.defineProperty(o, prop, {
300
 
            value: ret,
301
 
            configurable: true,
302
 
            writable: true
303
 
        });
304
 
        return ret;
305
 
    }
306
 
    Object.defineProperty(o, prop, {
307
 
        get: val,
308
 
        set: val,
309
 
        configurable: true
310
 
    });
311
 
};
312
 
 
313
 
if (imp && (!imp.hasFeature('Events', '2.0'))) {
314
 
    if (useLazyFacade) {
315
 
        // Make sure we can use the lazy facade logic
316
 
        try {
317
 
            Object.defineProperty(Y.config.doc.createEventObject(), 'z', {});
318
 
        } catch (e) {
319
 
            useLazyFacade = false;
320
 
        }
321
 
    }
322
 
        
323
 
    Y.DOMEventFacade = (useLazyFacade) ? IELazyFacade : IEEventFacade;
324
 
}
325
 
 
326
 
 
327
 
}, '3.4.1' ,{after:['event-base'], requires:['node-base']});