📄 _base.js
字号:
if(!dojo._hasResource["dojox.flash._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.dojo._hasResource["dojox.flash._base"] = true;dojo.provide("dojox.flash._base");// for dijit.getViewport(), needed by dojox.flash.Embed.center()dojo.require("dijit._base.place");dojox.flash = function(){ // summary: // The goal of dojox.flash is to make it easy to extend Flash's capabilities // into an Ajax/DHTML environment. // // dojox.flash provides an easy object for interacting with the Flash plugin. // This object provides methods to determine the current version of the Flash // plugin (dojox.flash.info); write out the necessary markup to // dynamically insert a Flash object into the page (dojox.flash.Embed; and // do dynamic installation and upgrading of the current Flash plugin in // use (dojox.flash.Install). If you want to call methods on the Flash object // embedded into the page it is your responsibility to use Flash's ExternalInterface // API and get a reference to the Flash object yourself. // // To use dojox.flash, you must first wait until Flash is finished loading // and initializing before you attempt communication or interaction. // To know when Flash is finished use dojo.connect: // // dojo.connect(dojox.flash, "loaded", myInstance, "myCallback"); // // Then, while the page is still loading provide the file name: // // dojox.flash.setSwf(dojo.moduleUrl("dojox", "_storage/storage.swf")); // // If no SWF files are specified, then Flash is not initialized. // // Your Flash must use Flash's ExternalInterface to expose Flash methods and // to call JavaScript. // // setSwf can take an optional 'visible' attribute to control whether // the Flash object is visible or not on the page; the default is visible: // // dojox.flash.setSwf(dojo.moduleUrl("dojox", "_storage/storage.swf"), // false); // // Once finished, you can query Flash version information: // // dojox.flash.info.version // // Or can communicate with Flash methods that were exposed: // // var f = dojox.flash.get(); // var results = f.sayHello("Some Message"); // // Your Flash files should use DojoExternalInterface.as to register methods; // this file wraps Flash's normal ExternalInterface but correct various // serialization bugs that ExternalInterface has. // // Note that dojox.flash is not meant to be a generic Flash embedding // mechanism; it is as generic as necessary to make Dojo Storage's // Flash Storage Provider as clean and modular as possible. If you want // a generic Flash embed mechanism see SWFObject // (http://blog.deconcept.com/swfobject/). // // Notes: // Note that dojox.flash can currently only work with one Flash object // on the page; it does not yet support multiple Flash objects on // the same page. // // Your code can detect whether the Flash player is installing or having // its version revved in two ways. First, if dojox.flash detects that // Flash installation needs to occur, it sets dojox.flash.info.installing // to true. Second, you can detect if installation is necessary with the // following callback: // // dojo.connect(dojox.flash, "installing", myInstance, "myCallback"); // // You can use this callback to delay further actions that might need Flash; // when installation is finished the full page will be refreshed and the // user will be placed back on your page with Flash installed. // // ------------------- // Todo/Known Issues // ------------------- // * On Internet Explorer, after doing a basic install, the page is // not refreshed or does not detect that Flash is now available. The way // to fix this is to create a custom small Flash file that is pointed to // during installation; when it is finished loading, it does a callback // that says that Flash installation is complete on IE, and we can proceed // to initialize the dojox.flash subsystem. // * Things aren't super tested for sending complex objects to Flash // methods, since Dojo Storage only needs strings // // Author- Brad Neuberg, http://codinginparadise.org}dojox.flash = { ready: false, url: null, _visible: true, _loadedListeners: new Array(), _installingListeners: new Array(), setSwf: function(/* String */ url, /* boolean? */ visible){ // summary: Sets the SWF files and versions we are using. // url: String // The URL to this Flash file. // visible: boolean? // Whether the Flash file is visible or not. If it is not visible we hide it off the // screen. This defaults to true (i.e. the Flash file is visible). this.url = url; if(typeof visible != "undefined"){ this._visible = visible; } // initialize ourselves this._initialize(); }, addLoadedListener: function(/* Function */ listener){ // summary: // Adds a listener to know when Flash is finished loading. // Useful if you don't want a dependency on dojo.event. // listener: Function // A function that will be called when Flash is done loading. this._loadedListeners.push(listener); }, addInstallingListener: function(/* Function */ listener){ // summary: // Adds a listener to know if Flash is being installed. // Useful if you don't want a dependency on dojo.event. // listener: Function // A function that will be called if Flash is being // installed this._installingListeners.push(listener); }, loaded: function(){ // summary: Called back when the Flash subsystem is finished loading. // description: // A callback when the Flash subsystem is finished loading and can be // worked with. To be notified when Flash is finished loading, add a // loaded listener: // // dojox.flash.addLoadedListener(loadedListener); dojox.flash.ready = true; if(dojox.flash._loadedListeners.length > 0){ for(var i = 0;i < dojox.flash._loadedListeners.length; i++){ dojox.flash._loadedListeners[i].call(null); } } }, installing: function(){ // summary: Called if Flash is being installed. // description: // A callback to know if Flash is currently being installed or // having its version revved. To be notified if Flash is installing, connect // your callback to this method using the following: // // dojo.event.connect(dojox.flash, "installing", myInstance, "myCallback"); if(dojox.flash._installingListeners.length > 0){ for(var i = 0; i < dojox.flash._installingListeners.length; i++){ dojox.flash._installingListeners[i].call(null); } } }, // Initializes dojox.flash. _initialize: function(){ //console.debug("dojox.flash._initialize"); // see if we need to rev or install Flash on this platform var installer = new dojox.flash.Install(); dojox.flash.installer = installer; if(installer.needed() == true){ installer.install(); }else{ // write the flash object into the page dojox.flash.obj = new dojox.flash.Embed(this._visible); dojox.flash.obj.write(); // setup the communicator dojox.flash.comm = new dojox.flash.Communicator(); } }};dojox.flash.Info = function(){ // summary: A class that helps us determine whether Flash is available. // description: // A class that helps us determine whether Flash is available, // it's major and minor versions, and what Flash version features should // be used for Flash/JavaScript communication. Parts of this code // are adapted from the automatic Flash plugin detection code autogenerated // by the Macromedia Flash 8 authoring environment. // // An instance of this class can be accessed on dojox.flash.info after // the page is finished loading. // // This constructor must be called before the page is finished loading. // Visual basic helper required to detect Flash Player ActiveX control // version information on Internet Explorer if(dojo.isIE){ document.write([ '<script language="VBScript" type="text/vbscript"\>', 'Function VBGetSwfVer(i)', ' on error resume next', ' Dim swControl, swVersion', ' swVersion = 0', ' set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash." + CStr(i))', ' if (IsObject(swControl)) then', ' swVersion = swControl.GetVariable("$version")', ' end if', ' VBGetSwfVer = swVersion', 'End Function', '</script\>'].join("\r\n")); } this._detectVersion();}dojox.flash.Info.prototype = { // version: String // The full version string, such as "8r22". version: -1, // versionMajor, versionMinor, versionRevision: String // The major, minor, and revisions of the plugin. For example, if the // plugin is 8r22, then the major version is 8, the minor version is 0, // and the revision is 22. versionMajor: -1, versionMinor: -1, versionRevision: -1, // capable: Boolean // Whether this platform has Flash already installed. capable: false, // installing: Boolean // Set if we are in the middle of a Flash installation session. installing: false, isVersionOrAbove: function( /* int */ reqMajorVer, /* int */ reqMinorVer, /* int */ reqVer){ /* Boolean */ // summary: // Asserts that this environment has the given major, minor, and revision // numbers for the Flash player. // description: // Asserts that this environment has the given major, minor, and revision // numbers for the Flash player. // // Example- To test for Flash Player 7r14: // // dojox.flash.info.isVersionOrAbove(7, 0, 14) // returns: // Returns true if the player is equal // or above the given version, false otherwise. // make the revision a decimal (i.e. transform revision 14 into // 0.14 reqVer = parseFloat("." + reqVer); if(this.versionMajor >= reqMajorVer && this.versionMinor >= reqMinorVer && this.versionRevision >= reqVer){ return true; }else{ return false; } }, _detectVersion: function(){ var versionStr; // loop backwards through the versions until we find the newest version for(var testVersion = 25; testVersion > 0; testVersion--){ if(dojo.isIE){ versionStr = VBGetSwfVer(testVersion); }else{ versionStr = this._JSFlashInfo(testVersion); } if(versionStr == -1 ){ this.capable = false; return; }else if(versionStr != 0){ var versionArray; if(dojo.isIE){ var tempArray = versionStr.split(" "); var tempString = tempArray[1]; versionArray = tempString.split(","); }else{ versionArray = versionStr.split("."); } this.versionMajor = versionArray[0]; this.versionMinor = versionArray[1]; this.versionRevision = versionArray[2]; // 7.0r24 == 7.24 var versionString = this.versionMajor + "." + this.versionRevision; this.version = parseFloat(versionString); this.capable = true; break; } } }, // JavaScript helper required to detect Flash Player PlugIn version // information. Internet Explorer uses a corresponding Visual Basic // version to interact with the Flash ActiveX control. _JSFlashInfo: function(testVersion){ // NS/Opera version >= 3 check for Flash plugin in plugin array if(navigator.plugins != null && navigator.plugins.length > 0){ if(navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]){ var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : ""; var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description; var descArray = flashDescription.split(" "); var tempArrayMajor = descArray[2].split("."); var versionMajor = tempArrayMajor[0]; var versionMinor = tempArrayMajor[1]; if(descArray[3] != ""){ var tempArrayMinor = descArray[3].split("r"); }else{ var tempArrayMinor = descArray[4].split("r"); } var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0; var version = versionMajor + "." + versionMinor + "." + versionRevision; return version; } } return -1; }};dojox.flash.Embed = function(visible){ // summary: A class that is used to write out the Flash object into the page. // description: // Writes out the necessary tags to embed a Flash file into the page. Note that // these tags are written out as the page is loaded using document.write, so // you must call this class before the page has finished loading. this._visible = visible;}dojox.flash.Embed.prototype = { // width: int // The width of this Flash applet. The default is the minimal width // necessary to show the Flash settings dialog. Current value is // 215 pixels. width: 215, // height: int // The height of this Flash applet. The default is the minimal height // necessary to show the Flash settings dialog. Current value is // 138 pixels. height: 138, // id: String // The id of the Flash object. Current value is 'flashObject'. id: "flashObject", // Controls whether this is a visible Flash applet or not. _visible: true, protocol: function(){ switch(window.location.protocol){ case "https:":
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -