cherryext/orun/extjs/static/ext-6.2.0/packages/ux/classic/ux.js

43 lines
160 KiB
JavaScript
Raw Normal View History

2018-08-17 12:14:11 +03:00
Ext.define("Ext.ux.Gauge",{extend:"Ext.Gadget",xtype:"gauge",requires:["Ext.util.Region"],config:{baseCls:Ext.baseCSSPrefix+"gauge",padding:10,trackStart:135,trackLength:270,angleOffset:0,minValue:0,maxValue:100,value:50,clockwise:true,textTpl:['<tpl>{value:number("0.00")}%</tpl>'],textAlign:"c-c",trackStyle:{outerRadius:"100%",innerRadius:"100% - 20",round:false},valueStyle:{outerRadius:"100% - 2",innerRadius:"100% - 18",round:false},animation:true},template:[{reference:"innerElement",children:[{reference:"textElement",cls:Ext.baseCSSPrefix+"gauge-text"}]}],defaultBindProperty:"value",pathAttributes:{fill:true,fillOpacity:true,stroke:true,strokeOpacity:true,strokeWidth:true},easings:{linear:Ext.identityFn,"in":function(a){return a*a*a},out:function(a){return(--a)*a*a+1},inOut:function(a){return a<0.5?4*a*a*a:(a-1)*(2*a-2)*(2*a-2)+1}},resizeDelay:0,resizeTimerId:0,size:null,svgNS:"http://www.w3.org/2000/svg",svg:null,defs:null,trackArc:null,valueArc:null,trackGradient:null,valueGradient:null,fx:null,fxValue:0,fxAngleOffset:0,constructor:function(a){var b=this;b.fitSectorInRectCache={startAngle:null,lengthAngle:null,minX:null,maxX:null,minY:null,maxY:null};b.interpolator=b.createInterpolator();b.callParent([a]);b.on("resize","onElementResize",b)},doDestroy:function(){var a=this;a.un("resize","onElementResize",a);a.stopAnimation();a.callParent()},afterComponentLayout:function(c,a,b,d){this.callParent([c,a,b,d]);if(Ext.isIE9){this.handleResize()}},onElementResize:function(b,a){this.handleResize(a)},handleResize:function(b,a){var d=this,c=d.element;if(!(c&&(b=b||c.getSize())&&b.width&&b.height)){return}clearTimeout(d.resizeTimerId);if(a||d.resizeDelay){d.resizeTimerId=0}else{d.resizeTimerId=Ext.defer(d.handleResize,d.resizeDelay,d,[b,true]);return}d.size=b;d.resizeHandler(b)},updateMinValue:function(b){var a=this;a.interpolator.setDomain(b,a.getMaxValue());if(!a.isConfiguring){a.render()}},updateMaxValue:function(b){var a=this;a.interpolator.setDomain(a.getMinValue(),b);if(!a.isConfiguring){a.render()}},updateAngleOffset:function(a,b){var c=this,d=c.getAnimation();c.fxAngleOffset=a;if(!c.isConfiguring){if(d.duration){c.animate(b,a,d.duration,c.easings[d.easing],function(e){c.fxAngleOffset=e;c.render()})}else{c.render()}}},updateTrackStart:function(b){var a=this;if(!a.isConfiguring){a.render()}},updateTrackLength:function(a){var b=this;b.interpolator.setRange(0,a);if(!b.isConfiguring){b.render()}},applyPadding:function(b){if(typeof b==="string"){var a=parseFloat(b)/100;return function(c){return c*a}}return function(){return b}},updatePadding:function(){if(!this.isConfiguring){this.render()}},applyValue:function(b){var a=this.getMinValue(),c=this.getMaxValue();return Math.min(Math.max(b,a),c)},updateValue:function(d,a){var b=this,c=b.getAnimation();b.fxValue=d;if(!b.isConfiguring){b.writeText();if(c.duration){b.animate(a,d,c.duration,b.easings[c.easing],function(e){b.fxValue=e;b.render()})}else{b.render()}}},applyTextTpl:function(a){if(a&&!a.isTemplate){a=new Ext.XTemplate(a)}return a},updateTextTpl:function(){this.writeText();if(!this.isConfiguring){this.centerText()}},writeText:function(a){var c=this,e=c.getValue(),d=c.getMinValue(),f=c.getMaxValue(),g=f-d,b=c.getTextTpl();b.overwrite(c.textElement,{value:e,percent:(e-d)/g*100,minValue:d,maxValue:f,delta:g})},centerText:function(e,d,c,g,f){var b=this.textElement,a=this.getTextAlign(),i,h;if(Ext.Number.isEqual(g,0,0.1)||c.isOutOfBound({x:e,y:d})){i=b.getRegion().alignTo({align:a,target:c});b.setLeft(i.left);b.setTop(i.top)}else{h=b.getBox();b.setLeft(e-h.width/2);b.setTop(d-h.height/2)}},camelCaseRe:/([a-z])([A-Z])/g,camelToHyphen:function(a){return a.replace(this.camelCaseRe,"$1-$2").toLowerCase()},applyTrackStyle:function(a){var c=this,b;a.innerRadius=c.getRadiusFn(a.innerRadius);a.outerRadius=c.getRadiusFn(a.outerRadius);if(Ext.isArray(a.fill)){b=c.getTrackGradient();c.setGradientStops(b,a.fill);a.fill="url(#"+b.getAttribute("id")+")"}return a},updateTrackStyle:function(a){var d=this,c=Ext.fly(d.getTrackArc()),b;for(b in a){if(b in d.pathAttributes){c.setStyle(d.camelToHy
/*!
* Ext JS Library
* Copyright(c) 2006-2014 Sencha Inc.
* licensing@sencha.com
* http://www.sencha.com/license
*/
Ext.define("Ext.ux.desktop.Desktop",{extend:"Ext.panel.Panel",alias:"widget.desktop",uses:["Ext.util.MixedCollection","Ext.menu.Menu","Ext.view.View","Ext.window.Window","Ext.ux.desktop.TaskBar","Ext.ux.desktop.Wallpaper"],activeWindowCls:"ux-desktop-active-win",inactiveWindowCls:"ux-desktop-inactive-win",lastActiveWindow:null,border:false,html:"&#160;",layout:"fit",xTickSize:1,yTickSize:1,app:null,shortcuts:null,shortcutItemSelector:"div.ux-desktop-shortcut",shortcutTpl:['<tpl for=".">','<div class="ux-desktop-shortcut" id="{name}-shortcut">','<div class="ux-desktop-shortcut-icon {iconCls}">','<img src="',Ext.BLANK_IMAGE_URL,'" title="{name}">',"</div>",'<span class="ux-desktop-shortcut-text">{name}</span>',"</div>","</tpl>",'<div class="x-clear"></div>'],taskbarConfig:null,windowMenu:null,initComponent:function(){var b=this;b.windowMenu=new Ext.menu.Menu(b.createWindowMenu());b.bbar=b.taskbar=new Ext.ux.desktop.TaskBar(b.taskbarConfig);b.taskbar.windowMenu=b.windowMenu;b.windows=new Ext.util.MixedCollection();b.contextMenu=new Ext.menu.Menu(b.createDesktopMenu());b.items=[{xtype:"wallpaper",id:b.id+"_wallpaper"},b.createDataView()];b.callParent();b.shortcutsView=b.items.getAt(1);b.shortcutsView.on("itemclick",b.onShortcutItemClick,b);var a=b.wallpaper;b.wallpaper=b.items.getAt(0);if(a){b.setWallpaper(a,b.wallpaperStretch)}},afterRender:function(){var a=this;a.callParent();a.el.on("contextmenu",a.onDesktopMenu,a)},createDataView:function(){var a=this;return{xtype:"dataview",overItemCls:"x-view-over",trackOver:true,itemSelector:a.shortcutItemSelector,store:a.shortcuts,style:{position:"absolute"},x:0,y:0,tpl:new Ext.XTemplate(a.shortcutTpl)}},createDesktopMenu:function(){var b=this,a={items:b.contextMenuItems||[]};if(a.items.length){a.items.push("-")}a.items.push({text:"Tile",handler:b.tileWindows,scope:b,minWindows:1},{text:"Cascade",handler:b.cascadeWindows,scope:b,minWindows:1});return a},createWindowMenu:function(){var a=this;return{defaultAlign:"br-tr",items:[{text:"Restore",handler:a.onWindowMenuRestore,scope:a},{text:"Minimize",handler:a.onWindowMenuMinimize,scope:a},{text:"Maximize",handler:a.onWindowMenuMaximize,scope:a},"-",{text:"Close",handler:a.onWindowMenuClose,scope:a}],listeners:{beforeshow:a.onWindowMenuBeforeShow,hide:a.onWindowMenuHide,scope:a}}},onDesktopMenu:function(b){var a=this,c=a.contextMenu;b.stopEvent();if(!c.rendered){c.on("beforeshow",a.onDesktopMenuBeforeShow,a)}c.showAt(b.getXY());c.doConstrain()},onDesktopMenuBeforeShow:function(c){var b=this,a=b.windows.getCount();c.items.each(function(e){var d=e.minWindows||0;e.setDisabled(a<d)})},onShortcutItemClick:function(e,a){var c=this,b=c.app.getModule(a.data.module),d=b&&b.createWindow();if(d){c.restoreWindow(d)}},onWindowClose:function(b){var a=this;a.windows.remove(b);a.taskbar.removeTaskButton(b.taskButton);a.updateActiveWindow()},onWindowMenuBeforeShow:function(c){var a=c.items.items,b=c.theWin;a[0].setDisabled(b.maximized!==true&&b.hidden!==true);a[1].setDisabled(b.minimized===true);a[2].setDisabled(b.maximized===true||b.hidden===true)},onWindowMenuClose:function(){var a=this,b=a.windowMenu.theWin;b.close()},onWindowMenuHide:function(a){Ext.defer(function(){a.theWin=null},1)},onWindowMenuMaximize:function(){var a=this,b=a.windowMenu.theWin;b.maximize();b.toFront()},onWindowMenuMinimize:function(){var a=this,b=a.windowMenu.theWin;b.minimize()},onWindowMenuRestore:function(){var a=this,b=a.windowMenu.theWin;a.restoreWindow(b)},getWallpaper:function(){return this.wallpaper.wallpaper},setTickSize:function(b,c){var e=this,a=e.xTickSize=b,d=e.yTickSize=(arguments.length>1)?c:a;e.windows.each(function(g){var f=g.dd,h=g.resizer;f.xTickSize=a;f.yTickSize=d;h.widthIncrement=a;h.heightIncrement=d})},setWallpaper:function(b,a){this.wallpaper.setWallpaper(b,a);return this},cascadeWindows:function(){var a=0,c=0,b=this.getDesktopZIndexManager();b.eachBottomUp(function(d){if(d.isWindow&&d.isVisible()&&!d.maximized){d.setPosition(a,c);a+=20;c+=20}})},createWindow:function(c,b){var d=this,e,a=Ext.applyIf(c||{},{stateful:false,isWindow:true,constrainHeader:tr
/*!
* Ext JS Library
* Copyright(c) 2006-2014 Sencha Inc.
* licensing@sencha.com
* http://www.sencha.com/license
*/
Ext.define("Ext.ux.desktop.Module",{mixins:{observable:"Ext.util.Observable"},constructor:function(a){this.mixins.observable.constructor.call(this,a);this.init()},init:Ext.emptyFn});
/*!
* Ext JS Library
* Copyright(c) 2006-2014 Sencha Inc.
* licensing@sencha.com
* http://www.sencha.com/license
*/
Ext.define("Ext.ux.desktop.ShortcutModel",{extend:"Ext.data.Model",fields:[{name:"name",convert:Ext.String.createVarName},{name:"iconCls"},{name:"module"}]});Ext.define("Ext.ux.desktop.StartMenu",{extend:"Ext.menu.Menu",baseCls:Ext.baseCSSPrefix+"panel",cls:"x-menu ux-start-menu",bodyCls:"ux-start-menu-body",defaultAlign:"bl-tl",iconCls:"user",bodyBorder:true,width:300,initComponent:function(){var a=this;a.layout.align="stretch";a.items=a.menu;a.callParent();a.toolbar=new Ext.toolbar.Toolbar(Ext.apply({dock:"right",cls:"ux-start-menu-toolbar",vertical:true,width:100,layout:{align:"stretch"}},a.toolConfig));a.addDocked(a.toolbar);delete a.toolItems},addMenuItem:function(){var a=this.menu;a.add.apply(a,arguments)},addToolItem:function(){var a=this.toolbar;a.add.apply(a,arguments)}});
/*!
* Ext JS Library
* Copyright(c) 2006-2014 Sencha Inc.
* licensing@sencha.com
* http://www.sencha.com/license
*/
Ext.define("Ext.ux.desktop.TaskBar",{extend:"Ext.toolbar.Toolbar",requires:["Ext.button.Button","Ext.resizer.Splitter","Ext.menu.Menu","Ext.ux.desktop.StartMenu"],alias:"widget.taskbar",cls:"ux-taskbar",startBtnText:"Start",initComponent:function(){var a=this;a.startMenu=new Ext.ux.desktop.StartMenu(a.startConfig);a.quickStart=new Ext.toolbar.Toolbar(a.getQuickStart());a.windowBar=new Ext.toolbar.Toolbar(a.getWindowBarConfig());a.tray=new Ext.toolbar.Toolbar(a.getTrayConfig());a.items=[{xtype:"button",cls:"ux-start-button",iconCls:"ux-start-button-icon",menu:a.startMenu,menuAlign:"bl-tl",text:a.startBtnText},a.quickStart,{xtype:"splitter",html:"&#160;",height:14,width:2,cls:"x-toolbar-separator x-toolbar-separator-horizontal"},a.windowBar,"-",a.tray];a.callParent()},afterLayout:function(){var a=this;a.callParent();a.windowBar.el.on("contextmenu",a.onButtonContextMenu,a)},getQuickStart:function(){var b=this,a={minWidth:20,width:Ext.themeName==="neptune"?70:60,items:[],enableOverflow:true};Ext.each(this.quickStart,function(c){a.items.push({tooltip:{text:c.name,align:"bl-tl"},overflowText:c.name,iconCls:c.iconCls,module:c.module,handler:b.onQuickStartClick,scope:b})});return a},getTrayConfig:function(){var a={items:this.trayItems};delete this.trayItems;return a},getWindowBarConfig:function(){return{flex:1,cls:"ux-desktop-windowbar",items:["&#160;"],layout:{overflowHandler:"Scroller"}}},getWindowBtnFromEl:function(a){var b=this.windowBar.getChildByElement(a);return b||null},onQuickStartClick:function(b){var a=this.app.getModule(b.module),c;if(a){c=a.createWindow();c.show()}},onButtonContextMenu:function(d){var c=this,b=d.getTarget(),a=c.getWindowBtnFromEl(b);if(a){d.stopEvent();c.windowMenu.theWin=a.win;c.windowMenu.showBy(b)}},onWindowBtnClick:function(a){var b=a.win;if(b.minimized||b.hidden){a.disable();b.show(null,function(){a.enable()})}else{if(b.active){a.disable();b.on("hide",function(){a.enable()},null,{single:true});b.minimize()}else{b.toFront()}}},addTaskButton:function(c){var a={iconCls:c.iconCls,enableToggle:true,toggleGroup:"all",width:140,margin:"0 2 0 3",text:Ext.util.Format.ellipsis(c.title,20),listeners:{click:this.onWindowBtnClick,scope:this},win:c};var b=this.windowBar.add(a);b.toggle(true);return b},removeTaskButton:function(a){var c,b=this;b.windowBar.items.each(function(d){if(d===a){c=d}return !c});if(c){b.windowBar.remove(c)}return c},setActiveButton:function(a){if(a){a.toggle(true)}else{this.windowBar.items.each(function(b){if(b.isButton){b.toggle(false)}})}}});Ext.define("Ext.ux.desktop.TrayClock",{extend:"Ext.toolbar.TextItem",alias:"widget.trayclock",cls:"ux-desktop-trayclock",html:"&#160;",timeFormat:"g:i A",tpl:"{time}",initComponent:function(){var a=this;a.callParent();if(typeof(a.tpl)=="string"){a.tpl=new Ext.XTemplate(a.tpl)}},afterRender:function(){var a=this;Ext.Function.defer(a.updateTime,100,a);a.callParent()},doDestroy:function(){var a=this;if(a.timer){window.clearTimeout(a.timer);a.timer=null}a.callParent()},updateTime:function(){var a=this,b=Ext.Date.format(new Date(),a.timeFormat),c=a.tpl.apply({time:b});if(a.lastText!=c){a.setText(c);a.lastText=c}a.timer=Ext.Function.defer(a.updateTime,10000,a)}});
/*!
* Ext JS Library
* Copyright(c) 2006-2015 Sencha Inc.
* licensing@sencha.com
* http://www.sencha.com/license
*/
Ext.define("Ext.ux.desktop.Video",{extend:"Ext.panel.Panel",alias:"widget.video",layout:"fit",autoplay:false,controls:true,bodyStyle:"background-color:#000;color:#fff",html:"",tpl:['<video id="{id}-video" autoPlay="{autoplay}" controls="{controls}" poster="{poster}" start="{start}" loopstart="{loopstart}" loopend="{loopend}" autobuffer="{autobuffer}" loop="{loop}" style="width:100%;height:100%">','<tpl for="src">','<source src="{src}" type="{type}"/>',"</tpl>","{html}","</video>"],initComponent:function(){var e=this,f,c,b,d;if(e.fallbackHTML){f=e.fallbackHTML}else{f="Your browser does not support HTML5 Video. ";if(Ext.isChrome){f+="Upgrade Chrome."}else{if(Ext.isGecko){f+="Upgrade to Firefox 3.5 or newer."}else{var a='<a href="http://www.google.com/chrome">Chrome</a>';f+='Please try <a href="http://www.mozilla.com">Firefox</a>';if(Ext.isIE){f+=", "+a+' or <a href="http://www.apple.com/safari/">Safari</a>.'}else{f+=" or "+a+"."}}}}e.fallbackHTML=f;b=e.data=Ext.copyTo({tag:"video",html:f},e,"id,poster,start,loopstart,loopend,playcount,autobuffer,loop");if(e.autoplay){b.autoplay=1}if(e.controls){b.controls=1}if(Ext.isArray(e.src)){b.src=e.src}else{b.src=[{src:e.src}]}e.callParent()},afterRender:function(){var a=this;a.callParent();a.video=a.body.getById(a.id+"-video");el=a.video.dom;a.supported=(el&&el.tagName.toLowerCase()=="video");if(a.supported){a.video.on("error",a.onVideoError,a)}},getFallback:function(){return'<h1 style="background-color:#ff4f4f;padding: 10px;">'+this.fallbackHTML+"</h1>"},onVideoError:function(){var a=this;a.video.remove();a.supported=false;a.body.createChild(a.getFallback())},doDestroy:function(){var c=this;var b=c.video;if(c.supported&&b){var a=b.dom;if(a&&a.pause){a.pause()}b.remove();c.video=null}c.callParent()}});
/*!
* Ext JS Library
* Copyright(c) 2006-2014 Sencha Inc.
* licensing@sencha.com
* http://www.sencha.com/license
*/
Ext.define("Ext.ux.desktop.Wallpaper",{extend:"Ext.Component",alias:"widget.wallpaper",cls:"ux-wallpaper",html:'<img src="'+Ext.BLANK_IMAGE_URL+'">',stretch:false,wallpaper:null,stateful:true,stateId:"desk-wallpaper",afterRender:function(){var a=this;a.callParent();a.setWallpaper(a.wallpaper,a.stretch)},applyState:function(){var b=this,a=b.wallpaper;b.callParent(arguments);if(a!=b.wallpaper){b.setWallpaper(b.wallpaper)}},getState:function(){return this.wallpaper&&{wallpaper:this.wallpaper}},setWallpaper:function(b,a){var c=this,e,d;c.stretch=(a!==false);c.wallpaper=b;if(c.rendered){e=c.el.dom.firstChild;if(!b||b==Ext.BLANK_IMAGE_URL){Ext.fly(e).hide()}else{if(c.stretch){e.src=b;c.el.removeCls("ux-wallpaper-tiled");Ext.fly(e).setStyle({width:"100%",height:"100%"}).show()}else{Ext.fly(e).hide();d="url("+b+")";c.el.addCls("ux-wallpaper-tiled")}}c.el.setStyle({backgroundImage:d||""});if(c.stateful){c.saveState()}}return c}});Ext.define("Ext.ux.event.RecorderManager",{extend:"Ext.panel.Panel",alias:"widget.eventrecordermanager",uses:["Ext.ux.event.Recorder","Ext.ux.event.Player"],layout:"fit",buttonAlign:"left",eventsToIgnore:{mousemove:1,mouseover:1,mouseout:1},bodyBorder:false,playSpeed:1,initComponent:function(){var b=this;b.recorder=new Ext.ux.event.Recorder({attachTo:b.attachTo,listeners:{add:b.updateEvents,coalesce:b.updateEvents,buffer:200,scope:b}});b.recorder.eventsToRecord=Ext.apply({},b.recorder.eventsToRecord);function c(e,d){return{text:e,speed:d,group:"speed",checked:d==b.playSpeed,handler:b.onPlaySpeed,scope:b}}b.tbar=[{text:"Record",xtype:"splitbutton",whenIdle:true,handler:b.onRecord,scope:b,menu:b.makeRecordButtonMenu()},{text:"Play",xtype:"splitbutton",whenIdle:true,handler:b.onPlay,scope:b,menu:[c("Qarter Speed (0.25x)",0.25),c("Half Speed (0.5x)",0.5),c("3/4 Speed (0.75x)",0.75),"-",c("Recorded Speed (1x)",1),c("Double Speed (2x)",2),c("Quad Speed (4x)",4),"-",c("Full Speed",1000)]},{text:"Clear",whenIdle:true,handler:b.onClear,scope:b},"->",{text:"Stop",whenActive:true,disabled:true,handler:b.onStop,scope:b}];var a=b.attachTo&&b.attachTo.testEvents;b.items=[{xtype:"textarea",itemId:"eventView",fieldStyle:"font-family: monospace",selectOnFocus:true,emptyText:"Events go here!",value:a?b.stringifyEvents(a):"",scrollToBottom:function(){var d=this.inputEl.dom;d.scrollTop=d.scrollHeight}}];b.fbar=[{xtype:"tbtext",text:"Attached To: "+(b.attachTo&&b.attachTo.location.href)}];b.callParent()},makeRecordButtonMenu:function(){var b=[],c={},e=this.recorder.eventsToRecord,d=this.eventsToIgnore;Ext.Object.each(e,function(f,h){var g=c[h.kind];if(!g){c[h.kind]=g=[];b.push({text:h.kind,menu:g})}g.push({text:f,checked:true,handler:function(i){if(i.checked){e[f]=h}else{delete e[f]}}});if(d[f]){g[g.length-1].checked=false;Ext.Function.defer(function(){delete e[f]},1)}});function a(f,g){return(f.text<g.text)?-1:((g.text<f.text)?1:0)}b.sort(a);Ext.Array.each(b,function(f){f.menu.sort(a)});return b},getEventView:function(){return this.down("#eventView")},onClear:function(){var a=this.getEventView();a.setValue("")},onPlay:function(){var c=this,a=c.getEventView(),b=a.getValue();if(b){b=Ext.decode(b);if(b.length){c.player=Ext.create("Ext.ux.event.Player",{attachTo:window.opener,eventQueue:b,speed:c.playSpeed,listeners:{stop:c.onPlayStop,scope:c}});c.player.start();c.syncBtnUI()}}},onPlayStop:function(){this.player=null;this.syncBtnUI()},onPlaySpeed:function(a){this.playSpeed=a.speed},onRecord:function(){this.recorder.start();this.syncBtnUI()},onStop:function(){var a=this;if(a.player){a.player.stop();a.player=null}else{a.recorder.stop()}a.syncBtnUI();a.updateEvents()},syncBtnUI:function(){var c=this,b=!c.player&&!c.recorder.active;Ext.each(c.query("[whenIdle]"),function(d){d.setDisabled(!b)});Ext.each(c.query("[whenActive]"),function(d){d.setDisabled(b)});var a=c.getEventView();a.setReadOnly(!b)},stringifyEvents:function(c){var b,a=[];Ext.each(c,function(d){b=[];Ext.Object.each(d,function(e,f){if(b.length){b.push(", ")}else{b.push(" { ")}b.push(e,": ");b.push(Ext.encode(f))});b.push(" }");a.push(b.join(""))});return"[\n"+a.join(