Default.js 81 KB

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