Layout.js 101 KB

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