[ Index ]

PHP Cross Reference of phpwcms V1.4.3 _r380 (23.11.09)

title

Body

[close]

/include/inc_js/mootools/FancyUpload/ -> Swiff.Base.js (source)

   1  /*
   2  Script: Swiff.Base.js
   3      Contains <Swiff>, <Swiff.getVersion>, <Swiff.remote>
   4  
   5  Author:
   6      Valerio Proietti, <http://mad4milk.net>
   7      enhanced by Harald Kirschner <http://digitarald.de>
   8  
   9  Credits:
  10      Flash detection 'borrowed' from SWFObject.
  11  
  12  License:
  13      MIT-style license.
  14  */
  15  
  16  /*
  17  Function: Swiff
  18      creates a flash object with supplied parameters.
  19  
  20  Arguments:
  21      source - the swf path.
  22      properties - an object with key/value pairs. all options are optional. see below.
  23      where - the $(element) to inject the flash object.
  24  
  25  Properties:
  26      width - int, the width of the flash object. defaults to 0.
  27      height - int, the height of the flash object. defaults to 0.
  28      id - string, the id of the flash object. defaults to 'Swiff-Object-num_of_object_inserted'.
  29      wmode - string, transparent or opaque.
  30      bgcolor - string, hex value for the movie background color.
  31      vars - an object of variables (functions, anything) you want to pass to your flash movie
  32  
  33  Returns:
  34      the object element, to be injected somewhere.
  35      Important: the $ function on the OBJECT element wont extend it, will just target the movie by its id/reference. So its not possible to use the <Element> methods on it.
  36      This is why it has to be injected using $('myFlashContainer').adopt(myObj) instead of $(myObj).injectInside('myFlashContainer');
  37  
  38  Example:
  39      (start code)
  40      var obj = new Swiff('myMovie.swf', {
  41          width: 500,
  42          height: 400,
  43          id: 'myBeautifulMovie',
  44          wmode: 'opaque',
  45          bgcolor: '#ff3300',
  46          vars: {
  47              onLoad: myOnloadFunc,
  48              myVariable: myJsVar,
  49              myVariableString: 'hello'
  50          }
  51      });
  52      $('myElement').adopt(obj);
  53      (end)
  54  */
  55  
  56  var Swiff = function(source, props){
  57      if (!Swiff.fixed) Swiff.fix();
  58      var instance = Swiff.nextInstance();
  59      Swiff.vars[instance] = {};
  60      props = $merge({
  61          width: 1,
  62          height: 1,
  63          id: instance,
  64          wmode: 'transparent',
  65          bgcolor: '#ffffff',
  66          allowScriptAccess: 'sameDomain',
  67          callBacks: {'onLoad': Class.empty},
  68          params: {}
  69      }, props || {});
  70      var append = [];
  71      if (window.ie) append.push('__salt=' + $time());
  72      for (var p in props.callBacks){
  73          Swiff.vars[instance][p] = props.callBacks[p];
  74          append.push(p + '=Swiff.vars.' + instance + '.' + p);
  75      }
  76      if (props.params) append.push(Object.toQueryString(props.params));
  77      var swf = source + (source.contains('?') ? '&' : '?') + append.join('&');
  78      return new Element('div').setHTML(
  79          '<object width="', props.width, '" height="', props.height, '" id="', props.id, '" type="application/x-shockwave-flash" data="', swf, '">'
  80              ,'<param name="allowScriptAccess" value="', props.allowScriptAccess, '" />'
  81              ,'<param name="movie" value="', swf, '" />'
  82              ,'<param name="bgcolor" value="', props.bgcolor, '" />'
  83              ,'<param name="scale" value="noscale" />'
  84              ,'<param name="salign" value="lt" />'
  85              ,'<param name="wmode" value="', props.wmode, '" />'
  86          ,'</object>').firstChild;
  87  };
  88  
  89  Swiff.extend = $extend;
  90  
  91  Swiff.extend({
  92  
  93      count: 0,
  94  
  95      callBacks: {},
  96  
  97      vars: {},
  98  
  99      nextInstance: function(){
 100          return 'Swiff' + Swiff.count++;
 101      },
 102  
 103      //from swfObject, fixes bugs in ie+fp9
 104      fix: function(){
 105          Swiff.fixed = true;
 106          window.addEvent('beforeunload', function(){
 107              __flash_unloadHandler = __flash_savedUnloadHandler = Class.empty;
 108          });
 109          if (!window.ie) return;
 110          window.addEvent('unload', function(){
 111              $each(document.getElementsByTagName("object"), function(swf){
 112                  swf.style.display = 'none';
 113                  for (var p in swf){
 114                      if (typeof swf[p] == 'function') swf[p] = Class.empty;
 115                  }
 116                  swf.parentNode.removeChild(swf);
 117              });
 118          });
 119      },
 120  
 121      /*
 122      Function: Swiff.getVersion
 123          gets the major version of the flash player installed.
 124  
 125      Returns:
 126          a number representing the flash version installed, or 0 if no player is installed.
 127      */
 128  
 129      getVersion: function(){
 130          if (!Swiff.pluginVersion) {
 131              var x;
 132              if(navigator.plugins && navigator.mimeTypes.length){
 133                  x = navigator.plugins["Shockwave Flash"];
 134                  if(x && x.description) x = x.description;
 135              } else if (window.ie){
 136                  try {
 137                      x = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
 138                      x = x.GetVariable("$version");
 139                  } catch(e){}
 140              }
 141              Swiff.pluginVersion = ($type(x) == 'string') ? parseInt(x.match(/\d+/)[0]) : 0;
 142          }
 143          return Swiff.pluginVersion;
 144      },
 145  
 146      /*
 147      Function: Swiff.remote
 148          Calls an ActionScript function from javascript. Requires ExternalInterface.
 149  
 150      Returns:
 151          Whatever the ActionScript Returns
 152      */
 153  
 154      remote: function(obj, fn){
 155          var rs = obj.CallFunction("<invoke name=\"" + fn + "\" returntype=\"javascript\">" + __flash__argumentsToXML(arguments, 2) + "</invoke>");
 156          return eval(rs);
 157      }
 158  
 159  });


Generated: Wed Dec 30 05:55:15 2009 Cross-referenced by PHPXref 0.7