Layout.js 101 KB

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