uxflash.js.svn-base

来自「一个使用ssh+ext的例子。 希望对开发这个应用的人带来好处。仔细研究里面的」· SVN-BASE 代码 · 共 368 行 · 第 1/2 页

SVN-BASE
368
字号
/*
 * @class
 *        Ext.ux.Media.Flash,
 *        Ext.ux.FlashComponent (xtype: uxflash)
 *        Ext.ux.FlashPanel     (xtype: uxflashpanel, flashpanel)
 *        Ext.ux.FlashWindow
 *
 * Version:  RC1
 * Author: Doug Hendricks. doug[always-At]theactivegroup.com
 * Copyright 2007-2008, Active Group, Inc.  All rights reserved.
 *
 ************************************************************************************
 *   This file is distributed on an AS IS BASIS WITHOUT ANY WARRANTY;
 *   without even the implied warranty of MERCHANTABILITY or
 *   FITNESS FOR A PARTICULAR PURPOSE.
 ************************************************************************************

 License: ux.Media.Flash classes are licensed under the terms of
 the Open Source LGPL 3.0 license.  Commercial use is permitted to the extent
 that the code/component(s) do NOT become part of another Open Source or Commercially
 licensed development library or toolkit without explicit permission.

 Donations are welcomed: http://donate.theactivegroup.com

 License details: http://www.gnu.org/licenses/lgpl.html

 Notes: the <embed> tag is NOT used(or necessary) in this implementation
 Version:  Rc1
           Adds inline media rendering within markup: <div><script>document.write(String(new Ext.ux.Media.Flash(mediaCfg)));</script></div>
           New extensible classes :
              ux.Media.Flash
              ux.FlashComponent
              ux.FlashPanel
              ux.FlashWindow

   A custom implementation for advanced Flash object interaction
       Supports:
            version detection,
            version assertion,
            Flash Express Installation (inplace version upgrades),
            and custom Event Sync for interaction with SWF.ActionScript.

    mediaCfg: {Object}
         {
           url       : Url resource to load when rendered
          ,loop      : (true/false)
          ,start     : (true/false)
          ,height    : (defaults 100%)
          ,width     : (defaults 100%)
          ,scripting : (true/false) (@macro enabled)
          ,controls  : optional: show plugins control menu (true/false)
          ,eventSynch: (Bool) If true, this class initializes an internal event Handler for
                       ActionScript event synchronization
          ,listeners  : {"mouseover": function() {}, .... } DOM listeners to set each time the Media is rendered.
          ,requiredVersion: (String,Array,Number) If specified, used in version detection.
          ,unsupportedText: (String,DomHelper cfg) Text to render if plugin is not installed/available.
          ,installUrl:(string) Url to inline SWFInstaller, if specified activates inline Express Install.
          ,installRedirect : (string) optional post install redirect
          ,installDescriptor: (Object) optional Install descriptor config
         }
    */

(function(){

   var ux = Ext.ux.Media;

    ux.Flash = Ext.extend( ux, {
        constructor: function() {
            ux.Flash.superclass.constructor.apply(this, arguments);
        },

        SWFObject      : null,

        varsName       :'flashVars',

        mediaType: Ext.apply({
              tag      : 'object'
             ,cls      : 'x-media x-media-swf'
             ,type     : 'application/x-shockwave-flash'
             ,data     : "@url"
             ,loop     : null
             ,scripting: "sameDomain"
             ,start    : true
             ,unsupportedText : {cn:['The Adobe Flash Player{0}is required. Current Version:{1}',{tag:'br'},{tag:'a',cn:'The free download is available here.',href:'http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash',target:'_flash'}]}
             ,params   : {
                  movie     : "@url"
                 ,play      : "@start"
                 ,loop      : "@loop"
                 ,menu      : "@controls"
                 ,quality   : "high"
                 ,bgcolor   : "#FFFFFF"
                 ,wmode     : "opaque"
                 ,allowscriptaccess : "@scripting"
                }
             },Ext.isIE?{classid :"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
                   ,codebase:"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"
                   }:false),

        getMediaType: function(){
             return this.mediaType;
        },
        // private
        initMedia : function(){

            var mc = Ext.apply({url:false}, this.mediaCfg||{});

            if(mc.url ){

                var requiredVersion = (this.requiredVersion = mc.requiredVersion || this.requiredVersion|| false ) ;

                var hasFlash  = !!(this.playerVersion = this.detectVersion());
                var hasRequired = hasFlash && (requiredVersion?this.assertVersion(requiredVersion):true);

                var unsupportedText = this.assert(mc.unsupportedText || this.unsupportedText || (this.getMediaType()||{}).unsupportedText,null);
                if(unsupportedText){
                     unsupportedText = Ext.DomHelper.markup(unsupportedText);
                     unsupportedText = mc.unsupportedText = String.format(unsupportedText,
                         (requiredVersion?' '+requiredVersion+' ':' '),
                         (this.playerVersion?' '+this.playerVersion+' ':' Not installed.'));
                }

                if(!hasRequired ){

                    //Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
                    var canInstall = hasFlash && this.assertVersion('6.0.65');

                    if(canInstall && mc.installUrl){

                           mc =  mc.installDescriptor || {
                                 tag      : 'object'
                                ,cls      : 'x-media x-media-swf'
                                ,id       : 'SWFInstaller'
                                ,type     : 'application/x-shockwave-flash'
                                ,data     : "@url"
                                ,url              : mc.installUrl
                                //The dimensions of playerProductInstall.swf must be at least 215 x 138 pixels,
                                ,width            : (parseInt(mc.width,10) || 0) < 215 ? 215 :mc.width
                                ,height           : (parseInt(mc.height,10) || 0) < 138 ? 138 :mc.height
                                ,loop             : false
                                ,start            : true
                                ,unsupportedText  : unsupportedText
                                ,params:{
                                          quality          : "high"
                                         ,movie            : '@url'
                                         ,allowScriptAcess : "always"
                                         ,align            : "middle"
                                         ,bgcolor          : "#3A6EA5"
                                         ,pluginspage      : mc.pluginsPage || this.pluginsPage || "http://www.adobe.com/go/getflashplayer"
                                       }
                            };
                            mc.params[this.varsName] = "MMredirectURL="+( mc.installRedirect || window.location)+
                                                "&MMplayerType="+(Ext.isIE?"ActiveX":"Plugin")+
                                                "&MMdoctitle="+(document.title = document.title.slice(0, 47) + " - Flash Player Installation")
                    } else {
                        //Let superclass handle with unsupportedText property
                        mc.url=null;
                    }
                }

                /*
                *  Sets up a eventSynch between the ActionScript environment
                *  and converts it's events into native Ext events.
                */

                if(mc.eventSynch){
                    mc.params || (mc.params = {});
                    var vars = mc.params[this.varsName] || (mc.params[this.varsName] = {});
                    if(typeof vars == 'string'){ vars = Ext.urlDecode(vars,true); }
                    var eventVars = (mc.eventSynch === true ? {
                             allowedDomain  : vars.allowedDomain || document.location.hostname
                            ,elementID      : mc.id || (mc.id = Ext.id())
                            ,eventHandler   : 'Ext.ux.Media.Flash.eventSynch'
                            }: mc.eventSynch );

                    Ext.apply(mc.params,{
                         allowscriptaccess  : 'always'
                    })[this.varsName] = Ext.applyIf(vars,eventVars);
                }

                delete mc.requiredVersion;
                delete mc.installUrl;
                delete mc.installRedirect;
                delete mc.installDescriptor;
                delete mc.eventSynch;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?