Layout.js 102 KB

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