Created
May 8, 2012 23:03
-
-
Save kara-ryli/2640239 to your computer and use it in GitHub Desktop.
Adds expressInstall functionality to Y.SWF, using expressInstall.swf from the SWFObject project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*global YUI*/ | |
| /** | |
| * Adds expressInstall functionality to SWF | |
| * | |
| * @module swf-expressinstall | |
| * @requires swf | |
| */ | |
| YUI.add("swf-expressinstall", function (Y) { | |
| "use strict"; | |
| var handles = {}, | |
| swfURL = Y.config.groups.nfl.base + "swf-expressinstall/expressInstall.swf"; | |
| /** | |
| * Adds expressInstall functionality to SWF | |
| * @class SWF | |
| */ | |
| /** | |
| * @method expressInstall | |
| * @param {String|Node} node Node within which to render the expressInstall SWF. | |
| * @return {String} handle for the swf. | |
| * @static | |
| */ | |
| Y.mix(Y.SWF, { | |
| expressInstall: function (ref) { | |
| // handle SWF Upgrade | |
| var node = Y.one(ref), | |
| nodeId, | |
| swf; | |
| if (node) { | |
| nodeId = node.get("id"); | |
| swf = new Y.SWF(Y.one(node), swfURL, { | |
| fixedAttributes: { | |
| allowScriptAccess: 'always' | |
| }, | |
| flashVars: { | |
| MMredirectURL: Y.config.win.location.href, | |
| MMdoctitle: Y.config.doc.title, | |
| // This logic is taken from SWFObject and translated to YUI | |
| // http://code.google.com/p/swfobject/ | |
| MMplayerType: Y.UA.ie && /win/i.test(Y.config.win.navigator.platform || Y.UA.userAgent) ? "ActiveX" : "PlugIn" | |
| } | |
| }); | |
| handles[nodeId] = Y.bind("destroy", swf); | |
| } | |
| return nodeId; | |
| }, | |
| /** | |
| * @method removeExpressInstall | |
| * @param {String} handle a SWF handle returned from Y.SWF.expressInstall. | |
| * @static | |
| */ | |
| removeExpressInstall: function (handle) { | |
| var fn = handles[handle]; | |
| if (Y.Lang.isFunction(fn)) { | |
| delete handles[handle]; | |
| fn(); | |
| } | |
| } | |
| }); | |
| // adds a destructor method to Y.SWF | |
| if (!Y.Lang.isFunction(Y.SWF.prototype.destroy)) { | |
| Y.SWF.prototype.destroy = function () { | |
| this.detachAll(); | |
| this._swf.remove(true); | |
| delete this._swf; | |
| delete Y.SWF._instances[this._id]; | |
| }; | |
| } | |
| }, "3.4.1", { | |
| group: "nfl", | |
| requires: ["swf"] | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment