~smagoun/whoopsie/whoopsie-lp1017637

« back to all changes in this revision

Viewing changes to backend/stats/static/js/yui/build/swf/swf-debug.js

  • Committer: Evan Dandrea
  • Date: 2012-05-09 05:53:45 UTC
  • Revision ID: evan.dandrea@canonical.com-20120509055345-z2j41tmcbf4as5uf
The backend now lives in lp:daisy and the website (errors.ubuntu.com) now lives in lp:errors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
YUI 3.5.0 (build 5089)
3
 
Copyright 2012 Yahoo! Inc. All rights reserved.
4
 
Licensed under the BSD License.
5
 
http://yuilibrary.com/license/
6
 
*/
7
 
YUI.add('swf', function(Y) {
8
 
 
9
 
/**
10
 
 * Embed a Flash applications in a standard manner and communicate with it
11
 
 * via External Interface.
12
 
 * @module swf
13
 
 */
14
 
 
15
 
    var Event = Y.Event,
16
 
        SWFDetect = Y.SWFDetect,
17
 
        Lang = Y.Lang,
18
 
        uA = Y.UA,
19
 
        Node = Y.Node,
20
 
        Escape = Y.Escape,
21
 
 
22
 
        // private
23
 
        FLASH_CID = "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000",
24
 
        FLASH_TYPE = "application/x-shockwave-flash",
25
 
        FLASH_VER = "10.0.22",
26
 
        EXPRESS_INSTALL_URL = "http://fpdownload.macromedia.com/pub/flashplayer/update/current/swf/autoUpdater.swf?" + Math.random(),
27
 
        EVENT_HANDLER = "SWF.eventHandler",
28
 
        possibleAttributes = {align:"", allowFullScreen:"", allowNetworking:"", allowScriptAccess:"", base:"", bgcolor:"", menu:"", name:"", quality:"", salign:"", scale:"", tabindex:"", wmode:""};
29
 
 
30
 
        /**
31
 
         * The SWF utility is a tool for embedding Flash applications in HTML pages.
32
 
         * @module swf
33
 
         * @title SWF Utility
34
 
         * @requires event-custom, node, swfdetect
35
 
         */
36
 
 
37
 
        /**
38
 
         * Creates the SWF instance and keeps the configuration data
39
 
         *
40
 
         * @class SWF
41
 
         * @augments Y.Event.Target
42
 
         * @constructor
43
 
         * @param {String|HTMLElement} id The id of the element, or the element itself that the SWF will be inserted into.
44
 
         *        The width and height of the SWF will be set to the width and height of this container element.
45
 
         * @param {String} swfURL The URL of the SWF to be embedded into the page.
46
 
         * @param {Object} p_oAttributes (optional) Configuration parameters for the Flash application and values for Flashvars
47
 
         *        to be passed to the SWF. The p_oAttributes object allows the following additional properties:
48
 
         *        <dl>
49
 
         *          <dt>version : String</dt>
50
 
         *          <dd>The minimum version of Flash required on the user's machine.</dd>
51
 
         *          <dt>fixedAttributes : Object</dt>
52
 
         *          <dd>An object literal containing one or more of the following String keys and their values: <code>align,
53
 
         *              allowFullScreen, allowNetworking, allowScriptAccess, base, bgcolor, menu, name, quality, salign, scale,
54
 
         *              tabindex, wmode.</code> event from the thumb</dd>
55
 
         *        </dl>
56
 
         */
57
 
 
58
 
function SWF (p_oElement /*:String*/, swfURL /*:String*/, p_oAttributes /*:Object*/ ) {
59
 
 
60
 
    this._id = Y.guid("yuiswf");
61
 
 
62
 
 
63
 
    var _id = this._id;
64
 
    var oElement = Node.one(p_oElement);
65
 
    
66
 
    var p_oAttributes = p_oAttributes || {};
67
 
 
68
 
    var flashVersion = p_oAttributes.version || FLASH_VER;
69
 
 
70
 
    var flashVersionSplit = (flashVersion + '').split(".");
71
 
    var isFlashVersionRight = SWFDetect.isFlashVersionAtLeast(parseInt(flashVersionSplit[0], 10), parseInt(flashVersionSplit[1], 10), parseInt(flashVersionSplit[2], 10));
72
 
    var canExpressInstall = (SWFDetect.isFlashVersionAtLeast(8,0,0));
73
 
    var shouldExpressInstall = canExpressInstall && !isFlashVersionRight && p_oAttributes.useExpressInstall;
74
 
    var flashURL = (shouldExpressInstall)?EXPRESS_INSTALL_URL:swfURL;
75
 
    var objstring = '<object ';
76
 
    var w, h;
77
 
    var flashvarstring = "yId=" + Y.id + "&YUISwfId=" + _id + "&YUIBridgeCallback=" + EVENT_HANDLER + "&allowedDomain=" + document.location.hostname;
78
 
 
79
 
    Y.SWF._instances[_id] = this;
80
 
    if (oElement && (isFlashVersionRight || shouldExpressInstall) && flashURL) {
81
 
        objstring += 'id="' + _id + '" ';
82
 
        if (uA.ie) {
83
 
            objstring += 'classid="' + FLASH_CID + '" ';
84
 
        } else {
85
 
            objstring += 'type="' + FLASH_TYPE + '" data="' + Escape.html(flashURL) + '" ';
86
 
        }
87
 
 
88
 
        w = "100%";
89
 
        h = "100%";
90
 
 
91
 
        objstring += 'width="' + w + '" height="' + h + '">';
92
 
 
93
 
        if (uA.ie) {
94
 
            objstring += '<param name="movie" value="' + Escape.html(flashURL) + '"/>';
95
 
        }
96
 
 
97
 
        for (var attribute in p_oAttributes.fixedAttributes) {
98
 
            if (possibleAttributes.hasOwnProperty(attribute)) {
99
 
                objstring += '<param name="' + Escape.html(attribute) + '" value="' + Escape.html(p_oAttributes.fixedAttributes[attribute]) + '"/>';
100
 
            }
101
 
        }
102
 
 
103
 
        for (var flashvar in p_oAttributes.flashVars) {
104
 
            var fvar = p_oAttributes.flashVars[flashvar];
105
 
            if (Lang.isString(fvar)) {
106
 
                flashvarstring += "&" + Escape.html(flashvar) + "=" + Escape.html(encodeURIComponent(fvar));
107
 
            }
108
 
        }
109
 
 
110
 
        if (flashvarstring) {
111
 
            objstring += '<param name="flashVars" value="' + flashvarstring + '"/>';
112
 
        }
113
 
 
114
 
        objstring += "</object>";
115
 
        oElement.setContent(objstring);
116
 
 
117
 
        this._swf = Node.one("#" + _id);
118
 
    } else {
119
 
        /**
120
 
         * Fired when the Flash player version on the user's machine is
121
 
         * below the required value.
122
 
         *
123
 
         * @event wrongflashversion
124
 
         */
125
 
        var event = {};
126
 
        event.type = "wrongflashversion";
127
 
        this.publish("wrongflashversion", {fireOnce:true});
128
 
        this.fire("wrongflashversion", event);
129
 
    }
130
 
}
131
 
 
132
 
/**
133
 
 * @private
134
 
 * The static collection of all instances of the SWFs on the page.
135
 
 * @property _instances
136
 
 * @type Object
137
 
 */
138
 
 
139
 
SWF._instances = SWF._instances || {};
140
 
 
141
 
/**
142
 
 * @private
143
 
 * Handles an event coming from within the SWF and delegate it
144
 
 * to a specific instance of SWF.
145
 
 * @method eventHandler
146
 
 * @param swfid {String} the id of the SWF dispatching the event
147
 
 * @param event {Object} the event being transmitted.
148
 
 */
149
 
SWF.eventHandler = function (swfid, event) {
150
 
    SWF._instances[swfid]._eventHandler(event);
151
 
};
152
 
 
153
 
SWF.prototype = {
154
 
    /**
155
 
     * @private
156
 
     * Propagates a specific event from Flash to JS.
157
 
     * @method _eventHandler
158
 
     * @param event {Object} The event to be propagated from Flash.
159
 
     */
160
 
    _eventHandler: function(event) {
161
 
        if (event.type === "swfReady") {
162
 
            this.publish("swfReady", {fireOnce:true});
163
 
            this.fire("swfReady", event);
164
 
        } else if(event.type === "log") {
165
 
            Y.log(event.message, event.category, this.toString());
166
 
        } else {
167
 
            this.fire(event.type, event);
168
 
        }
169
 
    },
170
 
 
171
 
        /**
172
 
     * Calls a specific function exposed by the SWF's
173
 
     * ExternalInterface.
174
 
     * @method callSWF
175
 
     * @param func {String} the name of the function to call
176
 
     * @param args {Array} the set of arguments to pass to the function.
177
 
     */
178
 
    
179
 
    callSWF: function (func, args)
180
 
    {
181
 
    if (!args) { 
182
 
          args= []; 
183
 
    }   
184
 
        if (this._swf._node[func]) {
185
 
        return(this._swf._node[func].apply(this._swf._node, args));
186
 
        } else {
187
 
        return null;
188
 
        }
189
 
    },
190
 
    
191
 
    /**
192
 
     * Public accessor to the unique name of the SWF instance.
193
 
     *
194
 
     * @method toString
195
 
     * @return {String} Unique name of the SWF instance.
196
 
     */
197
 
    toString: function()
198
 
    {
199
 
        return "SWF " + this._id;
200
 
    }
201
 
};
202
 
 
203
 
Y.augment(SWF, Y.EventTarget);
204
 
 
205
 
Y.SWF = SWF;
206
 
 
207
 
 
208
 
}, '3.5.0' ,{requires:['event-custom','node','swfdetect','escape']});