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