Default.js 78 KB

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