Layout.js 105 KB

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