[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/yuilib/3.17.2/swf/ -> swf.js (source)

   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  function SWF (p_oElement /*:String*/, swfURL /*:String*/, p_oAttributes /*:Object*/ ) {
  62  
  63      this._id = Y.guid("yuiswf");
  64  
  65  
  66      var _id = this._id;
  67      var oElement = Node.one(p_oElement);
  68  
  69      var p_oAttributes = p_oAttributes || {};
  70  
  71      var flashVersion = p_oAttributes.version || FLASH_VER;
  72  
  73      var flashVersionSplit = (flashVersion + '').split(".");
  74      var isFlashVersionRight = SWFDetect.isFlashVersionAtLeast(parseInt(flashVersionSplit[0], 10), parseInt(flashVersionSplit[1], 10), parseInt(flashVersionSplit[2], 10));
  75      var canExpressInstall = (SWFDetect.isFlashVersionAtLeast(8,0,0));
  76      var shouldExpressInstall = canExpressInstall && !isFlashVersionRight && p_oAttributes.useExpressInstall;
  77      var flashURL = (shouldExpressInstall)?EXPRESS_INSTALL_URL:swfURL;
  78      var objstring = '<object ';
  79      var w, h;
  80      var flashvarstring = "yId=" + Y.id + "&YUISwfId=" + _id + "&YUIBridgeCallback=" + EVENT_HANDLER + "&allowedDomain=" + document.location.hostname;
  81  
  82      Y.SWF._instances[_id] = this;
  83      if (oElement && (isFlashVersionRight || shouldExpressInstall) && flashURL) {
  84          objstring += 'id="' + _id + '" ';
  85          if (uA.ie) {
  86              objstring += 'classid="' + FLASH_CID + '" ';
  87          } else {
  88              objstring += 'type="' + FLASH_TYPE + '" data="' + Escape.html(flashURL) + '" ';
  89          }
  90  
  91          w = "100%";
  92          h = "100%";
  93  
  94          objstring += 'width="' + w + '" height="' + h + '">';
  95  
  96          if (uA.ie) {
  97              objstring += '<param name="movie" value="' + Escape.html(flashURL) + '"/>';
  98          }
  99  
 100          for (var attribute in p_oAttributes.fixedAttributes) {
 101              if (possibleAttributes.hasOwnProperty(attribute)) {
 102                  objstring += '<param name="' + Escape.html(attribute) + '" value="' + Escape.html(p_oAttributes.fixedAttributes[attribute]) + '"/>';
 103              }
 104          }
 105  
 106          for (var flashvar in p_oAttributes.flashVars) {
 107              var fvar = p_oAttributes.flashVars[flashvar];
 108              if (Lang.isString(fvar)) {
 109                  flashvarstring += "&" + Escape.html(flashvar) + "=" + Escape.html(encodeURIComponent(fvar));
 110              }
 111          }
 112  
 113          if (flashvarstring) {
 114              objstring += '<param name="flashVars" value="' + flashvarstring + '"/>';
 115          }
 116  
 117          objstring += "</object>";
 118          //using innerHTML as setHTML/setContent causes some issues with ExternalInterface for IE versions of the player
 119          oElement.set("innerHTML", objstring);
 120  
 121          this._swf = Node.one("#" + _id);
 122      } else {
 123          /**
 124           * Fired when the Flash player version on the user's machine is
 125           * below the required value.
 126           *
 127           * @event wrongflashversion
 128           */
 129          var event = {};
 130          event.type = "wrongflashversion";
 131          this.publish("wrongflashversion", {fireOnce:true});
 132          this.fire("wrongflashversion", event);
 133      }
 134  }
 135  
 136  /**
 137   * @private
 138   * The static collection of all instances of the SWFs on the page.
 139   * @property _instances
 140   * @type Object
 141   */
 142  
 143  SWF._instances = SWF._instances || {};
 144  
 145  /**
 146   * @private
 147   * Handles an event coming from within the SWF and delegate it
 148   * to a specific instance of SWF.
 149   * @method eventHandler
 150   * @param swfid {String} the id of the SWF dispatching the event
 151   * @param event {Object} the event being transmitted.
 152   */
 153  SWF.eventHandler = function (swfid, event) {
 154      SWF._instances[swfid]._eventHandler(event);
 155  };
 156  
 157  SWF.prototype = {
 158      /**
 159       * @private
 160       * Propagates a specific event from Flash to JS.
 161       * @method _eventHandler
 162       * @param event {Object} The event to be propagated from Flash.
 163       */
 164      _eventHandler: function(event) {
 165          if (event.type === "swfReady") {
 166              this.publish("swfReady", {fireOnce:true});
 167              this.fire("swfReady", event);
 168          } else if(event.type === "log") {
 169          } else {
 170              this.fire(event.type, event);
 171          }
 172      },
 173  
 174          /**
 175       * Calls a specific function exposed by the SWF's
 176       * ExternalInterface.
 177       * @method callSWF
 178       * @param func {String} the name of the function to call
 179       * @param args {Array} the set of arguments to pass to the function.
 180       */
 181  
 182      callSWF: function (func, args)
 183      {
 184      if (!args) {
 185            args= [];
 186      }
 187          if (this._swf._node[func]) {
 188          return(this._swf._node[func].apply(this._swf._node, args));
 189          } else {
 190          return null;
 191          }
 192      },
 193  
 194      /**
 195       * Public accessor to the unique name of the SWF instance.
 196       *
 197       * @method toString
 198       * @return {String} Unique name of the SWF instance.
 199       */
 200      toString: function()
 201      {
 202          return "SWF " + this._id;
 203      }
 204  };
 205  
 206  Y.augment(SWF, Y.EventTarget);
 207  
 208  Y.SWF = SWF;
 209  
 210  
 211  }, '3.17.2', {"requires": ["event-custom", "node", "swfdetect", "escape"]});


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1