⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ext-air-debug.js

📁 ext-2.3.0
💻 JS
📖 第 1 页 / 共 4 页
字号:
				
				if(!_parentMenu){
					icon.menu = menu;
				}
			}
			
			return menu;
		}
	};	
}();

Ext.air.DragType = {
	
	TEXT : 'text/plain',
	
	HTML : 'text/html',
	
	URL : 'text/uri-list',
	
	BITMAP : 'image/x-vnd.adobe.air.bitmap',
	
	FILES : 'application/x-vnd.adobe.air.file-list'
};


// workaround for DD dataTransfer Clipboard not having hasFormat

Ext.apply(Ext.EventObjectImpl.prototype, {
	hasFormat : function(format){
		if (this.browserEvent.dataTransfer) {
			for (var i = 0, len = this.browserEvent.dataTransfer.types.length; i < len; i++) {
				if(this.browserEvent.dataTransfer.types[i] == format) {
					return true;
				}
			}
		}
		return false;
	},
	
	getData : function(type){
		return this.browserEvent.dataTransfer.getData(type);
	}
});



Ext.air.Sound = {
	
	play : function(file, startAt){
		var soundFile = air.File.applicationDirectory.resolvePath(file);
		var sound = new air.Sound();
		sound.load(new air.URLRequest(soundFile.url));
		sound.play(startAt);
	}
};

Ext.air.SystemMenu = function(){
	var menu;
	// windows
	if(air.NativeWindow.supportsMenu && nativeWindow.systemChrome != air.NativeWindowSystemChrome.NONE) {
        menu = new air.NativeMenu();
        nativeWindow.menu = menu;
    }
    
	// mac
    if(air.NativeApplication.supportsMenu) {
		menu = air.NativeApplication.nativeApplication.menu;
    }

    function find(menu, text){
        for(var i = 0, len = menu.items.length; i < len; i++){
            if(menu.items[i]['label'] == text){
                return menu.items[i];
            }
        }
        return null;
    }

    return {
		
		add: function(text, actions, mindex){

            var item = find(menu, text);
            if(!item){
                item = menu.addItem(new air.NativeMenuItem(text));
                item.mnemonicIndex = mindex || 0;

                item.submenu = new air.NativeMenu();
			}
			for (var i = 0, len = actions.length; i < len; i++) {
				item.submenu.addItem(actions[i] == '-' ? new air.NativeMenuItem("", true) : Ext.air.MenuItem(actions[i]));
			}
            return item.submenu;
        },
		
		
		get : function(){
			return menu;
		}
	};	
}();

// ability to bind native menu items to an Ext.Action
Ext.air.MenuItem = function(action){
	if(!action.isAction){
		action = new Ext.Action(action);
	}
	var cfg = action.initialConfig;
	var nativeItem = new air.NativeMenuItem(cfg.itemText || cfg.text);
	
	nativeItem.enabled = !cfg.disabled;

    if(!Ext.isEmpty(cfg.checked)){
        nativeItem.checked = cfg.checked;
    }

    var handler = cfg.handler;
	var scope = cfg.scope;
	
	nativeItem.addEventListener(air.Event.SELECT, function(){
		handler.call(scope || window, cfg);
	});
	
	action.addComponent({
		setDisabled : function(v){
			nativeItem.enabled = !v;
		},
		
		setText : function(v){
			nativeItem.label = v;
		},
		
		setVisible : function(v){
			// could not find way to hide in air so disable?
			nativeItem.enabled = !v;
		},
		
		setHandler : function(newHandler, newScope){
			handler = newHandler;
			scope = newScope;
		},
		// empty function
		on : function(){}
	});
	
	return nativeItem;
}
Ext.ns('Ext.air');

Ext.air.MusicPlayer = Ext.extend(Ext.util.Observable, {
	
	activeSound: null,
	
	activeChannel: null,
	
	activeTransform: new air.SoundTransform(1, 0),
	// private 
	pausePosition: 0,
	
	progressInterval: 500,
	
	constructor: function(config) {
		config = config || {};
		Ext.apply(this, config);
		
		this.addEvents(
			
			'stop',
			
			'pause',
			
			'play',
			
			'load',
			
			'id3info',
			
			'complete',
			
			'progress',
			
			'skip'
		);
		
		Ext.air.MusicPlayer.superclass.constructor.call(this, config);
		this.onSoundFinishedDelegate = this.onSoundFinished.createDelegate(this);
		this.onSoundLoadDelegate = this.onSoundLoad.createDelegate(this);
		this.onSoundID3LoadDelegate = this.onSoundID3Load.createDelegate(this);

		Ext.TaskMgr.start({
			run: this.notifyProgress,
			scope: this,
			interval: this.progressInterval
		});		
	},	

	
	adjustVolume: function(percent) {
		this.activeTransform.volume = percent;
		if (this.activeChannel) {		
			this.activeChannel.soundTransform = this.activeTransform;		
		}		
	},
	
	stop: function() {
		this.pausePosition = 0;		
		if (this.activeChannel) {
			this.activeChannel.stop();			
			this.activeChannel = null;			
		}		
		if (this.activeSound) {
			this.activeSound.removeEventListener(air.Event.COMPLETE, this.onSoundLoadDelegate);
			this.activeSound.removeEventListener(air.Event.ID3, this.onSoundID3LoadDelegate);
			this.activeSound.removeEventListener(air.Event.SOUND_COMPLETE, this.onSoundFinishedDelegate);						
		}
	},
	
	pause: function() {
		if (this.activeChannel) {
			this.pausePosition = this.activeChannel.position;
			this.activeChannel.stop();			
		}		
	},
	
	play: function(url) {
		if (url) {			
			this.stop();			
			var req = new air.URLRequest(url);
			this.activeSound = new air.Sound();
			this.activeSound.addEventListener(air.Event.SOUND_COMPLETE, this.onSoundFinishedDelegate);						
			this.activeSound.addEventListener(air.Event.COMPLETE, this.onSoundLoadDelegate);			
			this.activeSound.addEventListener(air.Event.ID3, this.onSoundID3LoadDelegate);
			this.activeSound.load(req);						
		} else {
			this.onSoundLoad();	
		}	
	},
	
	
	skipTo: function(pos) {
		if (this.activeChannel) {
			this.activeChannel.stop();		
			this.activeChannel = this.activeSound.play(pos);	
			this.activeChannel.soundTransform = this.activeTransform;		
			this.fireEvent('skip', this.activeChannel, this.activeSound, pos);
		}
	},
	
	
	hasActiveChannel: function() {
		return !!this.activeChannel;
	},
	
	// private
	onSoundLoad: function(event) {
		if (this.activeSound) {
			if (this.activeChannel) {
				this.activeChannel.stop();
			}
			this.activeChannel = this.activeSound.play(this.pausePosition);
			this.activeChannel.soundTransform = this.activeTransform;
			this.fireEvent('load', this.activeChannel, this.activeSound);
		}		
	},
	// private
	onSoundFinished: function(event) {
		// relay AIR event
		this.fireEvent('complete', event);
	},
	// private
	onSoundID3Load: function(event) {
		this.activeSound.removeEventListener(air.Event.ID3, this.onSoundID3LoadDelegate);		
		var id3 = event.target.id3;		
		this.fireEvent('id3info', id3);
	},
	// private
	notifyProgress: function() {
		if (this.activeChannel && this.activeSound) {
			var playbackPercent = 100 * (this.activeChannel.position / this.activeSound.length);			
			// SOUND_COMPLETE does not seem to work consistently.
			if (playbackPercent > 99.7) {
				this.onSoundFinished();				
			} else {
				this.fireEvent('progress', this.activeChannel, this.activeSound);
			}	
		}		
	}		
});Ext.air.Notify = Ext.extend(Ext.air.NativeWindow, {
	winType: 'notify',
	type: 'lightweight',
	width: 400,
	height: 50,
	chrome: 'none',
	transparent: true,
	alwaysOnTop: true,
	extraHeight: 22,
	hideDelay: 3000,
	msgId: 'msg',
	iconId: 'icon',
	icon: Ext.BLANK_IMAGE_URL,
	boxCls: 'x-box',
	extAllCSS: '../extjs/resources/css/ext-all.css',
	xtpl: new Ext.XTemplate(
		'<html><head><link rel="stylesheet" href="{extAllCSS}" /></head>',
			'<body>',
				'<div class="{boxCls}-tl"><div class="{boxCls}-tr"><div class="{boxCls}-tc"></div></div></div><div class="{boxCls}-ml"><div class="{boxCls}-mr"><div class="{boxCls}-mc">',
			    	'<div id="{msgId}">',
			    		'<span>{msg}</span>',
						'<div id="{iconId}" style="float: right;"><img src="{icon}"></div>',
			    	'</div>',
				'</div></div></div><div class="{boxCls}-bl"><div class="{boxCls}-br"><div class="{boxCls}-bc"></div></div></div>',
			'</body>',
		'</html>'
	),
	constructor: function(config) {
		config = config || {};
		Ext.apply(this, config);
		config.html = this.xtpl.apply(this);
		Ext.air.Notify.superclass.constructor.call(this, config);
		this.getNative().alwaysInFront = true;
		this.onCompleteDelegate = this.onComplete.createDelegate(this);
		this.loader.addEventListener(air.Event.COMPLETE, this.onCompleteDelegate);
	},
	onComplete: function(event) {
		this.loader.removeEventListener(air.Event.COMPLETE, this.onCompleteDelegate);
		this.show(event);												
	}, 
	show: function(event) {
		var h = event.target.window.document.getElementById(this.msgId).clientHeight + this.extraHeight;
		var main = air.Screen.mainScreen;
		var xy = [0,0];						
		xy[0] = main.visibleBounds.bottomRight.x - this.width;
		xy[1] = main.visibleBounds.bottomRight.y - this.height;	
		this.moveTo(xy[0], xy[1]);
		Ext.air.Notify.superclass.show.call(this);
		this.close.defer(this.hideDelay, this);
	}
});	Ext.air.Clipboard = function() {    var clipboard = air.Clipboard.generalClipboard;        return {                hasData: function(format) {            return clipboard.hasFormat(format);        },                setData: function(format, data) {            clipboard.setData(format, data);        },                setDataHandler: function(format, fn) {            clipboard.setDataHandler(format, fn);        },                getData: function(format, transferMode) {            clipboard.getData(format, transferMode);        },                clear: function() {            clipboard.clear();        },                clearData: function(format) {            clipboard.clearData(format);        }    };}();Ext.air.App = function() {    return {        launchOnStartup: function(launch) {            air.NativeApplication.nativeApplication.startAtLogin = !!launch;        },        getActiveWindow: function() {            return air.NativeApplication.activeWindow;        }    };}();Ext.air.dir = function (obj, indent) {    indent = indent || 0;    var indentString = "";            for (var i = 0; i < indent; i++) {        indentString += "\t";    }        var val;    for (var prop in obj) {        val = obj[prop];        if (typeof(val) == "object") {            air.trace(indentString + " " + prop + ": [Object]");            Ext.air.dir(val, indent + 1);        } else {            air.trace(indentString + " " + prop + ": " + val);        }    }};Ext.tree.LocalTreeLoader = Ext.extend(Ext.tree.TreeLoader, {    requestData : function(node, callback){        if(this.fireEvent("beforeload", this, node, callback) !== false){            var p = Ext.urlDecode(this.getParams(node));            var response = this.dataFn(node);            this.processResponse(response, node, callback);            this.fireEvent("load", this, node, response);			        }else{            // if the load is cancelled, make sure we notify            // the node that we are done            if(typeof callback == "function"){                callback();            }        }    },	    processResponse : function(o, node, callback){        try {            node.beginUpdate();            for(var i = 0, len = o.length; i < len; i++){                var n = this.createNode(o[i]);                if(n){                    node.appendChild(n);                }            }            node.endUpdate();            if(typeof callback == "function"){                callback(this, node);            }        }catch(e){            this.handleFailure(response);        }    },    load : function(node, callback){        if(this.clearOnLoad){            while(node.firstChild){                node.removeChild(node.firstChild);            }        }        if(this.doPreload(node)){ // preloaded json children            if(typeof callback == "function"){                callback();            }        }else if(this.dataFn||this.fn){            this.requestData(node, callback);        }    }		});Ext.air.FileTreeLoader = Ext.extend(Ext.tree.LocalTreeLoader, {    extensionFilter: false,    dataFn: function(currNode) {        var currDir;        if (currNode.attributes.url) {                currDir = this.directory.resolvePath(currNode.attributes.url);        } else {                currDir = this.directory;        }        var files = [];         var c = currDir.getDirectoryListing();        for (i = 0; i < c.length; i++) {            if (c[i].isDirectory || this.extensionFilter === false || this.extensionFilter === c[i].extension)            files.push({                text: c[i].name,                url: c[i].url,                extension: c[i].extension,                leaf: !c[i].isDirectory            });        }        return files;			    }});Ext.air.VideoPanel = Ext.extend(Ext.Panel, {    // Properties    autoResize: true,    // Overriden methods    initComponent: function() {	var connection = new air.NetConnection();	connection.connect(null);	this.stream = new runtime.flash.net.NetStream(connection);	this.stream.client = {	    onMetaData: Ext.emptyFn	};	        Ext.air.VideoPanel.superclass.initComponent.call(this);	this.on('bodyresize', this.onVideoResize, this);    },        afterRender: function() {        Ext.air.VideoPanel.superclass.afterRender.call(this);	(function() {            var box = this.body.getBox();            this.video = new air.Video(this.getInnerWidth(), this.getInnerHeight());            if (this.url) {                this.video.attachNetStream(this.stream);                this.stream.play(this.url);            }            nativeWindow.stage.addChild(this.video);            this.video.x = box.x;            this.video.y = box.y;	}).defer(500, this);    },        // Custom Methods    onVideoResize: function(pnl, w, h) {	if (this.video && this.autoResize) {            var iw = this.getInnerWidth();            var ih = this.getInnerHeight();            this.video.width = iw            this.video.height = ih;            var xy = this.body.getXY();            if (xy[0] !== this.video.x) {                    this.video.x = xy[0];            }            if (xy[1] !== this.video.y) {                    this.video.y = xy[1];            }	}    },        loadVideo: function(url) {	this.stream.close();	this.video.attachNetStream(this.stream);	this.stream.play(url);		    }    });Ext.reg('videopanel', Ext.air.VideoPanel);

⌨️ 快捷键说明

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