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

📄 ext-air.js

📁 ext-2.3.0
💻 JS
📖 第 1 页 / 共 3 页
字号:
clause+=sort+' '+(dir||'ASC');}var rs=this.table.selectBy(clause,args);this.onLoad({callback:callback,scope:scope,arg:arg,reader:reader},rs);}else{callback.call(scope||this,null,arg,false);}},onLoad:function(trans,rs,e,stmt){if(rs===false){this.fireEvent("loadexception",this,null,trans.arg,e);trans.callback.call(trans.scope||window,null,trans.arg,false);return;}var result=trans.reader.readRecords(rs);this.fireEvent("load",this,rs,trans.arg);trans.callback.call(trans.scope||window,result,trans.arg,true);},processData:function(o){var fs=this.store.fields;var r={};for(var key in o){var f=fs.key(key),v=o[key];if(f){if(f.type=='date'){r[key]=v?v.format(Ext.sql.Proxy.DATE_FORMAT,10):'';}else if(f.type=='boolean'){r[key]=v?1:0;}else{r[key]=v;}}}return r;},onUpdate:function(ds,record){var changes=record.getChanges();var kn=this.table.keyName;this.table.updateBy(this.processData(changes),kn+' = ?',[record.data[kn]]);record.commit(true);},onAdd:function(ds,records,index){for(var i=0,len=records.length;i<len;i++){this.table.insert(this.processData(records[i].data));}},onRemove:function(ds,record,index){var kn=this.table.keyName;this.table.removeBy(kn+' = ?',[record.data[kn]]);}});Ext.sql.AirConnection=Ext.extend(Ext.sql.Connection,{open:function(db){this.conn=new air.SQLConnection();var file=air.File.applicationDirectory.resolvePath(db);this.conn.open(file);this.openState=true;this.fireEvent('open',this);},close:function(){this.conn.close();this.fireEvent('close',this);},createStatement:function(type){var stmt=new air.SQLStatement();stmt.sqlConnection=this.conn;return stmt;},exec:function(sql){var stmt=this.createStatement('exec');stmt.text=sql;stmt.execute();},execBy:function(sql,args){var stmt=this.createStatement('exec');stmt.text=sql;this.addParams(stmt,args);stmt.execute();},query:function(sql){var stmt=this.createStatement('query');stmt.text=sql;stmt.execute(this.maxResults);return this.readResults(stmt.getResult());},queryBy:function(sql,args){var stmt=this.createStatement('query');stmt.text=sql;this.addParams(stmt,args);stmt.execute(this.maxResults);return this.readResults(stmt.getResult());},addParams:function(stmt,args){if(!args){return;}for(var key in args){if(args.hasOwnProperty(key)){if(!isNaN(key)){var v=args[key];if(Ext.isDate(v)){v=v.format(Ext.sql.Proxy.DATE_FORMAT);}stmt.parameters[parseInt(key)]=v;}else{stmt.parameters[':'+key]=args[key];}}}return stmt;},readResults:function(rs){var r=[];if(rs&&rs.data){var len=rs.data.length;for(var i=0;i<len;i++){r[r.length]=rs.data[i];}}return r;}});Ext.air.SystemTray=function(){var app=air.NativeApplication.nativeApplication;var icon,isWindows=false,bitmaps;if(air.NativeApplication.supportsSystemTrayIcon){icon=app.icon;isWindows=true;}if(air.NativeApplication.supportsDockIcon){icon=app.icon;}return{setIcon:function(icon,tooltip,initWithIcon){if(!icon){return;}var loader=new air.Loader();loader.contentLoaderInfo.addEventListener(air.Event.COMPLETE,function(e){bitmaps=new runtime.Array(e.target.content.bitmapData);if(initWithIcon){icon.bitmaps=bitmaps;}});loader.load(new air.URLRequest(icon));if(tooltip&&air.NativeApplication.supportsSystemTrayIcon){app.icon.tooltip=tooltip;}},bounce:function(priority){icon.bounce(priority);},on:function(eventName,fn,scope){icon.addEventListener(eventName,function(){fn.apply(scope||this,arguments);});},hideIcon:function(){if(!icon){return;}icon.bitmaps=[];},showIcon:function(){if(!icon){return;}icon.bitmaps=bitmaps;},setMenu:function(actions,_parentMenu){if(!icon){return;}var menu=new air.NativeMenu();for(var i=0,len=actions.length;i<len;i++){var a=actions[i];if(a=='-'){menu.addItem(new air.NativeMenuItem("",true));}else{var item=menu.addItem(Ext.air.MenuItem(a));if(a.menu||(a.initialConfig&&a.initialConfig.menu)){item.submenu=Ext.air.SystemTray.setMenu(a.menu||a.initialConfig.menu,menu);}}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'};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;if(air.NativeWindow.supportsMenu&&nativeWindow.systemChrome!=air.NativeWindowSystemChrome.NONE){menu=new air.NativeMenu();nativeWindow.menu=menu;}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;}};}();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){nativeItem.enabled=!v;},setHandler:function(newHandler,newScope){handler=newHandler;scope=newScope;},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),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;},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);}},onSoundFinished:function(event){this.fireEvent('complete',event);},onSoundID3Load:function(event){this.activeSound.removeEventListener(air.Event.ID3,this.onSoundID3LoadDelegate);var id3=event.target.id3;this.fireEvent('id3info',id3);},notifyProgress:function(){if(this.activeChannel&&this.activeSound){var playbackPercent=100*(this.activeChannel.position/this.activeSound.length);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(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)){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,{autoResize:true,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);},onVideoResize:function(pnl,w,h){if(this.video&&this.autoResize){var iw=this.getInnerWidth();var ih=this.getInnerHeight();this.video.width=iwthis.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 + -