Layout.js 104 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559
  1. MWF.xDesktop = MWF.xDesktop || {};
  2. MWF.xDesktop.requireApp = function(module, clazz, callback, async){
  3. o2.requireApp(module, clazz, callback, async)
  4. };
  5. MWF.xApplication = MWF.xApplication || {};
  6. // MWF.require("MWF.widget.Common", null, false);
  7. // MWF.require("MWF.xDesktop.Common", null, false);
  8. // MWF.require("o2.xDesktop.Dialog", null, false);
  9. // MWF.require("MWF.xAction.RestActions", null, false);
  10. // MWF.require("MWF.xDesktop.Menu", null, false);
  11. // MWF.require("MWF.widget.UUID", null, false);
  12. MWF.require("MWF.xDesktop.Lnk", null, false);
  13. // MWF.require("MWF.xDesktop.Actions.RestActions", null, false);
  14. // MWF.require("MWF.xDesktop.Authentication", null, false);
  15. MWF.require("MWF.xDesktop.Message", null, false);
  16. // MWF.require("MWF.xDesktop.UserData", null, false);
  17. MWF.require("MWF.xDesktop.shortcut", null, false);
  18. // MWF.require("MWF.widget.PinYin", null, false);
  19. // MWF.xDesktop.requireApp("Common", "", null, false);
  20. MWF.xDesktop.requireApp("Common", "Widget", null, false);
  21. MWF.require("MWF.xDesktop.WebSocket", null, false);
  22. //MWF.require("MWF.xDesktop.UserPanel", null, false);
  23. // MWF.require("MWF.xDesktop.Access", null, false);
  24. MWF.xDesktop.Layout = new Class({
  25. Extends: MWF.widget.Common,
  26. Implements: [Options, Events],
  27. options: {
  28. "style": "default",
  29. "defaultStyle": "default",
  30. "topShim": "layout_top_shim",
  31. "top": "layout_top",
  32. "desktop": "layout_desktop",
  33. "content": "desktop_content",
  34. "navi": "desktop_navi"
  35. },
  36. categoryCount: 20,
  37. processCount: 40,
  38. initialize: function(node, options){
  39. this.setOptions(options);
  40. this.type = "layout";
  41. this.path = MWF.defaultPath+"/xDesktop/$Layout/";
  42. this.initData();
  43. this.initNode(node);
  44. //this.load();
  45. // this.authentication = new MWF.xDesktop.Authentication({
  46. // "onLogin": this.load.bind(this)
  47. // });
  48. // this.authentication.isAuthenticated(function(json){
  49. // this.session.user = json.data;
  50. // layout.session.user = json.data;
  51. //this.getStyleLoad(node);
  52. // }.bind(this), function(){
  53. // if (layout.config.loginPage && layout.config.loginPage.enable && layout.config.loginPage.portal){
  54. // MWF.xDesktop.loadPortal(layout.config.loginPage.portal);
  55. // //window.location = "portal.html?portal="+layout.config.loginPage.portal;
  56. // }else{
  57. // this.getPublicStyleLoad(node);
  58. // }
  59. // // this.initNode(node);
  60. // // this.load();
  61. // }.bind(this));
  62. },
  63. getPublicStyleLoad: function(node){
  64. MWF.UD.getPublicData("defaultLayout", function(json) {
  65. if (json){
  66. this.status = json;
  67. }
  68. this.initNode(node);
  69. this.load();
  70. }.bind(this));
  71. },
  72. // getStyleLoad: function(node){
  73. //
  74. // MWF.UD.getPublicData("forceLayout", function(json) {
  75. // var forceStatus = null;
  76. // if (json){
  77. // forceStatus = json;
  78. // }
  79. //
  80. // MWF.UD.getData("layout", function(json) {
  81. // if (json.data) {
  82. // this.status = JSON.decode(json.data);
  83. //
  84. // if (forceStatus) this.status.apps = Object.merge(this.status.apps, forceStatus.apps);
  85. //
  86. // if (this.status.style) this.options.style = this.status.style;
  87. // if (this.status.styleType) this.options.styleType = this.status.styleType;
  88. // this.initNode(node);
  89. // this.load();
  90. // }else{
  91. // MWF.UD.getPublicData("defaultLayout", function(json) {
  92. // if (json){
  93. // this.status = json;
  94. //
  95. // if (forceStatus) this.status.apps = Object.merge(this.status.apps, forceStatus.apps);
  96. //
  97. // if (this.status.style) this.options.style = this.status.style;
  98. // if (this.status.styleType) this.options.styleType = this.status.styleType;
  99. // }
  100. // this.initNode(node);
  101. // this.load();
  102. // }.bind(this));
  103. // }
  104. // }.bind(this));
  105. // }.bind(this));
  106. // },
  107. loadCss: function(){
  108. var uri = new URI(window.location.href);
  109. var style = uri.getData("style");
  110. var styletype = (uri.getData("styletype"));
  111. if (style){
  112. if (styletype=="custom"){
  113. MWF.UD.getPublicData(style, function(json){
  114. if (json && json.data.desktop && json.data.window){
  115. this.css = json.data.desktop;
  116. this.windowCss = json.data.window;
  117. }else{
  118. MWF.UD.deletePublicData(style);
  119. this.options.style = this.options.defaultStyle;
  120. this.cssPath = MWF.defaultPath+"/xDesktop/$Layout/"+this.options.style+"/css.wcss";
  121. this._loadCss();
  122. }
  123. }.bind(this), false);
  124. }else{
  125. this.options.style = style;
  126. this.cssPath = MWF.defaultPath+"/xDesktop/$Layout/"+this.options.style+"/css.wcss";
  127. this._loadCss();
  128. }
  129. }else{
  130. if ((!this.status) || !this.status.style || this.status.styleType != "custom"){
  131. if (this.status) if (this.status.style) this.options.style = this.status.style;
  132. //this.options.style = "default";
  133. this.cssPath = MWF.defaultPath+"/xDesktop/$Layout/"+this.options.style+"/css.wcss";
  134. this._loadCss();
  135. if (!this.css){
  136. this.options.style = this.options.defaultStyle;
  137. this.cssPath = MWF.defaultPath+"/xDesktop/$Layout/"+this.options.style+"/css.wcss";
  138. this._loadCss();
  139. }
  140. }else{
  141. MWF.UD.getPublicData(this.status.style, function(json){
  142. if (json && json.data.desktop && json.data.window){
  143. this.css = json.data.desktop;
  144. this.windowCss = json.data.window;
  145. }else{
  146. MWF.UD.deletePublicData(this.status.style);
  147. this.options.style = this.options.defaultStyle;
  148. this.cssPath = MWF.defaultPath+"/xDesktop/$Layout/"+this.options.style+"/css.wcss";
  149. this._loadCss();
  150. }
  151. }.bind(this), false);
  152. }
  153. }
  154. },
  155. initNode: function(node){
  156. debugger;
  157. this.loadCss();
  158. //$("appContent").destroy();
  159. this.node = $(node);
  160. this.topShimNode = this.node.getElement("#"+this.options.topShim);
  161. this.topNode = this.node.getElement("#"+this.options.top);
  162. this.topAreaNode = this.node.getElement("#"+this.options.top);
  163. this.desktopNode = this.node.getElement("#"+this.options.desktop);
  164. this.contentNode = this.node.getElement("#"+this.options.content);
  165. this.naviNode = this.node.getElement("#"+this.options.navi);
  166. if (this.node) this.node.setStyles(this.css.layoutNode);
  167. if (this.topShimNode) this.topShimNode.setStyles(this.css.layoutTopShimNode);
  168. if (this.topNode) this.topNode.setStyles(this.css.layoutTopNode);
  169. if (this.desktopNode) this.desktopNode.setStyles(this.css.desktopNode);
  170. if (this.contentNode) this.contentNode.setStyles(this.css.contentNode);
  171. if (this.naviNode) this.naviNode.setStyles(this.css.naviNode);
  172. var dskImg = this.css.desktop.background;
  173. //MWF.defaultPath+"/xDesktop/$Layout/"+this.options.style+"/desktop.jpg";
  174. this.node.setStyle("background-image", this.css.desktop.background);
  175. },
  176. initData: function(){
  177. this.apps = {};
  178. this.widgets = {};
  179. this.appCurrentList = [];
  180. this.lnkAreas = [];
  181. this.lnks = [];
  182. this.currentApp = null;
  183. this.session = {};
  184. this.status = layout.userLayout;
  185. this.session.user = layout.session.user
  186. this.serviceAddressList = layout.serviceAddressList;
  187. this.centerServer = layout.centerServer;
  188. if (this.status && this.status.style) this.options.style = this.status.style;
  189. if (this.status && this.status.styleType) this.options.styleType = this.status.styleType;
  190. layout.openApplication = this.openApplication.bind(this);
  191. },
  192. // isAuthentication: function(success){
  193. // var returnValue = true;
  194. // if (this.session.user){
  195. // if (success) success();
  196. // }else{
  197. // this.authentication.loadLogin(this.node);
  198. // this.fireEvent("login");
  199. // returnValue = false;
  200. // }
  201. // return returnValue;
  202. // },
  203. load : function(){
  204. if (document.body.addEventListener){
  205. document.body.addEventListener('dragover', function(e){
  206. e.stopPropagation();
  207. e.preventDefault();
  208. }.bind(this), false);
  209. }
  210. //this.isAuthentication(function(){
  211. if (this.status){
  212. if (this.status.style){
  213. if (this.options.style !== this.status.style){
  214. this.changStyle(this.status.style);
  215. }
  216. }
  217. }
  218. this.getNodeBackground();
  219. this.loadDesktop();
  220. if (this.session.user.passwordExpired){
  221. this.openApplication({"page":{"x": 0, "y": 0}}, "Profile", {"tab": "passwordConfigPage"});
  222. window.setTimeout(function(){
  223. MWF.xDesktop.notice("error", {"y":"top", "x": "left"}, MWF.LP.desktop.notice.changePassword, this.desktopNode);
  224. }.bind(this), 500);
  225. }
  226. if (MWF.AC.isAdministrator()){
  227. //this.checkO2Collect();
  228. }
  229. this.fireEvent("load");
  230. //}.bind(this));
  231. },
  232. checkO2Collect: function(){
  233. var action = new MWF.xDesktop.Actions.RestActions("/xDesktop/Actions/action.json", "x_program_center");
  234. action.invoke({"name": "collectConnected", "success": function(json){
  235. if (json.data.value){
  236. action.invoke({"name": "collectValidate", "success": function(json){
  237. if (!json.data.value){
  238. this.openApplication({"page":{"x": 0, "y": 0}}, "Collect");
  239. }
  240. }.bind(this), "failure": function(){
  241. this.openApplication({"page":{"x": 0, "y": 0}}, "Collect");
  242. }.bind(this)});
  243. }else{
  244. this.showMessageNotConnectCollect();
  245. }
  246. }.bind(this), "failure": function(){
  247. this.showMessageNotConnectCollect();
  248. }.bind(this)});
  249. },
  250. showMessageNotConnectCollect: function(){
  251. var msg = {
  252. "subject": MWF.LP.desktop.collect.collectNotConnected,
  253. "content": MWF.LP.desktop.collect.collectNotConnectedText
  254. };
  255. var tooltipItem = layout.desktop.message.addTooltip(msg);
  256. var messageItem = layout.desktop.message.addMessage(msg);
  257. },
  258. loadDesktop: function(){
  259. this.setHeight();
  260. var size = this.desktopNode.getSize();
  261. this.size = {
  262. "x" : size.x,
  263. "y": size.y
  264. };
  265. //this.loadSession();
  266. this.loadTop();
  267. //this.loadNavi(); //@todo 暂时不要快速启动导航了
  268. this.loadLnkArea();
  269. this.setEvent();
  270. this.loadWidget();
  271. this.loadStatus(function(){
  272. this.openWebSocket();
  273. }.bind(this));
  274. },
  275. openWebSocket: function(){
  276. this.socket = new MWF.xDesktop.WebSocket();
  277. //window.setTimeout(this.checkWebSocket.bind(this), 30000);
  278. },
  279. checkWebSocket: function(){
  280. if (!this.socket || this.socket.webSocket.readyState !== 1) {
  281. this.socket = new MWF.xDesktop.WebSocket();
  282. }else{
  283. this.socket.heartbeat("heartbeat");
  284. }
  285. window.setTimeout(this.checkWebSocket.bind(this), 30000);
  286. },
  287. loadWidget: function(){
  288. },
  289. loadLnkAreaContainer: function(){
  290. this.lnkAreaContainer = new Element("div", {
  291. "styles": {
  292. "height": "100%",
  293. "overflow": "hidden"
  294. }
  295. }).inject(this.contentNode);
  296. },
  297. loadLnkArea: function(){
  298. if (!this.lnkAreaContainer) this.loadLnkAreaContainer();
  299. var lnkArea = new Element("div", {
  300. "styles": this.css.dsektopLnkArea
  301. }).inject(this.lnkAreaContainer);
  302. this.lnkAreas.push(lnkArea);
  303. var width = (lnkArea.getSize().x)*(this.lnkAreas.length);
  304. var contentSize = this.contentNode.getSize();
  305. this.lnkAreaContainer.setStyle("width", ""+Math.max(width, contentSize.x)+"px");
  306. this.setCurrentLnkArea();
  307. },
  308. setCurrentLnkArea: function(){
  309. if (this.lnkAreas.length>1){
  310. var lnkSize = this.lnkAreas[0].getSize().x;
  311. var width = (lnkSize)*(this.lnkAreas.length);
  312. var contentSize = this.contentNode.getSize();
  313. var currentArea = this.lnkAreas[this.lnkAreas.length-1];
  314. if (width<contentSize.x){
  315. width = width-lnkSize;
  316. currentArea.setStyles({
  317. "width": "auto",
  318. "margin-left": ""+width+"px",
  319. "float": "none"
  320. });
  321. }else{
  322. currentArea.setStyles(this.css.dsektopLnkArea);
  323. }
  324. }else{
  325. if (this.lnkAreas.length){
  326. this.lnkAreas[0].setStyles({
  327. "width": "auto",
  328. "margin-left": "0px",
  329. "float": "none"
  330. });
  331. }
  332. }
  333. },
  334. addLnkArea: function(){
  335. if (this.lnkAreas.length){
  336. this.lnkAreas[this.lnkAreas.length-1].setStyles(this.css.dsektopLnkArea);
  337. }
  338. this.loadLnkArea();
  339. },
  340. addLnk: function(json){
  341. var lnk = new MWF.xDesktop.Lnk(json.icon, json.title, json.par);
  342. if (!this.lnkAreas.length) this.loadLnkArea();
  343. lnk.inject(this.lnkAreas[this.lnkAreas.length-1]);
  344. this.lnks.push(lnk);
  345. },
  346. resizeLnk: function(){
  347. if (this.lnkAreaContainer){
  348. if (this.lnkAreas.length>1){
  349. var width = (this.lnkAreas[0].getSize().x)*(this.lnkAreas.length);
  350. var contentSize = this.contentNode.getSize();
  351. this.lnkAreaContainer.setStyle("width", ""+Math.max(width, contentSize.x)+"px");
  352. }else{
  353. this.lnkAreaContainer.setStyle("width", ""+this.contentNode.getSize().x+"px");
  354. }
  355. }
  356. var n=0;
  357. var count = 0;
  358. this.lnks.each(function(lnk, idx){
  359. while(!this.lnkAreas[n]) this.addLnkArea();
  360. var linkArea = this.lnkAreas[n];
  361. lnk.inject(linkArea);
  362. count++;
  363. //var y = lnk.node.getSize().y+lnk.node.getStyle("margin-top").toFloat()+lnk.node.getStyle("margin-bottom").toFloat();
  364. var y = lnk.node.getSize().y+lnk.node.getStyle("margin-top").toFloat();
  365. if (y*(count+1)>linkArea.getSize().y){
  366. if (idx<this.lnks.length-1) n++;
  367. count = 0;
  368. }
  369. }.bind(this));
  370. if (this.lnkAreas.length) while (this.lnkAreas.length>n+1 ) this.lnkAreas.pop().destroy();
  371. this.setCurrentLnkArea();
  372. },
  373. refreshApp:function(app){
  374. if (app.window){
  375. var appStatus ={
  376. "id": app.appId,
  377. "name": app.options.name,
  378. "style": app.options.style,
  379. "appId": app.appId,
  380. "window": {
  381. "size": {"x": app.window.css.to.width.toFloat(), "y": app.window.css.to.height.toFloat()},
  382. "position": {"x": app.window.css.to.left.toFloat(), "y": app.window.css.to.top.toFloat()},
  383. "isMax": app.window.isMax,
  384. "isHide": app.window.isHide,
  385. "style": app.window.options.style
  386. },
  387. "app": null
  388. };
  389. if (app.recordStatus) appStatus.app = app.recordStatus();
  390. app.close();
  391. this.openApplicationWithStatus(appStatus);
  392. }
  393. },
  394. openApplicationWithStatus: function(appStatus){
  395. var appName = appStatus.name;
  396. var style = (appStatus.style) ? appStatus.style : this.options.defaultStyle;
  397. // var appClass = "MWF.xApplication."+appName+".Main";
  398. this.requireApp(appName, function(appNamespace){
  399. var app = new appNamespace["Main"](this, {
  400. "style": style,
  401. "isRefresh": true,
  402. "onLoadWindow": function(){
  403. this.window.setOptions({
  404. "top": appStatus.window.position.y,
  405. "left": appStatus.window.position.x,
  406. "width": appStatus.window.size.x,
  407. "height": appStatus.window.size.y
  408. });
  409. this.window.reStyle();
  410. },
  411. "onPostLoadWindow": function(){
  412. if (appStatus.window.isMax){
  413. this.maxSize(function(){
  414. this.fireAppEvent("postLoadWindowMax");
  415. }.bind(this));
  416. }
  417. if (appStatus.window.isHide){
  418. this.minSize(function(){
  419. this.fireAppEvent("postLoadWindowMin");
  420. }.bind(this));
  421. }
  422. },
  423. "onPostLoad": function(){
  424. }
  425. });
  426. app.desktop = this;
  427. app.appId = appStatus.id;
  428. app.taskitem = new MWF.xDesktop.Layout.Taskitem(app, this);
  429. this.apps[appStatus.id] = app;
  430. app.status = appStatus.app;
  431. this.appCurrentList.push(app);
  432. app.loadNoAnimation(true, appStatus.window.isMax, appStatus.window.isHide);
  433. }.bind(this));
  434. },
  435. loadStatus: function(callback){
  436. if (this.status){
  437. if (this.status.apps){
  438. Object.each(this.status.apps, function(appStatus, id){
  439. var appName = appStatus.name;
  440. var style = (appStatus.style) ? appStatus.style : this.options.defaultStyle;
  441. // var appClass = "MWF.xApplication."+appName+".Main";
  442. this.requireApp(appName, function(appNamespace){
  443. var app = new appNamespace["Main"](this, {
  444. "style": style,
  445. "isRefresh": true,
  446. "onLoadWindow": function(){
  447. this.window.setOptions({
  448. "top": (appStatus.window.position) ? appStatus.window.position.y : 10,
  449. "left": (appStatus.window.position) ? appStatus.window.position.x : 10,
  450. "width": (appStatus.window.size) ? appStatus.window.size.x : this.options.width,
  451. "height": (appStatus.window.size) ? appStatus.window.size.y : this.options.height,
  452. });
  453. this.window.reStyle();
  454. },
  455. "onPostLoadWindow": function(){
  456. if (appStatus.window.isMax){
  457. this.maxSize(function(){
  458. this.fireAppEvent("postLoadWindowMax");
  459. }.bind(this));
  460. }
  461. if (appStatus.window.isHide){
  462. this.minSize(function(){
  463. this.fireAppEvent("postLoadWindowMin");
  464. }.bind(this));
  465. }
  466. },
  467. "onPostLoad": function(){
  468. }
  469. });
  470. app.desktop = this;
  471. app.appId = id;
  472. app.taskitem = new MWF.xDesktop.Layout.Taskitem(app, this);
  473. this.apps[id] = app;
  474. app.status = appStatus.app;
  475. this.appCurrentList.push(app);
  476. app.loadNoAnimation((this.status.currentApp==id), appStatus.window.isMax, appStatus.window.isHide);
  477. }.bind(this));
  478. }.bind(this));
  479. }
  480. if (this.status.widgets){
  481. Object.each(this.status.widgets, function(widgetStatus, id){
  482. var name = widgetStatus.name;
  483. var appName = widgetStatus.appName;
  484. this.requireApp(appName, function(appNamespace){
  485. var widget = new appNamespace[name](this, {
  486. "position": widgetStatus.position,
  487. "onLoadWidget": function(){
  488. this.widget.setOptions({
  489. "position": widgetStatus.position
  490. });
  491. }
  492. });
  493. widget.desktop = this;
  494. widget.widgetId = id;
  495. this.widgets[id] = widget;
  496. widget.status = widgetStatus.widget;
  497. widget.load();
  498. }.bind(this), name);
  499. }.bind(this));
  500. }
  501. if (this.status.lnks){
  502. this.status.lnks.each(function(lnkJson){
  503. this.addLnk(lnkJson);
  504. }.bind(this));
  505. this.resizeLnk();
  506. }
  507. }
  508. var loadLocal = false;
  509. var loadWeb = false;
  510. var checkLoaded = function(){
  511. if (loadLocal && loadWeb) if (callback) callback();
  512. };
  513. var url = MWF.defaultPath+"/xDesktop/$Layout/applications.json";
  514. MWF.getJSON(url, function(json){
  515. json.each(function(value, key){
  516. if (value.widgetName){
  517. if (value.widgetStart){
  518. this.openWidget(null, value.widgetName, value.path);
  519. }
  520. }
  521. }.bind(this));
  522. loadLocal = true;
  523. checkLoaded();
  524. }.bind(this));
  525. var action = new MWF.xDesktop.Actions.RestActions("/xDesktop/Actions/action.json", "x_component_assemble_control");
  526. action.invoke({"name": "listComponent", "success": function(json){
  527. //var currentName = this.session.user.name;
  528. var user = this.session.user;
  529. var currentNames = [user.name, user.distinguishedName, user.id, user.unique];
  530. if (user.roleList) currentNames = currentNames.concat(user.roleList);
  531. if (user.groupList) currentNames = currentNames.concat(user.groupList);
  532. json.data.each(function(value, key){
  533. if (value.visible){
  534. var isAllow = (value.allowList.length) ? (value.allowList.isIntersect(currentNames)) : true;
  535. var isDeny = (value.denyList.length) ? (value.denyList.isIntersect(currentNames)) : false;
  536. if ((!isDeny && isAllow) || MWF.AC.isAdministrator()){
  537. if (value.widgetName){
  538. if (value.widgetStart){
  539. this.openWidget(null, value.widgetName, value.path);
  540. }
  541. }
  542. }
  543. }
  544. }.bind(this));
  545. loadWeb = true;
  546. checkLoaded();
  547. }.bind(this)});
  548. },
  549. setEvent: function(){
  550. this.node.addEvent("selectstart", function(e){
  551. var select = "text";
  552. if (e.target.getStyle("-webkit-user-select")){
  553. select = e.target.getStyle("-webkit-user-select").toString().toLowerCase();
  554. }
  555. if (select.toString()!=="text" && select.toString()!=="auto") e.preventDefault();
  556. });
  557. window.onunload = function(e){
  558. //if (this.socket && this.socket.webSocket && this.socket.webSocket.readyState.toInt() === 1) {\
  559. // if (this.socket && this.socket.webSocket) {
  560. // console.log("websocket is onunload close ...");
  561. // this.socket.webSocket.close();
  562. // }
  563. }.bind(this);
  564. window.onbeforeunload = function(e){
  565. if (!this.isLogout){
  566. if (!this.notRecordStatus) this.recordDesktopStatus();
  567. if (this.socket && this.socket.webSocket) {
  568. //console.log("websocket is onbeforeunload close ...");
  569. debugger;
  570. this.socket.reConnect = false;
  571. this.socket.webSocket.close();
  572. //return false;
  573. }
  574. this.fireEvent("unload");
  575. e = e || window.event;
  576. e.returnValue = MWF.LP.desktop.notice.unload;
  577. return MWF.LP.desktop.notice.unload;
  578. }
  579. }.bind(this);
  580. },
  581. recordDesktopStatus: function(callback){
  582. Object.each(this.apps, function(app, id){
  583. if (!app.options.desktopReload){
  584. this.closeApp(app);
  585. }
  586. }.bind(this));
  587. this.recordStatusData(function(){
  588. if (callback) callback();
  589. });
  590. },
  591. getLayoutStatusData: function(){
  592. var status = {
  593. "viewMode": "Layout",
  594. "style": this.options.style,
  595. "styleType": this.options.styleType || "",
  596. "flatStyle": this.status.flatStyle || "blue",
  597. "currentApp": (this.currentApp) ? this.currentApp.appId : "Homepage",
  598. "apps": {},
  599. "lnks": [],
  600. "flatLnks": (this.status.flatLnks && o2.typeOf(this.status.flatLnks)==="array") ? this.status.flatLnks : [],
  601. "widgets": {}
  602. };
  603. Object.each(this.apps, function(app, id){
  604. debugger;
  605. if (app.window){
  606. if (app.options.desktopReload){
  607. var appStatus ={
  608. "title": app.options.title,
  609. "appId": app.appId,
  610. "name": app.options.name,
  611. "style": app.options.style,
  612. "window": {
  613. //"size": app.window.node.getSize(),
  614. "size": {"x": app.window.css.to.width.toFloat(), "y": app.window.css.to.height.toFloat()},
  615. "position": {"x": app.window.css.to.left.toFloat(), "y": app.window.css.to.top.toFloat()},
  616. "isMax": app.window.isMax,
  617. "isHide": app.window.isHide,
  618. "style": app.window.options.style
  619. },
  620. "app": null
  621. };
  622. if (app.recordStatus) appStatus.app = app.recordStatus();
  623. status.apps[id] = appStatus;
  624. }
  625. }
  626. });
  627. this.lnks.each(function(lnk){
  628. status.lnks.push({
  629. "icon": lnk.icon,
  630. "title": lnk.title,
  631. "par": lnk.par
  632. });
  633. });
  634. Object.each(this.widgets, function(widget, id){
  635. //var p = widget.widget.node.getPosition(widget.widget.node.getOffsetParent());
  636. var widgetStatus ={
  637. "name": widget.options.name,
  638. "appName": widget.options.appName,
  639. "position": widget.options.position,
  640. "widget": null
  641. };
  642. if (widget.recordStatus) widgetStatus.widget = widget.recordStatus();
  643. status.widgets[id] = widgetStatus;
  644. });
  645. return status;
  646. },
  647. recordStatusData: function(callback){
  648. var status = this.getLayoutStatusData();
  649. MWF.UD.putData("layout", status, function(){
  650. if (callback) callback();
  651. });
  652. //this.recordStatusCookies(status);
  653. },
  654. getPageDesignerStyle: function(callback){
  655. if (!this.pageDesignerStyle){
  656. this.pageDesignerStyle = "default";
  657. MWF.UD.getData("pageDesignerStyle", function(json) {
  658. if (json.data) {
  659. var styles = JSON.decode(json.data);
  660. this.pageDesignerStyle = styles.style;
  661. }
  662. if (callback) callback();
  663. }.bind(this));
  664. }else{
  665. if (callback) callback();
  666. }
  667. },
  668. getFormDesignerStyle: function(callback){
  669. if (!this.formDesignerStyle){
  670. this.formDesignerStyle = "default";
  671. MWF.UD.getData("formDesignerStyle", function(json) {
  672. if (json.data) {
  673. var styles = JSON.decode(json.data);
  674. this.formDesignerStyle = styles.style;
  675. }
  676. if (callback) callback();
  677. }.bind(this));
  678. }else{
  679. if (callback) callback();
  680. }
  681. },
  682. recordStatusCookies: function(status){
  683. var statusString = JSON.encode(status);
  684. Cookie.write("xdesktop", statusString);
  685. },
  686. setHeight: function(){
  687. this.resizeHeight();
  688. $(window).addEvent("resize", function(){
  689. this.resizeHeight();
  690. }.bind(this));
  691. },
  692. resizeHeight: function(){
  693. var yTop = this.topNode.getSize().y;
  694. var yBody = $(document.body).getSize().y;
  695. var y = yBody - yTop;
  696. this.desktopNode.setStyle("height", ""+y+"px");
  697. this.desktopHeight = y;
  698. var yNavi = this.naviNode.getSize().y;
  699. y = y - yNavi;
  700. this.contentNode.setStyle("height", ""+y+"px");
  701. this.resizeApps();
  702. this.resizeLnk();
  703. this.resizeMessage();
  704. this.setTaskitemSize();
  705. if (this.top) if (this.top.userPanel) this.top.userPanel.setPosition();
  706. this.fireEvent("resize");
  707. },
  708. setTaskitemSize: function(){
  709. if (this.top){
  710. var x1 = 10;
  711. var x2 = 5;
  712. var size = this.top.taskbar.getSize();
  713. var taskItems = this.top.taskbar.getChildren();
  714. var allWidth = 0;
  715. if (taskItems.length){
  716. var w = taskItems[0].getStyles("border-left-width", "border-right-width", "margin-left", "margin-right", "padding-left", "padding-right");
  717. for (var i=0; i<taskItems.length; i++){
  718. taskItems[i].setStyle("width", "auto");
  719. allWidth += taskItems[i].getSize().x+w["border-left-width"].toInt()+w["border-right-width"].toInt()+w["margin-left"].toInt()+w["margin-right"].toInt()+w["padding-left"].toInt()+w["padding-right"].toInt();
  720. }
  721. if (allWidth>(size.x-x1)){
  722. var x = (size.x-x1)/taskItems.length;
  723. var width = x-w["border-left-width"].toInt()-w["border-right-width"].toInt()-w["margin-left"].toInt()-w["margin-right"].toInt()-w["padding-left"].toInt()-w["padding-right"].toInt();
  724. taskItems.each(function(item){
  725. item.setStyle("width", ""+width+"px");
  726. });
  727. }else{
  728. taskItems.each(function(item){
  729. item.setStyle("width", "auto");
  730. });
  731. }
  732. }
  733. // var x = (size.x-x1)/taskItems.length;
  734. // if (x<165){
  735. // var width = x-x2;
  736. // taskItems.each(function(item){
  737. // item.setStyle("width", ""+width+"px");
  738. // });
  739. // }else{
  740. // taskItems.each(function(item){
  741. // item.setStyle("width", "auto");
  742. // });
  743. //
  744. // //this.node.setStyle("width", "160px");
  745. // }
  746. }
  747. },
  748. resizeMessage: function(){
  749. if (this.message) this.message.resize();
  750. },
  751. resizeApps: function(){
  752. var size = $(document.body).getSize();
  753. Object.each(this.apps, function(app, id){
  754. var left = app.window.css.to.left.toFloat();
  755. var top = app.window.css.to.top.toFloat();
  756. if (left>size.x) left = size.x-100;
  757. if (top>size.y) top = size.y-100;
  758. app.window.css.to.left = left+"px";
  759. app.window.css.to.top = top+"px";
  760. if (app.window.css.spacerTo) app.window.css.spacerTo.left = left+"px";
  761. if (app.window.css.spacerTo) app.window.css.spacerTo.top = top+"px";
  762. if (!app.window.isHide){
  763. if (app.window.isMax){
  764. app.window.maxSizeIm();
  765. }else{
  766. app.window.restoreIm();
  767. }
  768. }
  769. }.bind(this));
  770. },
  771. loadTop: function(){
  772. if (!this.top){
  773. this.top = new MWF.xDesktop.Layout.Top(this.topNode, this);
  774. this.top.load();
  775. }
  776. },
  777. loadNavi: function(){
  778. if (!this.navi){
  779. this.navi = new MWF.xDesktop.Layout.Navi(this.naviNode, this);
  780. this.navi.load();
  781. }
  782. },
  783. getNodeBackground: function(){
  784. MWF.UD.getDataJson("layoutDesktop", function(json){
  785. //var dskImg = MWF.defaultPath+"/xDesktop/$Layout/"+this.options.style+"/desktop.jpg";
  786. var dskImg = this.css.desktop.background;
  787. if (json){
  788. currentSrc = json.src;
  789. dskImg = "url("+MWF.defaultPath+"/xDesktop/$Layout/"+currentSrc+"/desktop.jpg"+")";
  790. }
  791. this.node.setStyle("background-image", dskImg);
  792. }.bind(this), false);
  793. },
  794. changStyle: function(style, isCustom){
  795. if (!isCustom){
  796. this.options.style = style;
  797. this.options.styleType = "default";
  798. this.cssPath = MWF.defaultPath+"/xDesktop/$Layout/"+this.options.style+"/css.wcss";
  799. this._loadCss();
  800. }else{
  801. this.options.style = style;
  802. this.options.styleType = "custom";
  803. MWF.UD.getPublicData(style, function(json){
  804. this.css = json.data.desktop;
  805. this.windowCss = json.data.window;
  806. }.bind(this), false);
  807. }
  808. MWF.require("MWF.widget.Mask", function(){
  809. // this.mask = new MWF.widget.Mask({"style": "desktop"});
  810. // this.mask.load();
  811. window.setTimeout(function(){
  812. if (this.node) this.node.setStyles(this.css.layoutNode);
  813. if (this.topShimNode) this.topShimNode.setStyles(this.css.layoutTopShimNode);
  814. if (this.topNode) this.topNode.setStyles(this.css.layoutTopNode);
  815. if (this.desktopNode) this.desktopNode.setStyles(this.css.desktopNode);
  816. if (this.contentNode) this.contentNode.setStyles(this.css.contentNode);
  817. if (this.naviNode) this.naviNode.setStyles(this.css.naviNode);
  818. if (this.message){
  819. if (this.message.unreadNode){
  820. this.message.unreadNode.clearStyles();
  821. this.message.unreadNode.setStyles(this.css.messageUnreadCountNode);
  822. }
  823. }
  824. this.getNodeBackground();
  825. this.changeAppsStyle();
  826. if (this.top) this.top.changStyle();
  827. if (this.navi) this.navi.changStyle();
  828. Object.each(this.apps, function(app){
  829. if (app.taskitem) app.taskitem.changStyle();
  830. });
  831. this.resizeHeight();
  832. //this.mask.hide();
  833. }.bind(this), 0);
  834. }.bind(this));
  835. },
  836. changeAppsStyle: function(){
  837. Object.each(this.apps, function(app, id){
  838. app.window.options.style = "desktop_"+this.options.style;
  839. app.window.changeStyle();
  840. }.bind(this));
  841. },
  842. openProcessApp: function(e, app){
  843. var options = {"id": app.id, "appId": "process.Application"+app.id};
  844. this.openApplication(e, "process.Application", options);
  845. },
  846. openQueryApp: function(e, app){
  847. var options = {"id": app.id, "appId": "query.Query"+app.id};
  848. this.openApplication(e, "query.Query", options);
  849. },
  850. openPortalApp: function(e, app){
  851. var options = {"portalId": app.id, "appId": "portal.Portal"+app.id};
  852. this.openApplication(e, "portal.Portal", options);
  853. },
  854. openCMSApp: function(e, app){
  855. var appId = "cms.Module"+app.id;
  856. if (this.apps[appId]){
  857. this.apps[appId].setCurrent();
  858. }else{
  859. this.openApplication(e, "cms.Module", {
  860. "columnData": app,
  861. "appId": appId
  862. });
  863. }
  864. },
  865. openWidget: function(e, widgetName, appName, options, obj){
  866. this.requireApp(appName, function(appNamespace){
  867. if (!this.widgets[appName+widgetName]){
  868. this.createNewWidget(e, appNamespace, appName+widgetName, widgetName, options, obj);
  869. }
  870. }.bind(this), widgetName);
  871. },
  872. openApplication: function(e, appNames, options, obj, inBrowser){
  873. if (appNames.substring(0, 4)==="@url"){
  874. var url = appNames.replace(/\@url\:/i, "");
  875. var a = new Element("a", {"href": url, "target": "_blank"});
  876. a.click();
  877. a.destroy();
  878. a = null;
  879. return true;
  880. }
  881. var appPath = appNames.split(".");
  882. var appName = appPath[appPath.length-1];
  883. this.requireApp(appNames, function(appNamespace){
  884. if (appNamespace.options.multitask){
  885. if (options && options.appId){
  886. if (this.apps[options.appId]){
  887. this.apps[options.appId].setCurrent();
  888. }else {
  889. this.createNewApplication(e, appNamespace, appName, options, obj, inBrowser);
  890. }
  891. }else{
  892. this.createNewApplication(e, appNamespace, appName, options, obj, inBrowser);
  893. }
  894. }else{
  895. if (this.apps[appName]){
  896. this.apps[appName].setCurrent();
  897. }else{
  898. this.createNewApplication(e, appNamespace, appName, options, obj, inBrowser);
  899. }
  900. }
  901. }.bind(this));
  902. },
  903. createNewWidget: function(e, appNamespace, appName, widgetName, options, obj){
  904. var widget = new appNamespace[widgetName](this, options);
  905. widget.desktop = this;
  906. if (obj){
  907. Object.each(obj, function(value, key){
  908. app[key] = value;
  909. });
  910. }
  911. widget.load(true);
  912. var widgetId = appName;
  913. if (options){
  914. if (options.widgetId){
  915. widgetId = options.widgetId;
  916. }
  917. }
  918. widget.widgetId = widgetId;
  919. this.widgets[widgetId] = widget;
  920. },
  921. createNewApplication: function(e, appNamespace, appName, options, obj, inBrowser){
  922. if (options){
  923. options.event = e;
  924. }else{
  925. options = {"event": e};
  926. }
  927. var app = new appNamespace["Main"](this, options);
  928. app.desktop = this;
  929. if (obj){
  930. Object.each(obj, function(value, key){
  931. app[key] = value;
  932. });
  933. }
  934. if (!inBrowser){
  935. app.taskitem = new MWF.xDesktop.Layout.Taskitem(app, this);
  936. }else{
  937. app.inBrowser = true;
  938. }
  939. app.load(true);
  940. var appId = appName;
  941. if (options.appId){
  942. appId = options.appId;
  943. }else{
  944. if (appNamespace.options.multitask) appId = appId+"-"+(new MWF.widget.UUID());
  945. }
  946. app.appId = appId;
  947. this.apps[appId] = app;
  948. return app;
  949. },
  950. closeApp: function(app){
  951. var appId = app.appId;
  952. this.appCurrentList.erase(app);
  953. // if (this.appCurrentList.length) this.appCurrentList[this.appCurrentList.length-1].setCurrent();
  954. this.setTaskitemSize();
  955. this.apps[appId] = null;
  956. delete this.apps[appId];
  957. },
  958. closeWidget: function(app){
  959. var widgetId = app.widgetId;
  960. delete this.widgets[widgetId];
  961. },
  962. requireApp: function(appNames, callback, clazzName){
  963. var appPath = appNames.split(".");
  964. var appName = appPath[appPath.length-1];
  965. var appObject = "MWF.xApplication."+appNames;
  966. var className = clazzName || "Main";
  967. var appClass = appObject+"."+className;
  968. var appLp = appObject+".lp."+MWF.language;
  969. var baseObject = MWF.xApplication;
  970. appPath.each(function(path, i){
  971. if (i<(appPath.length-1)){
  972. baseObject[path] = baseObject[path] || {};
  973. }else {
  974. baseObject[path] = baseObject[path] || {"options": Object.clone(MWF.xApplication.Common.options)};
  975. }
  976. baseObject = baseObject[path];
  977. }.bind(this));
  978. if (!baseObject.options) baseObject.options = Object.clone(MWF.xApplication.Common.options);
  979. MWF.xDesktop.requireApp(appNames, "lp."+MWF.language, {
  980. "onRequestFailure": function(){
  981. MWF.xDesktop.requireApp(appNames, "lp.zh-cn", null, false);
  982. }.bind(this),
  983. "onSuccess": function(){}.bind(this)
  984. }, false);
  985. MWF.xDesktop.requireApp(appNames, clazzName, function(){
  986. if (callback) callback(baseObject);
  987. });
  988. },
  989. playMessageAudio: function(){
  990. var flag = true;
  991. if (this.playMessageAudioTime){
  992. var now = new Date();
  993. var diff = now.getTime()-this.playMessageAudioTime.getTime();
  994. if (diff<5000) flag = false;
  995. }
  996. if (flag){
  997. if (!this.messageAudioNode){
  998. var url = MWF.defaultPath+"/xDesktop/$Layout/"+layout.desktop.options.style+"/sound/message.wav";
  999. var url2 = MWF.defaultPath+"/xDesktop/$Layout/"+layout.desktop.options.style+"/sound/message.mp3";
  1000. this.messageAudioNode = new Element("div", {
  1001. "html": "<audio autoplay=\"autoplay\" volume=0.6 preload=\"metadata\"><source src=\""+url+"\" type=\"audio/x-wav\"><source src=\""+url2+"\" type=\"audio/mpeg\"></source></audio>",
  1002. "styles": {"display": "none"}
  1003. }).inject(this.node);
  1004. this.messageAudio = this.messageAudioNode.getFirst();
  1005. }
  1006. this.messageAudio.play();
  1007. this.playMessageAudioTime = new Date();
  1008. }
  1009. },
  1010. logout: function(){
  1011. this.isLogout = true;
  1012. if (!this.notRecordStatus){
  1013. this.recordDesktopStatus(function(){
  1014. (layout.authentication || new o2.xDesktop.Authentication()).logout();
  1015. }.bind(this.layout));
  1016. }else{
  1017. (layout.authentication || new o2.xDesktop.Authentication()).logout();
  1018. }
  1019. }
  1020. });
  1021. MWF.xDesktop.Layout.Taskitem = new Class({
  1022. initialize: function(app, layout){
  1023. this.layout = layout;
  1024. this.app = app;
  1025. this.node = new Element("div", {
  1026. "styles": this.layout.css.taskItemNode,
  1027. "title": this.app.options.title+((this.app.appId) ? "-"+this.app.appId : "")
  1028. }).inject(this.layout.top.taskbar);
  1029. this.iconNode = new Element("div", {
  1030. "styles": this.layout.css.taskItemIconNode
  1031. }).inject(this.node);
  1032. this.iconNode.setStyle("background-image", "url("+this.app.options.icon+")");
  1033. this.closeNode = new Element("div", {
  1034. "styles": this.layout.css.taskItemCloseNode
  1035. }).inject(this.node);
  1036. //this.closeNode.
  1037. this.textNode = new Element("div", {
  1038. "styles": this.layout.css.taskItemTextNode
  1039. }).inject(this.node);
  1040. this.textNode.set("text", this.app.options.title);
  1041. this.setTaskitemSize();
  1042. this.setEvent();
  1043. },
  1044. setTaskitemSize: function(){
  1045. var x1 = 10;
  1046. var x2 = 5;
  1047. var size = this.layout.top.taskbar.getSize();
  1048. var taskItems = this.layout.top.taskbar.getChildren();
  1049. var allWidth = 0;
  1050. if (taskItems.length){
  1051. var w = taskItems[0].getStyles("border-left-width", "border-right-width", "margin-left", "margin-right", "padding-left", "padding-right");
  1052. for (var i=0; i<taskItems.length; i++){
  1053. taskItems[i].setStyle("width", "auto");
  1054. allWidth += taskItems[i].getSize().x+w["border-left-width"].toInt()+w["border-right-width"].toInt()+w["margin-left"].toInt()+w["margin-right"].toInt()+w["padding-left"].toInt()+w["padding-right"].toInt();
  1055. }
  1056. if (allWidth>(size.x-x1)){
  1057. var x = (size.x-x1)/taskItems.length;
  1058. var width = x-w["border-left-width"].toInt()-w["border-right-width"].toInt()-w["margin-left"].toInt()-w["margin-right"].toInt()-w["padding-left"].toInt()-w["padding-right"].toInt();
  1059. taskItems.each(function(item){
  1060. item.setStyle("width", ""+width+"px");
  1061. });
  1062. }else{
  1063. taskItems.each(function(item){
  1064. item.setStyle("width", "auto");
  1065. });
  1066. }
  1067. }
  1068. // var x = (size.x-x1)/taskItems.length;
  1069. // if (x<165){
  1070. // var width = x-x2;
  1071. // taskItems.each(function(item){
  1072. // item.setStyle("width", ""+width+"px");
  1073. // });
  1074. // }else{
  1075. // taskItems.each(function(item){
  1076. // item.setStyle("width", "auto");
  1077. // });
  1078. // //this.node.setStyle("width", "160px");
  1079. // }
  1080. },
  1081. setText: function(str){
  1082. this.textNode.set("text", str || this.app.options.title);
  1083. },
  1084. setEvent: function(){
  1085. this.textNode.addEvents({
  1086. "mouseover": function(){
  1087. if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode_over);
  1088. }.bind(this),
  1089. "mouseout": function(){
  1090. if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode);
  1091. }.bind(this),
  1092. "mousedown": function(){
  1093. if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode_down);
  1094. }.bind(this),
  1095. "mouseup": function(){
  1096. if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode_over);
  1097. }.bind(this),
  1098. "click": function(){
  1099. if (this.layout.currentApp==this.app){
  1100. this.app.minSize();
  1101. }else{
  1102. this.app.setCurrent();
  1103. }
  1104. }.bind(this)
  1105. });
  1106. this.iconNode.addEvents({
  1107. "mouseover": function(){
  1108. if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode_over);
  1109. }.bind(this),
  1110. "mouseout": function(){
  1111. if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode);
  1112. }.bind(this),
  1113. "mousedown": function(){
  1114. if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode_down);
  1115. }.bind(this),
  1116. "mouseup": function(){
  1117. if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode_over);
  1118. }.bind(this),
  1119. "click": function(){
  1120. if (this.layout.currentApp==this.app){
  1121. this.app.minSize();
  1122. }else{
  1123. this.app.setCurrent();
  1124. }
  1125. }.bind(this)
  1126. });
  1127. this.node.addEvents({
  1128. "mouseover": function(){
  1129. //if (this.layout.currentApp!==this.app)
  1130. this.closeNode.fade("in");
  1131. }.bind(this),
  1132. "mouseout": function(){
  1133. //if (this.layout.currentApp!==this.app)
  1134. this.closeNode.fade("out");
  1135. }.bind(this)
  1136. });
  1137. this.closeNode.addEvent("click", function(){
  1138. this.app.close();
  1139. }.bind(this));
  1140. },
  1141. selected: function(){
  1142. this.node.setStyles(this.layout.css.taskItemNode_current);
  1143. //this.closeNode.setStyles(this.layout.css.taskItemCloseNode_current);
  1144. },
  1145. unSelected: function(){
  1146. this.node.setStyles(this.layout.css.taskItemNode);
  1147. //this.closeNode.setStyles(this.layout.css.taskItemCloseNode);
  1148. },
  1149. changStyle: function(){
  1150. if (this.node){
  1151. if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this){
  1152. this.node.setStyles(this.layout.css.taskItemNode);
  1153. }else{
  1154. this.node.setStyles(this.layout.css.taskItemNode);
  1155. this.node.setStyles(this.layout.css.taskItemNode_current);
  1156. }
  1157. }
  1158. if (this.iconNode) this.iconNode.setStyles(this.layout.css.taskItemIconNode);
  1159. if (this.textNode) this.textNode.setStyles(this.layout.css.taskItemTextNode);
  1160. },
  1161. destroy: function(){
  1162. this.node.destroy();
  1163. o2.release(this);
  1164. //this.layout.setTaskitemSize();
  1165. }
  1166. });
  1167. MWF.xDesktop.Layout.Top = new Class({
  1168. initialize: function(node, layout){
  1169. this.layout = layout;
  1170. this.node = $(node);
  1171. this.userApplicationsLog = [];
  1172. this.sysApplicationsLog = [];
  1173. },
  1174. load: function(){
  1175. this.loadMenuAction();
  1176. this.loadSeparate();
  1177. this.loadShowDesktop();
  1178. this.loadClock();
  1179. this.loadSeparate("right");
  1180. this.loadUserMenu();
  1181. this.loadStyleAction();
  1182. this.loadUserChat();
  1183. this.loadMessageAction();
  1184. this.loadSeparate("right");
  1185. this.loadTaskbar();
  1186. },
  1187. loadMenuAction: function(){
  1188. this.loadMenuAction = new Element("div", {
  1189. "styles": this.layout.css.loadMenuAction,
  1190. "title": MWF.LP.desktop.menuAction
  1191. }).inject(this.node);
  1192. // this.loadMenu();
  1193. this.loadMenuAction.addEvent("click", function(){
  1194. this.loadMenu();
  1195. }.bind(this));
  1196. },
  1197. loadShowDesktop: function(){
  1198. this.showDesktopAction = new Element("div", {
  1199. "styles": this.layout.css.showDesktopAction
  1200. }).inject(this.node);
  1201. this.showDesktopAction.addEvents({
  1202. "mouseover": function(){
  1203. this.showDesktopAction.setStyles(this.layout.css.showDesktopAction_over);
  1204. }.bind(this),
  1205. "mouseout": function(){
  1206. this.showDesktopAction.setStyles(this.layout.css.showDesktopAction);
  1207. }.bind(this),
  1208. "click": function(){
  1209. var flag = true;
  1210. Object.each(this.layout.apps, function(app, id){
  1211. if (!app.window.isHide){
  1212. flag = false;
  1213. app.minSize();
  1214. }
  1215. }.bind(this));
  1216. if (flag){
  1217. Object.each(this.layout.apps, function(app, id){
  1218. app.setCurrent();
  1219. }.bind(this));
  1220. }
  1221. }.bind(this)
  1222. });
  1223. },
  1224. loadMenu: function(){
  1225. this.createApplicationMenuArea();
  1226. this.showApplicationMenu();
  1227. window.setTimeout(function(){
  1228. this.getApplicationsCatalogue(function(catalog){
  1229. //var currentName = this.layout.session.user.name;
  1230. var user = this.layout.session.user;
  1231. var currentNames = [user.name, user.distinguishedName, user.id, user.unique];
  1232. if (user.roleList) currentNames = currentNames.concat(user.roleList);
  1233. if (user.groupList) currentNames = currentNames.concat(user.groupList);
  1234. catalog.each(function(value, key){
  1235. var isAllow = true;
  1236. if (value.allowList) isAllow = (value.allowList.length) ? (value.allowList.isIntersect(currentNames)) : true;
  1237. var isDeny = false;
  1238. if (value.denyList) isDeny = (value.denyList.length) ? (value.denyList.isIntersect(currentNames)!==-1) : false;
  1239. if ((!isDeny && isAllow) || MWF.AC.isAdministrator()){
  1240. this.createApplicationMenu(value, key);
  1241. }
  1242. }.bind(this));
  1243. this.getComponentList(function(json){
  1244. json.data.each(function(value, key){
  1245. if (value.visible){
  1246. var isAllow = (value.allowList.length) ? (value.allowList.isIntersect(currentNames)) : true;
  1247. var isDeny = (value.denyList.length) ? (value.denyList.isIntersect(currentNames)) : false;
  1248. if ((!isDeny && isAllow) || MWF.AC.isAdministrator()){
  1249. this.createApplicationMenu(value, key);
  1250. }
  1251. }
  1252. }.bind(this));
  1253. }.bind(this));
  1254. var action = new MWF.xDesktop.Actions.RestActions("/xDesktop/Actions/action.json", "x_portal_assemble_surface");
  1255. action.invoke({"name": "listPortalApplication", "success": function(json){
  1256. if (json.data){
  1257. json.data.each(function(app){
  1258. this.createPortalAppMenu(app);
  1259. }.bind(this));
  1260. }
  1261. }.bind(this)});
  1262. }.bind(this));
  1263. this.getProcessApplications(function(json){
  1264. //json.data.each(function(app){
  1265. // if( app.isCMSApp ){
  1266. // this.createCMSAppMenu(app);
  1267. // }else{
  1268. // this.createProcessAppMenu(app);
  1269. // }
  1270. //}.bind(this));
  1271. }.bind(this));
  1272. }.bind(this), 0);
  1273. },
  1274. showApplicationMenu: function(){
  1275. this.applicationMenuAreaMark.fade(0.7);
  1276. this.applicationMenuArea.fade("in");
  1277. },
  1278. closeApplicationMenu: function(){
  1279. if (this.applicationMenuSearchBar) this.closeApplicationMenuSearchBar();
  1280. if (!this.isApplicationMenuScroll){
  1281. this.applicationMenuAreaMark.destroy();
  1282. this.applicationMenuArea.destroy();
  1283. this.applicationMenuFxScroll = null;
  1284. this.userApplicationsLog = [];
  1285. this.sysApplicationsLog = [];
  1286. this.layout.removeEvent("resize", this.resizeApplicationMenuSizeFun);
  1287. }
  1288. this.currentApplicationMenuContent = "app";
  1289. this.isApplicationMenuScroll = false;
  1290. if (this.closeApplicationMenuFun) document.body.removeEvent("keydown", this.closeApplicationMenuFun);
  1291. },
  1292. closeApplicationMenuEsc: function(e){
  1293. if (e.key==="esc"){
  1294. if (!this.applicationMenuSearchBar){
  1295. this.closeApplicationMenu();
  1296. }
  1297. }
  1298. },
  1299. createCMSAppMenu: function(app){
  1300. var applicationMenuNode = new Element("div", {
  1301. "styles": this.layout.css.applicationMenuNode,
  1302. "title": app.appName
  1303. }).inject(this.applicationMenuProcessArea);
  1304. this.userApplicationsLog.push({
  1305. "node": applicationMenuNode,
  1306. "py": app.appName.toPY().toLowerCase(),
  1307. "name": app.appName.toLowerCase(),
  1308. "first": app.appName.toPYFirst().toLowerCase()
  1309. });
  1310. var applicationMenuIconNode = new Element("div", {
  1311. "styles": this.layout.css.applicationMenuIconNode
  1312. }).inject(applicationMenuNode);
  1313. var icon = "";
  1314. if (app.appIcon){
  1315. icon = "url(data:image/png;base64,"+app.appIcon+")";
  1316. }else{
  1317. icon = "url(/x_component_cms_Index/$Main/default/icon/column.png)";
  1318. }
  1319. applicationMenuIconNode.setStyle("background-image", icon);
  1320. new Element("div", {
  1321. "styles": this.layout.css.applicationMenuTextNode,
  1322. "text": app.appName
  1323. }).inject(applicationMenuNode);
  1324. applicationMenuNode.addEvent("click", function(e){
  1325. this.layout.openCMSApp(e, app);
  1326. this.closeApplicationMenu();
  1327. }.bind(this));
  1328. applicationMenuNode.makeLnk({
  1329. "par": {
  1330. "icon": icon,
  1331. "title": app.name,
  1332. "par": "cms.Module#{\"columnId\": \""+app.id+"\", \"appId\": \"cms.Module"+app.id+"\"}"
  1333. },
  1334. "onStart": function(){
  1335. this.applicationMenuAreaMark.fade("out");
  1336. this.applicationMenuArea.fade("out");
  1337. }.bind(this),
  1338. "onComplete": function(){
  1339. this.showApplicationMenu();
  1340. }.bind(this)
  1341. });
  1342. },
  1343. createPortalAppMenu: function(app){
  1344. var applicationMenuNode = new Element("div", {
  1345. "styles": this.layout.css.applicationMenuNode,
  1346. "title": app.name
  1347. }).inject(this.applicationMenuAppIconArea);
  1348. this.userApplicationsLog.push({
  1349. "node": applicationMenuNode,
  1350. "py": app.name.toPY().toLowerCase(),
  1351. "name": app.name.toLowerCase(),
  1352. "first": app.name.toPYFirst().toLowerCase()
  1353. });
  1354. var applicationMenuIconNode = new Element("div", {
  1355. "styles": this.layout.css.applicationMenuIconNode
  1356. }).inject(applicationMenuNode);
  1357. var icon = "";
  1358. if (app.icon){
  1359. icon = "url(data:image/png;base64,"+app.icon+")";
  1360. }else{
  1361. icon = "url(/x_component_portal_PortalExplorer/$Main/default/icon/application.png)";
  1362. }
  1363. applicationMenuIconNode.setStyle("background-image", icon);
  1364. new Element("div", {
  1365. "styles": this.layout.css.applicationMenuTextNode,
  1366. "text": app.name
  1367. }).inject(applicationMenuNode);
  1368. applicationMenuNode.addEvent("click", function(e){
  1369. this.layout.openPortalApp(e, app);
  1370. this.closeApplicationMenu();
  1371. }.bind(this));
  1372. applicationMenuNode.makeLnk({
  1373. "par": {"icon": icon, "title": app.name, "par": "portal.Portal#{\"portalId\": \""+app.id+"\", \"appId\": \"portal.Portal"+app.id+"\"}"},
  1374. "onStart": function(){
  1375. this.applicationMenuAreaMark.fade("out");
  1376. this.applicationMenuArea.fade("out");
  1377. }.bind(this),
  1378. "onComplete": function(){
  1379. this.showApplicationMenu();
  1380. }.bind(this)
  1381. });
  1382. },
  1383. createQueryAppMenu: function(app){
  1384. var applicationMenuNode = new Element("div", {
  1385. "styles": this.layout.css.applicationMenuNode,
  1386. "title": app.name
  1387. }).inject(this.applicationMenuProcessArea);
  1388. this.userApplicationsLog.push({
  1389. "node": applicationMenuNode,
  1390. "py": app.name.toPY().toLowerCase(),
  1391. "name": app.name.toLowerCase(),
  1392. "first": app.name.toPYFirst().toLowerCase()
  1393. });
  1394. var applicationMenuIconNode = new Element("div", {
  1395. "styles": this.layout.css.applicationMenuIconNode
  1396. }).inject(applicationMenuNode);
  1397. var icon = "";
  1398. if (app.icon){
  1399. icon = "url(data:image/png;base64,"+app.icon+")";
  1400. }else{
  1401. icon = "url(/x_component_query_Query/$Main/appicon.png)";
  1402. }
  1403. applicationMenuIconNode.setStyle("background-image", icon);
  1404. new Element("div", {
  1405. "styles": this.layout.css.applicationMenuTextNode,
  1406. "text": app.name
  1407. }).inject(applicationMenuNode);
  1408. applicationMenuNode.addEvent("click", function(e){
  1409. this.layout.openQueryApp(e, app);
  1410. this.closeApplicationMenu();
  1411. }.bind(this));
  1412. applicationMenuNode.makeLnk({
  1413. "par": {"icon": icon, "title": app.name, "par": "query.Query#{\"id\": \""+app.id+"\", \"appId\": \"query.Query"+app.id+"\"}"},
  1414. "onStart": function(){
  1415. this.applicationMenuAreaMark.fade("out");
  1416. this.applicationMenuArea.fade("out");
  1417. }.bind(this),
  1418. "onComplete": function(){
  1419. this.showApplicationMenu();
  1420. }.bind(this)
  1421. });
  1422. },
  1423. createProcessAppMenu: function(app){
  1424. var applicationMenuNode = new Element("div", {
  1425. "styles": this.layout.css.applicationMenuNode,
  1426. "title": app.name
  1427. }).inject(this.applicationMenuProcessArea);
  1428. this.userApplicationsLog.push({
  1429. "node": applicationMenuNode,
  1430. "py": app.name.toPY().toLowerCase(),
  1431. "name": app.name.toLowerCase(),
  1432. "first": app.name.toPYFirst().toLowerCase()
  1433. });
  1434. var applicationMenuIconNode = new Element("div", {
  1435. "styles": this.layout.css.applicationMenuIconNode
  1436. }).inject(applicationMenuNode);
  1437. var icon = "";
  1438. if (app.icon){
  1439. icon = "url(data:image/png;base64,"+app.icon+")";
  1440. }else{
  1441. icon = "url(/x_component_process_ApplicationExplorer/$Main/default/icon/application.png)";
  1442. }
  1443. applicationMenuIconNode.setStyle("background-image", icon);
  1444. new Element("div", {
  1445. "styles": this.layout.css.applicationMenuTextNode,
  1446. "text": app.name
  1447. }).inject(applicationMenuNode);
  1448. applicationMenuNode.addEvent("click", function(e){
  1449. this.layout.openProcessApp(e, app);
  1450. this.closeApplicationMenu();
  1451. }.bind(this));
  1452. applicationMenuNode.makeLnk({
  1453. "par": {"icon": icon, "title": app.name, "par": "process.Application#{\"id\": \""+app.id+"\", \"appId\": \"process.Application"+app.id+"\"}"},
  1454. "onStart": function(){
  1455. this.applicationMenuAreaMark.fade("out");
  1456. this.applicationMenuArea.fade("out");
  1457. }.bind(this),
  1458. "onComplete": function(){
  1459. this.showApplicationMenu();
  1460. }.bind(this)
  1461. });
  1462. },
  1463. createApplicationMenu: function(value, key){
  1464. var applicationMenuNode = new Element("div", {
  1465. "styles": this.layout.css.applicationMenuNode,
  1466. "title": value.title
  1467. }).inject(this.applicationMenuAppIconArea);
  1468. this.sysApplicationsLog.push({
  1469. "node": applicationMenuNode,
  1470. "py": value.title.toPY().toLowerCase(),
  1471. "name": value.title.toLowerCase(),
  1472. "first": value.title.toPYFirst().toLowerCase()
  1473. });
  1474. var applicationMenuIconNode = new Element("div", {
  1475. "styles": this.layout.css.applicationMenuIconNode
  1476. }).inject(applicationMenuNode);
  1477. var icon;
  1478. if (value.path.substring(0, 4)==="@url"){
  1479. if (value.iconPath){
  1480. icon = value.iconPath;
  1481. }else{
  1482. icon = "/x_component_Setting/$Main/default/icon/site.png";
  1483. }
  1484. }else{
  1485. icon = "/x_component_"+value.path.replace(/\./g, "_")+"/$Main/"+value.iconPath;
  1486. }
  1487. applicationMenuIconNode.setStyle("background-image", "url("+icon+")");
  1488. new Element("div", {
  1489. "styles": this.layout.css.applicationMenuTextNode,
  1490. "text": value.title
  1491. }).inject(applicationMenuNode);
  1492. applicationMenuNode.addEvent("click", function(e){
  1493. this.layout.openApplication(e, value.path);
  1494. this.closeApplicationMenu();
  1495. }.bind(this));
  1496. applicationMenuNode.makeLnk({
  1497. "par": {"icon": icon, "title": value.title, "par": value.path},
  1498. "onStart": function(){
  1499. this.applicationMenuAreaMark.fade("out");
  1500. this.applicationMenuArea.fade("out");
  1501. }.bind(this),
  1502. "onComplete": function(){
  1503. this.showApplicationMenu();
  1504. }.bind(this)
  1505. });
  1506. var appName = value.path;
  1507. //if (value.widgetName){
  1508. // if (!(value.widgetVisible===false)){
  1509. // this.createApplicationWidgetMenu(value.widgetName, value.widgetTitle, value.widgetIconPath, appName);
  1510. // }
  1511. // //Object.each(value.widget, function(value, key){
  1512. // // this.createApplicationWidgetMenu(value.widgetName, value.widgetTitle, value.widgetIconPath, appName);
  1513. // //}.bind(this));
  1514. // //if (value.widgetStart){
  1515. // // this.layout.openWidget(null, value.widgetName, appName);
  1516. // //}
  1517. //
  1518. //}
  1519. },
  1520. createApplicationWidgetMenu: function(name, title, icon, appName){
  1521. var applicationMenuNode = new Element("div", {
  1522. "styles": this.layout.css.widgetMenuNode,
  1523. "title": title
  1524. }).inject(this.applicationMenuWidgetArea);
  1525. var applicationMenuIconNode = new Element("div", {
  1526. "styles": this.layout.css.widgetMenuIconNode
  1527. }).inject(applicationMenuNode);
  1528. var icon = "/x_component_"+appName.replace(/\./g, "_")+"/$"+name+"/"+icon;
  1529. applicationMenuIconNode.setStyle("background-image", "url("+icon+")");
  1530. new Element("div", {
  1531. "styles": this.layout.css.applicationMenuTextNode,
  1532. "text": title
  1533. }).inject(applicationMenuNode);
  1534. applicationMenuNode.addEvent("click", function(e){
  1535. this.layout.openWidget(e, name, appName);
  1536. this.closeApplicationMenu();
  1537. }.bind(this));
  1538. },
  1539. createApplicationMenuArea: function(){
  1540. var index = MWF.xDesktop.zIndexPool.zIndex;
  1541. //mask-----------------------------------------
  1542. this.applicationMenuAreaMark = new Element("iframe", {
  1543. //"src": (Browser.iecomp) ? MWF.defaultPath+"/xDesktop/_blank.html" : "",
  1544. "styles": this.layout.css.applicationMenuAreaMark
  1545. }).inject(this.layout.node);
  1546. //this.applicationMenuAreaMark.contentWindow.document.documentElement.styles.background = "#000000";
  1547. this.applicationMenuAreaMark.setStyle("z-index", index);
  1548. //---------------------------------------------
  1549. //top node ------------------------------------
  1550. this.applicationMenuArea = new Element("div", {
  1551. "styles": this.layout.css.applicationMenuArea
  1552. }).inject(this.layout.node);
  1553. this.applicationMenuArea.setStyle("z-index", index+1);
  1554. //---------------------------------------------
  1555. this.applicationMenuLeftAction = new Element("div", {
  1556. "styles": this.layout.css.applicationMenuLeftAction
  1557. }).inject(this.applicationMenuArea);
  1558. this.applicationMenuRightAction = new Element("div", {
  1559. "styles": this.layout.css.applicationMenuRightAction
  1560. }).inject(this.applicationMenuArea);
  1561. this.applicationMenuScrollArea = new Element("div", {
  1562. "styles": this.layout.css.applicationMenuScrollArea
  1563. }).inject(this.applicationMenuArea);
  1564. this.applicationMenuContentArea = new Element("div", {
  1565. "styles": this.layout.css.applicationMenuContentArea
  1566. }).inject(this.applicationMenuScrollArea);
  1567. ////widget---------------------------------------
  1568. //this.applicationMemuWidgetContent = new Element("div", {
  1569. // "styles": this.layout.css.applicationMemuWidgetContent
  1570. //}).inject(this.applicationMenuContentArea);
  1571. //
  1572. //this.applicationMenuWidgetTitleArea = new Element("div", {
  1573. // "styles": this.layout.css.applicationMenuWidgetTitleArea,
  1574. // "text": MWF.LP.desktop.widget
  1575. //}).inject(this.applicationMemuWidgetContent);
  1576. //
  1577. //this.applicationMenuWidgetScrollArea = new Element("div", {
  1578. // "styles": this.layout.css.applicationMenuWidgetScrollArea
  1579. //}).inject(this.applicationMemuWidgetContent);
  1580. //
  1581. //this.applicationMenuWidgetArea = new Element("div", {
  1582. // "styles": this.layout.css.applicationMenuWidgetArea
  1583. //}).inject(this.applicationMenuWidgetScrollArea);
  1584. ////---------------------------------------------
  1585. //application----------------------------------
  1586. this.applicationMemuAppContent = new Element("div", {
  1587. "styles": this.layout.css.applicationMemuAppContent
  1588. }).inject(this.applicationMenuContentArea);
  1589. this.applicationMenuAppTitleArea = new Element("div", {
  1590. "styles": this.layout.css.applicationMenuAppTitleArea,
  1591. "text": MWF.LP.desktop.application
  1592. }).inject(this.applicationMemuAppContent);
  1593. this.applicationMenuAppIconScrollArea = new Element("div", {
  1594. "styles": this.layout.css.applicationMenuAppIconScrollArea
  1595. }).inject(this.applicationMemuAppContent);
  1596. this.applicationMenuAppIconArea = new Element("div", {
  1597. "styles": this.layout.css.applicationMenuAppIconArea
  1598. }).inject(this.applicationMenuAppIconScrollArea);
  1599. //---------------------------------------------
  1600. //Process---------------------------------------
  1601. this.applicationMemuProcessContent = new Element("div", {
  1602. "styles": this.layout.css.applicationMemuProcessContent
  1603. }).inject(this.applicationMenuContentArea);
  1604. this.applicationMenuProcessTitleArea = new Element("div", {
  1605. "styles": this.layout.css.applicationMenuProcessTitleArea,
  1606. "text": MWF.LP.desktop.process
  1607. }).inject(this.applicationMemuProcessContent);
  1608. this.applicationMenuProcessScrollArea = new Element("div", {
  1609. "styles": this.layout.css.applicationMenuProcessScrollArea
  1610. }).inject(this.applicationMemuProcessContent);
  1611. this.applicationMenuProcessArea = new Element("div", {
  1612. "styles": this.layout.css.applicationMenuProcessArea
  1613. }).inject(this.applicationMenuProcessScrollArea);
  1614. //---------------------------------------------
  1615. this.setApplicationMenuSize();
  1616. this.setApplicationMenuEvent();
  1617. },
  1618. setApplicationMenuSize: function(){
  1619. this.resizeApplicationMenuSize();
  1620. this.resizeApplicationMenuSizeFun = this.resizeApplicationMenuSize.bind(this);
  1621. this.layout.addEvent("resize", this.resizeApplicationMenuSizeFun);
  1622. },
  1623. resizeApplicationMenuSize: function(){
  1624. var wSize = this.applicationMenuScrollArea.getSize();
  1625. this.applicationMemuAppContent.setStyle("width", ""+wSize.x+"px");
  1626. //this.applicationMemuWidgetContent.setStyle("width", ""+wSize.x+"px");
  1627. this.applicationMemuProcessContent.setStyle("width", ""+wSize.x+"px");
  1628. var x = wSize.x*2;
  1629. this.applicationMenuContentArea.setStyle("width", ""+x+"px");
  1630. var size = this.applicationMenuArea.getSize();
  1631. var titleSize = this.applicationMenuAppTitleArea.getSize();
  1632. var tmt = this.applicationMenuAppTitleArea.getStyle("margin-top").toInt();
  1633. var tmb = this.applicationMenuAppTitleArea.getStyle("margin-bottom").toInt();
  1634. var cmt = this.applicationMenuAppIconScrollArea.getStyle("margin-top").toInt();
  1635. var cmb = this.applicationMenuAppIconScrollArea.getStyle("margin-bottom").toInt();
  1636. var y = size.y - titleSize.y - tmt - tmb - cmt - cmb;
  1637. this.applicationMenuAppIconScrollArea.setStyle("height", ""+y+"px");
  1638. //titleSize = this.applicationMenuWidgetTitleArea.getSize();
  1639. //tmt = this.applicationMenuWidgetTitleArea.getStyle("margin-top").toInt();
  1640. //tmb = this.applicationMenuWidgetTitleArea.getStyle("margin-bottom").toInt();
  1641. //cmt = this.applicationMenuWidgetScrollArea.getStyle("margin-top").toInt();
  1642. //cmb = this.applicationMenuWidgetScrollArea.getStyle("margin-bottom").toInt();
  1643. //y = size.y - titleSize.y - tmt - tmb - cmt - cmb;
  1644. //this.applicationMenuWidgetScrollArea.setStyle("height", ""+y+"px");
  1645. titleSize = this.applicationMenuProcessTitleArea.getSize();
  1646. tmt = this.applicationMenuProcessTitleArea.getStyle("margin-top").toInt();
  1647. tmb = this.applicationMenuProcessTitleArea.getStyle("margin-bottom").toInt();
  1648. cmt = this.applicationMenuProcessScrollArea.getStyle("margin-top").toInt();
  1649. cmb = this.applicationMenuProcessScrollArea.getStyle("margin-bottom").toInt();
  1650. y = size.y - titleSize.y - tmt - tmb - cmt - cmb;
  1651. this.applicationMenuProcessScrollArea.setStyle("height", ""+y+"px");
  1652. },
  1653. setApplicationMenuEvent: function(){
  1654. MWF.require("MWF.widget.ScrollBar", function(){
  1655. new MWF.widget.ScrollBar(this.applicationMenuAppIconScrollArea, {
  1656. "style":"xDesktop_Menu", "where": "after", "distance": 30, "friction": 4, "axis": {"x": false, "y": true},
  1657. "onScrollStart": function(){
  1658. this.isApplicationMenuScroll = true;
  1659. }.bind(this)
  1660. });
  1661. //new MWF.widget.ScrollBar(this.applicationMenuWidgetScrollArea, {
  1662. // "style":"xDesktop_Menu", "where": "after", "distance": 30, "friction": 4, "axis": {"x": false, "y": true},
  1663. // "onScrollStart": function(){
  1664. // this.isApplicationMenuScroll = true;
  1665. // }.bind(this)
  1666. //});
  1667. new MWF.widget.ScrollBar(this.applicationMenuProcessScrollArea, {
  1668. "style":"xDesktop_Menu", "where": "after", "distance": 30, "friction": 4, "axis": {"x": false, "y": true},
  1669. "onScrollStart": function(){
  1670. this.isApplicationMenuScroll = true;
  1671. }.bind(this)
  1672. });
  1673. }.bind(this));
  1674. this.applicationMenuRightAction.addEvent("click", function(e){
  1675. this.closeApplicationMenuSearchBar();
  1676. if (!this.currentApplicationMenuContent) this.currentApplicationMenuContent = "app";
  1677. var next = "";
  1678. var nextNode = null;
  1679. var currentNode = null;
  1680. if (this.currentApplicationMenuContent == "app"){
  1681. //nextNode = this.applicationMemuWidgetContent;
  1682. nextNode = this.applicationMemuProcessContent;
  1683. next="process";
  1684. currentNode = this.applicationMemuAppContent;
  1685. }
  1686. //if (this.currentApplicationMenuContent == "widget"){
  1687. // nextNode = this.applicationMemuProcessContent;
  1688. // next="process";
  1689. // currentNode = this.applicationMemuWidgetContent;
  1690. //}
  1691. if (this.currentApplicationMenuContent == "process"){
  1692. nextNode = this.applicationMemuAppContent;
  1693. next="app";
  1694. currentNode = this.applicationMemuProcessContent;
  1695. }
  1696. //this.applicationMenuScrollArea.set("scrollLeft", "0px");
  1697. //if (this.applicationMenuFxScroll){
  1698. // this.applicationMenuFxScroll = null;
  1699. // delete this.applicationMenuFxScroll
  1700. //}
  1701. if (!this.applicationMenuFxScroll) this.applicationMenuFxScroll = new Fx.Scroll(this.applicationMenuScrollArea, {"wheelStops": false});
  1702. nextNode.inject(currentNode, "after");
  1703. this.applicationMenuFxScroll.set(0);
  1704. this.applicationMenuFxScroll.toElement(nextNode, "x").chain(function(){
  1705. //currentNode.inject(nextNode, "after");
  1706. //this.applicationMenuFxScroll.set(0);
  1707. //this.applicationMenuFxScroll.toLeft();
  1708. }.bind(this));
  1709. //this.applicationMenuScrollArea.toElement(nextNode);
  1710. this.currentApplicationMenuContent = next;
  1711. e.stopPropagation();
  1712. }.bind(this));
  1713. this.applicationMenuLeftAction.addEvent("click", function(e){
  1714. this.closeApplicationMenuSearchBar();
  1715. if (!this.currentApplicationMenuContent) this.currentApplicationMenuContent = "app";
  1716. var next = "";
  1717. var nextNode = null;
  1718. var currentNode = null;
  1719. if (this.currentApplicationMenuContent == "app"){
  1720. nextNode = this.applicationMemuProcessContent;
  1721. next="process";
  1722. currentNode = this.applicationMemuAppContent;
  1723. }
  1724. //if (this.currentApplicationMenuContent == "widget"){
  1725. // nextNode = this.applicationMemuAppContent;
  1726. // next="app";
  1727. // currentNode = this.applicationMemuWidgetContent;
  1728. //}
  1729. if (this.currentApplicationMenuContent == "process"){
  1730. //nextNode = this.applicationMemuWidgetContent;
  1731. nextNode = this.applicationMemuAppContent;
  1732. next="app";
  1733. currentNode = this.applicationMemuProcessContent;
  1734. }
  1735. //nextNode.inject(currentNode, "before");
  1736. if (!this.applicationMenuFxScroll) this.applicationMenuFxScroll = new Fx.Scroll(this.applicationMenuScrollArea, {"wheelStops": false});
  1737. nextNode.inject(currentNode, "before");
  1738. this.applicationMenuFxScroll.set(this.applicationMenuScrollArea.getScrollSize().x);
  1739. this.applicationMenuFxScroll.toElement(nextNode);
  1740. //this.applicationMenuScrollArea.toElement(nextNode);
  1741. this.currentApplicationMenuContent = next;
  1742. e.stopPropagation();
  1743. }.bind(this));
  1744. this.applicationMenuArea.addEvent("click", function(){
  1745. this.closeApplicationMenu();
  1746. }.bind(this));
  1747. this.closeApplicationMenuFun = this.closeApplicationMenuEsc.bind(this);
  1748. document.body.addEvent("keydown", this.closeApplicationMenuFun);
  1749. this.showApplicationSearchFun = this.showApplicationSearch.bind(this);
  1750. document.body.addEvent("keydown", this.showApplicationSearchFun);
  1751. },
  1752. showApplicationSearch: function(e){
  1753. if (e.key==="esc"){
  1754. if (this.applicationMenuSearchBar) this.closeApplicationMenuSearchBar();
  1755. }else{
  1756. if (!this.applicationMenuSearchBar) this.createApplicationMenuSearchBar(e);
  1757. }
  1758. },
  1759. closeApplicationMenuSearchBar: function(){
  1760. if (this.applicationMenuSearchBar){
  1761. this.applicationMenuSearchBar.destroy();
  1762. this.applicationMenuSearchBar = null;
  1763. //if (this.showApplicationSearchFun) document.body.removeEvent("keydown", this.showApplicationSearchFun);
  1764. if ((this.currentApplicationMenuContent === "process") || (!this.currentApplicationMenuContent)){
  1765. this.userApplicationsLog.each(function(o){
  1766. o.node.setStyle("display", "block");
  1767. }.bind(this));
  1768. }
  1769. if (this.currentApplicationMenuContent === "app"){
  1770. this.sysApplicationsLog.each(function(o){
  1771. o.node.setStyle("display", "block");
  1772. }.bind(this));
  1773. }
  1774. }
  1775. },
  1776. createApplicationMenuSearchBar: function(e){
  1777. this.applicationMenuSearchBar = new Element("div", {
  1778. "styles": this.layout.css.applicationMenuSearchBar
  1779. }).inject(this.applicationMenuArea);
  1780. this.applicationMenuSearchBarBox = new Element("div", {
  1781. "styles": this.layout.css.applicationMenuSearchBarBox
  1782. }).inject(this.applicationMenuSearchBar);
  1783. this.applicationMenuSearchBarClose = new Element("div", {
  1784. "styles": this.layout.css.applicationMenuSearchBarClose
  1785. }).inject(this.applicationMenuSearchBarBox);
  1786. this.applicationMenuSearchBarInputBox = new Element("div", {
  1787. "styles": this.layout.css.applicationMenuSearchBarInputBox
  1788. }).inject(this.applicationMenuSearchBarBox);
  1789. this.applicationMenuSearchBarInput = new Element("input", {
  1790. "styles": this.layout.css.applicationMenuSearchBarInput
  1791. }).inject(this.applicationMenuSearchBarInputBox);
  1792. this.applicationMenuSearchBarInput.focus();
  1793. this.applicationMenuSearchBarInput.addEvent("keydown", function(e){
  1794. if (e.key==="esc"){
  1795. this.closeApplicationMenuSearchBar();
  1796. }
  1797. if (e.key==="enter"){
  1798. this.doApplicationMenuSearch();
  1799. }
  1800. e.stopPropagation();
  1801. }.bind(this));
  1802. this.applicationMenuSearchBarInput.addEvent("click", function(e){
  1803. e.stopPropagation();
  1804. }.bind(this));
  1805. this.applicationMenuSearchBarClose.addEvent("click", function(e){
  1806. this.closeApplicationMenuSearchBar();
  1807. }.bind(this));
  1808. },
  1809. doApplicationMenuSearch: function(){
  1810. var value = this.applicationMenuSearchBarInput.get("value").toLowerCase();
  1811. if (value){
  1812. if ((this.currentApplicationMenuContent === "process") || (!this.currentApplicationMenuContent) ){
  1813. this.userApplicationsLog.each(function(o){
  1814. if ((o.py.indexOf(value)===-1) && (o.first.indexOf(value)===-1) && (o.name.indexOf(value)===-1)){
  1815. o.node.setStyle("display", "none");
  1816. }else{
  1817. o.node.setStyle("display", "block");
  1818. }
  1819. }.bind(this));
  1820. }
  1821. if (this.currentApplicationMenuContent === "app"){
  1822. this.sysApplicationsLog.each(function(o){
  1823. if ((o.py.indexOf(value)===-1) && (o.first.indexOf(value)===-1) && (o.name.indexOf(value)===-1)){
  1824. o.node.setStyle("display", "none");
  1825. }else{
  1826. o.node.setStyle("display", "block");
  1827. }
  1828. }.bind(this));
  1829. }
  1830. }
  1831. },
  1832. getApplicationsCatalogue: function(callback){
  1833. var url = MWF.defaultPath+"/xDesktop/$Layout/applications.json";
  1834. MWF.getJSON(url, function(json){
  1835. if (callback) callback(json);
  1836. }.bind(this));
  1837. },
  1838. getProcessApplications: function(callback){
  1839. action = new MWF.xDesktop.Actions.RestActions("/xDesktop/Actions/action.json", "x_processplatform_assemble_surface");
  1840. action.invoke({"name": "listApplication", "success": function(json){
  1841. if (json.data){
  1842. json.data.each(function(app){
  1843. this.createProcessAppMenu(app);
  1844. }.bind(this));
  1845. }
  1846. }.bind(this)});
  1847. action = new MWF.xDesktop.Actions.RestActions("/xDesktop/Actions/action.json", "x_cms_assemble_control");
  1848. action.invoke({"name": "listCMSApplication", "success": function(json){
  1849. if (json.data) {
  1850. json.data.each(function (app) {
  1851. app.name = app.appName;
  1852. app.icon = app.appIcon;
  1853. this.createCMSAppMenu(app);
  1854. }.bind(this));
  1855. }
  1856. }.bind(this)});
  1857. action = MWF.Actions.get("x_query_assemble_surface");
  1858. action.listQuery(function(json){
  1859. if (json.data) {
  1860. json.data.each(function (app) {
  1861. this.createQueryAppMenu(app);
  1862. }.bind(this));
  1863. }
  1864. }.bind(this));
  1865. //var action = new MWF.xDesktop.Actions.RestActions("/xDesktop/Actions/action.json", "x_processplatform_assemble_surface");
  1866. //action.invoke({"name": "listApplication", "success": function(json){
  1867. // //add by cxy
  1868. // var action_cms = new MWF.xDesktop.Actions.RestActions("/xDesktop/Actions/action.json", "x_cms_assemble_control");
  1869. // action_cms.invoke({"name": "listCMSApplication", "success": function(json2){
  1870. // var data = json2.data || [];
  1871. // data.each(function(d){
  1872. // d.isCMSApp = true;
  1873. // d.name = d.appName;
  1874. // d.icon = d.appIcon;
  1875. // json.data.push(d);
  1876. // })
  1877. // if (callback) callback(json)
  1878. // }})
  1879. //}.bind(this)});
  1880. },
  1881. getComponentList: function(callback){
  1882. var action = new MWF.xDesktop.Actions.RestActions("/xDesktop/Actions/action.json", "x_component_assemble_control");
  1883. action.invoke({"name": "listComponent", "success": function(json){
  1884. if (callback) callback(json);
  1885. }.bind(this)});
  1886. },
  1887. // loadMenu: function(){
  1888. // this.startMenu = new MWF.xDesktop.Menu(this.loadMenuAction, {
  1889. // "event": "click",
  1890. // "style": "desktopStyle",
  1891. // "offsetX": -3,
  1892. // "offsetY": 8,
  1893. // });
  1894. // this.startMenu.load();
  1895. //
  1896. // var icon = MWF.defaultPath+"/xDesktop/$Layout/"+this.layout.options.style+"/menu/find.png";
  1897. // this.startMenu.addMenuItem("查找", "click", function(){}.bind(this), icon);
  1898. //
  1899. // this.startMenu.addMenuLine();
  1900. //
  1901. // Properties.navi.each(function(item){
  1902. // this.addStartMenuItem(item, this.startMenu);
  1903. // }.bind(this));
  1904. // },
  1905. // addStartMenuItem: function(item, menu){
  1906. // if (item.sub && item.sub.length>0){
  1907. // startSubMenu = new MWF.xDesktop.Menu(null, {
  1908. // "event": "click",
  1909. // "style": "desktopMenuSub",
  1910. // "offsetX": 2
  1911. // });
  1912. // startSubMenu.load();
  1913. // item.sub.each(function(subitem){
  1914. // this.addStartMenuItem(subitem, startSubMenu);
  1915. // }.bind(this));
  1916. //
  1917. // var icon = MWF.defaultPath+"/xDesktop/$Layout/"+this.layout.options.style+"/menu/"+item.icon;
  1918. // menu.addMenuMenu(item.title, icon, startSubMenu);
  1919. // }else{
  1920. // var icon = MWF.defaultPath+"/xDesktop/$Layout/"+this.layout.options.style+"/menu/"+item.icon;
  1921. // menu.addMenuItem(item.title, "click", function(){}, icon);
  1922. // }
  1923. // },
  1924. loadConfigAction: function(){
  1925. this.configActionNode = new Element("div", {
  1926. "styles": this.layout.css.configActionNode,
  1927. "title": MWF.LP.desktop.configAction
  1928. }).inject(this.node);
  1929. this.configActionNode.addEvent("click", function(){
  1930. alert("show config");
  1931. });
  1932. },
  1933. loadSeparate : function(cssfloat){
  1934. var separateNode = new Element("div.separateNode", {
  1935. "styles": this.layout.css.separateNode
  1936. }).inject(this.node);
  1937. if (cssfloat) separateNode.setStyle("float",cssfloat);
  1938. },
  1939. loadTaskbar: function(){
  1940. this.taskbar = new Element("div", {
  1941. "styles": this.layout.css.taskbar
  1942. }).inject(this.node);
  1943. },
  1944. loadUserChat: function(){
  1945. this.userChatNode = new Element("div", {
  1946. "styles": this.layout.css.userChatNode,
  1947. "title": MWF.LP.desktop.userChat
  1948. }).inject(this.node);
  1949. this.userChatNode.addEvents({
  1950. "mouseover": function(){if (this.layout.css.userChatNode_over) this.userChatNode.setStyles(this.layout.css.userChatNode_over);}.bind(this),
  1951. "mouseout": function(){this.userChatNode.setStyles(this.layout.css.userChatNode);}.bind(this)
  1952. });
  1953. this.userChatNode.addEvent("click", function(e){
  1954. this.userConfig();
  1955. return false;
  1956. if (!this.socket || this.layout.socket.webSocket.readyState != 1) {
  1957. this.layout.socket = new MWF.xDesktop.WebSocket();
  1958. }
  1959. this.layout.openApplication(e, "IM");
  1960. var widget = this.layout.widgets["IMIMWidget"];
  1961. if (widget){
  1962. if (widget.unreadNode){
  1963. var chat = this.layout.apps["Chat"];
  1964. if (chat){
  1965. Object.each(widget.unShowMessage, function(v, k){
  1966. if (v.length){
  1967. var dialogue = chat.dialogues[k];
  1968. if (!dialogue){
  1969. widget.getPerson(v[0].from, function(){
  1970. dialogue = chat.addDialogue(widget.owner, [widget.users[v[0].from]]);
  1971. }.bind(this));
  1972. }
  1973. }
  1974. //if (!dialogue) dialogue = chat.addDialogue(widget.owner, [this.data]);
  1975. }.bind(this));
  1976. //var key = this.data.name+layout.desktop.session.user.name;
  1977. //
  1978. //dialogue.setCurrent();
  1979. // this.clearUnread();
  1980. }
  1981. var _self = this;
  1982. layout.desktop.openApplication(e, "Chat", {
  1983. "onPostLoad": function(){
  1984. Object.each(widget.unShowMessage, function(v, k){
  1985. if (v.length){
  1986. widget.getPerson(v[0].from, function(){
  1987. dialogue = this.addDialogue(widget.owner, [widget.users[v[0].from]]);
  1988. }.bind(this));
  1989. }
  1990. }.bind(this));
  1991. }
  1992. });
  1993. }
  1994. }
  1995. }.bind(this));
  1996. //// this.userActionNode.addEvent("click", function(){
  1997. //// alert("show user infor");
  1998. //// });
  1999. //
  2000. // this.userMenu = new MWF.xDesktop.Menu(this.userActionNode, {
  2001. // "event": "click",
  2002. // "style": "desktopUser",
  2003. // "offsetX": -10,
  2004. // "offsetY": 10
  2005. // });
  2006. // this.userMenu.load();
  2007. // var img = MWF.defaultPath+"/xDesktop/$Layout/"+this.layout.options.style+"/usermenu/config.png";
  2008. // this.userMenu.addMenuItem(MWF.LP.desktop.userConfig, "click", function(e){this.userConfig(e);}.bind(this), img);
  2009. //
  2010. // this.userMenu.addMenuLine();
  2011. //
  2012. // img = MWF.defaultPath+"/xDesktop/$Layout/"+this.layout.options.style+"/usermenu/logout.png";
  2013. // this.userMenu.addMenuItem(MWF.LP.desktop.logout, "click", function(){this.logout();}.bind(this), img);
  2014. //this.userPanel = new MWF.xDesktop.UserPanel(this.layout.desktopNode, {"style": this.layout.options.style});
  2015. //this.userPanel.desktop = this.layout;
  2016. //this.userPanel.load();
  2017. //this.userChatNode.addEvent("click", function(){
  2018. // if (this.layout.socket.webSocket.readyState != 1) {
  2019. // this.layout.socket = new MWF.xDesktop.WebSocket();
  2020. // }
  2021. // this.userPanel.show();
  2022. //}.bind(this));
  2023. },
  2024. userConfig: function(e){
  2025. this.layout.openApplication(e, "Profile");
  2026. },
  2027. logout: function(){
  2028. this.layout.isLogout = true;
  2029. if (!this.notRecordStatus){
  2030. this.layout.recordDesktopStatus(function(){
  2031. (layout.authentication || new o2.xDesktop.Authentication()).logout();
  2032. }.bind(this.layout));
  2033. }else{
  2034. (layout.authentication || new o2.xDesktop.Authentication()).logout();
  2035. }
  2036. },
  2037. loadStyleAction: function(){
  2038. this.styleActionNode = new Element("div", {
  2039. "styles": this.layout.css.styleActionNode,
  2040. "title": MWF.LP.desktop.styleAction
  2041. }).inject(this.node);
  2042. this.styleActionNode.addEvents({
  2043. "mouseover": function(){if (this.layout.css.styleActionNode_over) this.styleActionNode.setStyles(this.layout.css.styleActionNode_over);}.bind(this),
  2044. "mouseout": function(){this.styleActionNode.setStyles(this.layout.css.styleActionNode);}.bind(this)
  2045. });
  2046. this.setChangeStyle();
  2047. },
  2048. setChangeStyle: function(){
  2049. if (!this.styleMenu){
  2050. this.styleMenu = new MWF.xDesktop.Menu(this.styleActionNode, {
  2051. "event": "click",
  2052. "style": "desktopStyle",
  2053. "offsetX": -60,
  2054. "offsetY": 10,
  2055. "container": this.layout.node,
  2056. "onQueryShow": function(){
  2057. this.styleMenu.items.each(function(item){
  2058. if (this.layout.options.style==item.styleName){
  2059. item.setDisable(true);
  2060. }else{
  2061. item.setDisable(false);
  2062. }
  2063. }.bind(this));
  2064. //if (this.layout.options.style=="default"){
  2065. // this.styleMenu.items[0].setDisable(true);
  2066. //}else if (this.layout.options.style=="black"){
  2067. // this.styleMenu.items[1].setDisable(true);
  2068. //}else if (this.layout.options.style=="color"){
  2069. // this.styleMenu.items[2].setDisable(true);
  2070. //}else if (this.layout.options.style=="lotus"){
  2071. // this.styleMenu.items[3].setDisable(true);
  2072. //}else if (this.layout.options.style=="crane"){
  2073. // this.styleMenu.items[4].setDisable(true);
  2074. //}else if (this.layout.options.style=="peony"){
  2075. // this.styleMenu.items[5].setDisable(true);
  2076. //}else if (this.layout.options.style=="car"){
  2077. // this.styleMenu.items[6].setDisable(true);
  2078. //}
  2079. }.bind(this)
  2080. });
  2081. this.styleMenu.load();
  2082. MWF.UD.getPublicData("indexThemes", function(themesJson){
  2083. MWF.getJSON(this.layout.path+"styles.json", function(json){
  2084. json.each(function(style){
  2085. if (!themesJson || themesJson.indexOf(style.style)!=-1){
  2086. var img = MWF.defaultPath+"/xDesktop/$Layout/"+style.style+"/preview.jpg";
  2087. var memuItem = this.styleMenu.addMenuItem(style.title, "click", function(){this.changeLayoutStyle(style.style);}.bind(this), img);
  2088. memuItem.styleName = style.style
  2089. }
  2090. }.bind(this));
  2091. }.bind(this));
  2092. MWF.UD.getPublicData("indexStyleList", function(json){
  2093. this.indexStyleList = json;
  2094. if (!this.indexStyleList) this.indexStyleList = {"styleList": []};
  2095. this.indexStyleList.styleList.each(function(style){
  2096. if (style.enabled){
  2097. //MWF.UD.getPublicData(style.id, function(styleData){
  2098. // var img = styleData.data.desktop.desktop.background;
  2099. var img = style.preview;
  2100. //img = img.substr(4, img.length-1);
  2101. var memuItem = this.styleMenu.addMenuItem(style.title, "click", function(){this.changeLayoutStyle(style.id, true);}.bind(this), img);
  2102. memuItem.styleName = style.id
  2103. //}.bind(this), false);
  2104. }
  2105. }.bind(this));
  2106. this.styleMenu.addMenuLine();
  2107. var memuItem = this.styleMenu.addMenuItem(o2.LP.flat_style, "click", function(e){this.changeToFlatStyle(e);}.bind(this));
  2108. var imgDiv = memuItem.item.getFirst();
  2109. var imgNode = new Element("div", {"styles": memuItem.menu.css.menuItemImg}).inject(imgDiv);
  2110. imgNode.setStyle("background-color", "#4A90E2");
  2111. }.bind(this));
  2112. }.bind(this));
  2113. //var img = MWF.defaultPath+"/xDesktop/$Layout/default/preview.jpg";
  2114. //this.styleMenu.addMenuItem(MWF.LP.desktop.styleMenu["default"], "click", function(){this.changeLayoutStyle("default");}.bind(this), img);
  2115. //
  2116. //img = MWF.defaultPath+"/xDesktop/$Layout/black/preview.jpg";
  2117. //this.styleMenu.addMenuItem(MWF.LP.desktop.styleMenu.black, "click", function(){this.changeLayoutStyle("black");}.bind(this), img);
  2118. //
  2119. //img = MWF.defaultPath+"/xDesktop/$Layout/color/preview.jpg";
  2120. //this.styleMenu.addMenuItem(MWF.LP.desktop.styleMenu.color, "click", function(){this.changeLayoutStyle("color");}.bind(this), img);
  2121. //
  2122. //img = MWF.defaultPath+"/xDesktop/$Layout/lotus/preview.jpg";
  2123. //this.styleMenu.addMenuItem(MWF.LP.desktop.styleMenu.lotus, "click", function(){this.changeLayoutStyle("lotus");}.bind(this), img);
  2124. //
  2125. //img = MWF.defaultPath+"/xDesktop/$Layout/crane/preview.jpg";
  2126. //this.styleMenu.addMenuItem(MWF.LP.desktop.styleMenu.crane, "click", function(){this.changeLayoutStyle("crane");}.bind(this), img);
  2127. //
  2128. //img = MWF.defaultPath+"/xDesktop/$Layout/peony/preview.jpg";
  2129. //this.styleMenu.addMenuItem(MWF.LP.desktop.styleMenu.peony, "click", function(){this.changeLayoutStyle("peony");}.bind(this), img);
  2130. //
  2131. //img = MWF.defaultPath+"/xDesktop/$Layout/car/preview.jpg";
  2132. //this.styleMenu.addMenuItem(MWF.LP.desktop.styleMenu.car, "click", function(){this.changeLayoutStyle("car");}.bind(this), img);
  2133. }
  2134. },
  2135. changeToFlatStyle: function(e){
  2136. // MWF.xDesktop.confirm("infor", e, o2.LP.desktop.changeViewTitle, {"html": o2.LP.desktop.changeView}, 500, 100, function(){
  2137. // this.close();
  2138. var uri = new URI(window.location.href);
  2139. uri.setData("view", "default");
  2140. uri.go();
  2141. // }, function(){
  2142. // this.close();
  2143. // }, null, null, "o2"
  2144. // );
  2145. },
  2146. changeLayoutStyle: function(style, isCustom){
  2147. MWF.UD.deleteData("layoutDesktop", function(){
  2148. this.layout.changStyle(style, isCustom);
  2149. }.bind(this));
  2150. },
  2151. loadMessageAction: function(){
  2152. this.messageActionNode = new Element("div", {
  2153. "styles": this.layout.css.messageActionNode,
  2154. "title": MWF.LP.desktop.showMessage
  2155. }).inject(this.node);
  2156. this.messageActionNode.addEvents({
  2157. "mouseover": function(){if (this.layout.css.messageActionNode_over) this.messageActionNode.setStyles(this.layout.css.messageActionNode_over);}.bind(this),
  2158. "mouseout": function(){this.messageActionNode.setStyles(this.layout.css.messageActionNode);}.bind(this)
  2159. });
  2160. this.layout.message = new MWF.xDesktop.Message(this.layout);
  2161. this.layout.message.load();
  2162. this.messageActionNode.addEvent("click", function(){
  2163. this.showDesktopMessage();
  2164. }.bind(this));
  2165. },
  2166. showDesktopMessage: function(){
  2167. if (!this.layout.message.isShow){
  2168. // this.layout.message.addMessage({
  2169. // "subject": "测试消息",
  2170. // "content": "这是一个测试消息,看看效果,看看效果,看看效果,看看效果,看看效果,看看效果,看看效果,看看效果,看看效果,看看效果,看看效果,看看效果,看看效果,看看效果,看看效果,看看效果"
  2171. // });
  2172. this.layout.message.show();
  2173. }
  2174. },
  2175. loadUserMenu: function(){
  2176. this.userMenuNode = new Element("div", {
  2177. "styles": this.layout.css.userMenuNode,
  2178. "title": MWF.LP.desktop.userMenu
  2179. }).inject(this.node);
  2180. this.userMenuNode.addEvents({
  2181. "mouseover": function(){if (this.layout.css.userMenuNode_over) this.userMenuNode.setStyles(this.layout.css.userMenuNode_over);}.bind(this),
  2182. "mouseout": function(){this.userMenuNode.setStyles(this.layout.css.userMenuNode);}.bind(this)
  2183. });
  2184. this.userMenu = new MWF.xDesktop.Menu(this.userMenuNode, {
  2185. "event": "click",
  2186. "style": "desktopUser",
  2187. "offsetX": -10,
  2188. "offsetY": 10,
  2189. "container": this.layout.node
  2190. });
  2191. this.userMenu.load();
  2192. var img = MWF.defaultPath+"/xDesktop/$Layout/"+this.layout.options.style+"/usermenu/config.png";
  2193. this.userMenu.addMenuItem(MWF.LP.desktop.userConfig, "click", function(e){this.userConfig(e);}.bind(this), img);
  2194. this.userMenu.addMenuLine();
  2195. img = MWF.defaultPath+"/xDesktop/$Layout/"+this.layout.options.style+"/usermenu/logout.png";
  2196. this.userMenu.addMenuItem(MWF.LP.desktop.logout, "click", function(){this.logout();}.bind(this), img);
  2197. },
  2198. loadClock: function(){
  2199. this.clockNode = new Element("div", {
  2200. "styles": this.layout.css.clockNode
  2201. }).inject(this.node);
  2202. this.setTime();
  2203. },
  2204. setTime: function(){
  2205. var now = new Date();
  2206. var ms = 1000-now.getMilliseconds();
  2207. var ss = 60-now.getSeconds();
  2208. var d = now.format("%Y/%m/%d#%H:%M");
  2209. dl = d.split("#");
  2210. this.clockNode.set("html", dl[1]+"<br/>"+dl[0]);
  2211. window.setTimeout(this.setTime.bind(this), ss*1000+ms);
  2212. },
  2213. changStyle: function(){
  2214. if (this.loadMenuAction) this.loadMenuAction.setStyles(this.layout.css.loadMenuAction);
  2215. if (this.configActionNode) this.configActionNode.setStyles(this.layout.css.configActionNode);
  2216. var separateNodeStyle = this.layout.css.separateNode;
  2217. delete separateNodeStyle['float'];
  2218. this.node.getElements(".separateNode").setStyles(separateNodeStyle);
  2219. if (this.userChatNode) this.userChatNode.setStyles(this.layout.css.userChatNode);
  2220. if (this.styleActionNode) this.styleActionNode.setStyles(this.layout.css.styleActionNode);
  2221. if (this.messageActionNode) this.messageActionNode.setStyles(this.layout.css.messageActionNode);
  2222. if (this.clockNode) this.clockNode.setStyles(this.layout.css.clockNode);
  2223. if (this.userMenuNode) this.userMenuNode.setStyles(this.layout.css.userMenuNode);
  2224. if (this.styleActionNode) this.styleActionNode.setStyles(this.layout.css.styleActionNode);
  2225. if (this.userActionNode) this.userActionNode.setStyles(this.layout.css.userActionNode);
  2226. if (this.taskbar) this.taskbar.setStyles(this.layout.css.taskbar);
  2227. if (this.userPanel) this.userPanel.changStyle(this.layout.options.style);
  2228. }
  2229. });
  2230. MWF.xDesktop.Layout.Navi = new Class({
  2231. initialize: function(node, layout){
  2232. this.layout = layout;
  2233. this.node = $(node);
  2234. this.navis = [];
  2235. },
  2236. load: function(){
  2237. this.createNaviArea();
  2238. this.loadNavis();
  2239. },
  2240. createNaviArea: function(){
  2241. this.naviNodeBottomArea = new Element("div", {
  2242. "styles": this.layout.css.naviNodeBottomArea
  2243. }).inject(this.node);
  2244. this.naviNodeArea = new Element("div", {
  2245. "styles": this.layout.css.naviNodeArea
  2246. }).inject(this.node);
  2247. //this.editButton = new Element("div", {
  2248. // "styles": this.layout.css.naviEditButton
  2249. //}).inject(this.naviNodeArea);
  2250. //
  2251. //this.naviNodeArea.addEvents({
  2252. // "mouseover": function(){ this.editButton.fade("in");}.bind(this),
  2253. // "mouseout": function(){ this.editButton.fade("out");}.bind(this)
  2254. //});
  2255. //
  2256. //this.editButton.addEvent("click", function(){
  2257. // this.editQuickNavi();
  2258. //}.bind(this));
  2259. },
  2260. editQuickNavi: function(){
  2261. },
  2262. loadNavis: function(){
  2263. MWF.getJSON(this.layout.path+"quickStart.json", function(json){
  2264. json.navi.each(function(navi){
  2265. this.navis.push(this.createNaviNode(navi));
  2266. }.bind(this));
  2267. }.bind(this));
  2268. },
  2269. createNaviNode: function(navi){
  2270. var node = new Element("div", {
  2271. "styles": this.layout.css.mainNaviNode
  2272. }).inject(this.naviNodeArea);
  2273. node.store("navi", navi);
  2274. var iconNode = new Element("div", {
  2275. "styles": this.layout.css.mainNaviIconNode
  2276. }).inject(node);
  2277. iconNode.setStyle("background-image", "url("+MWF.defaultPath+"/xDesktop/$Layout/"+this.layout.options.style+"/navi/"+navi.icon+")");
  2278. new Element("div", {
  2279. "styles": this.layout.css.mainNaviTextNode,
  2280. "text": navi.title
  2281. }).inject(node);
  2282. var _self = this;
  2283. node.addEvents({
  2284. "mouseover": function(){
  2285. var navi = this.retrieve("navi");
  2286. this.setStyle("background", "#CCC");
  2287. var icon = navi.icon.replace(".", "_over.");
  2288. this.getFirst("div").setStyle("background-image", "url("+MWF.defaultPath+"/xDesktop/$Layout/"+_self.layout.options.style+"/navi/"+icon+")");
  2289. this.getLast("div").setStyle("color", "#444");
  2290. },
  2291. "mouseout": function(){
  2292. this.setStyle("background", "transparent");
  2293. var navi = this.retrieve("navi");
  2294. this.setStyle("background", "transparent");
  2295. this.getFirst("div").setStyle("background-image", "url("+MWF.defaultPath+"/xDesktop/$Layout/"+_self.layout.options.style+"/navi/"+navi.icon+")");
  2296. this.getLast("div").setStyle("color", "#FFF");
  2297. },
  2298. "mousedown": function(){
  2299. this.setStyle("background", "#FFF");
  2300. },
  2301. "mouseup": function(){
  2302. this.setStyle("background", "#CCC");
  2303. },
  2304. "click": function(e){
  2305. var navi = this.retrieve("navi");
  2306. _self.layout.openApplication(e,navi.action);
  2307. }
  2308. });
  2309. return node;
  2310. },
  2311. changStyle: function(){
  2312. if (this.naviNodeBottomArea) this.naviNodeBottomArea.setStyles(this.layout.css.naviNodeBottomArea);
  2313. if (this.naviNodeArea) this.naviNodeArea.setStyles(this.layout.css.naviNodeArea);
  2314. this.navis.each(function(nv){
  2315. nv.setStyles(this.layout.css.mainNaviNode);
  2316. nv.getFirst("div").setStyles(this.layout.css.mainNaviIconNode);
  2317. nv.getLast("div").setStyles(this.layout.css.mainNaviTextNode);
  2318. }.bind(this));
  2319. }
  2320. });
  2321. MWF.xDesktop.zIndexPool = {
  2322. zIndex: 100,
  2323. applyZindex: function(){
  2324. var i = this.zIndex;
  2325. this.zIndex = this.zIndex+2;
  2326. return i;
  2327. }
  2328. };