Layout.js 102 KB

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