Layout.js 101 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495
  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. this.apps[appId] = null;
  924. delete this.apps[appId];
  925. },
  926. closeWidget: function(app){
  927. var widgetId = app.widgetId;
  928. delete this.widgets[widgetId];
  929. },
  930. requireApp: function(appNames, callback, clazzName){
  931. var appPath = appNames.split(".");
  932. var appName = appPath[appPath.length-1];
  933. var appObject = "MWF.xApplication."+appNames;
  934. var className = clazzName || "Main";
  935. var appClass = appObject+"."+className;
  936. var appLp = appObject+".lp."+MWF.language;
  937. var baseObject = MWF.xApplication;
  938. appPath.each(function(path, i){
  939. if (i<(appPath.length-1)){
  940. baseObject[path] = baseObject[path] || {};
  941. }else {
  942. baseObject[path] = baseObject[path] || {"options": Object.clone(MWF.xApplication.Common.options)};
  943. }
  944. baseObject = baseObject[path];
  945. }.bind(this));
  946. if (!baseObject.options) baseObject.options = Object.clone(MWF.xApplication.Common.options);
  947. MWF.xDesktop.requireApp(appNames, "lp."+MWF.language, {
  948. "onRequestFailure": function(){
  949. MWF.xDesktop.requireApp(appNames, "lp.zh-cn", null, false);
  950. }.bind(this),
  951. "onSuccess": function(){}.bind(this)
  952. }, false);
  953. MWF.xDesktop.requireApp(appNames, clazzName, function(){
  954. if (callback) callback(baseObject);
  955. });
  956. },
  957. playMessageAudio: function(){
  958. var flag = true;
  959. if (this.playMessageAudioTime){
  960. var now = new Date();
  961. var diff = now.getTime()-this.playMessageAudioTime.getTime();
  962. if (diff<5000) flag = false;
  963. }
  964. if (flag){
  965. if (!this.messageAudioNode){
  966. var url = MWF.defaultPath+"/xDesktop/$Layout/"+layout.desktop.options.style+"/sound/message.wav";
  967. var url2 = MWF.defaultPath+"/xDesktop/$Layout/"+layout.desktop.options.style+"/sound/message.mp3";
  968. this.messageAudioNode = new Element("div", {
  969. "html": "<audio autoplay=\"autoplay\" volume=0.6 preload=\"metadata\"><source src=\""+url+"\" type=\"audio/x-wav\"><source src=\""+url2+"\" type=\"audio/mpeg\"></source></audio>",
  970. "styles": {"display": "none"}
  971. }).inject(this.node);
  972. this.messageAudio = this.messageAudioNode.getFirst();
  973. }
  974. this.messageAudio.play();
  975. this.playMessageAudioTime = new Date();
  976. }
  977. }
  978. });
  979. MWF.xDesktop.Layout.Taskitem = new Class({
  980. initialize: function(app, layout){
  981. this.layout = layout;
  982. this.app = app;
  983. this.node = new Element("div", {
  984. "styles": this.layout.css.taskItemNode,
  985. "title": this.app.options.title+((this.app.appId) ? "-"+this.app.appId : "")
  986. }).inject(this.layout.top.taskbar);
  987. this.iconNode = new Element("div", {
  988. "styles": this.layout.css.taskItemIconNode
  989. }).inject(this.node);
  990. this.iconNode.setStyle("background-image", "url("+this.app.options.icon+")");
  991. this.closeNode = new Element("div", {
  992. "styles": this.layout.css.taskItemCloseNode
  993. }).inject(this.node);
  994. //this.closeNode.
  995. this.textNode = new Element("div", {
  996. "styles": this.layout.css.taskItemTextNode
  997. }).inject(this.node);
  998. this.textNode.set("text", this.app.options.title);
  999. this.setTaskitemSize();
  1000. this.setEvent();
  1001. },
  1002. setTaskitemSize: function(){
  1003. var x1 = 10;
  1004. var x2 = 5;
  1005. var size = this.layout.top.taskbar.getSize();
  1006. var taskItems = this.layout.top.taskbar.getChildren();
  1007. var allWidth = 0;
  1008. if (taskItems.length){
  1009. var w = taskItems[0].getStyles("border-left-width", "border-right-width", "margin-left", "margin-right", "padding-left", "padding-right");
  1010. for (var i=0; i<taskItems.length; i++){
  1011. taskItems[i].setStyle("width", "auto");
  1012. 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();
  1013. }
  1014. if (allWidth>(size.x-x1)){
  1015. var x = (size.x-x1)/taskItems.length;
  1016. 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();
  1017. taskItems.each(function(item){
  1018. item.setStyle("width", ""+width+"px");
  1019. });
  1020. }else{
  1021. taskItems.each(function(item){
  1022. item.setStyle("width", "auto");
  1023. });
  1024. }
  1025. }
  1026. // var x = (size.x-x1)/taskItems.length;
  1027. // if (x<165){
  1028. // var width = x-x2;
  1029. // taskItems.each(function(item){
  1030. // item.setStyle("width", ""+width+"px");
  1031. // });
  1032. // }else{
  1033. // taskItems.each(function(item){
  1034. // item.setStyle("width", "auto");
  1035. // });
  1036. // //this.node.setStyle("width", "160px");
  1037. // }
  1038. },
  1039. setText: function(str){
  1040. this.textNode.set("text", str || this.app.options.title);
  1041. },
  1042. setEvent: function(){
  1043. this.textNode.addEvents({
  1044. "mouseover": function(){
  1045. if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode_over);
  1046. }.bind(this),
  1047. "mouseout": function(){
  1048. if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode);
  1049. }.bind(this),
  1050. "mousedown": function(){
  1051. if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode_down);
  1052. }.bind(this),
  1053. "mouseup": function(){
  1054. if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode_over);
  1055. }.bind(this),
  1056. "click": function(){
  1057. if (this.layout.currentApp==this.app){
  1058. this.app.minSize();
  1059. }else{
  1060. this.app.setCurrent();
  1061. }
  1062. }.bind(this)
  1063. });
  1064. this.iconNode.addEvents({
  1065. "mouseover": function(){
  1066. if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode_over);
  1067. }.bind(this),
  1068. "mouseout": function(){
  1069. if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode);
  1070. }.bind(this),
  1071. "mousedown": function(){
  1072. if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode_down);
  1073. }.bind(this),
  1074. "mouseup": function(){
  1075. if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode_over);
  1076. }.bind(this),
  1077. "click": function(){
  1078. if (this.layout.currentApp==this.app){
  1079. this.app.minSize();
  1080. }else{
  1081. this.app.setCurrent();
  1082. }
  1083. }.bind(this)
  1084. });
  1085. this.node.addEvents({
  1086. "mouseover": function(){
  1087. //if (this.layout.currentApp!==this.app)
  1088. this.closeNode.fade("in");
  1089. }.bind(this),
  1090. "mouseout": function(){
  1091. //if (this.layout.currentApp!==this.app)
  1092. this.closeNode.fade("out");
  1093. }.bind(this)
  1094. });
  1095. this.closeNode.addEvent("click", function(){
  1096. this.app.close();
  1097. }.bind(this));
  1098. },
  1099. selected: function(){
  1100. this.node.setStyles(this.layout.css.taskItemNode_current);
  1101. //this.closeNode.setStyles(this.layout.css.taskItemCloseNode_current);
  1102. },
  1103. unSelected: function(){
  1104. this.node.setStyles(this.layout.css.taskItemNode);
  1105. //this.closeNode.setStyles(this.layout.css.taskItemCloseNode);
  1106. },
  1107. changStyle: function(){
  1108. if (this.node){
  1109. if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this){
  1110. this.node.setStyles(this.layout.css.taskItemNode);
  1111. }else{
  1112. this.node.setStyles(this.layout.css.taskItemNode);
  1113. this.node.setStyles(this.layout.css.taskItemNode_current);
  1114. }
  1115. }
  1116. if (this.iconNode) this.iconNode.setStyles(this.layout.css.taskItemIconNode);
  1117. if (this.textNode) this.textNode.setStyles(this.layout.css.taskItemTextNode);
  1118. },
  1119. destroy: function(){
  1120. this.node.destroy();
  1121. o2.release(this);
  1122. //this.layout.setTaskitemSize();
  1123. }
  1124. });
  1125. MWF.xDesktop.Layout.Top = new Class({
  1126. initialize: function(node, layout){
  1127. this.layout = layout;
  1128. this.node = $(node);
  1129. this.userApplicationsLog = [];
  1130. this.sysApplicationsLog = [];
  1131. },
  1132. load: function(){
  1133. this.loadMenuAction();
  1134. this.loadSeparate();
  1135. this.loadShowDesktop();
  1136. this.loadClock();
  1137. this.loadSeparate("right");
  1138. this.loadUserMenu();
  1139. this.loadStyleAction();
  1140. this.loadUserChat();
  1141. this.loadMessageAction();
  1142. this.loadSeparate("right");
  1143. this.loadTaskbar();
  1144. },
  1145. loadMenuAction: function(){
  1146. this.loadMenuAction = new Element("div", {
  1147. "styles": this.layout.css.loadMenuAction,
  1148. "title": MWF.LP.desktop.menuAction
  1149. }).inject(this.node);
  1150. // this.loadMenu();
  1151. this.loadMenuAction.addEvent("click", function(){
  1152. this.loadMenu();
  1153. }.bind(this));
  1154. },
  1155. loadShowDesktop: function(){
  1156. this.showDesktopAction = new Element("div", {
  1157. "styles": this.layout.css.showDesktopAction
  1158. }).inject(this.node);
  1159. this.showDesktopAction.addEvents({
  1160. "mouseover": function(){
  1161. this.showDesktopAction.setStyles(this.layout.css.showDesktopAction_over);
  1162. }.bind(this),
  1163. "mouseout": function(){
  1164. this.showDesktopAction.setStyles(this.layout.css.showDesktopAction);
  1165. }.bind(this),
  1166. "click": function(){
  1167. var flag = true;
  1168. Object.each(this.layout.apps, function(app, id){
  1169. if (!app.window.isHide){
  1170. flag = false;
  1171. app.minSize();
  1172. }
  1173. }.bind(this));
  1174. if (flag){
  1175. Object.each(this.layout.apps, function(app, id){
  1176. app.setCurrent();
  1177. }.bind(this));
  1178. }
  1179. }.bind(this)
  1180. });
  1181. },
  1182. loadMenu: function(){
  1183. this.createApplicationMenuArea();
  1184. this.showApplicationMenu();
  1185. window.setTimeout(function(){
  1186. this.getApplicationsCatalogue(function(catalog){
  1187. //var currentName = this.layout.session.user.name;
  1188. var user = this.layout.session.user;
  1189. var currentNames = [user.name, user.distinguishedName, user.id, user.unique];
  1190. if (user.roleList) currentNames = currentNames.concat(user.roleList);
  1191. if (user.groupList) currentNames = currentNames.concat(user.groupList);
  1192. catalog.each(function(value, key){
  1193. var isAllow = true;
  1194. if (value.allowList) isAllow = (value.allowList.length) ? (value.allowList.isIntersect(currentNames)) : true;
  1195. var isDeny = false;
  1196. if (value.denyList) isDeny = (value.denyList.length) ? (value.denyList.isIntersect(currentNames)!==-1) : false;
  1197. if ((!isDeny && isAllow) || MWF.AC.isAdministrator()){
  1198. this.createApplicationMenu(value, key);
  1199. }
  1200. }.bind(this));
  1201. this.getComponentList(function(json){
  1202. json.data.each(function(value, key){
  1203. if (value.visible){
  1204. var isAllow = (value.allowList.length) ? (value.allowList.isIntersect(currentNames)) : true;
  1205. var isDeny = (value.denyList.length) ? (value.denyList.isIntersect(currentNames)) : false;
  1206. if ((!isDeny && isAllow) || MWF.AC.isAdministrator()){
  1207. this.createApplicationMenu(value, key);
  1208. }
  1209. }
  1210. }.bind(this));
  1211. }.bind(this));
  1212. var action = new MWF.xDesktop.Actions.RestActions("/xDesktop/Actions/action.json", "x_portal_assemble_surface");
  1213. action.invoke({"name": "listPortalApplication", "success": function(json){
  1214. if (json.data){
  1215. json.data.each(function(app){
  1216. this.createPortalAppMenu(app);
  1217. }.bind(this));
  1218. }
  1219. }.bind(this)});
  1220. }.bind(this));
  1221. this.getProcessApplications(function(json){
  1222. //json.data.each(function(app){
  1223. // if( app.isCMSApp ){
  1224. // this.createCMSAppMenu(app);
  1225. // }else{
  1226. // this.createProcessAppMenu(app);
  1227. // }
  1228. //}.bind(this));
  1229. }.bind(this));
  1230. }.bind(this), 0);
  1231. },
  1232. showApplicationMenu: function(){
  1233. this.applicationMenuAreaMark.fade(0.8);
  1234. this.applicationMenuArea.fade("in");
  1235. },
  1236. closeApplicationMenu: function(){
  1237. if (this.applicationMenuSearchBar) this.closeApplicationMenuSearchBar();
  1238. if (!this.isApplicationMenuScroll){
  1239. this.applicationMenuAreaMark.destroy();
  1240. this.applicationMenuArea.destroy();
  1241. this.applicationMenuFxScroll = null;
  1242. this.userApplicationsLog = [];
  1243. this.sysApplicationsLog = [];
  1244. this.layout.removeEvent("resize", this.resizeApplicationMenuSizeFun);
  1245. }
  1246. this.currentApplicationMenuContent = "app";
  1247. this.isApplicationMenuScroll = false;
  1248. if (this.closeApplicationMenuFun) document.body.removeEvent("keydown", this.closeApplicationMenuFun);
  1249. },
  1250. closeApplicationMenuEsc: function(e){
  1251. if (e.key==="esc"){
  1252. if (!this.applicationMenuSearchBar){
  1253. this.closeApplicationMenu();
  1254. }
  1255. }
  1256. },
  1257. createCMSAppMenu: function(app){
  1258. var applicationMenuNode = new Element("div", {
  1259. "styles": this.layout.css.applicationMenuNode,
  1260. "title": app.appName
  1261. }).inject(this.applicationMenuProcessArea);
  1262. this.userApplicationsLog.push({
  1263. "node": applicationMenuNode,
  1264. "py": app.appName.toPY().toLowerCase(),
  1265. "name": app.appName.toLowerCase(),
  1266. "first": app.appName.toPYFirst().toLowerCase()
  1267. });
  1268. var applicationMenuIconNode = new Element("div", {
  1269. "styles": this.layout.css.applicationMenuIconNode
  1270. }).inject(applicationMenuNode);
  1271. var icon = "";
  1272. if (app.appIcon){
  1273. icon = "url(data:image/png;base64,"+app.appIcon+")";
  1274. }else{
  1275. icon = "url(/x_component_cms_Index/$Main/default/icon/column.png)";
  1276. }
  1277. applicationMenuIconNode.setStyle("background-image", icon);
  1278. new Element("div", {
  1279. "styles": this.layout.css.applicationMenuTextNode,
  1280. "text": app.appName
  1281. }).inject(applicationMenuNode);
  1282. applicationMenuNode.addEvent("click", function(e){
  1283. this.layout.openCMSApp(e, app);
  1284. this.closeApplicationMenu();
  1285. }.bind(this));
  1286. applicationMenuNode.makeLnk({
  1287. "par": {
  1288. "icon": icon,
  1289. "title": app.name,
  1290. "par": "cms.Module#{\"columnId\": \""+app.id+"\", \"appId\": \"cms.Module"+app.id+"\"}"
  1291. },
  1292. "onStart": function(){
  1293. this.applicationMenuAreaMark.fade("out");
  1294. this.applicationMenuArea.fade("out");
  1295. }.bind(this),
  1296. "onComplete": function(){
  1297. this.showApplicationMenu();
  1298. }.bind(this)
  1299. });
  1300. },
  1301. createPortalAppMenu: function(app){
  1302. var applicationMenuNode = new Element("div", {
  1303. "styles": this.layout.css.applicationMenuNode,
  1304. "title": app.name
  1305. }).inject(this.applicationMenuAppIconArea);
  1306. this.userApplicationsLog.push({
  1307. "node": applicationMenuNode,
  1308. "py": app.name.toPY().toLowerCase(),
  1309. "name": app.name.toLowerCase(),
  1310. "first": app.name.toPYFirst().toLowerCase()
  1311. });
  1312. var applicationMenuIconNode = new Element("div", {
  1313. "styles": this.layout.css.applicationMenuIconNode
  1314. }).inject(applicationMenuNode);
  1315. var icon = "";
  1316. if (app.icon){
  1317. icon = "url(data:image/png;base64,"+app.icon+")";
  1318. }else{
  1319. icon = "url(/x_component_portal_PortalExplorer/$Main/default/icon/application.png)";
  1320. }
  1321. applicationMenuIconNode.setStyle("background-image", icon);
  1322. new Element("div", {
  1323. "styles": this.layout.css.applicationMenuTextNode,
  1324. "text": app.name
  1325. }).inject(applicationMenuNode);
  1326. applicationMenuNode.addEvent("click", function(e){
  1327. this.layout.openPortalApp(e, app);
  1328. this.closeApplicationMenu();
  1329. }.bind(this));
  1330. applicationMenuNode.makeLnk({
  1331. "par": {"icon": icon, "title": app.name, "par": "portal.Portal#{\"portalId\": \""+app.id+"\", \"appId\": \"portal.Portal"+app.id+"\"}"},
  1332. "onStart": function(){
  1333. this.applicationMenuAreaMark.fade("out");
  1334. this.applicationMenuArea.fade("out");
  1335. }.bind(this),
  1336. "onComplete": function(){
  1337. this.showApplicationMenu();
  1338. }.bind(this)
  1339. });
  1340. },
  1341. createQueryAppMenu: function(app){
  1342. var applicationMenuNode = new Element("div", {
  1343. "styles": this.layout.css.applicationMenuNode,
  1344. "title": app.name
  1345. }).inject(this.applicationMenuProcessArea);
  1346. this.userApplicationsLog.push({
  1347. "node": applicationMenuNode,
  1348. "py": app.name.toPY().toLowerCase(),
  1349. "name": app.name.toLowerCase(),
  1350. "first": app.name.toPYFirst().toLowerCase()
  1351. });
  1352. var applicationMenuIconNode = new Element("div", {
  1353. "styles": this.layout.css.applicationMenuIconNode
  1354. }).inject(applicationMenuNode);
  1355. var icon = "";
  1356. if (app.icon){
  1357. icon = "url(data:image/png;base64,"+app.icon+")";
  1358. }else{
  1359. icon = "url(/x_component_query_Query/$Main/appicon.png)";
  1360. }
  1361. applicationMenuIconNode.setStyle("background-image", icon);
  1362. new Element("div", {
  1363. "styles": this.layout.css.applicationMenuTextNode,
  1364. "text": app.name
  1365. }).inject(applicationMenuNode);
  1366. applicationMenuNode.addEvent("click", function(e){
  1367. this.layout.openQueryApp(e, app);
  1368. this.closeApplicationMenu();
  1369. }.bind(this));
  1370. applicationMenuNode.makeLnk({
  1371. "par": {"icon": icon, "title": app.name, "par": "query.Query#{\"id\": \""+app.id+"\", \"appId\": \"query.Query"+app.id+"\"}"},
  1372. "onStart": function(){
  1373. this.applicationMenuAreaMark.fade("out");
  1374. this.applicationMenuArea.fade("out");
  1375. }.bind(this),
  1376. "onComplete": function(){
  1377. this.showApplicationMenu();
  1378. }.bind(this)
  1379. });
  1380. },
  1381. createProcessAppMenu: function(app){
  1382. var applicationMenuNode = new Element("div", {
  1383. "styles": this.layout.css.applicationMenuNode,
  1384. "title": app.name
  1385. }).inject(this.applicationMenuProcessArea);
  1386. this.userApplicationsLog.push({
  1387. "node": applicationMenuNode,
  1388. "py": app.name.toPY().toLowerCase(),
  1389. "name": app.name.toLowerCase(),
  1390. "first": app.name.toPYFirst().toLowerCase()
  1391. });
  1392. var applicationMenuIconNode = new Element("div", {
  1393. "styles": this.layout.css.applicationMenuIconNode
  1394. }).inject(applicationMenuNode);
  1395. var icon = "";
  1396. if (app.icon){
  1397. icon = "url(data:image/png;base64,"+app.icon+")";
  1398. }else{
  1399. icon = "url(/x_component_process_ApplicationExplorer/$Main/default/icon/application.png)";
  1400. }
  1401. applicationMenuIconNode.setStyle("background-image", icon);
  1402. new Element("div", {
  1403. "styles": this.layout.css.applicationMenuTextNode,
  1404. "text": app.name
  1405. }).inject(applicationMenuNode);
  1406. applicationMenuNode.addEvent("click", function(e){
  1407. this.layout.openProcessApp(e, app);
  1408. this.closeApplicationMenu();
  1409. }.bind(this));
  1410. applicationMenuNode.makeLnk({
  1411. "par": {"icon": icon, "title": app.name, "par": "process.Application#{\"id\": \""+app.id+"\", \"appId\": \"process.Application"+app.id+"\"}"},
  1412. "onStart": function(){
  1413. this.applicationMenuAreaMark.fade("out");
  1414. this.applicationMenuArea.fade("out");
  1415. }.bind(this),
  1416. "onComplete": function(){
  1417. this.showApplicationMenu();
  1418. }.bind(this)
  1419. });
  1420. },
  1421. createApplicationMenu: function(value, key){
  1422. var applicationMenuNode = new Element("div", {
  1423. "styles": this.layout.css.applicationMenuNode,
  1424. "title": value.title
  1425. }).inject(this.applicationMenuAppIconArea);
  1426. this.sysApplicationsLog.push({
  1427. "node": applicationMenuNode,
  1428. "py": value.title.toPY().toLowerCase(),
  1429. "name": value.title.toLowerCase(),
  1430. "first": value.title.toPYFirst().toLowerCase()
  1431. });
  1432. var applicationMenuIconNode = new Element("div", {
  1433. "styles": this.layout.css.applicationMenuIconNode
  1434. }).inject(applicationMenuNode);
  1435. var icon = "/x_component_"+value.path.replace(/\./g, "_")+"/$Main/"+value.iconPath;
  1436. applicationMenuIconNode.setStyle("background-image", "url("+icon+")");
  1437. new Element("div", {
  1438. "styles": this.layout.css.applicationMenuTextNode,
  1439. "text": value.title
  1440. }).inject(applicationMenuNode);
  1441. applicationMenuNode.addEvent("click", function(e){
  1442. this.layout.openApplication(e, value.path);
  1443. this.closeApplicationMenu();
  1444. }.bind(this));
  1445. applicationMenuNode.makeLnk({
  1446. "par": {"icon": icon, "title": value.title, "par": value.path},
  1447. "onStart": function(){
  1448. this.applicationMenuAreaMark.fade("out");
  1449. this.applicationMenuArea.fade("out");
  1450. }.bind(this),
  1451. "onComplete": function(){
  1452. this.showApplicationMenu();
  1453. }.bind(this)
  1454. });
  1455. var appName = value.path;
  1456. //if (value.widgetName){
  1457. // if (!(value.widgetVisible===false)){
  1458. // this.createApplicationWidgetMenu(value.widgetName, value.widgetTitle, value.widgetIconPath, appName);
  1459. // }
  1460. // //Object.each(value.widget, function(value, key){
  1461. // // this.createApplicationWidgetMenu(value.widgetName, value.widgetTitle, value.widgetIconPath, appName);
  1462. // //}.bind(this));
  1463. // //if (value.widgetStart){
  1464. // // this.layout.openWidget(null, value.widgetName, appName);
  1465. // //}
  1466. //
  1467. //}
  1468. },
  1469. createApplicationWidgetMenu: function(name, title, icon, appName){
  1470. var applicationMenuNode = new Element("div", {
  1471. "styles": this.layout.css.widgetMenuNode,
  1472. "title": title
  1473. }).inject(this.applicationMenuWidgetArea);
  1474. var applicationMenuIconNode = new Element("div", {
  1475. "styles": this.layout.css.widgetMenuIconNode
  1476. }).inject(applicationMenuNode);
  1477. var icon = "/x_component_"+appName.replace(/\./g, "_")+"/$"+name+"/"+icon;
  1478. applicationMenuIconNode.setStyle("background-image", "url("+icon+")");
  1479. new Element("div", {
  1480. "styles": this.layout.css.applicationMenuTextNode,
  1481. "text": title
  1482. }).inject(applicationMenuNode);
  1483. applicationMenuNode.addEvent("click", function(e){
  1484. this.layout.openWidget(e, name, appName);
  1485. this.closeApplicationMenu();
  1486. }.bind(this));
  1487. },
  1488. createApplicationMenuArea: function(){
  1489. var index = MWF.xDesktop.zIndexPool.zIndex;
  1490. //mask-----------------------------------------
  1491. this.applicationMenuAreaMark = new Element("iframe", {
  1492. //"src": (Browser.iecomp) ? MWF.defaultPath+"/xDesktop/_blank.html" : "",
  1493. "styles": this.layout.css.applicationMenuAreaMark
  1494. }).inject(this.layout.node);
  1495. //this.applicationMenuAreaMark.contentWindow.document.documentElement.styles.background = "#000000";
  1496. this.applicationMenuAreaMark.setStyle("z-index", index);
  1497. //---------------------------------------------
  1498. //top node ------------------------------------
  1499. this.applicationMenuArea = new Element("div", {
  1500. "styles": this.layout.css.applicationMenuArea
  1501. }).inject(this.layout.node);
  1502. this.applicationMenuArea.setStyle("z-index", index+1);
  1503. //---------------------------------------------
  1504. this.applicationMenuLeftAction = new Element("div", {
  1505. "styles": this.layout.css.applicationMenuLeftAction
  1506. }).inject(this.applicationMenuArea);
  1507. this.applicationMenuRightAction = new Element("div", {
  1508. "styles": this.layout.css.applicationMenuRightAction
  1509. }).inject(this.applicationMenuArea);
  1510. this.applicationMenuScrollArea = new Element("div", {
  1511. "styles": this.layout.css.applicationMenuScrollArea
  1512. }).inject(this.applicationMenuArea);
  1513. this.applicationMenuContentArea = new Element("div", {
  1514. "styles": this.layout.css.applicationMenuContentArea
  1515. }).inject(this.applicationMenuScrollArea);
  1516. ////widget---------------------------------------
  1517. //this.applicationMemuWidgetContent = new Element("div", {
  1518. // "styles": this.layout.css.applicationMemuWidgetContent
  1519. //}).inject(this.applicationMenuContentArea);
  1520. //
  1521. //this.applicationMenuWidgetTitleArea = new Element("div", {
  1522. // "styles": this.layout.css.applicationMenuWidgetTitleArea,
  1523. // "text": MWF.LP.desktop.widget
  1524. //}).inject(this.applicationMemuWidgetContent);
  1525. //
  1526. //this.applicationMenuWidgetScrollArea = new Element("div", {
  1527. // "styles": this.layout.css.applicationMenuWidgetScrollArea
  1528. //}).inject(this.applicationMemuWidgetContent);
  1529. //
  1530. //this.applicationMenuWidgetArea = new Element("div", {
  1531. // "styles": this.layout.css.applicationMenuWidgetArea
  1532. //}).inject(this.applicationMenuWidgetScrollArea);
  1533. ////---------------------------------------------
  1534. //application----------------------------------
  1535. this.applicationMemuAppContent = new Element("div", {
  1536. "styles": this.layout.css.applicationMemuAppContent
  1537. }).inject(this.applicationMenuContentArea);
  1538. this.applicationMenuAppTitleArea = new Element("div", {
  1539. "styles": this.layout.css.applicationMenuAppTitleArea,
  1540. "text": MWF.LP.desktop.application
  1541. }).inject(this.applicationMemuAppContent);
  1542. this.applicationMenuAppIconScrollArea = new Element("div", {
  1543. "styles": this.layout.css.applicationMenuAppIconScrollArea
  1544. }).inject(this.applicationMemuAppContent);
  1545. this.applicationMenuAppIconArea = new Element("div", {
  1546. "styles": this.layout.css.applicationMenuAppIconArea
  1547. }).inject(this.applicationMenuAppIconScrollArea);
  1548. //---------------------------------------------
  1549. //Process---------------------------------------
  1550. this.applicationMemuProcessContent = new Element("div", {
  1551. "styles": this.layout.css.applicationMemuProcessContent
  1552. }).inject(this.applicationMenuContentArea);
  1553. this.applicationMenuProcessTitleArea = new Element("div", {
  1554. "styles": this.layout.css.applicationMenuProcessTitleArea,
  1555. "text": MWF.LP.desktop.process
  1556. }).inject(this.applicationMemuProcessContent);
  1557. this.applicationMenuProcessScrollArea = new Element("div", {
  1558. "styles": this.layout.css.applicationMenuProcessScrollArea
  1559. }).inject(this.applicationMemuProcessContent);
  1560. this.applicationMenuProcessArea = new Element("div", {
  1561. "styles": this.layout.css.applicationMenuProcessArea
  1562. }).inject(this.applicationMenuProcessScrollArea);
  1563. //---------------------------------------------
  1564. this.setApplicationMenuSize();
  1565. this.setApplicationMenuEvent();
  1566. },
  1567. setApplicationMenuSize: function(){
  1568. this.resizeApplicationMenuSize();
  1569. this.resizeApplicationMenuSizeFun = this.resizeApplicationMenuSize.bind(this);
  1570. this.layout.addEvent("resize", this.resizeApplicationMenuSizeFun);
  1571. },
  1572. resizeApplicationMenuSize: function(){
  1573. var wSize = this.applicationMenuScrollArea.getSize();
  1574. this.applicationMemuAppContent.setStyle("width", ""+wSize.x+"px");
  1575. //this.applicationMemuWidgetContent.setStyle("width", ""+wSize.x+"px");
  1576. this.applicationMemuProcessContent.setStyle("width", ""+wSize.x+"px");
  1577. var x = wSize.x*2;
  1578. this.applicationMenuContentArea.setStyle("width", ""+x+"px");
  1579. var size = this.applicationMenuArea.getSize();
  1580. var titleSize = this.applicationMenuAppTitleArea.getSize();
  1581. var tmt = this.applicationMenuAppTitleArea.getStyle("margin-top").toInt();
  1582. var tmb = this.applicationMenuAppTitleArea.getStyle("margin-bottom").toInt();
  1583. var cmt = this.applicationMenuAppIconScrollArea.getStyle("margin-top").toInt();
  1584. var cmb = this.applicationMenuAppIconScrollArea.getStyle("margin-bottom").toInt();
  1585. var y = size.y - titleSize.y - tmt - tmb - cmt - cmb;
  1586. this.applicationMenuAppIconScrollArea.setStyle("height", ""+y+"px");
  1587. //titleSize = this.applicationMenuWidgetTitleArea.getSize();
  1588. //tmt = this.applicationMenuWidgetTitleArea.getStyle("margin-top").toInt();
  1589. //tmb = this.applicationMenuWidgetTitleArea.getStyle("margin-bottom").toInt();
  1590. //cmt = this.applicationMenuWidgetScrollArea.getStyle("margin-top").toInt();
  1591. //cmb = this.applicationMenuWidgetScrollArea.getStyle("margin-bottom").toInt();
  1592. //y = size.y - titleSize.y - tmt - tmb - cmt - cmb;
  1593. //this.applicationMenuWidgetScrollArea.setStyle("height", ""+y+"px");
  1594. titleSize = this.applicationMenuProcessTitleArea.getSize();
  1595. tmt = this.applicationMenuProcessTitleArea.getStyle("margin-top").toInt();
  1596. tmb = this.applicationMenuProcessTitleArea.getStyle("margin-bottom").toInt();
  1597. cmt = this.applicationMenuProcessScrollArea.getStyle("margin-top").toInt();
  1598. cmb = this.applicationMenuProcessScrollArea.getStyle("margin-bottom").toInt();
  1599. y = size.y - titleSize.y - tmt - tmb - cmt - cmb;
  1600. this.applicationMenuProcessScrollArea.setStyle("height", ""+y+"px");
  1601. },
  1602. setApplicationMenuEvent: function(){
  1603. MWF.require("MWF.widget.ScrollBar", function(){
  1604. new MWF.widget.ScrollBar(this.applicationMenuAppIconScrollArea, {
  1605. "style":"xDesktop_Menu", "where": "after", "distance": 30, "friction": 4, "axis": {"x": false, "y": true},
  1606. "onScrollStart": function(){
  1607. this.isApplicationMenuScroll = true;
  1608. }.bind(this)
  1609. });
  1610. //new MWF.widget.ScrollBar(this.applicationMenuWidgetScrollArea, {
  1611. // "style":"xDesktop_Menu", "where": "after", "distance": 30, "friction": 4, "axis": {"x": false, "y": true},
  1612. // "onScrollStart": function(){
  1613. // this.isApplicationMenuScroll = true;
  1614. // }.bind(this)
  1615. //});
  1616. new MWF.widget.ScrollBar(this.applicationMenuProcessScrollArea, {
  1617. "style":"xDesktop_Menu", "where": "after", "distance": 30, "friction": 4, "axis": {"x": false, "y": true},
  1618. "onScrollStart": function(){
  1619. this.isApplicationMenuScroll = true;
  1620. }.bind(this)
  1621. });
  1622. }.bind(this));
  1623. this.applicationMenuRightAction.addEvent("click", function(e){
  1624. this.closeApplicationMenuSearchBar();
  1625. if (!this.currentApplicationMenuContent) this.currentApplicationMenuContent = "app";
  1626. var next = "";
  1627. var nextNode = null;
  1628. var currentNode = null;
  1629. if (this.currentApplicationMenuContent == "app"){
  1630. //nextNode = this.applicationMemuWidgetContent;
  1631. nextNode = this.applicationMemuProcessContent;
  1632. next="process";
  1633. currentNode = this.applicationMemuAppContent;
  1634. }
  1635. //if (this.currentApplicationMenuContent == "widget"){
  1636. // nextNode = this.applicationMemuProcessContent;
  1637. // next="process";
  1638. // currentNode = this.applicationMemuWidgetContent;
  1639. //}
  1640. if (this.currentApplicationMenuContent == "process"){
  1641. nextNode = this.applicationMemuAppContent;
  1642. next="app";
  1643. currentNode = this.applicationMemuProcessContent;
  1644. }
  1645. //this.applicationMenuScrollArea.set("scrollLeft", "0px");
  1646. //if (this.applicationMenuFxScroll){
  1647. // this.applicationMenuFxScroll = null;
  1648. // delete this.applicationMenuFxScroll
  1649. //}
  1650. if (!this.applicationMenuFxScroll) this.applicationMenuFxScroll = new Fx.Scroll(this.applicationMenuScrollArea, {"wheelStops": false});
  1651. nextNode.inject(currentNode, "after");
  1652. this.applicationMenuFxScroll.set(0);
  1653. this.applicationMenuFxScroll.toElement(nextNode, "x").chain(function(){
  1654. //currentNode.inject(nextNode, "after");
  1655. //this.applicationMenuFxScroll.set(0);
  1656. //this.applicationMenuFxScroll.toLeft();
  1657. }.bind(this));
  1658. //this.applicationMenuScrollArea.toElement(nextNode);
  1659. this.currentApplicationMenuContent = next;
  1660. e.stopPropagation();
  1661. }.bind(this));
  1662. this.applicationMenuLeftAction.addEvent("click", function(e){
  1663. this.closeApplicationMenuSearchBar();
  1664. if (!this.currentApplicationMenuContent) this.currentApplicationMenuContent = "app";
  1665. var next = "";
  1666. var nextNode = null;
  1667. var currentNode = null;
  1668. if (this.currentApplicationMenuContent == "app"){
  1669. nextNode = this.applicationMemuProcessContent;
  1670. next="process";
  1671. currentNode = this.applicationMemuAppContent;
  1672. }
  1673. //if (this.currentApplicationMenuContent == "widget"){
  1674. // nextNode = this.applicationMemuAppContent;
  1675. // next="app";
  1676. // currentNode = this.applicationMemuWidgetContent;
  1677. //}
  1678. if (this.currentApplicationMenuContent == "process"){
  1679. //nextNode = this.applicationMemuWidgetContent;
  1680. nextNode = this.applicationMemuAppContent;
  1681. next="app";
  1682. currentNode = this.applicationMemuProcessContent;
  1683. }
  1684. //nextNode.inject(currentNode, "before");
  1685. if (!this.applicationMenuFxScroll) this.applicationMenuFxScroll = new Fx.Scroll(this.applicationMenuScrollArea, {"wheelStops": false});
  1686. nextNode.inject(currentNode, "before");
  1687. this.applicationMenuFxScroll.set(this.applicationMenuScrollArea.getScrollSize().x);
  1688. this.applicationMenuFxScroll.toElement(nextNode);
  1689. //this.applicationMenuScrollArea.toElement(nextNode);
  1690. this.currentApplicationMenuContent = next;
  1691. e.stopPropagation();
  1692. }.bind(this));
  1693. this.applicationMenuArea.addEvent("click", function(){
  1694. this.closeApplicationMenu();
  1695. }.bind(this));
  1696. this.closeApplicationMenuFun = this.closeApplicationMenuEsc.bind(this);
  1697. document.body.addEvent("keydown", this.closeApplicationMenuFun);
  1698. this.showApplicationSearchFun = this.showApplicationSearch.bind(this);
  1699. document.body.addEvent("keydown", this.showApplicationSearchFun);
  1700. },
  1701. showApplicationSearch: function(e){
  1702. if (e.key==="esc"){
  1703. if (this.applicationMenuSearchBar) this.closeApplicationMenuSearchBar();
  1704. }else{
  1705. if (!this.applicationMenuSearchBar) this.createApplicationMenuSearchBar(e);
  1706. }
  1707. },
  1708. closeApplicationMenuSearchBar: function(){
  1709. if (this.applicationMenuSearchBar){
  1710. this.applicationMenuSearchBar.destroy();
  1711. this.applicationMenuSearchBar = null;
  1712. //if (this.showApplicationSearchFun) document.body.removeEvent("keydown", this.showApplicationSearchFun);
  1713. if ((this.currentApplicationMenuContent === "process") || (!this.currentApplicationMenuContent)){
  1714. this.userApplicationsLog.each(function(o){
  1715. o.node.setStyle("display", "block");
  1716. }.bind(this));
  1717. }
  1718. if (this.currentApplicationMenuContent === "app"){
  1719. this.sysApplicationsLog.each(function(o){
  1720. o.node.setStyle("display", "block");
  1721. }.bind(this));
  1722. }
  1723. }
  1724. },
  1725. createApplicationMenuSearchBar: function(e){
  1726. this.applicationMenuSearchBar = new Element("div", {
  1727. "styles": this.layout.css.applicationMenuSearchBar
  1728. }).inject(this.applicationMenuArea);
  1729. this.applicationMenuSearchBarBox = new Element("div", {
  1730. "styles": this.layout.css.applicationMenuSearchBarBox
  1731. }).inject(this.applicationMenuSearchBar);
  1732. this.applicationMenuSearchBarClose = new Element("div", {
  1733. "styles": this.layout.css.applicationMenuSearchBarClose
  1734. }).inject(this.applicationMenuSearchBarBox);
  1735. this.applicationMenuSearchBarInputBox = new Element("div", {
  1736. "styles": this.layout.css.applicationMenuSearchBarInputBox
  1737. }).inject(this.applicationMenuSearchBarBox);
  1738. this.applicationMenuSearchBarInput = new Element("input", {
  1739. "styles": this.layout.css.applicationMenuSearchBarInput
  1740. }).inject(this.applicationMenuSearchBarInputBox);
  1741. this.applicationMenuSearchBarInput.focus();
  1742. this.applicationMenuSearchBarInput.addEvent("keydown", function(e){
  1743. if (e.key==="esc"){
  1744. this.closeApplicationMenuSearchBar();
  1745. }
  1746. if (e.key==="enter"){
  1747. this.doApplicationMenuSearch();
  1748. }
  1749. e.stopPropagation();
  1750. }.bind(this));
  1751. this.applicationMenuSearchBarInput.addEvent("click", function(e){
  1752. e.stopPropagation();
  1753. }.bind(this));
  1754. this.applicationMenuSearchBarClose.addEvent("click", function(e){
  1755. this.closeApplicationMenuSearchBar();
  1756. }.bind(this));
  1757. },
  1758. doApplicationMenuSearch: function(){
  1759. var value = this.applicationMenuSearchBarInput.get("value").toLowerCase();
  1760. if (value){
  1761. if ((this.currentApplicationMenuContent === "process") || (!this.currentApplicationMenuContent) ){
  1762. this.userApplicationsLog.each(function(o){
  1763. if ((o.py.indexOf(value)===-1) && (o.first.indexOf(value)===-1) && (o.name.indexOf(value)===-1)){
  1764. o.node.setStyle("display", "none");
  1765. }else{
  1766. o.node.setStyle("display", "block");
  1767. }
  1768. }.bind(this));
  1769. }
  1770. if (this.currentApplicationMenuContent === "app"){
  1771. this.sysApplicationsLog.each(function(o){
  1772. if ((o.py.indexOf(value)===-1) && (o.first.indexOf(value)===-1) && (o.name.indexOf(value)===-1)){
  1773. o.node.setStyle("display", "none");
  1774. }else{
  1775. o.node.setStyle("display", "block");
  1776. }
  1777. }.bind(this));
  1778. }
  1779. }
  1780. },
  1781. getApplicationsCatalogue: function(callback){
  1782. var url = MWF.defaultPath+"/xDesktop/$Layout/applications.json";
  1783. MWF.getJSON(url, function(json){
  1784. if (callback) callback(json);
  1785. }.bind(this));
  1786. },
  1787. getProcessApplications: function(callback){
  1788. action = new MWF.xDesktop.Actions.RestActions("/xDesktop/Actions/action.json", "x_processplatform_assemble_surface");
  1789. action.invoke({"name": "listApplication", "success": function(json){
  1790. if (json.data){
  1791. json.data.each(function(app){
  1792. this.createProcessAppMenu(app);
  1793. }.bind(this));
  1794. }
  1795. }.bind(this)});
  1796. action = new MWF.xDesktop.Actions.RestActions("/xDesktop/Actions/action.json", "x_cms_assemble_control");
  1797. action.invoke({"name": "listCMSApplication", "success": function(json){
  1798. if (json.data) {
  1799. json.data.each(function (app) {
  1800. app.name = app.appName;
  1801. app.icon = app.appIcon;
  1802. this.createCMSAppMenu(app);
  1803. }.bind(this));
  1804. }
  1805. }.bind(this)});
  1806. action = MWF.Actions.get("x_query_assemble_surface");
  1807. action.listQuery(function(json){
  1808. if (json.data) {
  1809. json.data.each(function (app) {
  1810. this.createQueryAppMenu(app);
  1811. }.bind(this));
  1812. }
  1813. }.bind(this));
  1814. //var action = new MWF.xDesktop.Actions.RestActions("/xDesktop/Actions/action.json", "x_processplatform_assemble_surface");
  1815. //action.invoke({"name": "listApplication", "success": function(json){
  1816. // //add by cxy
  1817. // var action_cms = new MWF.xDesktop.Actions.RestActions("/xDesktop/Actions/action.json", "x_cms_assemble_control");
  1818. // action_cms.invoke({"name": "listCMSApplication", "success": function(json2){
  1819. // var data = json2.data || [];
  1820. // data.each(function(d){
  1821. // d.isCMSApp = true;
  1822. // d.name = d.appName;
  1823. // d.icon = d.appIcon;
  1824. // json.data.push(d);
  1825. // })
  1826. // if (callback) callback(json)
  1827. // }})
  1828. //}.bind(this)});
  1829. },
  1830. getComponentList: function(callback){
  1831. var action = new MWF.xDesktop.Actions.RestActions("/xDesktop/Actions/action.json", "x_component_assemble_control");
  1832. action.invoke({"name": "listComponent", "success": function(json){
  1833. if (callback) callback(json);
  1834. }.bind(this)});
  1835. },
  1836. // loadMenu: function(){
  1837. // this.startMenu = new MWF.xDesktop.Menu(this.loadMenuAction, {
  1838. // "event": "click",
  1839. // "style": "desktopStyle",
  1840. // "offsetX": -3,
  1841. // "offsetY": 8,
  1842. // });
  1843. // this.startMenu.load();
  1844. //
  1845. // var icon = MWF.defaultPath+"/xDesktop/$Layout/"+this.layout.options.style+"/menu/find.png";
  1846. // this.startMenu.addMenuItem("查找", "click", function(){}.bind(this), icon);
  1847. //
  1848. // this.startMenu.addMenuLine();
  1849. //
  1850. // Properties.navi.each(function(item){
  1851. // this.addStartMenuItem(item, this.startMenu);
  1852. // }.bind(this));
  1853. // },
  1854. // addStartMenuItem: function(item, menu){
  1855. // if (item.sub && item.sub.length>0){
  1856. // startSubMenu = new MWF.xDesktop.Menu(null, {
  1857. // "event": "click",
  1858. // "style": "desktopMenuSub",
  1859. // "offsetX": 2
  1860. // });
  1861. // startSubMenu.load();
  1862. // item.sub.each(function(subitem){
  1863. // this.addStartMenuItem(subitem, startSubMenu);
  1864. // }.bind(this));
  1865. //
  1866. // var icon = MWF.defaultPath+"/xDesktop/$Layout/"+this.layout.options.style+"/menu/"+item.icon;
  1867. // menu.addMenuMenu(item.title, icon, startSubMenu);
  1868. // }else{
  1869. // var icon = MWF.defaultPath+"/xDesktop/$Layout/"+this.layout.options.style+"/menu/"+item.icon;
  1870. // menu.addMenuItem(item.title, "click", function(){}, icon);
  1871. // }
  1872. // },
  1873. loadConfigAction: function(){
  1874. this.configActionNode = new Element("div", {
  1875. "styles": this.layout.css.configActionNode,
  1876. "title": MWF.LP.desktop.configAction
  1877. }).inject(this.node);
  1878. this.configActionNode.addEvent("click", function(){
  1879. alert("show config");
  1880. });
  1881. },
  1882. loadSeparate : function(cssfloat){
  1883. var separateNode = new Element("div.separateNode", {
  1884. "styles": this.layout.css.separateNode
  1885. }).inject(this.node);
  1886. if (cssfloat) separateNode.setStyle("float",cssfloat);
  1887. },
  1888. loadTaskbar: function(){
  1889. this.taskbar = new Element("div", {
  1890. "styles": this.layout.css.taskbar
  1891. }).inject(this.node);
  1892. },
  1893. loadUserChat: function(){
  1894. this.userChatNode = new Element("div", {
  1895. "styles": this.layout.css.userChatNode,
  1896. "title": MWF.LP.desktop.userChat
  1897. }).inject(this.node);
  1898. this.userChatNode.addEvents({
  1899. "mouseover": function(){if (this.layout.css.userChatNode_over) this.userChatNode.setStyles(this.layout.css.userChatNode_over);}.bind(this),
  1900. "mouseout": function(){this.userChatNode.setStyles(this.layout.css.userChatNode);}.bind(this)
  1901. });
  1902. this.userChatNode.addEvent("click", function(e){
  1903. this.userConfig();
  1904. return false;
  1905. if (!this.socket || this.layout.socket.webSocket.readyState != 1) {
  1906. this.layout.socket = new MWF.xDesktop.WebSocket();
  1907. }
  1908. this.layout.openApplication(e, "IM");
  1909. var widget = this.layout.widgets["IMIMWidget"];
  1910. if (widget){
  1911. if (widget.unreadNode){
  1912. var chat = this.layout.apps["Chat"];
  1913. if (chat){
  1914. Object.each(widget.unShowMessage, function(v, k){
  1915. if (v.length){
  1916. var dialogue = chat.dialogues[k];
  1917. if (!dialogue){
  1918. widget.getPerson(v[0].from, function(){
  1919. dialogue = chat.addDialogue(widget.owner, [widget.users[v[0].from]]);
  1920. }.bind(this));
  1921. }
  1922. }
  1923. //if (!dialogue) dialogue = chat.addDialogue(widget.owner, [this.data]);
  1924. }.bind(this));
  1925. //var key = this.data.name+layout.desktop.session.user.name;
  1926. //
  1927. //dialogue.setCurrent();
  1928. // this.clearUnread();
  1929. }
  1930. var _self = this;
  1931. layout.desktop.openApplication(e, "Chat", {
  1932. "onPostLoad": function(){
  1933. Object.each(widget.unShowMessage, function(v, k){
  1934. if (v.length){
  1935. widget.getPerson(v[0].from, function(){
  1936. dialogue = this.addDialogue(widget.owner, [widget.users[v[0].from]]);
  1937. }.bind(this));
  1938. }
  1939. }.bind(this));
  1940. }
  1941. });
  1942. }
  1943. }
  1944. }.bind(this));
  1945. //// this.userActionNode.addEvent("click", function(){
  1946. //// alert("show user infor");
  1947. //// });
  1948. //
  1949. // this.userMenu = new MWF.xDesktop.Menu(this.userActionNode, {
  1950. // "event": "click",
  1951. // "style": "desktopUser",
  1952. // "offsetX": -10,
  1953. // "offsetY": 10
  1954. // });
  1955. // this.userMenu.load();
  1956. // var img = MWF.defaultPath+"/xDesktop/$Layout/"+this.layout.options.style+"/usermenu/config.png";
  1957. // this.userMenu.addMenuItem(MWF.LP.desktop.userConfig, "click", function(e){this.userConfig(e);}.bind(this), img);
  1958. //
  1959. // this.userMenu.addMenuLine();
  1960. //
  1961. // img = MWF.defaultPath+"/xDesktop/$Layout/"+this.layout.options.style+"/usermenu/logout.png";
  1962. // this.userMenu.addMenuItem(MWF.LP.desktop.logout, "click", function(){this.logout();}.bind(this), img);
  1963. //this.userPanel = new MWF.xDesktop.UserPanel(this.layout.desktopNode, {"style": this.layout.options.style});
  1964. //this.userPanel.desktop = this.layout;
  1965. //this.userPanel.load();
  1966. //this.userChatNode.addEvent("click", function(){
  1967. // if (this.layout.socket.webSocket.readyState != 1) {
  1968. // this.layout.socket = new MWF.xDesktop.WebSocket();
  1969. // }
  1970. // this.userPanel.show();
  1971. //}.bind(this));
  1972. },
  1973. userConfig: function(e){
  1974. this.layout.openApplication(e, "Profile");
  1975. },
  1976. logout: function(){
  1977. this.layout.isLogout = true;
  1978. if (!this.notRecordStatus){
  1979. this.layout.recordDesktopStatus(function(){
  1980. this.authentication.logout();
  1981. }.bind(this.layout));
  1982. }else{
  1983. this.authentication.logout();
  1984. }
  1985. },
  1986. loadStyleAction: function(){
  1987. this.styleActionNode = new Element("div", {
  1988. "styles": this.layout.css.styleActionNode,
  1989. "title": MWF.LP.desktop.styleAction
  1990. }).inject(this.node);
  1991. this.styleActionNode.addEvents({
  1992. "mouseover": function(){if (this.layout.css.styleActionNode_over) this.styleActionNode.setStyles(this.layout.css.styleActionNode_over);}.bind(this),
  1993. "mouseout": function(){this.styleActionNode.setStyles(this.layout.css.styleActionNode);}.bind(this)
  1994. });
  1995. this.setChangeStyle();
  1996. },
  1997. setChangeStyle: function(){
  1998. if (!this.styleMenu){
  1999. this.styleMenu = new MWF.xDesktop.Menu(this.styleActionNode, {
  2000. "event": "click",
  2001. "style": "desktopStyle",
  2002. "offsetX": -60,
  2003. "offsetY": 10,
  2004. "container": this.layout.node,
  2005. "onQueryShow": function(){
  2006. this.styleMenu.items.each(function(item){
  2007. if (this.layout.options.style==item.styleName){
  2008. item.setDisable(true);
  2009. }else{
  2010. item.setDisable(false);
  2011. }
  2012. }.bind(this));
  2013. //if (this.layout.options.style=="default"){
  2014. // this.styleMenu.items[0].setDisable(true);
  2015. //}else if (this.layout.options.style=="black"){
  2016. // this.styleMenu.items[1].setDisable(true);
  2017. //}else if (this.layout.options.style=="color"){
  2018. // this.styleMenu.items[2].setDisable(true);
  2019. //}else if (this.layout.options.style=="lotus"){
  2020. // this.styleMenu.items[3].setDisable(true);
  2021. //}else if (this.layout.options.style=="crane"){
  2022. // this.styleMenu.items[4].setDisable(true);
  2023. //}else if (this.layout.options.style=="peony"){
  2024. // this.styleMenu.items[5].setDisable(true);
  2025. //}else if (this.layout.options.style=="car"){
  2026. // this.styleMenu.items[6].setDisable(true);
  2027. //}
  2028. }.bind(this)
  2029. });
  2030. this.styleMenu.load();
  2031. MWF.UD.getPublicData("indexThemes", function(themesJson){
  2032. MWF.getJSON(this.layout.path+"styles.json", function(json){
  2033. json.each(function(style){
  2034. if (!themesJson || themesJson.indexOf(style.style)!=-1){
  2035. var img = MWF.defaultPath+"/xDesktop/$Layout/"+style.style+"/preview.jpg";
  2036. var memuItem = this.styleMenu.addMenuItem(style.title, "click", function(){this.changeLayoutStyle(style.style);}.bind(this), img);
  2037. memuItem.styleName = style.style
  2038. }
  2039. }.bind(this));
  2040. }.bind(this));
  2041. MWF.UD.getPublicData("indexStyleList", function(json){
  2042. this.indexStyleList = json;
  2043. if (!this.indexStyleList) this.indexStyleList = {"styleList": []};
  2044. this.indexStyleList.styleList.each(function(style){
  2045. if (style.enabled){
  2046. //MWF.UD.getPublicData(style.id, function(styleData){
  2047. // var img = styleData.data.desktop.desktop.background;
  2048. var img = style.preview;
  2049. //img = img.substr(4, img.length-1);
  2050. var memuItem = this.styleMenu.addMenuItem(style.title, "click", function(){this.changeLayoutStyle(style.id, true);}.bind(this), img);
  2051. memuItem.styleName = style.id
  2052. //}.bind(this), false);
  2053. }
  2054. }.bind(this));
  2055. }.bind(this));
  2056. }.bind(this));
  2057. //var img = MWF.defaultPath+"/xDesktop/$Layout/default/preview.jpg";
  2058. //this.styleMenu.addMenuItem(MWF.LP.desktop.styleMenu["default"], "click", function(){this.changeLayoutStyle("default");}.bind(this), img);
  2059. //
  2060. //img = MWF.defaultPath+"/xDesktop/$Layout/black/preview.jpg";
  2061. //this.styleMenu.addMenuItem(MWF.LP.desktop.styleMenu.black, "click", function(){this.changeLayoutStyle("black");}.bind(this), img);
  2062. //
  2063. //img = MWF.defaultPath+"/xDesktop/$Layout/color/preview.jpg";
  2064. //this.styleMenu.addMenuItem(MWF.LP.desktop.styleMenu.color, "click", function(){this.changeLayoutStyle("color");}.bind(this), img);
  2065. //
  2066. //img = MWF.defaultPath+"/xDesktop/$Layout/lotus/preview.jpg";
  2067. //this.styleMenu.addMenuItem(MWF.LP.desktop.styleMenu.lotus, "click", function(){this.changeLayoutStyle("lotus");}.bind(this), img);
  2068. //
  2069. //img = MWF.defaultPath+"/xDesktop/$Layout/crane/preview.jpg";
  2070. //this.styleMenu.addMenuItem(MWF.LP.desktop.styleMenu.crane, "click", function(){this.changeLayoutStyle("crane");}.bind(this), img);
  2071. //
  2072. //img = MWF.defaultPath+"/xDesktop/$Layout/peony/preview.jpg";
  2073. //this.styleMenu.addMenuItem(MWF.LP.desktop.styleMenu.peony, "click", function(){this.changeLayoutStyle("peony");}.bind(this), img);
  2074. //
  2075. //img = MWF.defaultPath+"/xDesktop/$Layout/car/preview.jpg";
  2076. //this.styleMenu.addMenuItem(MWF.LP.desktop.styleMenu.car, "click", function(){this.changeLayoutStyle("car");}.bind(this), img);
  2077. }
  2078. },
  2079. changeLayoutStyle: function(style, isCustom){
  2080. MWF.UD.deleteData("layoutDesktop", function(){
  2081. this.layout.changStyle(style, isCustom);
  2082. }.bind(this));
  2083. },
  2084. loadMessageAction: function(){
  2085. this.messageActionNode = new Element("div", {
  2086. "styles": this.layout.css.messageActionNode,
  2087. "title": MWF.LP.desktop.showMessage
  2088. }).inject(this.node);
  2089. this.messageActionNode.addEvents({
  2090. "mouseover": function(){if (this.layout.css.messageActionNode_over) this.messageActionNode.setStyles(this.layout.css.messageActionNode_over);}.bind(this),
  2091. "mouseout": function(){this.messageActionNode.setStyles(this.layout.css.messageActionNode);}.bind(this)
  2092. });
  2093. this.layout.message = new MWF.xDesktop.Message(this.layout);
  2094. this.layout.message.load();
  2095. this.messageActionNode.addEvent("click", function(){
  2096. this.showDesktopMessage();
  2097. }.bind(this));
  2098. },
  2099. showDesktopMessage: function(){
  2100. if (!this.layout.message.isShow){
  2101. // this.layout.message.addMessage({
  2102. // "subject": "测试消息",
  2103. // "content": "这是一个测试消息,看看效果,看看效果,看看效果,看看效果,看看效果,看看效果,看看效果,看看效果,看看效果,看看效果,看看效果,看看效果,看看效果,看看效果,看看效果,看看效果"
  2104. // });
  2105. this.layout.message.show();
  2106. }
  2107. },
  2108. loadUserMenu: function(){
  2109. this.userMenuNode = new Element("div", {
  2110. "styles": this.layout.css.userMenuNode,
  2111. "title": MWF.LP.desktop.userMenu
  2112. }).inject(this.node);
  2113. this.userMenuNode.addEvents({
  2114. "mouseover": function(){if (this.layout.css.userMenuNode_over) this.userMenuNode.setStyles(this.layout.css.userMenuNode_over);}.bind(this),
  2115. "mouseout": function(){this.userMenuNode.setStyles(this.layout.css.userMenuNode);}.bind(this)
  2116. });
  2117. this.userMenu = new MWF.xDesktop.Menu(this.userMenuNode, {
  2118. "event": "click",
  2119. "style": "desktopUser",
  2120. "offsetX": -10,
  2121. "offsetY": 10,
  2122. "container": this.layout.node
  2123. });
  2124. this.userMenu.load();
  2125. var img = MWF.defaultPath+"/xDesktop/$Layout/"+this.layout.options.style+"/usermenu/config.png";
  2126. this.userMenu.addMenuItem(MWF.LP.desktop.userConfig, "click", function(e){this.userConfig(e);}.bind(this), img);
  2127. this.userMenu.addMenuLine();
  2128. img = MWF.defaultPath+"/xDesktop/$Layout/"+this.layout.options.style+"/usermenu/logout.png";
  2129. this.userMenu.addMenuItem(MWF.LP.desktop.logout, "click", function(){this.logout();}.bind(this), img);
  2130. },
  2131. loadClock: function(){
  2132. this.clockNode = new Element("div", {
  2133. "styles": this.layout.css.clockNode
  2134. }).inject(this.node);
  2135. this.setTime();
  2136. },
  2137. setTime: function(){
  2138. var now = new Date();
  2139. var ms = 1000-now.getMilliseconds();
  2140. var ss = 60-now.getSeconds();
  2141. var d = now.format("%Y/%m/%d#%H:%M");
  2142. dl = d.split("#");
  2143. this.clockNode.set("html", dl[1]+"<br/>"+dl[0]);
  2144. window.setTimeout(this.setTime.bind(this), ss*1000+ms);
  2145. },
  2146. changStyle: function(){
  2147. if (this.loadMenuAction) this.loadMenuAction.setStyles(this.layout.css.loadMenuAction);
  2148. if (this.configActionNode) this.configActionNode.setStyles(this.layout.css.configActionNode);
  2149. var separateNodeStyle = this.layout.css.separateNode;
  2150. delete separateNodeStyle['float'];
  2151. this.node.getElements(".separateNode").setStyles(separateNodeStyle);
  2152. if (this.userChatNode) this.userChatNode.setStyles(this.layout.css.userChatNode);
  2153. if (this.styleActionNode) this.styleActionNode.setStyles(this.layout.css.styleActionNode);
  2154. if (this.messageActionNode) this.messageActionNode.setStyles(this.layout.css.messageActionNode);
  2155. if (this.clockNode) this.clockNode.setStyles(this.layout.css.clockNode);
  2156. if (this.userMenuNode) this.userMenuNode.setStyles(this.layout.css.userMenuNode);
  2157. if (this.styleActionNode) this.styleActionNode.setStyles(this.layout.css.styleActionNode);
  2158. if (this.userActionNode) this.userActionNode.setStyles(this.layout.css.userActionNode);
  2159. if (this.taskbar) this.taskbar.setStyles(this.layout.css.taskbar);
  2160. if (this.userPanel) this.userPanel.changStyle(this.layout.options.style);
  2161. }
  2162. });
  2163. MWF.xDesktop.Layout.Navi = new Class({
  2164. initialize: function(node, layout){
  2165. this.layout = layout;
  2166. this.node = $(node);
  2167. this.navis = [];
  2168. },
  2169. load: function(){
  2170. this.createNaviArea();
  2171. this.loadNavis();
  2172. },
  2173. createNaviArea: function(){
  2174. this.naviNodeBottomArea = new Element("div", {
  2175. "styles": this.layout.css.naviNodeBottomArea
  2176. }).inject(this.node);
  2177. this.naviNodeArea = new Element("div", {
  2178. "styles": this.layout.css.naviNodeArea
  2179. }).inject(this.node);
  2180. //this.editButton = new Element("div", {
  2181. // "styles": this.layout.css.naviEditButton
  2182. //}).inject(this.naviNodeArea);
  2183. //
  2184. //this.naviNodeArea.addEvents({
  2185. // "mouseover": function(){ this.editButton.fade("in");}.bind(this),
  2186. // "mouseout": function(){ this.editButton.fade("out");}.bind(this)
  2187. //});
  2188. //
  2189. //this.editButton.addEvent("click", function(){
  2190. // this.editQuickNavi();
  2191. //}.bind(this));
  2192. },
  2193. editQuickNavi: function(){
  2194. },
  2195. loadNavis: function(){
  2196. MWF.getJSON(this.layout.path+"quickStart.json", function(json){
  2197. json.navi.each(function(navi){
  2198. this.navis.push(this.createNaviNode(navi));
  2199. }.bind(this));
  2200. }.bind(this));
  2201. },
  2202. createNaviNode: function(navi){
  2203. var node = new Element("div", {
  2204. "styles": this.layout.css.mainNaviNode
  2205. }).inject(this.naviNodeArea);
  2206. node.store("navi", navi);
  2207. var iconNode = new Element("div", {
  2208. "styles": this.layout.css.mainNaviIconNode
  2209. }).inject(node);
  2210. iconNode.setStyle("background-image", "url("+MWF.defaultPath+"/xDesktop/$Layout/"+this.layout.options.style+"/navi/"+navi.icon+")");
  2211. new Element("div", {
  2212. "styles": this.layout.css.mainNaviTextNode,
  2213. "text": navi.title
  2214. }).inject(node);
  2215. var _self = this;
  2216. node.addEvents({
  2217. "mouseover": function(){
  2218. var navi = this.retrieve("navi");
  2219. this.setStyle("background", "#CCC");
  2220. var icon = navi.icon.replace(".", "_over.");
  2221. this.getFirst("div").setStyle("background-image", "url("+MWF.defaultPath+"/xDesktop/$Layout/"+_self.layout.options.style+"/navi/"+icon+")");
  2222. this.getLast("div").setStyle("color", "#444");
  2223. },
  2224. "mouseout": function(){
  2225. this.setStyle("background", "transparent");
  2226. var navi = this.retrieve("navi");
  2227. this.setStyle("background", "transparent");
  2228. this.getFirst("div").setStyle("background-image", "url("+MWF.defaultPath+"/xDesktop/$Layout/"+_self.layout.options.style+"/navi/"+navi.icon+")");
  2229. this.getLast("div").setStyle("color", "#FFF");
  2230. },
  2231. "mousedown": function(){
  2232. this.setStyle("background", "#FFF");
  2233. },
  2234. "mouseup": function(){
  2235. this.setStyle("background", "#CCC");
  2236. },
  2237. "click": function(e){
  2238. var navi = this.retrieve("navi");
  2239. _self.layout.openApplication(e,navi.action);
  2240. }
  2241. });
  2242. return node;
  2243. },
  2244. changStyle: function(){
  2245. if (this.naviNodeBottomArea) this.naviNodeBottomArea.setStyles(this.layout.css.naviNodeBottomArea);
  2246. if (this.naviNodeArea) this.naviNodeArea.setStyles(this.layout.css.naviNodeArea);
  2247. this.navis.each(function(nv){
  2248. nv.setStyles(this.layout.css.mainNaviNode);
  2249. nv.getFirst("div").setStyles(this.layout.css.mainNaviIconNode);
  2250. nv.getLast("div").setStyles(this.layout.css.mainNaviTextNode);
  2251. }.bind(this));
  2252. }
  2253. });
  2254. MWF.xDesktop.zIndexPool = {
  2255. zIndex: 100,
  2256. applyZindex: function(){
  2257. var i = this.zIndex;
  2258. this.zIndex = this.zIndex+2;
  2259. return i;
  2260. }
  2261. };