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