| 1 |
- MWF.require("MWF.widget.Tree",null,false);MWF.xApplication.Minder.Main=new Class({Extends:MWF.xApplication.Common.Main,Implements:[Options,Events],options:{style:"default",name:"Minder",icon:"icon.png",width:"1200",height:"700",isResize:false,title:MWF.xApplication.Minder.LP.title,defaultAction:"openMineExplorer"},onQueryLoad:function(){this.lp=MWF.xApplication.Minder.LP;this.restActions=MWF.Actions.get("x_mind_assemble_control")},loadApplication:function(e){this.createNode();this.loadApplicationContent();if(e)e()},createNode:function(){this.content.setStyle("overflow","hidden");this.node=new Element("div",{styles:{width:"100%",height:"100%",overflow:"hidden"}}).inject(this.content)},loadApplicationContent:function(){this.naviNode=new Element("div.naviNode",{styles:this.css.naviNode}).inject(this.node);new Element("div.naviTopNode",{styles:this.css.naviTopNode}).inject(this.naviNode);this.contentNode=new Element("div.contentNode",{styles:this.css.contentNode}).inject(this.node);this.resizeContent();this.resizeFun=this.resizeContent.bind(this);this.addEvent("resize",this.resizeFun);this.loadNavi()},loadNavi:function(){var e=[{title:"我的文件",action:"openMineExplorer",icon:"navi_mine"},{title:"分享文件",action:"openSharedExplorer",icon:"navi_share"},{title:"收到文件",action:"openReceivedExplorer",icon:"navi_receive"},{title:"回收站",action:"openRecycleExplorer",icon:"navi_recycle"},{title:"来自应用",action:"personConfig",icon:"navi_fromapp"}];e.each(function(e){this.createNaviNode(e)}.bind(this))},openMineExplorer:function(){MWF.xDesktop.requireApp("Minder","MineExplorer",null,false);if(this.currentExplorer){this.currentExplorer.destroy()}var e=this.status&&this.status.explorerStatus?this.status.explorerStatus:{};this.currentExplorer=new MWF.xApplication.Minder.MineExplorer(this.contentNode,this,e);this.currentExplorer.load()},openSharedExplorer:function(){MWF.xDesktop.requireApp("Minder","SharedExplorer",null,false);if(this.currentExplorer){this.currentExplorer.destroy()}var e=this.status&&this.status.explorerStatus?this.status.explorerStatus:{};this.currentExplorer=new MWF.xApplication.Minder.SharedExplorer(this.contentNode,this,e);this.currentExplorer.load()},openReceivedExplorer:function(){MWF.xDesktop.requireApp("Minder","ReceivedExplorer",null,false);if(this.currentExplorer){this.currentExplorer.destroy()}var e=this.status&&this.status.explorerStatus?this.status.explorerStatus:{};this.currentExplorer=new MWF.xApplication.Minder.ReceivedExplorer(this.contentNode,this,e);this.currentExplorer.load()},openRecycleExplorer:function(){MWF.xDesktop.requireApp("Minder","RecycleBinExplorer",null,false);if(this.currentExplorer){this.currentExplorer.destroy()}var e=this.status&&this.status.explorerStatus?this.status.explorerStatus:{};this.currentExplorer=new MWF.xApplication.Minder.RecycleBinExplorer(this.contentNode,this,e);this.currentExplorer.load()},createNaviNode:function(t){var i=this;var e=new Element("div",{text:t.title,styles:this.css.naviItemNode,events:{click:function(e){if(i.currentAction==t.action)return;e.target.setStyles(i.css.naviItemNode_selected);if(i.currentNaviItemNode)i.currentNaviItemNode.setStyles(i.css.naviItemNode);i.currentNaviItemNode=e.target;i.currentAction=t.action;i[t.action]()}}}).inject(this.naviNode);e.setStyle("background-image","url("+this.path+this.options.style+"/icon/"+t.icon+".png)");if(this.status&&this.status.action&&this.status.action==t.action){e.click()}else if(this.options.defaultAction==t.action){e.click()}},recordStatus:function(){return{action:this.currentAction,explorerStatus:this.currentExplorer.recordStatus()}},resizeContent:function(){var e=this.content.getSize();this.naviNode.setStyle("height",e.y)},getDateDiff:function(e){if(!e)return"";var t=Date.parse(e.replace(/-/gi,"/"));var i=1e3*60;var n=i*60;var s=n*24;var r=s*15;var o=s*30;var a=o*12;var l=(new Date).getTime();var c=l-t;if(c<0){}var h=(new Date).decrement("day",1);var d=(new Date).decrement("day",2);var p=c/a;var u=c/o;var f=c/(7*s);var v=c/s;var x=c/n;var E=c/i;if(h.getFullYear()==t.getFullYear()&&h.getMonth()==t.getMonth()&&h.getDate()==t.getDate()){result="昨天 "+t.getHours()+":"+t.getMinutes()}else if(d.getFullYear()==t.getFullYear()&&d.getMonth()==t.getMonth()&&d.getDate()==t.getDate()){result="前天 "+t.getHours()+":"+t.getMinutes()}else if(p>1){result=t.getFullYear()+"-"+(t.getMonth()+1)+"-"+t.getDate()}else if(u>=1){result=t.getFullYear()+"-"+(t.getMonth()+1)+"-"+t.getDate()}else if(f>=1){result=parseInt(f)+"周前"}else if(v>=1){result=parseInt(v)+"天前"}else if(x>=1){result=parseInt(x)+"小时前"}else if(E>=1){result=parseInt(E)+"分钟前"}else result="刚刚";return result}});MWF.xApplication.Minder.History=new Class({initialize:function(e){this.app=e;this.css=e.css;this.MAX_HISTORY=100;this.lastSnap;this.patchLock;this.undoDiffs=[];this.redoDiffs=[];this.reset();this.app.addEvent("patchChange",this.changed.bind(this))},load:function(e){if(this.node){this.node.inject(e)}else{this.loadNode(e)}},loadNode:function(e){this.node=new Element("div",{styles:this.css.historyNode}).inject(e);this.undoNode=new Element("div",{styles:this.css.undoNode}).inject(this.node);this.redoNode=new Element("div",{styles:this.css.redoNode}).inject(this.node);this.patchNode=new Element("div",{styles:this.css.patchNode}).inject(this.node)},reset:function(){this.undoDiffs=[];this.redoDiffs=[];this.lastSnap="mine/root"},makeUndoDiff:function(e){if(e!=this.lastSnap){this.undoDiffs.push(e);while(this.undoDiffs.length>this.MAX_HISTORY){this.undoDiffs.shift()}this.lastSnap=e;return true}},makeRedoDiff:function(e){this.redoDiffs.push(e)},undo:function(){this.patchLock=true;var e=this.undoDiffs.pop();if(e){this.app.applyPatches(e);this.makeRedoDiff(e)}this.patchLock=false},redo:function(){this.patchLock=true;var e=this.redoDiffs.pop();if(e){this.app.applyPatches(e);this.makeUndoDiff(e)}this.patchLock=false},changed:function(e){if(this.patchLock)return;if(this.makeUndoDiff(e))this.redoDiffs=[]},hasUndo:function(){return!!this.undoDiffs.length},hasRedo:function(){return!!this.redoDiffs.length}});
|