Default.js 90 KB

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