Default.js 78 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986
  1. // o2.require("o2.widget.Common", null, false);
  2. // o2.require("o2.xDesktop.Common", null, false);
  3. // o2.require("o2.xDesktop.Actions.RestActions", null, false);
  4. // o2.require("o2.xDesktop.Authentication", null, false);
  5. o2.xDesktop.Default = new Class({
  6. Implements: [Options, Events],
  7. options: {
  8. "style": "blue",
  9. "index": "Homepage"
  10. },
  11. initialize: function(node, options){
  12. this.setOptions(options);
  13. this.type = "layout";
  14. this.path = o2.session.path+"/xDesktop/$Default/";
  15. this.node = $(node);
  16. this.node.empty();
  17. this.initData();
  18. //this.load();
  19. },
  20. initData: function(){
  21. this.apps = {};
  22. this.appArr = [];
  23. this.appCurrentList = [];
  24. this.lnks = [];
  25. this.currentApp = null;
  26. this.session = {};
  27. this.serviceAddressList = layout.serviceAddressList;
  28. this.centerServer = layout.centerServer;
  29. this.session.user = layout.session.user
  30. this.status = layout.userLayout;
  31. if (this.status && this.status.flatStyle) this.options.style = this.status.flatStyle;
  32. },
  33. load: function(){
  34. this.loadLayout(function(){
  35. this.setEvent();
  36. this.loadDefaultPage();
  37. window.setTimeout(function(){
  38. var iconsPath = this.path+"icons.json";
  39. o2.JSON.get(iconsPath, function(json) {
  40. this.iconsJson = json;
  41. this.loadDefaultLnk();
  42. this.loadStatus();
  43. }.bind(this));
  44. this.openWebSocket();
  45. this.checkTaskBarSize();
  46. this.addEvent("resize", this.checkTaskBarSize.bind(this));
  47. }.bind(this), 0);
  48. this.loadMessageMenu();
  49. this.fireEvent("load");
  50. MWF.require("MWF.xDesktop.shortcut");
  51. }.bind(this));
  52. },
  53. resizeHeight: function(){
  54. var y = this.menuNode.getSize().y;
  55. var y1 = this.startMenuNode.getParent().getSize().y;
  56. var o1 = this.startMenuNode.getParent().getStyles("border-top-width", "margin-top", "padding-top", "border-bottom-width", "margin-bottom", "padding-bottom");
  57. var y2 = this.settingNode.getParent().getSize().y;
  58. var o2 = this.settingNode.getParent().getStyles("border-top-width", "margin-top", "padding-top", "border-bottom-width", "margin-bottom", "padding-bottom");
  59. oy1 = o1["border-top-width"].toInt()+o1["margin-top"].toInt()+o1["padding-top"].toInt()+o1["border-bottom-width"].toInt()+o1["margin-bottom"].toInt()+o1["padding-bottom"].toInt();
  60. oy2 = o2["border-top-width"].toInt()+o2["margin-top"].toInt()+o2["padding-top"].toInt()+o2["border-bottom-width"].toInt()+o2["margin-bottom"].toInt()+o2["padding-bottom"].toInt();
  61. var height = y-y1-y2-oy1-oy2;
  62. this.lnkContentNode.setStyle("height", ""+height+"px");
  63. },
  64. checkTaskBarSize: function(){
  65. window.setTimeout(function(){
  66. var size = this.taskContentAreaNode.getSize();
  67. var contentSize = this.taskContentNode.getSize();
  68. if (size.y<contentSize.y){
  69. this.taskActionUp.show();
  70. this.taskActionDown.show();
  71. }else{
  72. this.taskActionUp.hide();
  73. this.taskActionDown.hide();
  74. }
  75. }.bind(this), 50);
  76. },
  77. checkTaskBarScrollTo: function(app){
  78. var currentApp = app || this.currentApp;
  79. if (currentApp && currentApp.taskitem){
  80. var size = this.taskContentAreaNode.getSize();
  81. var scroll = this.taskContentAreaNode.getScroll();
  82. var scrollSize = this.taskContentAreaNode.getScrollSize();
  83. var p = currentApp.taskitem.node.getPosition(this.taskContentNode);
  84. if (p.y!=scroll.y){
  85. var scrollTo = p.y;
  86. if (scrollTo<scrollSize.y-size.y){
  87. this.taskActionDown.addClass("icon_down");
  88. this.taskActionDown.removeClass("icon_down_gray");
  89. }else{
  90. this.taskActionDown.removeClass("icon_down");
  91. this.taskActionDown.addClass("icon_down_gray");
  92. }
  93. if (scrollTo<=0){
  94. scrollTo = 0;
  95. this.taskActionUp.removeClass("icon_up");
  96. this.taskActionUp.addClass("icon_up_gray");
  97. }else{
  98. this.taskActionUp.addClass("icon_up");
  99. this.taskActionUp.removeClass("icon_up_gray");
  100. }
  101. this.taskContentAreaNode.scrollTo(0, p.y);
  102. }
  103. }
  104. },
  105. toolbarUp: function(){
  106. var size = this.taskContentAreaNode.getSize();
  107. var scroll = this.taskContentAreaNode.getScroll();
  108. var scrollSize = this.taskContentAreaNode.getScrollSize();
  109. var scrollTo = scroll.y-size.y;
  110. if (scrollTo<scrollSize.y-size.y){
  111. this.taskActionDown.addClass("icon_down");
  112. this.taskActionDown.removeClass("icon_down_gray");
  113. }
  114. if (scrollTo<=0){
  115. scrollTo = 0;
  116. this.taskActionUp.removeClass("icon_up");
  117. this.taskActionUp.addClass("icon_up_gray");
  118. }
  119. this.taskContentAreaNode.scrollTo(0,scrollTo);
  120. },
  121. toolbarDown: function(){
  122. var size = this.taskContentAreaNode.getSize();
  123. var scroll = this.taskContentAreaNode.getScroll();
  124. var scrollSize = this.taskContentAreaNode.getScrollSize();
  125. var scrollTo = scroll.y+size.y;
  126. if (scrollTo+size.y>=scrollSize.y){
  127. scrollTo=scrollSize.y-size.y;
  128. this.taskActionDown.removeClass("icon_down");
  129. this.taskActionDown.addClass("icon_down_gray");
  130. }
  131. if (scrollTo>0){
  132. this.taskActionUp.addClass("icon_up");
  133. this.taskActionUp.removeClass("icon_up_gray");
  134. }
  135. this.taskContentAreaNode.scrollTo(0, scrollTo);
  136. },
  137. loadLayout: function(callback){
  138. this.session.user.iconUrl = o2.Actions.get("x_organization_assemble_control").getPersonIcon(this.session.user.id);
  139. var css = this.path+this.options.style+ ((o2.session.isMobile || layout.mobile) ? "/style-mobile.css" : "/style-pc.css");
  140. var skinCss = this.path+this.options.style+ "/style-skin.css";
  141. var html = this.path+this.options.style+((o2.session.isMobile || layout.mobile) ? "/layout-mobile.html" : "/layout-pc.html");
  142. this.node.loadAll({ "css": [css], "html": [html]}, {"bind": {"user": this.session.user}, "module": this},function(){
  143. this.node.loadCss(skinCss);
  144. if (callback) callback();
  145. // this.node.load(html, {
  146. // "bind": {"user": this.session.user}
  147. // }, function(){});
  148. }.bind(this));
  149. },
  150. setEvent: function(){
  151. this.loadSkinMenu();
  152. this.loadUserMenu();
  153. window.onbeforeunload = function(e){
  154. if (!this.isLogout){
  155. if (!this.notRecordStatus) this.recordDesktopStatus();
  156. this.closeWebSocket();
  157. //if (this.socket && this.socket.webSocket) this.socket.close();
  158. this.fireEvent("unload");
  159. e = e || window.event;
  160. e.returnValue = o2.LP.desktop.notice.unload;
  161. return o2.LP.desktop.notice.unload;
  162. }
  163. }.bind(this);
  164. $(window).addEvent("resize", function(){
  165. this.fireEvent("resize");
  166. }.bind(this));
  167. this.resizeHeight();
  168. this.addEvent("resize", this.resizeHeight.bind(this));
  169. o2.require("o2.widget.ScrollBar", function(){
  170. this.appScrollBar = new o2.widget.ScrollBar(this.lnkContentNode, {
  171. "style":"hide", "where": "before", "indent": true, "distance": 100, "friction": 0, "axis": {"x": false, "y": true}
  172. });
  173. }.bind(this));
  174. },
  175. loadDefaultPage: function(){
  176. //默认载入首页
  177. if (layout.config.indexPage && layout.config.indexPage.enable && layout.config.indexPage.portal){
  178. appId = "portal.Portal"+layout.config.indexPage.portal;
  179. this.options.index = appId;
  180. var options = {"portalId": layout.config.indexPage.portal, "pageId": layout.config.indexPage.page, "appId": appId};
  181. layout.openApplication(null, "portal.Portal", options);
  182. }else{
  183. layout.openApplication(null, "Homepage");
  184. }
  185. },
  186. loadDefaultLnk: function(){
  187. if (this.status && this.status.flatLnks && this.status.flatLnks.length){
  188. }else{
  189. o2.JSON.get(this.path+"defaultLnk.json", function(defaultLnk){
  190. defaultLnk.each(function(lnkJson){
  191. this.addLnk(lnkJson);
  192. }.bind(this));
  193. }.bind(this));
  194. }
  195. },
  196. loadStatus: function(){
  197. if (this.status){
  198. var keys = Object.keys(this.status.apps);
  199. if (this.status.apps && keys.length){
  200. if (this.status.currentApp == "Note"){
  201. var idx = keys.length-1;
  202. while (idx>-1 && keys[idx]=="Note") idx--;
  203. this.status.currentApp = (idx>-1) ? this.status.apps[keys[idx]].appId : "";
  204. }
  205. var currentTaskitem = null;
  206. Object.each(this.status.apps, function(appStatus, id){
  207. var app = {
  208. "options": appStatus,
  209. "close": function(){
  210. this.taskitem.destroy();
  211. },
  212. "setCurrent": function(){
  213. this.taskitem.textNode.click();
  214. }
  215. };
  216. taskitem = layout.desktop.createTaskItem(app);
  217. app.taskitem = taskitem;
  218. this.apps[appStatus.appId] = app;
  219. if ((this.status.currentApp === appStatus.appId)) currentTaskitem=taskitem;
  220. }.bind(this));
  221. if (currentTaskitem) {
  222. currentTaskitem.textNode.click();
  223. }
  224. }
  225. if (this.status.widgets){/* nothing to do */}
  226. if (this.status.flatLnks && this.status.flatLnks.length){
  227. this.status.flatLnks.each(function(lnkJson){
  228. this.addLnk(lnkJson);
  229. }.bind(this));
  230. }
  231. }
  232. },
  233. addLnk: function(lnkData, targetLnk, position){
  234. var lnk = new o2.xDesktop.Default.Lnk(this, lnkData, targetLnk, position);
  235. if (targetLnk){
  236. var idx = this.lnks.indexOf(targetLnk);
  237. if (position=="before"){
  238. this.lnks.splice(idx, 0, lnk);
  239. }else{
  240. this.lnks.splice(idx+1, 0, lnk);
  241. }
  242. }else{
  243. this.lnks.push(lnk);
  244. }
  245. },
  246. openWebSocket: function(){
  247. MWF.require("MWF.xDesktop.WebSocket", function(){
  248. this.socket = new MWF.xDesktop.WebSocket();
  249. }.bind(this));
  250. },
  251. closeWebSocket: function(){
  252. if (this.socket) this.socket.close();
  253. },
  254. //******* begin page skin ****************************************************
  255. loadSkinMenu: function(){
  256. if (!this.styleMenu){
  257. this.styleMenu = new o2.xDesktop.Menu(this.skinActionNode, {
  258. "event": "click", "style": "flatStyle", "offsetX": -10, "offsetY": 26, "container": this.node,
  259. "onQueryShow": this.showSkinMenu.bind(this),
  260. "onQueryHide": function(){
  261. this.skinActionNode.removeClass("icon_skin_focus");
  262. this.skinActionNode.removeClass("mainColor_bg");
  263. }.bind(this)
  264. });
  265. this.styleMenu.load();
  266. this.loadSkinMenuItems();
  267. }
  268. },
  269. showSkinMenu: function(){
  270. this.styleMenu.items.each(function(item){
  271. if (this.options.style==item.styleName){
  272. item.setDisable(true);
  273. if (item.text) item.text.setStyles({ "background": "url("+this.path+this.options.style+"/icons/icon_gouxuan.png) right center no-repeat" });
  274. }else{
  275. item.setDisable(false);
  276. if (item.text) item.text.setStyles({ "background": "transparent" });
  277. }
  278. }.bind(this));
  279. this.skinActionNode.addClass("icon_skin_focus");
  280. this.skinActionNode.addClass("mainColor_bg");
  281. },
  282. loadSkinMenuItems: function(){
  283. o2.JSON.get(this.path+"styles.json", function(json){
  284. json.each(function(style){
  285. var color = style.color;
  286. var memuItem = this.styleMenu.addMenuItem(style.title, "click", function(){this.changeLayoutSkin(style.style);}.bind(this));
  287. memuItem.styleName = style.style;
  288. var imgDiv = memuItem.item.getFirst();
  289. var imgNode = new Element("div", {"styles": memuItem.menu.css.menuItemImg}).inject(imgDiv);
  290. imgNode.setStyle("background-color", color);
  291. }.bind(this));
  292. this.styleMenu.addMenuLine();
  293. var img = o2.defaultPath+"/xDesktop/$Layout/default/preview.jpg";
  294. var memuItem = this.styleMenu.addMenuItem(o2.LP.desktop_style, "click", function(e){this.changeToDesktopStyle(e);}.bind(this), img);
  295. memuItem.styleName = "desktop";
  296. }.bind(this));
  297. },
  298. changeLayoutSkin: function(style){
  299. var skinCss = this.path+this.options.style+ "/style-skin.css";
  300. o2.removeCss(skinCss);
  301. this.options.style = style;
  302. skinCss = this.path+this.options.style+"/style-skin.css";
  303. this.node.loadCss(skinCss);
  304. },
  305. changeToDesktopStyle: function(e){
  306. //MWF.xDesktop.confirm("infor", e, o2.LP.desktop.changeViewTitle, {"html": o2.LP.desktop.changeView}, 500, 100, function(){
  307. // this.close();
  308. var uri = new URI(window.location.href);
  309. uri.setData("view", "layout");
  310. uri.go();
  311. // }, function(){
  312. // this.close();
  313. // }, null, null, "o2"
  314. // );
  315. },
  316. //******* end page skin ****************************************************
  317. //******* begin user menu ****************************************************
  318. loadUserMenu: function(){
  319. if (!this.userMenu){
  320. this.userMenu = new o2.xDesktop.Menu(this.userInforNode, {
  321. "event": "click", "style": "flatUser", "offsetX": 30, "offsetY":6, "container": this.node
  322. // "onQueryShow": this.showSkinMenu.bind(this),
  323. // "onQueryHide": function(){
  324. // this.skinActionNode.removeClass("icon_skin_focus");
  325. // this.skinActionNode.removeClass("mainColor_bg");
  326. // }.bind(this),
  327. });
  328. this.userMenu.load();
  329. this.loadUserMenuItems();
  330. }
  331. },
  332. loadUserMenuItems: function(){
  333. var img = this.path+this.options.style+"/icons/config.png";
  334. this.userMenu.addMenuItem(o2.LP.desktop.userConfig, "click", function(e){this.userConfig(e);}.bind(this), img);
  335. this.userMenu.addMenuLine();
  336. img = this.path+this.options.style+"/icons/logout.png";
  337. this.userMenu.addMenuItem(o2.LP.desktop.logout, "click", function(){this.logout();}.bind(this), img);
  338. },
  339. userConfig: function(e){
  340. layout.openApplication(e, "Profile");
  341. },
  342. logout: function(){
  343. this.isLogout = true;
  344. if (!this.notRecordStatus){
  345. this.recordDesktopStatus(function(){
  346. (layout.authentication || new o2.xDesktop.Authentication()).logout();
  347. }.bind(this.layout));
  348. }else{
  349. (layout.authentication || new o2.xDesktop.Authentication()).logout();
  350. }
  351. },
  352. //******* end user menu ****************************************************
  353. //******* begin search *****************************************************
  354. focusSearch: function(){
  355. this.searchBoxNode.addClass("layout_content_taskbar_area_search_box_focus");
  356. this.searchBoxNode.addClass("mainColor_border");
  357. this.searchIconNode.addClass("icon_search_focus");
  358. },
  359. blurSearch: function(){
  360. this.searchBoxNode.removeClass("layout_content_taskbar_area_search_box_focus");
  361. this.searchBoxNode.removeClass("mainColor_border");
  362. this.searchIconNode.removeClass("icon_search_focus");
  363. },
  364. searchInputKeyDown: function(e){
  365. if (this.searchInputNode.get("value")){
  366. this.searchClearNode.addClass("icon_clear");
  367. }else{
  368. this.searchClearNode.removeClass("icon_clear");
  369. }
  370. if (e.keyCode===13) this.doSearch();
  371. },
  372. clearSearch: function(){
  373. this.searchInputNode.set("value", "");
  374. this.searchClearNode.removeClass("icon_clear");
  375. this.clearSearchResult();
  376. },
  377. doSearch: function(){
  378. var key = this.searchInputNode.get("value");
  379. if (key){
  380. if (this.apps["Search"]){
  381. this.apps["Search"].input.setValue(key);
  382. this.apps["Search"].input.doSearch();
  383. }
  384. layout.openApplication(null,"Search", {"key": key});
  385. }
  386. },
  387. clearSearchResult: function(){
  388. //alert("clear search result");
  389. // @todo
  390. },
  391. //******* end search*******************************************************
  392. //******* begin record status *********************************************
  393. recordDesktopStatus: function(callback){
  394. Object.each(this.apps, function(app, id){
  395. if (!app.options.desktopReload){
  396. this.closeApp(app);
  397. }
  398. }.bind(this));
  399. var status = this.getLayoutStatusData();
  400. o2.UD.putData("layout", status, function(){
  401. if (callback) callback();
  402. });
  403. },
  404. getLayoutStatusData: function(){
  405. var status = {
  406. "viewMode": "Default",
  407. "style": this.status.style,
  408. "flatStyle": this.options.style,
  409. "styleType": this.status.styleType || "",
  410. "currentApp": (this.currentApp) ? this.currentApp.appId : "Homepage",
  411. "apps": {},
  412. "lnks": (this.status.lnks && o2.typeOf(this.status.lnks)==="array") ? this.status.lnks : [],
  413. //"lnks": [],
  414. "flatLnks": [],
  415. "widgets": {}
  416. };
  417. // this.appArr.each(function(app){
  418. // if (app.options.appId!==this.options.index){
  419. // var appStatus = this.getAppStatusData(app, app.appId);
  420. // if (appStatus) status.apps[id] = appStatus;
  421. // }
  422. // }.bind(this));
  423. Object.each(this.apps, function(app, id){
  424. if (app.options.appId!==this.options.index){
  425. var appStatus = this.getAppStatusData(app, id);
  426. if (appStatus) status.apps[id] = appStatus;
  427. }
  428. }.bind(this));
  429. this.lnks.each(function(lnk){
  430. status.flatLnks.push(lnk.data);
  431. //status.flatLnks.push({"icon": lnk.icon, "color": lnk.color, "title": lnk.title,"par": lnk.par});
  432. });
  433. Object.each(this.widgets, function(widget, id){
  434. var widgetStatus = this.getWidgetStatusData(widget, id);
  435. if (widgetStatus) status.widgets[id] = widgetStatus;
  436. }.bind(this));
  437. return status;
  438. },
  439. getAppStatusData: function(app, id){
  440. var appStatus = null;
  441. if (app.window){
  442. if (app.options.desktopReload){
  443. appStatus ={
  444. "appId": app.appId,
  445. "name": app.options.name,
  446. "style": app.options.style,
  447. "title": app.options.title,
  448. "window": {
  449. // //"size": app.window.node.getSize(),
  450. // "size": {"x": app.window.css.to.width.toFloat(), "y": app.window.css.to.height.toFloat()},
  451. // "position": {"x": app.window.css.to.left.toFloat(), "y": app.window.css.to.top.toFloat()},
  452. // "isMax": app.window.isMax,
  453. // "isHide": app.window.isHide,
  454. // "style": app.window.options.style
  455. },
  456. "app": null
  457. };
  458. if (app.recordStatus) appStatus.app = app.recordStatus();
  459. }
  460. }else{
  461. if (app.options){
  462. appStatus = app.options;
  463. }
  464. }
  465. return appStatus;
  466. },
  467. getWidgetStatusData: function(widget, id){
  468. var widgetStatus ={
  469. "name": widget.options.name,
  470. "appName": widget.options.appName,
  471. "position": widget.options.position,
  472. "widget": null
  473. };
  474. if (widget.recordStatus) widgetStatus.widget = widget.recordStatus();
  475. return widgetStatus;
  476. },
  477. //******* end record status ***********************************************
  478. //******* begin start menu ************************************************
  479. showStartMenu: function(){
  480. this.loadStartMenu(function(){
  481. if (!this.startMenu.isShow){
  482. this.startMenuNode.addClass("overColor_bg");
  483. this.startMenu.show();
  484. }
  485. }.bind(this));
  486. },
  487. loadStartMenu: function(callback){
  488. if (!this.startMenu){
  489. this.startMenu = new o2.xDesktop.Default.StartMenu(this);
  490. this.startMenu.addEvents({
  491. "onHide": function(){
  492. this.startMenuNode.removeClass("overColor_bg");
  493. }.bind(this),
  494. "onLoad": function(){
  495. if (callback) callback();
  496. }
  497. });
  498. this.startMenu.load();
  499. }else{
  500. if (this.startMenu.isLoaded) if (callback) callback();
  501. }
  502. },
  503. //******* end start menu **************************************************
  504. //******* begin message menu **********************************************
  505. showDesktopMessage: function(){
  506. if (!this.message){
  507. this.loadMessageMenu(function(){
  508. this.showMessage();
  509. }.bind(this));
  510. }else{
  511. this.showMessage();
  512. }
  513. },
  514. loadMessageMenu: function(callback){
  515. o2.require("o2.xDesktop.MessageV2", function(){
  516. this.message = new o2.xDesktop.MessageV2(this);
  517. this.message.addEvents({
  518. "onLoad": function(){ if (callback) callback(); }.bind(this),
  519. "onHide": function(){
  520. this.msgActionNode.removeClass("icon_msg_focus");
  521. this.msgActionNode.removeClass("mainColor_bg");
  522. }.bind(this),
  523. });
  524. this.message.load();
  525. }.bind(this));
  526. },
  527. showMessage: function(){
  528. if (!this.message.isShow){
  529. this.msgActionNode.addClass("icon_msg_focus");
  530. this.msgActionNode.addClass("mainColor_bg");
  531. this.message.show();
  532. }
  533. },
  534. //******* end message menu ************************************************
  535. //******* begin task item *************************************************
  536. createTaskItem: function(app){
  537. return new o2.xDesktop.Default.TaskItem(this, app);
  538. },
  539. //******* end task item ***************************************************
  540. closeApp: function(app, hasTaskitem) {
  541. var appId = app.appId;
  542. this.appCurrentList.erase(app);
  543. this.appArr.erase(app);
  544. this.apps[appId] = null;
  545. delete this.apps[appId];
  546. if (!hasTaskitem){
  547. var i = this.appCurrentList.length;
  548. if (i && this.appCurrentList[i-1]){
  549. this.appCurrentList[i-1].setCurrent();
  550. }else{
  551. var keys = Object.keys(this.apps);
  552. i = keys.length;
  553. if (i && this.apps[keys[i-1]] && this.apps[keys[i-1]].setCurrent){
  554. this.apps[keys[i-1]].setCurrent();
  555. }else{
  556. //if (app.appId!=="Homepage") layout.openApplication(null, "Homepage");
  557. layout.openApplication(null, "Homepage");
  558. }
  559. }
  560. this.checkTaskBarSize();
  561. this.checkTaskBarScrollTo();
  562. }
  563. },
  564. refreshApp:function(app){
  565. if (app.window){
  566. var taskitem = app.taskitem;
  567. var appStatus ={
  568. "id": app.appId,
  569. "name": app.options.name,
  570. "style": app.options.style,
  571. "appId": app.appId
  572. };
  573. var status = (app.recordStatus) ? app.recordStatus() : null;
  574. app.close(true);
  575. layout.openApplication(null, appStatus.name, appStatus, status, false, taskitem);
  576. //this.openApplicationWithStatus(appStatus);
  577. }
  578. },
  579. getPageDesignerStyle: function(callback){
  580. if (!this.pageDesignerStyle){
  581. this.pageDesignerStyle = "default";
  582. MWF.UD.getData("pageDesignerStyle", function(json) {
  583. if (json.data) {
  584. var styles = JSON.decode(json.data);
  585. this.pageDesignerStyle = styles.style;
  586. }
  587. if (callback) callback();
  588. }.bind(this));
  589. }else{
  590. if (callback) callback();
  591. }
  592. },
  593. getFormDesignerStyle: function(callback){
  594. if (!this.formDesignerStyle){
  595. this.formDesignerStyle = "default";
  596. MWF.UD.getData("formDesignerStyle", function(json) {
  597. if (json.data) {
  598. var styles = JSON.decode(json.data);
  599. this.formDesignerStyle = styles.style;
  600. }
  601. if (callback) callback();
  602. }.bind(this));
  603. }else{
  604. if (callback) callback();
  605. }
  606. },
  607. createRefreshNode: function(){
  608. this.refreshNode = new Element("div.layout_refresh_node.icon_refresh").inject(this.desktopNode);
  609. this.refreshNode.set("morph", {
  610. "duration": 100,
  611. "transition": Fx.Transitions.Quart.easeOut
  612. });
  613. this.refreshNode.addEvent("click", function(){
  614. if (this.currentApp) this.currentApp.refresh();
  615. this.hideRefresh();
  616. }.bind(this));
  617. },
  618. showRefresh: function(){
  619. if (!this.refreshNodeShow){
  620. if (!this.refreshNode) this.createRefreshNode();
  621. var size = this.taskbarNode.getSize();
  622. var nodeSize = this.refreshNode.getSize();
  623. var top = size.y;
  624. var left = size.x/2-nodeSize.x/2;
  625. this.refreshNode.setStyles({
  626. "left": left,
  627. "top": 0-nodeSize.y,
  628. "opacity": 0
  629. });
  630. this.refreshNode.morph({
  631. "top": top,
  632. "left": left,
  633. "opacity": 0.9
  634. });
  635. this.refreshNodeShow = true;
  636. this.refreshTimeoutId = window.setTimeout(function(){
  637. this.hideRefresh();
  638. }.bind(this), 2000);
  639. }
  640. },
  641. hideRefresh: function(){
  642. if (this.refreshNodeShow){
  643. if (this.refreshNode){
  644. var size = this.taskbarNode.getSize();
  645. var nodeSize = this.refreshNode.getSize();
  646. var top = size.y;
  647. var left = size.x/2-nodeSize.x/2;
  648. this.refreshNode.morph({
  649. "top": 0-nodeSize.y,
  650. "left": left,
  651. "opacity": 0
  652. });
  653. window.setTimeout(function(){
  654. this.refreshNodeShow = false;
  655. }.bind(this), 100);
  656. }
  657. }
  658. if (this.refreshTimeoutId){
  659. window.clearTimeout(this.refreshTimeoutId);
  660. this.refreshTimeoutId = "";
  661. }
  662. }
  663. });
  664. o2.xDesktop.Default.StartMenu = new Class({
  665. Implements: [Events],
  666. initialize: function(layout){
  667. this.layout = layout;
  668. this.container = this.layout.startMenuArea;
  669. this.actionNode = this.layout.startMenuNode;
  670. this.isLoaded = false;
  671. this.isShow = false;
  672. this.isMorph = false;
  673. this.itemTempletedHtml = "" +
  674. " <div class='layout_start_item_iconArea'>" +
  675. " <div class='layout_start_item_icon'></div>" +
  676. " </div>" +
  677. " <div class='layout_start_item_text'></div>"+
  678. " <div class='layout_start_item_badge'></div>";
  679. },
  680. load: function(){
  681. var view = this.layout.path+this.layout.options.style+((o2.session.isMobile || layout.mobile) ? "/layout-menu-mobile.html" : "/layout-menu-pc.html");
  682. this.container.loadHtml(view, {"module": this}, function(){
  683. this.maskNode.setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex());
  684. this.node.setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex());
  685. this.layout.menuNode.setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex());
  686. this.node.addEvent("mousedown", function(e){
  687. e.stopPropagation();
  688. e.preventDefault();
  689. });
  690. this.triangleNode = new Element("div.layout_menu_start_triangle").inject(this.layout.menuNode, "after");
  691. this.hideMessage = function(){ this.hide(); }.bind(this);
  692. this.fireEvent("load");
  693. this.layout.addEvent("resize", this.setSize.bind(this));
  694. this.loadTitle();
  695. this.loadLnks();
  696. this.isLoaded = true;
  697. this.fireEvent("load");
  698. }.bind(this));
  699. },
  700. setScroll: function(){
  701. o2.require("o2.widget.ScrollBar", function(){
  702. this.appScrollBar = new o2.widget.ScrollBar(this.appScrollNode, {
  703. "style":"xDesktop_Message", "where": "before", "indent": false, "distance": 100, "friction": 6, "axis": {"x": false, "y": true}
  704. });
  705. }.bind(this));
  706. },
  707. loadTitle: function(){
  708. this.lnkTitleNode.set("text", o2.LP.desktop.lnkAppTitle);
  709. this.appCategoryTab = new Element("div.layout_start_tab", {"text": o2.LP.desktop.message.application}).inject(this.appTitleNode);
  710. this.processCategoryTab = new Element("div.layout_start_tab", {"text": o2.LP.desktop.message.process}).inject(this.appTitleNode);
  711. this.inforCategoryTab = new Element("div.layout_start_tab", {"text": o2.LP.desktop.message.infor}).inject(this.appTitleNode);
  712. this.queryCategoryTab = new Element("div.layout_start_tab", {"text": o2.LP.desktop.message.query}).inject(this.appTitleNode);
  713. this.searchNode = new Element("div.layout_start_search").inject(this.appTitleNode);
  714. this.searchIconNode = new Element("div.layout_start_search_icon").inject(this.searchNode);
  715. this.searchIconNode.addClass("icon_startMenu_search");
  716. var currentWidth = this.searchNode.getSize().x;
  717. this.searchNode.store("currentWidth", currentWidth);
  718. this.appCategoryTab.addEvent("click", function(){
  719. this.appTitleNode.getElements(".layout_start_tab").removeClass("mainColor_bg");
  720. this.appCategoryTab.addClass("mainColor_bg");
  721. this.currentTab = this.appCategoryTab;
  722. this.loadApplications();
  723. }.bind(this));
  724. this.processCategoryTab.addEvent("click", function(){
  725. this.appTitleNode.getElements(".layout_start_tab").removeClass("mainColor_bg");
  726. this.processCategoryTab.addClass("mainColor_bg");
  727. this.currentTab = this.processCategoryTab;
  728. this.loadProcesses();
  729. }.bind(this));
  730. this.inforCategoryTab.addEvent("click", function(){
  731. this.appTitleNode.getElements(".layout_start_tab").removeClass("mainColor_bg");
  732. this.inforCategoryTab.addClass("mainColor_bg");
  733. this.currentTab = this.inforCategoryTab;
  734. this.loadInfors();
  735. }.bind(this));
  736. this.queryCategoryTab.addEvent("click", function(){
  737. this.appTitleNode.getElements(".layout_start_tab").removeClass("mainColor_bg");
  738. this.queryCategoryTab.addClass("mainColor_bg");
  739. this.currentTab = this.queryCategoryTab;
  740. this.loadQuerys();
  741. }.bind(this));
  742. this.searchIconNode.addEvent("click", this.searchIconAction.bind(this));
  743. },
  744. searchIconAction: function(){
  745. if (!this.isMorph){
  746. if (this.isSearch){
  747. this.doSearch();
  748. }else{
  749. this.loadSearch()
  750. }
  751. }
  752. },
  753. loadSearch: function(){
  754. this.isSearch = true;
  755. this.searchNode.addClass("mainColor_border");
  756. this.appCategoryTab.hide();
  757. this.processCategoryTab.hide();
  758. this.inforCategoryTab.hide();
  759. this.queryCategoryTab.hide();
  760. var size = this.appTitleNode.getSize();
  761. var pr = this.appTitleNode.getStyle("padding-right").toInt() || 0;
  762. var pl = this.appTitleNode.getStyle("padding-left").toInt() || 0;
  763. var margin = this.searchNode.getStyle("margin-right").toInt() || 0;
  764. var w = size.x-margin*2-pr-pl;
  765. this.isMorph = true;
  766. this.searchNode.set("morph", {"duration": 200});
  767. this.searchNode.morph({"width": ""+w+"px"});
  768. window.setTimeout(function(){
  769. this.isMorph = false;
  770. }.bind(this), 220);
  771. if (!this.searchClearNode){
  772. this.searchClearNode = new Element("div.layout_start_search_clear").inject(this.searchNode);
  773. this.searchClearNode.addClass("icon_clear");
  774. this.searchClearNode.addEvent("click", this.hideSearch.bind(this));
  775. }
  776. this.searchClearNode.show();
  777. if (!this.searchAreaNode) this.searchAreaNode = new Element("div.layout_start_search_area").inject(this.searchNode);
  778. this.searchAreaNode.show();
  779. if (!this.searchInputNode){
  780. this.searchInputNode = new Element("input.layout_start_search_input", {"placeholder": o2.LP.searchKey}).inject(this.searchAreaNode);
  781. this.searchInputNode.addEvent("keydown", function(e){
  782. if (e.code==13) this.doSearch();
  783. }.bind(this));
  784. }
  785. this.searchInputNode.show();
  786. this.searchInputNode.focus();
  787. //this.searchNode.addClass("layout_start_search_load");
  788. },
  789. hideSearch: function(){
  790. if (this.isSearch){
  791. if (this.searchInputNode){
  792. this.searchInputNode.set("value", "");
  793. this.searchInputNode.hide();
  794. }
  795. if (this.searchAreaNode) this.searchAreaNode.hide();
  796. if (this.searchClearNode) this.searchClearNode.hide();
  797. this.isMorph = true;
  798. var currentWidth = this.searchNode.retrieve("currentWidth");
  799. this.searchNode.morph({"width": ""+currentWidth+"px"});
  800. window.setTimeout(function(){
  801. if (this.currentTab && this.isSearchResult) this.currentTab.click();
  802. this.searchNode.removeClass("mainColor_border");
  803. this.appCategoryTab.show();
  804. this.processCategoryTab.show();
  805. this.inforCategoryTab.show();
  806. this.queryCategoryTab.show();
  807. this.isSearch = false;
  808. this.isMorph = false;
  809. this.isSearchResult = false;
  810. }.bind(this), 220);
  811. }
  812. },
  813. doSearch: function(){
  814. var key = this.searchInputNode.get("value").toLowerCase();
  815. if (key){
  816. this.isSearchResult = true;
  817. this.appContentNode.empty();
  818. this.searchApplicatins(key);
  819. this.searchProcesses(key);
  820. this.searchInfors(key);
  821. this.searchQuerys(key);
  822. }
  823. },
  824. searchApplicatins: function(value){
  825. var user = this.layout.session.user;
  826. var currentNames = [user.name, user.distinguishedName, user.id, user.unique];
  827. if (user.roleList) currentNames = currentNames.concat(user.roleList);
  828. if (user.groupList) currentNames = currentNames.concat(user.groupList);
  829. if (this.layoutJson && this.layoutJson.length) this.layoutJson.each(function(v){
  830. if ( this.checkMenuItem(v, currentNames) ){
  831. if ((v.title.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.title.toPY().toLowerCase().indexOf(value)!==-1) || (v.title.indexOf(value)!==-1)){
  832. this.createApplicationMenuItem(v);
  833. }
  834. }
  835. }.bind(this));
  836. if (this.componentJson && this.componentJson.length) this.componentJson.each(function(v){
  837. if ( this.checkMenuItem(v, currentNames) ){
  838. if ((v.title.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.title.toPY().toLowerCase().indexOf(value)!==-1) || (v.title.indexOf(value)!==-1)){
  839. this.createApplicationMenuItem(v);
  840. }
  841. }
  842. }.bind(this));
  843. if (this.portalJson && this.portalJson.length) this.portalJson.each(function(v){
  844. if ((v.name.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.name.toPY().toLowerCase().indexOf(value)!==-1) || (v.name.indexOf(value)!==-1)){
  845. this.createPortalMenuItem(v);
  846. }
  847. }.bind(this));
  848. },
  849. searchProcesses: function(value){
  850. if (this.processJson && this.processJson.length) this.processJson.each(function(v){
  851. if ((v.name.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.name.toPY().toLowerCase().indexOf(value)!==-1) || (v.name.indexOf(value)!==-1)){
  852. this.createProcessMenuItem(v);
  853. }
  854. }.bind(this));
  855. },
  856. searchInfors: function(value){
  857. if (this.inforJson && this.inforJson.length) this.inforJson.each(function(v){
  858. if ((v.appName.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.appName.toPY().toLowerCase().indexOf(value)!==-1) || (v.appName.indexOf(value)!==-1)){
  859. this.createInforMenuItem(v);
  860. }
  861. }.bind(this));
  862. },
  863. searchQuerys: function(value){
  864. if (this.queryJson && this.queryJson.length) this.queryJson.each(function(v){
  865. if ((v.appName.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.appName.toPY().toLowerCase().indexOf(value)!==-1) || (v.appName.indexOf(value)!==-1)){
  866. this.createQueryMenuItem(v);
  867. }
  868. }.bind(this));
  869. },
  870. loadJsons: function(callback){
  871. this.clearAppContentNode();
  872. this.loadLayoutApplications(function(json_layout){
  873. var componentAction = o2.Actions.get("x_component_assemble_control");
  874. var portalAction = o2.Actions.get("x_portal_assemble_surface");
  875. var processAction = o2.Actions.get("x_processplatform_assemble_surface");
  876. var inforAction = o2.Actions.get("x_cms_assemble_control");
  877. var queryAction = o2.Actions.get("x_query_assemble_surface");
  878. var iconsPath = this.layout.path+"icons.json";
  879. this.getIconsJson(function(){
  880. o2.Actions.invokeAsync([
  881. {"action": componentAction, "name": "listComponent"},
  882. {"action": portalAction, "name": "listApplication"},
  883. {"action": processAction, "name": "listApplication"},
  884. {"action": inforAction, "name": "listColumn"},
  885. {"action": queryAction, "name": "listQuery"},
  886. ], {"success": function(json_component, json_portal, json_process, json_infor, json_query){
  887. this.layoutJson = json_layout;
  888. this.componentJson = json_component.data;
  889. this.portalJson = json_portal.data;
  890. this.processJson = json_process.data;
  891. this.inforJson = json_infor.data;
  892. this.queryJson = json_query.data;
  893. if (callback) callback();
  894. }.bind(this), "failure": function(){}}
  895. );
  896. }.bind(this));
  897. }.bind(this));
  898. },
  899. getIconsJson: function(callback){
  900. if (this.layout.iconsJson){
  901. if (callback) callback();
  902. }else{
  903. o2.JSON.get(iconsPath, function(json){
  904. this.layout.iconsJson = json;
  905. if (callback) callback();
  906. }.bind(this));
  907. }
  908. },
  909. setPosition: function(){
  910. //var size = this.container.getSize();
  911. var index = o2.xDesktop.zIndexPool.zIndex;
  912. var nodeSize = this.node.getSize();
  913. var left = 0-nodeSize.x;
  914. this.maskNode.setStyles({"left": ""+left+"px"});
  915. this.node.setStyles({"left": ""+left+"px"});
  916. },
  917. setSize: function(){
  918. if (this.appScrollBar && this.appScrollBar.scrollVNode) this.appScrollBar.scrollVNode.setStyle("margin-top", "0px");
  919. var isLnk = false;
  920. if (false && this.layout.lnks && this.layout.lnks.length){
  921. this.lnkAreaNode.show();
  922. this.lineNode.show();
  923. var h = 100*3;
  924. this.lnkScrollNode.setStyle("height", ""+h+"px");
  925. isLnk = true;
  926. }else{
  927. this.lnkAreaNode.hide();
  928. this.lineNode.hide();
  929. }
  930. var size = this.node.getSize();
  931. var lnkSizeY = (isLnk) ? this.lnkAreaNode.getSize().y : 0;
  932. var lineSizeY = (isLnk) ? this.lineNode.getSize().y : 0;
  933. var mt = (isLnk) ? (this.lineNode.getStyle("margin-top").toInt() || 0) : 0;
  934. var mb = (isLnk) ? (this.lineNode.getStyle("margin-bottom").toInt() || 0) : 0;
  935. var titleSize = this.appTitleNode.getSize();
  936. var y = size.y-lnkSizeY-lineSizeY-mt-mb-titleSize.y;
  937. this.appScrollNode.setStyle("height", ""+y+"px");
  938. },
  939. loadLnks: function(){
  940. // if (this.layout.lnks && this.layout.lnks.length){
  941. // this.lnkAreaNode.show();
  942. // this.lineNode.show();
  943. // this.lnkContentNode.empty();
  944. // this.createLnkMenuItem();
  945. // }else{
  946. this.lnkAreaNode.hide();
  947. this.lineNode.hide();
  948. //}
  949. },
  950. createLnkMenuItem: function(){
  951. //this.templetedHtml
  952. },
  953. clearAppContentNode: function(){
  954. this.appContentNode.empty();
  955. this.appContentNode.addClass("icon_loading");
  956. },
  957. loadApplications: function(callback){
  958. this.clearAppContentNode();
  959. // this.loadLayoutApplications(function(json_layout){
  960. // var componentAction = o2.Actions.get("x_component_assemble_control");
  961. // var portalAction = o2.Actions.get("x_portal_assemble_surface");
  962. // o2.Actions.invokeAsync([
  963. // {"action": componentAction, "name": "listComponent"},
  964. // {"action": portalAction, "name": "listApplication"},
  965. // ], {"success": function(json_component, json_portal){
  966. // this.loadApplicationsItem(json_layout, json_component.data, json_portal.data);
  967. // }.bind(this), "failure": function(){}}
  968. // );
  969. // }.bind(this));
  970. this.loadApplicationsItem(this.layoutJson, this.componentJson, this.portalJson);
  971. },
  972. loadLayoutApplications: function(callback){
  973. var url = this.layout.path+"applications.json";
  974. o2.getJSON(url, function(json){
  975. if (callback) callback(json);
  976. }.bind(this));
  977. },
  978. loadApplicationsItem: function(json_layout, json_component, json_portal){
  979. var user = this.layout.session.user;
  980. var currentNames = [user.name, user.distinguishedName, user.id, user.unique];
  981. if (user.roleList) currentNames = currentNames.concat(user.roleList);
  982. if (user.groupList) currentNames = currentNames.concat(user.groupList);
  983. this.appContentNode.removeClass("icon_loading");
  984. if (json_layout && json_layout.length) json_layout.each(function(value){
  985. if ( this.checkMenuItem(value, currentNames) ) this.createApplicationMenuItem(value);
  986. }.bind(this));
  987. if (json_component && json_component.length) json_component.each(function(value){
  988. if ( this.checkMenuItem(value, currentNames) ) this.createApplicationMenuItem(value);
  989. }.bind(this));
  990. if (json_portal && json_portal.length) json_portal.each(function(value){
  991. this.createPortalMenuItem(value);
  992. }.bind(this));
  993. },
  994. loadProcesses: function(){
  995. this.clearAppContentNode();
  996. // o2.Actions.get("x_processplatform_assemble_surface").listApplication(this.loadProcessesItem.bind(this));
  997. this.loadProcessesItem(this.processJson)
  998. },
  999. loadProcessesItem: function(json){
  1000. this.appContentNode.removeClass("icon_loading");
  1001. if (json && json.length) json.each(function(value){
  1002. this.createProcessMenuItem(value);
  1003. }.bind(this));
  1004. },
  1005. loadInfors: function(){
  1006. this.clearAppContentNode();
  1007. //o2.Actions.get("x_cms_assemble_control").listColumn(this.loadInforsItem.bind(this));
  1008. this.loadInforsItem(this.inforJson)
  1009. },
  1010. loadInforsItem: function(json){
  1011. this.appContentNode.removeClass("icon_loading");
  1012. if (json && json.length) json.each(function(value){
  1013. this.createInforMenuItem(value);
  1014. }.bind(this));
  1015. },
  1016. loadQuerys: function(){
  1017. this.clearAppContentNode();
  1018. // o2.Actions.get("x_query_assemble_surface").listQuery(this.loadQuerysItem.bind(this));
  1019. this.loadQuerysItem(this.queryJson)
  1020. },
  1021. loadQuerysItem: function(json){
  1022. this.appContentNode.removeClass("icon_loading");
  1023. if (json && json.length) json.each(function(value){
  1024. this.createQueryMenuItem(value);
  1025. }.bind(this));
  1026. },
  1027. checkMenuItem: function(value, currentNames){
  1028. if (value.visible===false) return false;
  1029. var isAllow = true;
  1030. if (value.allowList) isAllow = (value.allowList.length) ? (value.allowList.isIntersect(currentNames)) : true;
  1031. var isDeny = false;
  1032. if (value.denyList) isDeny = (value.denyList.length) ? (value.denyList.isIntersect(currentNames)!==-1) : false;
  1033. return ((!isDeny && isAllow) || o2.AC.isAdministrator());
  1034. },
  1035. createApplicationMenuItem: function(value){
  1036. new o2.xDesktop.Default.StartMenu.Item(this, this.appContentNode, value)
  1037. },
  1038. createPortalMenuItem: function(value){
  1039. new o2.xDesktop.Default.StartMenu.PortalItem(this, this.appContentNode, value)
  1040. },
  1041. createProcessMenuItem: function(value){
  1042. new o2.xDesktop.Default.StartMenu.ProcessItem(this, this.appContentNode, value)
  1043. },
  1044. createInforMenuItem: function(value){
  1045. new o2.xDesktop.Default.StartMenu.InforItem(this, this.appContentNode, value)
  1046. },
  1047. createQueryMenuItem: function(value){
  1048. new o2.xDesktop.Default.StartMenu.QueryItem(this, this.appContentNode, value)
  1049. },
  1050. show: function(){
  1051. if (!this.isMorph){
  1052. this.isMorph = true;
  1053. if (!this.morph){
  1054. this.maskMorph = new Fx.Morph(this.maskNode, {
  1055. duration: "200",
  1056. transition: Fx.Transitions.Sine.easeOut
  1057. });
  1058. this.morph = new Fx.Morph(this.node, {
  1059. duration: "200",
  1060. transition: Fx.Transitions.Sine.easeOut
  1061. });
  1062. }
  1063. this.maskNode.setStyles({"display": "block"});
  1064. this.node.setStyles({"display": "block"});
  1065. this.triangleNode.setStyles({"display": "block"});
  1066. this.setSize();
  1067. this.setPosition();
  1068. var size = this.layout.menuNode.getSize();
  1069. var left = size.x;
  1070. this.loadJsons(function(){
  1071. (this.currentTab || this.appCategoryTab).click();
  1072. }.bind(this));
  1073. //this.loadContent();
  1074. this.maskMorph.start({"left": ""+left+"px"});
  1075. this.morph.start({"left": ""+left+"px"}).chain(function(){
  1076. this.isShow = true;
  1077. this.isMorph = false;
  1078. this.layout.desktopNode.addEvent("mousedown", this.hideMessage);
  1079. this.setScroll();
  1080. this.fireEvent("show");
  1081. }.bind(this));
  1082. }
  1083. },
  1084. hide: function(callback){
  1085. if (!this.isMorph){
  1086. this.isMorph = true;
  1087. if (!this.morph){
  1088. this.maskMorph = new Fx.Morph(this.maskNode, {
  1089. duration: "200",
  1090. transition: Fx.Transitions.Sine.easeOut
  1091. });
  1092. this.morph = new Fx.Morph(this.node, {
  1093. duration: "200",
  1094. transition: Fx.Transitions.Sine.easeOut
  1095. });
  1096. }
  1097. var nodeSize = this.node.getSize();
  1098. var left = 0-nodeSize.x;
  1099. // var position = this.node.getPosition();
  1100. // var size = this.node.getSize();
  1101. // var left = position.x+size.x;
  1102. this.isSearchResult = false;
  1103. this.hideSearch();
  1104. this.lnkContentNode.empty();
  1105. this.appContentNode.empty();
  1106. if (this.appScrollBar) this.appScrollBar.destroy();
  1107. this.maskMorph.start({"left": ""+left+"px"}).chain(function(){
  1108. this.maskNode.setStyle("display", "none");
  1109. this.triangleNode.setStyles({"display": "none"});
  1110. }.bind(this));
  1111. this.morph.start({"left": ""+left+"px"}).chain(function(){
  1112. this.node.setStyle("display", "none");
  1113. this.isShow = false;
  1114. this.isMorph = false;
  1115. this.layout.desktopNode.removeEvent("mousedown", this.hideMessage);
  1116. this.fireEvent("hide");
  1117. if (callback) callback();
  1118. }.bind(this));
  1119. }
  1120. },
  1121. });
  1122. o2.xDesktop.Default.StartMenu.Item = new Class({
  1123. initialize: function (menu, container, data) {
  1124. this.menu = menu;
  1125. this.layout = this.menu.layout;
  1126. this.data = data;
  1127. this.container = $(container);
  1128. this.load();
  1129. },
  1130. load: function(){
  1131. this.node = new Element("div.layout_start_item").inject(this.container);
  1132. this.node.set("html", this.menu.itemTempletedHtml);
  1133. this.iconAreaNode = this.node.getElement(".layout_start_item_iconArea");
  1134. this.iconNode = this.node.getElement(".layout_start_item_icon");
  1135. this.badgeNode = this.node.getElement(".layout_start_item_badge");
  1136. this.textNode = this.node.getElement(".layout_start_item_text");
  1137. this.loadIcon();
  1138. this.loadBadge();
  1139. this.loadText();
  1140. this.setEvent();
  1141. },
  1142. loadIcon: function(){
  1143. var icon;
  1144. var bgcolor = "";
  1145. if (this.data.path.substring(0, 4)==="@url"){
  1146. if (this.data.iconPath){
  1147. icon = this.data.iconPath;
  1148. }else{
  1149. if (this.layout.iconsJson["Url"] && this.layout.iconsJson["Url"].icon){
  1150. icon = this.layout.path+"appicons/"+this.layout.iconsJson["Url"].icon;
  1151. bgcolor = this.layout.iconsJson["Url"].color;
  1152. }else{
  1153. icon = "/x_component_Setting/$Main/default/icon/site.png";
  1154. bgcolor = "";
  1155. }
  1156. }
  1157. }else{
  1158. if (this.layout.iconsJson[this.data.path] && this.layout.iconsJson[this.data.path].icon){
  1159. icon = this.layout.path+"appicons/"+this.layout.iconsJson[this.data.path].icon;
  1160. bgcolor = this.layout.iconsJson[this.data.path].color;
  1161. }else{
  1162. icon = "/x_component_"+this.data.path.replace(/\./g, "_")+"/$Main/"+this.data.iconPath;
  1163. bgcolor = "";
  1164. }
  1165. }
  1166. if (icon && bgcolor){
  1167. this.iconNode.addClass("layout_start_item_icon_flat");
  1168. this.iconNode.setStyle("background-color", bgcolor);
  1169. }
  1170. this.iconNode.setStyle("background-image", "url("+icon+")");
  1171. this.icon = icon;
  1172. this.bgcolor = bgcolor;
  1173. },
  1174. loadBadge: function(){
  1175. this.badgeNode.set("title", o2.LP.desktop.addLnk).addClass("icon_add_red");
  1176. },
  1177. loadText: function(){
  1178. this.textNode.set("text", this.data.title);
  1179. },
  1180. setEvent: function(){
  1181. this.node.addEvents({
  1182. "mouseover": function(){ this.badgeNode.fade("in"); }.bind(this),
  1183. "mouseout": function(){ this.badgeNode.fade("out"); }.bind(this),
  1184. "click": function(e){
  1185. this.menu.hide(function(){
  1186. this.open(e);
  1187. }.bind(this));
  1188. }.bind(this)
  1189. });
  1190. this.badgeNode.addEvent("click", function(e){
  1191. this.addLnk();
  1192. e.stopPropagation();
  1193. }.bind(this));
  1194. this.makeLnk();
  1195. },
  1196. addLnk: function(dragTargetLnk, dragPosition){
  1197. lnkdata = {
  1198. "name": this.data.path,
  1199. "title": this.data.title,
  1200. "iconData": this.data.iconData || null,
  1201. "icon": this.iconData || null,
  1202. "appType": null,
  1203. "options": null
  1204. }
  1205. this.layout.addLnk(lnkdata, dragTargetLnk, dragPosition);
  1206. },
  1207. open: function(e){
  1208. layout.openApplication(e, this.data.path);
  1209. },
  1210. makeLnk: function(){
  1211. var drag = new Drag(this.node, {
  1212. "stopPropagation": true,
  1213. "compensateScroll": true,
  1214. "onStart": function(el, e){
  1215. this.doDragMove(e);
  1216. drag.stop();
  1217. }.bind(this)
  1218. });
  1219. },
  1220. getDragNode: function(){
  1221. if (!this.dragNode){
  1222. this.dragNode = new Element("div.layout_menu_lnk_item_drag")
  1223. .setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex())
  1224. .inject(this.layout.node);
  1225. var dragIconNode = this.iconNode.clone(true).inject(this.dragNode)
  1226. .removeClass("layout_menu_lnk_item_icon")
  1227. .addClass("layout_menu_lnk_item_icon_drag");
  1228. if (this.bgcolor) dragIconNode.setStyle("background-color", this.bgcolor);
  1229. }
  1230. var p = this.iconNode.getPosition(this.dragNode.getOffsetParent());
  1231. this.dragNode.show().setStyles({
  1232. "left": ""+p.x+"px", "top": ""+p.y+"px"
  1233. });
  1234. },
  1235. doDragMove: function(e){
  1236. this.getDragNode();
  1237. var drag = new Drag.Move(this.dragNode, {
  1238. "stopPropagation": true,
  1239. "compensateScroll": true,
  1240. "droppables": [this.layout.lnkContentNode],
  1241. "onStart": function(){ this._drag_start(); }.bind(this),
  1242. "onDrag": function(dragging,e){ this._drag_drag(dragging, e); }.bind(this),
  1243. "onEnter": function(dragging, inObj){ this._drag_enter(dragging, inObj); }.bind(this),
  1244. "onLeave": function(dragging, obj){ this._drag_leave(dragging, obj); }.bind(this),
  1245. "onDrop": function(dragging, inObj){ this._drag_drop(dragging, inObj); }.bind(this),
  1246. "onCancel": function(dragging){ this._drag_cancel(dragging); }.bind(this),
  1247. "onComplete": function(dragging, e){ this._drag_complete(dragging, e); }.bind(this),
  1248. });
  1249. drag.start(e);
  1250. this.dragStatus == "remove";
  1251. },
  1252. _drag_start: function(){
  1253. this.dragTargetLnk = null;
  1254. this.dragPosition = "before";
  1255. },
  1256. _drag_drag: function(dragging, e){
  1257. if (this.dragStatus == "order"){
  1258. if (this.layout.lnks && this.layout.lnks.length){
  1259. var current = e.page.y;
  1260. for (var i=0; i<this.layout.lnks.length; i++){
  1261. var lnk = this.layout.lnks[i];
  1262. var y = lnk.node.getSize().y;
  1263. var top = lnk.node.getPosition(this.layout.node).y;
  1264. var center = top+y/2;
  1265. var bottom = top+y;
  1266. if (top<=current && center>=current){
  1267. this.dragTargetLnk = lnk;
  1268. this.dragPosition = "before";
  1269. break;
  1270. }else if (center<=current && bottom>=current){
  1271. this.dragTargetLnk = lnk;
  1272. this.dragPosition = "after";
  1273. break;
  1274. }
  1275. }
  1276. if (!this.layout.positionNode) this.layout.positionNode = new Element("div.layout_menu_lnk_item_position")
  1277. .setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex())
  1278. .inject(this.layout.node);
  1279. this.layout.positionNode.show();
  1280. if (!this.dragTargetLnk){
  1281. this.dragTargetLnk = this.layout.lnks[this.layout.lnks.length-1];
  1282. this.dragPosition = "after";
  1283. }
  1284. this.layout.positionNode.position({
  1285. relativeTo: this.dragTargetLnk.node,
  1286. position: (this.dragPosition=="before") ? 'topcenter' : 'bottomcenter',
  1287. edge: 'center'
  1288. });
  1289. }
  1290. }
  1291. },
  1292. _drag_enter: function(){
  1293. this.dragStatus = "order";
  1294. },
  1295. _drag_leave: function(){
  1296. this.dragStatus = "remove";
  1297. if (this.layout.positionNode) this.layout.positionNode.hide();
  1298. },
  1299. _drag_drop: function(dragging, inObj){
  1300. if (this.dragStatus == "order" && this.dragTargetLnk && this.dragTargetLnk!=this){
  1301. this.addLnk(this.dragTargetLnk, this.dragPosition);
  1302. // this.node.inject(this.dragTargetLnk.node, this.dragPosition);
  1303. // this.layout.lnks.erase(this);
  1304. // var idx = this.layout.lnks.indexOf(this.dragTargetLnk);
  1305. // if (this.dragPosition=="before"){
  1306. // this.layout.lnks.splice(idx, 0, this);
  1307. // }else{
  1308. // this.layout.lnks.splice(idx+1, 0, this);
  1309. // }
  1310. }
  1311. },
  1312. _drag_cancel: function(dragging){
  1313. dragging.hide();
  1314. if (this.layout.positionNode) this.layout.positionNode.hide();
  1315. if (this.dragRemoveNode) this.dragRemoveNode.hide();
  1316. },
  1317. _drag_complete: function(dragging){
  1318. this._drag_cancel(dragging);
  1319. }
  1320. });
  1321. o2.xDesktop.Default.StartMenu.PortalItem = new Class({
  1322. Extends: o2.xDesktop.Default.StartMenu.Item,
  1323. loadIcon: function(){
  1324. var icon = "";
  1325. var bgcolor = "";
  1326. if (this.data.icon){
  1327. icon = "data:image/png;base64,"+this.data.icon+"";
  1328. }else{
  1329. var p = "portalDefault";
  1330. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  1331. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  1332. bgcolor = this.layout.iconsJson[p].color;
  1333. }else{
  1334. icon = "/x_component_portal_PortalExplorer/$Main/default/icon/application.png";
  1335. bgcolor = "";
  1336. }
  1337. }
  1338. if (icon && bgcolor){
  1339. this.iconNode.addClass("layout_start_item_icon_flat");
  1340. this.iconNode.setStyle("background-color", bgcolor);
  1341. }
  1342. this.iconNode.setStyle("background-image", "url("+icon+")");
  1343. this.icon = icon;
  1344. },
  1345. loadText: function(){
  1346. this.textNode.set("text", this.data.name);
  1347. },
  1348. addLnk: function(dragTargetLnk, dragPosition){
  1349. var options = {"portalId": this.data.id, "appId": "portal.Portal"+this.data.id};
  1350. lnkdata = {
  1351. "name": "portal.Portal",
  1352. "title": this.data.name,
  1353. "iconData": (this.data.icon) || "",
  1354. "icon": null,
  1355. "appType": "portal",
  1356. "options": options
  1357. }
  1358. this.layout.addLnk(lnkdata, dragTargetLnk, dragPosition);
  1359. },
  1360. open: function(e){
  1361. var options = {"portalId": this.data.id, "appId": "portal.Portal"+this.data.id};
  1362. layout.openApplication(e, "portal.Portal", options);
  1363. }
  1364. // makeLnk: function(){
  1365. // //@todo
  1366. // // this.node.makeLnk({
  1367. // // "par": {"icon": this.icon, "color": this.color, "title": this.data.title, "par": this.data.path},
  1368. // // });
  1369. // }
  1370. });
  1371. o2.xDesktop.Default.StartMenu.ProcessItem = new Class({
  1372. Extends: o2.xDesktop.Default.StartMenu.PortalItem,
  1373. loadIcon: function(){
  1374. var icon = "";
  1375. var bgcolor = "";
  1376. if (this.data.icon){
  1377. icon = "data:image/png;base64,"+this.data.icon+"";
  1378. bgcolor = "";
  1379. }else{
  1380. var p = "processDefault";
  1381. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  1382. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  1383. bgcolor = this.layout.iconsJson[p].color;
  1384. }else{
  1385. icon = "/x_component_process_ApplicationExplorer/$Main/default/icon/application.png";
  1386. bgcolor = "";
  1387. }
  1388. }
  1389. if (icon && bgcolor){
  1390. this.iconNode.addClass("layout_start_item_icon_flat");
  1391. this.iconNode.setStyle("background-color", bgcolor);
  1392. }
  1393. this.iconNode.setStyle("background-image", "url("+icon+")");
  1394. this.icon = icon;
  1395. },
  1396. addLnk: function(dragTargetLnk, dragPosition){
  1397. var options = {"id": this.data.id, "appId": "process.Application"+this.data.id};
  1398. lnkdata = {
  1399. "name": "process.Application",
  1400. "title": this.data.name,
  1401. "iconData": (this.data.icon) || "",
  1402. "icon": null,
  1403. "appType": "process",
  1404. "options": options
  1405. }
  1406. this.layout.addLnk(lnkdata, dragTargetLnk, dragPosition);
  1407. },
  1408. open: function(e){
  1409. var options = {"id": this.data.id, "appId": "process.Application"+this.data.id};
  1410. layout.openApplication(e, "process.Application", options);
  1411. }
  1412. // makeLnk: function(){
  1413. // //@todo
  1414. // // this.node.makeLnk({
  1415. // // "par": {"icon": this.icon, "color": this.color, "title": this.data.title, "par": this.data.path},
  1416. // // });
  1417. // }
  1418. });
  1419. o2.xDesktop.Default.StartMenu.InforItem = new Class({
  1420. Extends: o2.xDesktop.Default.StartMenu.PortalItem,
  1421. loadIcon: function(){
  1422. var icon = "";
  1423. var bgcolor = "";
  1424. if (this.data.appIcon){
  1425. icon = "data:image/png;base64,"+this.data.appIcon+"";
  1426. bgcolor = "";
  1427. }else{
  1428. var p = "cmsDefault";
  1429. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  1430. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  1431. bgcolor = this.layout.iconsJson[p].color;
  1432. }else{
  1433. icon = "/x_component_cms_Index/$Main/default/icon/column.png";
  1434. bgcolor = "";
  1435. }
  1436. }
  1437. if (icon && bgcolor){
  1438. this.iconNode.addClass("layout_start_item_icon_flat");
  1439. this.iconNode.setStyle("background-color", bgcolor);
  1440. }
  1441. this.iconNode.setStyle("background-image", "url("+icon+")");
  1442. this.icon = icon;
  1443. },
  1444. loadText: function(){
  1445. this.textNode.set("text", this.data.appName);
  1446. },
  1447. addLnk: function(dragTargetLnk, dragPosition){
  1448. lnkdata = {
  1449. "name": "cms.Document",
  1450. "title": this.data.appName,
  1451. "iconData": (this.data.appIcon) || "",
  1452. "icon": null,
  1453. "appType": "cms",
  1454. "options": {"columnData": this.data, "appId": "cms.Module"+this.data.id}
  1455. }
  1456. this.layout.addLnk(lnkdata, dragTargetLnk, dragPosition);
  1457. },
  1458. open: function(e){
  1459. layout.openApplication(e, "cms.Module", {"columnData": this.data, "appId": "cms.Module"+this.data.id});
  1460. }
  1461. // makeLnk: function(){
  1462. // //@todo
  1463. // // this.node.makeLnk({
  1464. // // "par": {"icon": this.icon, "color": this.color, "title": this.data.title, "par": this.data.path},
  1465. // // });
  1466. // }
  1467. });
  1468. o2.xDesktop.Default.StartMenu.QueryItem = new Class({
  1469. Extends: o2.xDesktop.Default.StartMenu.PortalItem,
  1470. loadIcon: function(){
  1471. var icon = "";
  1472. var bgcolor = "";
  1473. if (this.data.icon){
  1474. icon = "data:image/png;base64,"+this.data.icon+"";
  1475. bgcolor = "";
  1476. }else{
  1477. var p = "queryDefault";
  1478. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  1479. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  1480. bgcolor = this.layout.iconsJson[p].color;
  1481. }else{
  1482. icon = "/x_component_query_Query/$Main/appicon.png";
  1483. bgcolor = "";
  1484. }
  1485. }
  1486. if (icon && bgcolor){
  1487. this.iconNode.addClass("layout_start_item_icon_flat");
  1488. this.iconNode.setStyle("background-color", bgcolor);
  1489. }
  1490. this.iconNode.setStyle("background-image", "url("+icon+")");
  1491. this.icon = icon;
  1492. },
  1493. addLnk: function(){
  1494. lnkdata = {
  1495. "name": "query.Query",
  1496. "title": this.data.name,
  1497. "iconData": (this.data.icon)||"",
  1498. "icon": null,
  1499. "appType": "query",
  1500. "options": {"id": this.data.id, "appId": "query.Query"+this.data.id}
  1501. }
  1502. this.layout.addLnk(lnkdata, dragTargetLnk, dragPosition);
  1503. },
  1504. open: function(e){
  1505. layout.openApplication(e, "query.Query", {"id": this.data.id, "appId": "query.Query"+this.data.id});
  1506. }
  1507. // makeLnk: function(){
  1508. // //@todo
  1509. // // this.node.makeLnk({
  1510. // // "par": {"icon": this.icon, "color": this.color, "title": this.data.title, "par": this.data.path},
  1511. // // });
  1512. // }
  1513. });
  1514. o2.xDesktop.Default.TaskItem = new Class({
  1515. initialize: function(desktop, app){
  1516. this.desktop = desktop;
  1517. this.container = this.desktop.taskContentNode;
  1518. this.app = app;
  1519. this.load();
  1520. },
  1521. load: function(){
  1522. this.node = new Element("div.layout_content_taskbar_item").inject(this.container);
  1523. this.iconNode = new Element("div");
  1524. this.closeNode = new Element("div.layout_content_taskbar_item_icon", {"title": o2.LP.widget.close}).inject(this.node);;
  1525. this.closeNode.addClass("icon_close");
  1526. if (this.app.options.appId==this.desktop.options.index){
  1527. this.closeNode.hide();
  1528. this.noCloseNode = true;
  1529. }
  1530. this.refreshNode = new Element("div.layout_content_taskbar_item_refresh", {"title": o2.LP.widget.refresh}).inject(this.node);;
  1531. this.refreshNode.addClass("icon_refresh");
  1532. this.refreshNode.addClass("animation_taskItemLoading");
  1533. this.textNode = new Element("div.layout_content_taskbar_item_text").inject(this.node);;
  1534. this.setText(this.app.options.title);
  1535. //this.desktop.checkTaskBarSize();
  1536. this.setEvent();
  1537. this.unSelected();
  1538. },
  1539. setEvent: function(){
  1540. this.textNode.addEvents({
  1541. "click": function(){
  1542. if (this.desktop.currentApp!=this.app){
  1543. if (!this.app.window){
  1544. this.desktop.apps[this.app.options.appId] = null;
  1545. layout.openApplication(null, this.app.options.name, this.app.options, this.app.options.app, false, this, false);
  1546. }else{
  1547. this.app.setCurrent();
  1548. }
  1549. }else{
  1550. // this.app.refresh();
  1551. }
  1552. }.bind(this),
  1553. "dblclick": function(){
  1554. this.app.openInNewBrowser((this.app.options.appId==this.desktop.options.index));
  1555. }.bind(this)
  1556. });
  1557. this.closeNode.addEvents({
  1558. "mouseover": function(){
  1559. // if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode_over);
  1560. }.bind(this),
  1561. "mouseout": function(){
  1562. // if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode);
  1563. }.bind(this),
  1564. "click": function(){
  1565. if (!this.app.window){
  1566. this.desktop.apps[this.app.options.appId] = null;
  1567. delete this.desktop.apps[this.app.options.appId];
  1568. this.destroy();
  1569. }else{
  1570. this.app.close();
  1571. }
  1572. }.bind(this)
  1573. });
  1574. this.refreshNode.addEvents({
  1575. "mouseover": function(){
  1576. // if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode_over);
  1577. }.bind(this),
  1578. "mouseout": function(){
  1579. // if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode);
  1580. }.bind(this),
  1581. "click": function(){
  1582. this.app.refresh();
  1583. }.bind(this)
  1584. });
  1585. },
  1586. setText: function(str){
  1587. this.textNode.set("text", str || this.app.options.title);
  1588. },
  1589. unSelected: function(){
  1590. this.node.removeClass("mainColor_bg");
  1591. if (!this.noCloseNode) {
  1592. this.closeNode.addClass("icon_close");
  1593. this.closeNode.removeClass("icon_close_focus");
  1594. //this.closeNode.hide();
  1595. }
  1596. this.refreshNode.hide();
  1597. },
  1598. selected: function(){
  1599. this.node.addClass("mainColor_bg");
  1600. if (!this.noCloseNode){
  1601. this.closeNode.removeClass("icon_close");
  1602. this.closeNode.addClass("icon_close_focus");
  1603. //this.closeNode.show();
  1604. }
  1605. this.desktop.checkTaskBarScrollTo(this.app);
  1606. //this.refreshNode.show();
  1607. },
  1608. destroy: function(){
  1609. this.iconNode.destroy();
  1610. this.node.destroy();
  1611. o2.release(this);
  1612. },
  1613. setTaskitemSize: function(){
  1614. this.desktop.checkTaskBarSize();
  1615. this.desktop.checkTaskBarScrollTo();
  1616. }
  1617. });
  1618. o2.xDesktop.Default.Lnk = new Class({
  1619. initialize: function(layout, data, targetLnk, position){
  1620. this.layout = layout;
  1621. this.container = this.layout.lnkAreaNode;
  1622. this.data = data;
  1623. this.load(targetLnk, position);
  1624. },
  1625. load: function(targetLnk, position){
  1626. this.node = new Element("div.layout_menu_lnk_item");
  1627. if (targetLnk){
  1628. if (!position) position = "before";
  1629. this.node.inject(targetLnk.node, position);
  1630. }else{
  1631. this.node.inject(this.container);
  1632. }
  1633. this.iconNode = new Element("div.layout_menu_lnk_item_icon").inject(this.node);
  1634. this.textNode = new Element("div.layout_menu_lnk_item_text", {"text": this.data.title}).inject(this.node);
  1635. this.actionNode = new Element("div.layout_menu_lnk_item_action", {"title": o2.LP.desktop.deleteLnk}).inject(this.node);
  1636. this.actionNode.addClass("icon_off_light");
  1637. var icon = this.getIcon();
  1638. this.iconNode.setStyle("background-image", "url("+icon+")");
  1639. this.setEvent();
  1640. },
  1641. setEvent: function(){
  1642. this.node.addEvents({
  1643. "click": function(){
  1644. layout.openApplication(null, this.data.name, this.data.options);
  1645. }.bind(this),
  1646. "mouseover": function(){
  1647. this.actionNode.fade("in");
  1648. this.node.addClass("overColor_bg");
  1649. this.textNode.fade("in");
  1650. }.bind(this),
  1651. "mouseout": function(){
  1652. this.actionNode.fade("out");
  1653. this.node.removeClass("overColor_bg");
  1654. this.textNode.fade("out");
  1655. }.bind(this)
  1656. });
  1657. this.actionNode.addEvents({
  1658. "click": function(e){
  1659. this.destroy();
  1660. e.stopPropagation();
  1661. }.bind(this),
  1662. "mouseover": function(){
  1663. this.actionNode.addClass("layout_menu_lnk_item_action_shadow");
  1664. }.bind(this),
  1665. "mouseout": function(){
  1666. this.actionNode.removeClass("layout_menu_lnk_item_action_shadow");
  1667. }.bind(this)
  1668. });
  1669. var drag = new Drag(this.node, {
  1670. "stopPropagation": true,
  1671. "compensateScroll": true,
  1672. "onStart": function(el, e){
  1673. this.doDragMove(e);
  1674. drag.stop();
  1675. }.bind(this)
  1676. });
  1677. },
  1678. getDragNode: function(){
  1679. if (!this.dragNode){
  1680. this.dragNode = new Element("div.layout_menu_lnk_item_drag")
  1681. .setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex())
  1682. .inject(this.layout.node);
  1683. var dragIconNode = this.iconNode.clone(true).inject(this.dragNode)
  1684. .removeClass("layout_menu_lnk_item_icon")
  1685. .addClass("layout_menu_lnk_item_icon_drag");
  1686. var p = (this.data.appType) ? this.data.appType+"Default" : this.data.name;
  1687. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].color){
  1688. dragIconNode.setStyle("background-color", this.layout.iconsJson[p].color)
  1689. }
  1690. this.dragRemoveNode = new Element("div.layout_menu_lnk_item_icon_drag_del").inject(this.dragNode)
  1691. .addClass("icon_remove_badge")
  1692. .hide();
  1693. }
  1694. var ps = this.iconNode.getPosition(this.dragNode.getOffsetParent());
  1695. this.dragNode.show().setStyles({
  1696. "left": ""+ps.x+"px", "top": ""+ps.y+"px"
  1697. });
  1698. },
  1699. doDragMove: function(e){
  1700. this.getDragNode();
  1701. var drag = new Drag.Move(this.dragNode, {
  1702. "stopPropagation": true,
  1703. "compensateScroll": true,
  1704. "droppables": [this.container.getParent()],
  1705. "onStart": function(){ this._drag_start(); }.bind(this),
  1706. "onDrag": function(dragging,e){ this._drag_drag(dragging, e); }.bind(this),
  1707. "onEnter": function(dragging, inObj){ this._drag_enter(dragging, inObj); }.bind(this),
  1708. "onLeave": function(dragging, obj){ this._drag_leave(dragging, obj); }.bind(this),
  1709. "onDrop": function(dragging, inObj){ this._drag_drop(dragging, inObj); }.bind(this),
  1710. "onCancel": function(dragging){ this._drag_cancel(dragging); }.bind(this),
  1711. "onComplete": function(dragging, e){ this._drag_complete(dragging, e); }.bind(this),
  1712. });
  1713. drag.start(e);
  1714. this.dragStatus = "order";
  1715. },
  1716. _drag_start: function(){
  1717. this.node.addClass("overColor_bg");
  1718. this.node.addClass("opacity50");
  1719. this.dragTargetLnk = null;
  1720. this.dragPosition = "before";
  1721. },
  1722. _drag_drag: function(dragging, e){
  1723. if (this.dragStatus == "order"){
  1724. if (this.layout.lnks && this.layout.lnks.length){
  1725. var current = e.page.y;
  1726. for (var i=0; i<this.layout.lnks.length; i++){
  1727. var lnk = this.layout.lnks[i];
  1728. var y = lnk.node.getSize().y;
  1729. var top = lnk.node.getPosition(this.layout.node).y;
  1730. var center = top+y/2;
  1731. var bottom = top+y;
  1732. if (top<=current && center>=current){
  1733. this.dragTargetLnk = lnk;
  1734. this.dragPosition = "before";
  1735. break;
  1736. }else if (center<=current && bottom>=current){
  1737. this.dragTargetLnk = lnk;
  1738. this.dragPosition = "after";
  1739. break;
  1740. }
  1741. }
  1742. if (!this.layout.positionNode) this.layout.positionNode = new Element("div.layout_menu_lnk_item_position")
  1743. .setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex())
  1744. .inject(this.layout.node);
  1745. this.layout.positionNode.show();
  1746. if (!this.dragTargetLnk){
  1747. this.dragTargetLnk = this.layout.lnks[this.layout.lnks.length-1];
  1748. this.dragPosition = "after";
  1749. }
  1750. this.layout.positionNode.position({
  1751. relativeTo: this.dragTargetLnk.node,
  1752. position: (this.dragPosition=="before") ? 'topcenter' : 'bottomcenter',
  1753. edge: 'center'
  1754. });
  1755. }
  1756. }
  1757. },
  1758. _drag_enter: function(){
  1759. this.dragStatus = "order";
  1760. if (this.dragRemoveNode) this.dragRemoveNode.hide();
  1761. },
  1762. _drag_leave: function(){
  1763. this.dragStatus = "remove";
  1764. if (this.dragRemoveNode) this.dragRemoveNode.show();
  1765. if (this.layout.positionNode) this.layout.positionNode.hide();
  1766. },
  1767. _drag_drop: function(dragging, inObj){
  1768. if (this.dragStatus == "order" && this.dragTargetLnk && this.dragTargetLnk!=this){
  1769. this.node.inject(this.dragTargetLnk.node, this.dragPosition);
  1770. this.layout.lnks.erase(this);
  1771. var idx = this.layout.lnks.indexOf(this.dragTargetLnk);
  1772. if (this.dragPosition=="before"){
  1773. this.layout.lnks.splice(idx, 0, this);
  1774. }else{
  1775. this.layout.lnks.splice(idx+1, 0, this);
  1776. }
  1777. }
  1778. },
  1779. _drag_cancel: function(dragging){
  1780. dragging.hide();
  1781. if (this.node) {
  1782. this.node.removeClass("overColor_bg");
  1783. this.node.removeClass("opacity50");
  1784. }
  1785. if (this.layout.positionNode) this.layout.positionNode.hide();
  1786. if (this.dragRemoveNode) this.dragRemoveNode.hide();
  1787. },
  1788. _drag_complete: function(dragging){
  1789. if (this.dragStatus == "remove"){
  1790. this.destroy();
  1791. }else{
  1792. this._drag_cancel(dragging);
  1793. }
  1794. },
  1795. destroy: function(){
  1796. this.layout.lnks.erase(this);
  1797. if (this.dragNode) this.dragNode.destroy();
  1798. //if (this.positionNode) this.positionNode.destroy();
  1799. this.node.destroy();
  1800. o2.release(this);
  1801. },
  1802. getIcon: function(){
  1803. if (this.data.icon) return this.data.icon;
  1804. var icon;
  1805. if (this.data.name.substring(0, 4)==="@url"){
  1806. if (this.layout.iconsJson["Url"] && this.layout.iconsJson["Url"].icon){
  1807. icon = this.layout.path+"appicons/"+this.layout.iconsJson["Url"].icon;
  1808. }else{
  1809. icon = this.layout.path+"appicons/url.png";
  1810. }
  1811. }else{
  1812. if (this.data.iconData){
  1813. icon = "data:image/png;base64,"+this.data.iconData+"";
  1814. }else if (this.data.iconPath){
  1815. icon = this.data.iconPath;
  1816. }else{
  1817. var p = (this.data.appType) ? this.data.appType+"Default" : this.data.name;
  1818. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  1819. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  1820. }else{
  1821. icon = "/x_component_"+this.data.name.replace(/\./g, "_")+"/$Main/appicon.png";
  1822. }
  1823. }
  1824. }
  1825. return icon;
  1826. }
  1827. });
  1828. o2.xDesktop.zIndexPool = {
  1829. zIndex: 102,
  1830. applyZindex: function(){
  1831. var i = this.zIndex;
  1832. this.zIndex = this.zIndex+2;
  1833. return i;
  1834. }
  1835. };