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