Default.js 112 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830
  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. if (item.data.type==="group"){
  801. var d = {
  802. "id": item.data.id,
  803. "name": item.data.name,
  804. "type": item.data.type,
  805. "itemDataList": []
  806. }
  807. if (item.data.itemDataList) item.data.itemDataList.each(function(i){
  808. d.itemDataList.push(i);
  809. });
  810. data.push(d);
  811. }else{
  812. data.push({
  813. "id": item.data.id,
  814. "name": item.data.name,
  815. "type": item.data.type,
  816. });
  817. }
  818. }
  819. }.bind(this));
  820. if (this.currentTab === this.appCategoryTab){
  821. this.menuData.appList = data;
  822. }else if (this.currentTab === this.processCategoryTab){
  823. this.menuData.processList = data;
  824. }else if (this.currentTab === this.inforCategoryTab){
  825. this.menuData.inforList = data;
  826. }else if (this.currentTab === this.queryCategoryTab){
  827. this.menuData.queryList = data;
  828. }
  829. this.layout.menuData = this.menuData;
  830. },
  831. setScroll: function(){
  832. o2.require("o2.widget.ScrollBar", function(){
  833. this.appScrollBar = new o2.widget.ScrollBar(this.appScrollNode, {
  834. "style":"xDesktop_Message", "where": "before", "indent": false, "distance": 100, "friction": 6, "axis": {"x": false, "y": true}
  835. });
  836. }.bind(this));
  837. },
  838. loadTitle: function(){
  839. this.lnkTitleNode.set("text", o2.LP.desktop.lnkAppTitle);
  840. this.appCategoryTab = new Element("div.layout_start_tab", {"text": o2.LP.desktop.message.application}).inject(this.appTitleNode);
  841. this.processCategoryTab = new Element("div.layout_start_tab", {"text": o2.LP.desktop.message.process}).inject(this.appTitleNode);
  842. this.inforCategoryTab = new Element("div.layout_start_tab", {"text": o2.LP.desktop.message.infor}).inject(this.appTitleNode);
  843. this.queryCategoryTab = new Element("div.layout_start_tab", {"text": o2.LP.desktop.message.query}).inject(this.appTitleNode);
  844. this.refreshNode = new Element("div.layout_start_search", {"title": o2.LP.desktop.message.refreshMenu}).inject(this.appTitleNode);
  845. this.refreshNode = new Element("div.layout_start_search_icon").inject(this.refreshNode);
  846. this.refreshNode.addClass("icon_startMenu_refresh");
  847. this.searchNode = new Element("div.layout_start_search").inject(this.appTitleNode);
  848. this.searchIconNode = new Element("div.layout_start_search_icon").inject(this.searchNode);
  849. this.searchIconNode.addClass("icon_startMenu_search");
  850. var currentWidth = this.searchNode.getSize().x;
  851. this.searchNode.store("currentWidth", currentWidth);
  852. this.appCategoryTab.addEvent("click", function(){
  853. this.appTitleNode.getElements(".layout_start_tab").removeClass("mainColor_bg");
  854. this.appCategoryTab.addClass("mainColor_bg");
  855. this.currentTab = this.appCategoryTab;
  856. this.loadApplications();
  857. }.bind(this));
  858. this.processCategoryTab.addEvent("click", function(){
  859. this.appTitleNode.getElements(".layout_start_tab").removeClass("mainColor_bg");
  860. this.processCategoryTab.addClass("mainColor_bg");
  861. this.currentTab = this.processCategoryTab;
  862. this.loadProcesses();
  863. }.bind(this));
  864. this.inforCategoryTab.addEvent("click", function(){
  865. this.appTitleNode.getElements(".layout_start_tab").removeClass("mainColor_bg");
  866. this.inforCategoryTab.addClass("mainColor_bg");
  867. this.currentTab = this.inforCategoryTab;
  868. this.loadInfors();
  869. }.bind(this));
  870. this.queryCategoryTab.addEvent("click", function(){
  871. this.appTitleNode.getElements(".layout_start_tab").removeClass("mainColor_bg");
  872. this.queryCategoryTab.addClass("mainColor_bg");
  873. this.currentTab = this.queryCategoryTab;
  874. this.loadQuerys();
  875. }.bind(this));
  876. this.searchIconNode.addEvent("click", this.searchIconAction.bind(this));
  877. this.refreshNode.addEvent("click", function(e){
  878. var _self = this;
  879. MWF.xDesktop.confirm("infor", e, o2.LP.desktop.defaultMenuTitle, o2.LP.desktop.defaultMenuInfor, 420, 100, function(){
  880. _self.defaultMenu();
  881. this.close();
  882. }, function(){
  883. this.close();
  884. }, null, null, "o2"
  885. );
  886. }.bind(this));
  887. },
  888. searchIconAction: function(){
  889. if (!this.isMorph){
  890. if (this.isSearch){
  891. this.doSearch();
  892. }else{
  893. this.loadSearch()
  894. }
  895. }
  896. },
  897. loadSearch: function(){
  898. this.isSearch = true;
  899. this.searchNode.addClass("mainColor_border");
  900. this.appCategoryTab.hide();
  901. this.processCategoryTab.hide();
  902. this.inforCategoryTab.hide();
  903. this.queryCategoryTab.hide();
  904. var size = this.appTitleNode.getSize();
  905. var pr = this.appTitleNode.getStyle("padding-right").toInt() || 0;
  906. var pl = this.appTitleNode.getStyle("padding-left").toInt() || 0;
  907. var margin = this.searchNode.getStyle("margin-right").toInt() || 0;
  908. var w = size.x-margin*2-pr-pl;
  909. this.isMorph = true;
  910. this.searchNode.set("morph", {"duration": 200});
  911. this.searchNode.morph({"width": ""+w+"px"});
  912. window.setTimeout(function(){
  913. this.isMorph = false;
  914. }.bind(this), 220);
  915. if (!this.searchClearNode){
  916. this.searchClearNode = new Element("div.layout_start_search_clear").inject(this.searchNode);
  917. this.searchClearNode.addClass("icon_clear");
  918. this.searchClearNode.addEvent("click", this.hideSearch.bind(this));
  919. }
  920. this.searchClearNode.show();
  921. if (!this.searchAreaNode) this.searchAreaNode = new Element("div.layout_start_search_area").inject(this.searchNode);
  922. this.searchAreaNode.show();
  923. if (!this.searchInputNode){
  924. this.searchInputNode = new Element("input.layout_start_search_input", {"placeholder": o2.LP.searchKey}).inject(this.searchAreaNode);
  925. this.searchInputNode.addEvent("keydown", function(e){
  926. if (e.code==13) this.doSearch();
  927. }.bind(this));
  928. }
  929. this.searchInputNode.show();
  930. this.searchInputNode.focus();
  931. //this.searchNode.addClass("layout_start_search_load");
  932. },
  933. hideSearch: function(){
  934. if (this.isSearch){
  935. if (this.searchInputNode){
  936. this.searchInputNode.set("value", "");
  937. this.searchInputNode.hide();
  938. }
  939. if (this.searchAreaNode) this.searchAreaNode.hide();
  940. if (this.searchClearNode) this.searchClearNode.hide();
  941. this.isMorph = true;
  942. var currentWidth = this.searchNode.retrieve("currentWidth");
  943. this.searchNode.morph({"width": ""+currentWidth+"px"});
  944. window.setTimeout(function(){
  945. if (this.currentTab && this.isSearchResult) this.currentTab.click();
  946. this.searchNode.removeClass("mainColor_border");
  947. this.appCategoryTab.show();
  948. this.processCategoryTab.show();
  949. this.inforCategoryTab.show();
  950. this.queryCategoryTab.show();
  951. this.isSearch = false;
  952. this.isMorph = false;
  953. this.isSearchResult = false;
  954. }.bind(this), 220);
  955. }
  956. },
  957. doSearch: function(){
  958. var key = this.searchInputNode.get("value").toLowerCase();
  959. if (key){
  960. this.isSearchResult = true;
  961. this.appContentNode.empty();
  962. this.searchApplicatins(key);
  963. this.searchProcesses(key);
  964. this.searchInfors(key);
  965. this.searchQuerys(key);
  966. }
  967. },
  968. searchApplicatins: function(value){
  969. // var user = this.layout.session.user;
  970. // // var currentNames = [user.name, user.distinguishedName, user.id, user.unique];
  971. // // if (user.roleList) currentNames = currentNames.concat(user.roleList);
  972. // // if (user.groupList) currentNames = currentNames.concat(user.groupList);
  973. this.getCurrentName( function (currentNames) {
  974. if (this.layoutJson && this.layoutJson.length) this.layoutJson.each(function(v){
  975. if ( this.checkMenuItem(v, currentNames) ){
  976. if ((v.title.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.title.toPY().toLowerCase().indexOf(value)!==-1) || (v.title.indexOf(value)!==-1)){
  977. this.createApplicationMenuItem(v);
  978. }
  979. }
  980. }.bind(this));
  981. if (this.componentJson && this.componentJson.length) this.componentJson.each(function(v){
  982. if ( this.checkMenuItem(v, currentNames) ){
  983. if ((v.title.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.title.toPY().toLowerCase().indexOf(value)!==-1) || (v.title.indexOf(value)!==-1)){
  984. this.createApplicationMenuItem(v);
  985. }
  986. }
  987. }.bind(this));
  988. if (this.portalJson && this.portalJson.length) this.portalJson.each(function(v){
  989. if ((v.name.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.name.toPY().toLowerCase().indexOf(value)!==-1) || (v.name.indexOf(value)!==-1)){
  990. this.createPortalMenuItem(v);
  991. }
  992. }.bind(this));
  993. })
  994. },
  995. searchProcesses: function(value){
  996. if (this.processJson && this.processJson.length) this.processJson.each(function(v){
  997. if ((v.name.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.name.toPY().toLowerCase().indexOf(value)!==-1) || (v.name.indexOf(value)!==-1)){
  998. this.createProcessMenuItem(v);
  999. }
  1000. }.bind(this));
  1001. },
  1002. searchInfors: function(value){
  1003. if (this.inforJson && this.inforJson.length) this.inforJson.each(function(v){
  1004. if ((v.appName.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.appName.toPY().toLowerCase().indexOf(value)!==-1) || (v.appName.indexOf(value)!==-1)){
  1005. this.createInforMenuItem(v);
  1006. }
  1007. }.bind(this));
  1008. },
  1009. searchQuerys: function(value){
  1010. if (this.queryJson && this.queryJson.length) this.queryJson.each(function(v){
  1011. if ((v.name.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.name.toPY().toLowerCase().indexOf(value)!==-1) || (v.name.indexOf(value)!==-1)){
  1012. this.createQueryMenuItem(v);
  1013. }
  1014. }.bind(this));
  1015. },
  1016. loadJsons: function(callback){
  1017. this.clearAppContentNode();
  1018. this.loadLayoutApplications(function(json_layout){
  1019. var componentAction = o2.Actions.get("x_component_assemble_control");
  1020. var portalAction = o2.Actions.get("x_portal_assemble_surface");
  1021. var processAction = o2.Actions.get("x_processplatform_assemble_surface");
  1022. var inforAction = o2.Actions.get("x_cms_assemble_control");
  1023. var queryAction = o2.Actions.get("x_query_assemble_surface");
  1024. var iconsPath = this.layout.path+"icons.json";
  1025. this.getIconsJson(function(){
  1026. o2.Actions.invokeAsync([
  1027. {"action": componentAction, "name": "listComponent"},
  1028. {"action": portalAction, "name": "listApplication"},
  1029. {"action": processAction, "name": "listApplication"},
  1030. {"action": inforAction, "name": "listColumn"},
  1031. {"action": queryAction, "name": "listQuery"},
  1032. ], {"success": function(json_component, json_portal, json_process, json_infor, json_query){
  1033. this.layoutJson = json_layout;
  1034. this.componentJson = json_component.data;
  1035. this.portalJson = json_portal.data;
  1036. this.processJson = json_process.data;
  1037. this.inforJson = json_infor.data;
  1038. this.queryJson = json_query.data;
  1039. if (callback) callback();
  1040. }.bind(this), "failure": function(){}}
  1041. );
  1042. }.bind(this));
  1043. }.bind(this));
  1044. },
  1045. getIconsJson: function(callback){
  1046. if (this.layout.iconsJson){
  1047. if (callback) callback();
  1048. }else{
  1049. o2.JSON.get(iconsPath, function(json){
  1050. this.layout.iconsJson = json;
  1051. if (callback) callback();
  1052. }.bind(this));
  1053. }
  1054. },
  1055. setPosition: function(){
  1056. //var size = this.container.getSize();
  1057. var index = o2.xDesktop.zIndexPool.zIndex;
  1058. var nodeSize = this.node.getSize();
  1059. var left = 0-nodeSize.x;
  1060. this.maskNode.setStyles({"left": ""+left+"px"});
  1061. this.node.setStyles({"left": ""+left+"px"});
  1062. },
  1063. setSize: function(){
  1064. if (this.appScrollBar && this.appScrollBar.scrollVNode) this.appScrollBar.scrollVNode.setStyle("margin-top", "0px");
  1065. var isLnk = false;
  1066. if (false && this.layout.lnks && this.layout.lnks.length){
  1067. this.lnkAreaNode.show();
  1068. this.lineNode.show();
  1069. var h = 100*3;
  1070. this.lnkScrollNode.setStyle("height", ""+h+"px");
  1071. isLnk = true;
  1072. }else{
  1073. this.lnkAreaNode.hide();
  1074. this.lineNode.hide();
  1075. }
  1076. var size = this.node.getSize();
  1077. var lnkSizeY = (isLnk) ? this.lnkAreaNode.getSize().y : 0;
  1078. var lineSizeY = (isLnk) ? this.lineNode.getSize().y : 0;
  1079. var mt = (isLnk) ? (this.lineNode.getStyle("margin-top").toInt() || 0) : 0;
  1080. var mb = (isLnk) ? (this.lineNode.getStyle("margin-bottom").toInt() || 0) : 0;
  1081. var titleSize = this.appTitleNode.getSize();
  1082. var y = size.y-lnkSizeY-lineSizeY-mt-mb-titleSize.y;
  1083. this.appScrollNode.setStyle("height", ""+y+"px");
  1084. },
  1085. loadLnks: function(){
  1086. // if (this.layout.lnks && this.layout.lnks.length){
  1087. // this.lnkAreaNode.show();
  1088. // this.lineNode.show();
  1089. // this.lnkContentNode.empty();
  1090. // this.createLnkMenuItem();
  1091. // }else{
  1092. this.lnkAreaNode.hide();
  1093. this.lineNode.hide();
  1094. //}
  1095. },
  1096. createLnkMenuItem: function(){
  1097. //this.templetedHtml
  1098. },
  1099. clearAppContentNode: function(){
  1100. this.appContentNode.empty();
  1101. this.appContentNode.addClass("icon_loading");
  1102. },
  1103. loadApplications: function(callback){
  1104. this.clearAppContentNode();
  1105. // this.loadLayoutApplications(function(json_layout){
  1106. // var componentAction = o2.Actions.get("x_component_assemble_control");
  1107. // var portalAction = o2.Actions.get("x_portal_assemble_surface");
  1108. // o2.Actions.invokeAsync([
  1109. // {"action": componentAction, "name": "listComponent"},
  1110. // {"action": portalAction, "name": "listApplication"},
  1111. // ], {"success": function(json_component, json_portal){
  1112. // this.loadApplicationsItem(json_layout, json_component.data, json_portal.data);
  1113. // }.bind(this), "failure": function(){}}
  1114. // );
  1115. // }.bind(this));
  1116. this.loadApplicationsItem(this.layoutJson, this.componentJson, this.portalJson);
  1117. },
  1118. loadLayoutApplications: function(callback){
  1119. var url = this.layout.path+"applications.json";
  1120. o2.getJSON(url, function(json){
  1121. if (callback) callback(json);
  1122. }.bind(this));
  1123. },
  1124. loadApplicationsItem: function(layoutJson, componentJson, portalJson){
  1125. debugger;
  1126. var user = this.layout.session.user;
  1127. var currentNames = [user.name, user.distinguishedName, user.id, user.unique];
  1128. if (user.roleList) currentNames = currentNames.concat(user.roleList);
  1129. if (user.groupList) currentNames = currentNames.concat(user.groupList);
  1130. var json_layout = Array.clone(layoutJson);
  1131. var json_component = Array.clone(componentJson);
  1132. var json_portal = Array.clone(portalJson);
  1133. this.appContentNode.removeClass("icon_loading");
  1134. var loadedApps = {};
  1135. if (this.menuData && this.menuData.appList && this.menuData.appList.length){
  1136. this.menuData.appList.each(function(app){
  1137. if (app.type==="group"){
  1138. this.createGroupMenuItem(app);
  1139. app.itemDataList.each(function(a){
  1140. var d = json_layout.find(function(i){ return (i.id === a.id); });
  1141. if (d) json_layout.erase(d);
  1142. d = json_component.find(function(i){ return (i.id === a.id); });
  1143. if (d) json_component.erase(d);
  1144. d = json_portal.find(function(i){ return (i.id === a.id); });
  1145. if (d) json_portal.erase(d);
  1146. }.bind(this));
  1147. }else{
  1148. var appData = null;
  1149. if (!appData && json_layout && json_layout.length){
  1150. appData = json_layout.find(function(i){ return (i.id === app.id); });
  1151. if (appData){
  1152. json_layout.erase(appData);
  1153. if ( this.checkMenuItem(appData, currentNames) ) this.createApplicationMenuItem(appData);
  1154. }
  1155. }
  1156. if (!appData && json_component && json_component.length){
  1157. appData = json_component.find(function(i){ return (i.id === app.id); });
  1158. if (appData){
  1159. json_component.erase(appData);
  1160. if ( this.checkMenuItem(appData, currentNames) ) this.createApplicationMenuItem(appData);
  1161. }
  1162. }
  1163. if (!appData && json_portal && json_portal.length){
  1164. appData = json_portal.find(function(i){ return (i.id === app.id); });
  1165. if (appData){
  1166. json_portal.erase(appData);
  1167. appData.type = "portal";
  1168. this.createPortalMenuItem(appData);
  1169. }
  1170. }
  1171. }.bind(this));
  1172. }
  1173. if (json_layout && json_layout.length) json_layout.each(function(value){
  1174. if ( this.checkMenuItem(value, currentNames) ) this.createApplicationMenuItem(value);
  1175. }.bind(this));
  1176. if (json_component && json_component.length) json_component.each(function(value){
  1177. if ( this.checkMenuItem(value, currentNames) ) this.createApplicationMenuItem(value);
  1178. }.bind(this));
  1179. if (json_portal && json_portal.length) json_portal.each(function(value){
  1180. this.createPortalMenuItem(value);
  1181. }.bind(this));
  1182. if (json_portal && json_portal.length) json_portal.each(function(value){
  1183. value.type = "portal";
  1184. this.createPortalMenuItem(value);
  1185. }.bind(this));
  1186. },
  1187. loadProcesses: function(){
  1188. this.clearAppContentNode();
  1189. // o2.Actions.get("x_processplatform_assemble_surface").listApplication(this.loadProcessesItem.bind(this));
  1190. this.loadProcessesItem(this.processJson)
  1191. },
  1192. loadProcessesItem: function(list){
  1193. this.appContentNode.removeClass("icon_loading");
  1194. var json = Array.clone(list);
  1195. if (this.menuData && this.menuData.processList && this.menuData.processList.length){
  1196. this.menuData.processList.each(function(app){
  1197. if (app.type==="group"){
  1198. this.createGroupMenuItem(app);
  1199. app.itemDataList.each(function(a){
  1200. var d = json.find(function(i){ return (i.id === a.id); });
  1201. if (d) json.erase(d);
  1202. }.bind(this));
  1203. }else{
  1204. var appData = null;
  1205. if (!appData && json && json.length){
  1206. appData = json.find(function(i){ return (i.id === app.id); });
  1207. if (appData){
  1208. json.erase(appData);
  1209. appData.type = "process";
  1210. this.createProcessMenuItem(appData);
  1211. }
  1212. }
  1213. }
  1214. }.bind(this));
  1215. }
  1216. if (json && json.length) json.each(function(value){
  1217. value.type = "process";
  1218. this.createProcessMenuItem(value);
  1219. }.bind(this));
  1220. },
  1221. loadInfors: function(){
  1222. this.clearAppContentNode();
  1223. //o2.Actions.get("x_cms_assemble_control").listColumn(this.loadInforsItem.bind(this));
  1224. this.loadInforsItem(this.inforJson)
  1225. },
  1226. loadInforsItem: function(list){
  1227. this.appContentNode.removeClass("icon_loading");
  1228. var json = Array.clone(list);
  1229. if (this.menuData && this.menuData.inforList && this.menuData.inforList.length){
  1230. this.menuData.inforList.each(function(app){
  1231. if (app.type==="group"){
  1232. this.createGroupMenuItem(app);
  1233. app.itemDataList.each(function(a){
  1234. var d = json.find(function(i){ return (i.id === a.id); });
  1235. if (d) json.erase(d);
  1236. }.bind(this));
  1237. }else{
  1238. var appData = null;
  1239. if (!appData && json && json.length){
  1240. appData = json.find(function(i){ return (i.id === app.id); });
  1241. if (appData){
  1242. json.erase(appData);
  1243. appData.type = "cms";
  1244. this.createInforMenuItem(appData);
  1245. }
  1246. }
  1247. }
  1248. }.bind(this));
  1249. }
  1250. if (json && json.length) json.each(function(value){
  1251. value.type = "cms";
  1252. this.createInforMenuItem(value);
  1253. }.bind(this));
  1254. },
  1255. loadQuerys: function(){
  1256. this.clearAppContentNode();
  1257. // o2.Actions.get("x_query_assemble_surface").listQuery(this.loadQuerysItem.bind(this));
  1258. this.loadQuerysItem(this.queryJson)
  1259. },
  1260. loadQuerysItem: function(list){
  1261. this.appContentNode.removeClass("icon_loading");
  1262. var json = Array.clone(list);
  1263. if (this.menuData && this.menuData.queryList && this.menuData.queryList.length){
  1264. this.menuData.queryList.each(function(app){
  1265. if (app.type==="group"){
  1266. this.createGroupMenuItem(app);
  1267. app.itemDataList.each(function(a){
  1268. var d = json.find(function(i){ return (i.id === a.id); });
  1269. if (d) json.erase(d);
  1270. }.bind(this));
  1271. }else{
  1272. var appData = null;
  1273. if (!appData && json && json.length){
  1274. appData = json.find(function(i){ return (i.id === app.id); });
  1275. if (appData){
  1276. json.erase(appData);
  1277. appData.type = "query";
  1278. this.createQueryMenuItem(appData);
  1279. }
  1280. }
  1281. }
  1282. }.bind(this));
  1283. }
  1284. if (json && json.length) json.each(function(value){
  1285. value.type = "query";
  1286. this.createQueryMenuItem(value);
  1287. }.bind(this));
  1288. },
  1289. checkMenuItem: function(value, currentNames){
  1290. if (value.visible===false) return false;
  1291. var isAllow = true;
  1292. if (value.allowList) isAllow = (value.allowList.length) ? (value.allowList.isIntersect(currentNames)) : true;
  1293. var isDeny = false;
  1294. if (value.denyList) isDeny = (value.denyList.length) ? (value.denyList.isIntersect(currentNames)) : false;
  1295. return ((!isDeny && isAllow) || o2.AC.isAdministrator());
  1296. },
  1297. createApplicationMenuItem: function(value){
  1298. this.items.push(new o2.xDesktop.Default.StartMenu.Item(this, this.appContentNode, value));
  1299. },
  1300. createPortalMenuItem: function(value){
  1301. this.items.push(new o2.xDesktop.Default.StartMenu.PortalItem(this, this.appContentNode, value));
  1302. },
  1303. createProcessMenuItem: function(value){
  1304. this.items.push(new o2.xDesktop.Default.StartMenu.ProcessItem(this, this.appContentNode, value));
  1305. },
  1306. createInforMenuItem: function(value){
  1307. this.items.push(new o2.xDesktop.Default.StartMenu.InforItem(this, this.appContentNode, value));
  1308. },
  1309. createQueryMenuItem: function(value){
  1310. this.items.push(new o2.xDesktop.Default.StartMenu.QueryItem(this, this.appContentNode, value));
  1311. },
  1312. createGroupMenuItem: function(value){
  1313. this.items.push(new o2.xDesktop.Default.StartMenu.GroupItem(this, this.appContentNode, value));
  1314. },
  1315. show: function(){
  1316. if (!this.isMorph){
  1317. this.isMorph = true;
  1318. if (!this.morph){
  1319. this.maskMorph = new Fx.Morph(this.maskNode, {
  1320. duration: "200",
  1321. transition: Fx.Transitions.Sine.easeOut
  1322. });
  1323. this.morph = new Fx.Morph(this.node, {
  1324. duration: "200",
  1325. transition: Fx.Transitions.Sine.easeOut
  1326. });
  1327. }
  1328. this.maskNode.setStyles({"display": "block"});
  1329. this.node.setStyles({"display": "block"});
  1330. this.triangleNode.setStyles({"display": "block"});
  1331. this.appAreaNode.setStyles({ "filter": "" });
  1332. this.setSize();
  1333. this.setPosition();
  1334. var size = this.layout.menuNode.getSize();
  1335. var left = size.x;
  1336. this.loadJsons(function(){
  1337. (this.currentTab || this.appCategoryTab).click();
  1338. }.bind(this));
  1339. //this.loadContent();
  1340. this.maskMorph.start({"left": ""+left+"px"});
  1341. this.morph.start({"left": ""+left+"px"}).chain(function(){
  1342. this.isShow = true;
  1343. this.isMorph = false;
  1344. this.layout.desktopNode.addEvent("mousedown", this.hideMessage);
  1345. this.setScroll();
  1346. this.fireEvent("show");
  1347. }.bind(this));
  1348. }
  1349. },
  1350. hide: function(callback){
  1351. if (!this.isMorph){
  1352. this.isMorph = true;
  1353. if (!this.morph){
  1354. this.maskMorph = new Fx.Morph(this.maskNode, {
  1355. duration: "200",
  1356. transition: Fx.Transitions.Sine.easeOut
  1357. });
  1358. this.morph = new Fx.Morph(this.node, {
  1359. duration: "200",
  1360. transition: Fx.Transitions.Sine.easeOut
  1361. });
  1362. }
  1363. var nodeSize = this.node.getSize();
  1364. var left = 0-nodeSize.x;
  1365. // var position = this.node.getPosition();
  1366. // var size = this.node.getSize();
  1367. // var left = position.x+size.x;
  1368. this.isSearchResult = false;
  1369. this.hideSearch();
  1370. this.lnkContentNode.empty();
  1371. this.appContentNode.empty();
  1372. this.groupMenuArea.empty();
  1373. if (this.appScrollBar) this.appScrollBar.destroy();
  1374. this.maskMorph.start({"left": ""+left+"px"}).chain(function(){
  1375. this.maskNode.setStyle("display", "none");
  1376. this.triangleNode.setStyles({"display": "none"});
  1377. }.bind(this));
  1378. this.morph.start({"left": ""+left+"px"}).chain(function(){
  1379. this.node.setStyle("display", "none");
  1380. this.isShow = false;
  1381. this.isMorph = false;
  1382. this.layout.desktopNode.removeEvent("mousedown", this.hideMessage);
  1383. this.fireEvent("hide");
  1384. if (callback) callback();
  1385. }.bind(this));
  1386. }
  1387. },
  1388. defaultMenu: function(){
  1389. this.layout.menuData = null;
  1390. if (this.layout.status) this.layout.status.menuData = null;
  1391. this.menuData = null;
  1392. this.hide();
  1393. }
  1394. });
  1395. o2.xDesktop.Default.StartMenu.Item = new Class({
  1396. initialize: function (menu, container, data, positionNode) {
  1397. this.menu = menu;
  1398. this.layout = this.menu.layout;
  1399. this.data = data;
  1400. this.container = $(container);
  1401. this.load(positionNode);
  1402. this.init();
  1403. },
  1404. load: function(positionNode){
  1405. this.node = new Element("div.layout_start_item");
  1406. if (positionNode){
  1407. this.node.inject(positionNode, "before");
  1408. }else{
  1409. this.node.inject(this.container);
  1410. }
  1411. this.node.set("html", this.menu.itemTempletedHtml);
  1412. this.iconAreaNode = this.node.getElement(".layout_start_item_iconArea");
  1413. this.iconNode = this.node.getElement(".layout_start_item_icon");
  1414. this.badgeNode = this.node.getElement(".layout_start_item_badge");
  1415. this.textNode = this.node.getElement(".layout_start_item_text");
  1416. this.loadIcon();
  1417. this.loadBadge();
  1418. this.loadText();
  1419. this.setEvent();
  1420. this.node.store("item", this);
  1421. if (this.menu.data && this.menu.data.type==="group"){
  1422. this.node.addClass("layout_start_item_sub");
  1423. }
  1424. },
  1425. init: function(){},
  1426. dragOver: function(){
  1427. if (!this.overNode){
  1428. this.overNode = new Element("div.layout_start_item_over").inject(this.container);
  1429. this.overNode.addClass("mainColor_bg");
  1430. }
  1431. this.overNode.position({
  1432. "relativeTo": this.iconAreaNode,
  1433. "position": "leftTop",
  1434. "edge": "leftTop",
  1435. "offset": {
  1436. "x": -6, "y":-6
  1437. }
  1438. });
  1439. this.overNode.show();
  1440. },
  1441. dragOut: function(){
  1442. if (this.overNode) this.overNode.hide();
  1443. },
  1444. loadIcon: function(){
  1445. var icon;
  1446. var bgcolor = "";
  1447. if (this.data.path.substring(0, 4)==="@url"){
  1448. if (this.data.iconPath){
  1449. icon = this.data.iconPath;
  1450. }else{
  1451. if (this.layout.iconsJson["Url"] && this.layout.iconsJson["Url"].icon){
  1452. icon = this.layout.path+"appicons/"+this.layout.iconsJson["Url"].icon;
  1453. bgcolor = this.layout.iconsJson["Url"].color;
  1454. }else{
  1455. icon = "../x_component_Setting/$Main/default/icon/site.png";
  1456. bgcolor = "";
  1457. }
  1458. }
  1459. }else{
  1460. if (this.layout.iconsJson[this.data.path] && this.layout.iconsJson[this.data.path].icon){
  1461. icon = this.layout.path+"appicons/"+this.layout.iconsJson[this.data.path].icon;
  1462. bgcolor = this.layout.iconsJson[this.data.path].color;
  1463. }else{
  1464. icon = "../x_component_"+this.data.path.replace(/\./g, "_")+"/$Main/"+this.data.iconPath;
  1465. bgcolor = "";
  1466. }
  1467. }
  1468. if (icon && bgcolor){
  1469. this.iconNode.addClass("layout_start_item_icon_flat");
  1470. this.iconNode.setStyle("background-color", bgcolor);
  1471. }
  1472. this.iconNode.setStyle("background-image", "url("+icon+")");
  1473. this.icon = icon;
  1474. this.bgcolor = bgcolor;
  1475. },
  1476. loadBadge: function(){
  1477. this.badgeNode.set("title", o2.LP.desktop.addLnk).addClass("icon_add_red");
  1478. },
  1479. loadText: function(){
  1480. this.textNode.set("text", this.data.title || this.data.name);
  1481. },
  1482. setEvent: function(){
  1483. this.node.addEvents({
  1484. "mouseover": function(){ this.badgeNode.fade("in"); }.bind(this),
  1485. "mouseout": function(){ this.badgeNode.fade("out"); }.bind(this),
  1486. "click": function(e){
  1487. //this.menu.hide(function(){
  1488. this.open(e);
  1489. //}.bind(this));
  1490. }.bind(this)
  1491. });
  1492. this.badgeNode.addEvent("click", function(e){
  1493. this.addLnk();
  1494. e.stopPropagation();
  1495. }.bind(this));
  1496. this.makeLnk();
  1497. },
  1498. addLnk: function(dragTargetLnk, dragPosition){
  1499. lnkdata = {
  1500. "name": this.data.path,
  1501. "title": this.data.title,
  1502. "iconData": this.data.iconData || null,
  1503. "icon": this.iconData || null,
  1504. "appType": null,
  1505. "options": null
  1506. }
  1507. this.layout.addLnk(lnkdata, dragTargetLnk, dragPosition);
  1508. },
  1509. open: function(e){
  1510. this.menu.hide(function(){
  1511. if (this.menu.menu){
  1512. this.menu.menu.hide(function(){
  1513. layout.openApplication(e, this.data.path);
  1514. }.bind(this));
  1515. }else{
  1516. layout.openApplication(e, this.data.path);
  1517. }
  1518. }.bind(this));
  1519. },
  1520. makeLnk: function(){
  1521. var drag = new Drag(this.node, {
  1522. "stopPropagation": true,
  1523. "compensateScroll": true,
  1524. "onStart": function(el, e){
  1525. this.doDragMove(e);
  1526. drag.stop();
  1527. }.bind(this)
  1528. });
  1529. },
  1530. getDragNode: function(){
  1531. if (!this.dragNode){
  1532. this.dragNode = new Element("div.layout_menu_lnk_item_drag")
  1533. .setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex())
  1534. .inject(this.layout.node);
  1535. var dragIconNode = this.iconNode.clone(true).inject(this.dragNode)
  1536. .removeClass("layout_menu_lnk_item_icon")
  1537. .addClass("layout_menu_lnk_item_icon_drag");
  1538. if (this.bgcolor) dragIconNode.setStyle("background-color", this.bgcolor);
  1539. }
  1540. var p = this.iconNode.getPosition(this.dragNode.getOffsetParent());
  1541. this.dragNode.show().setStyles({
  1542. "left": ""+p.x+"px", "top": ""+p.y+"px"
  1543. });
  1544. },
  1545. doDragMove: function(e){
  1546. this.getDragNode();
  1547. var droppables = [this.layout.lnkContentNode, this.menu.appContentNode];
  1548. if (this.menu.appContentNode.hasClass("layout_start_groupItem_menu_content")){
  1549. this.onGroup = true;
  1550. }
  1551. //if (this.menu.maskGroupNode) droppables.push(this.menu.maskGroupNode);
  1552. var drag = new Drag.Move(this.dragNode, {
  1553. "stopPropagation": true,
  1554. "compensateScroll": true,
  1555. "droppables": droppables,
  1556. "onStart": function(el){ this._drag_start(el); }.bind(this),
  1557. "onDrag": function(dragging,e){ this._drag_drag(dragging, e); }.bind(this),
  1558. "onEnter": function(dragging, inObj){ this._drag_enter(dragging, inObj); }.bind(this),
  1559. "onLeave": function(dragging, obj){ this._drag_leave(dragging, obj); }.bind(this),
  1560. "onDrop": function(dragging, inObj){ this._drag_drop(dragging, inObj); }.bind(this),
  1561. "onCancel": function(dragging){ this._drag_cancel(dragging); }.bind(this),
  1562. "onComplete": function(dragging, e){ this._drag_complete(dragging, e); }.bind(this),
  1563. });
  1564. drag.start(e);
  1565. this.dragStatus == "remove";
  1566. },
  1567. _drag_start: function(el){
  1568. this.isDrag = true;
  1569. this.dragTargetLnk = null;
  1570. this.dragPosition = "before";
  1571. this.node.setStyle("opacity", 0.2);
  1572. this.positionFlagNode = new Element("div", {"styles": {"display": "none"}}).inject(this.node, "after");
  1573. },
  1574. _drag_drag: function(dragging, e){
  1575. console.log(this.dragStatus);
  1576. if (this.dragStatus == "order"){
  1577. if (this.layout.lnks && this.layout.lnks.length){
  1578. var current = e.page.y;
  1579. for (var i=0; i<this.layout.lnks.length; i++){
  1580. var lnk = this.layout.lnks[i];
  1581. var y = lnk.node.getSize().y;
  1582. var top = lnk.node.getPosition(this.layout.node).y;
  1583. var center = top+y/2;
  1584. var bottom = top+y;
  1585. if (top<=current && center>=current){
  1586. this.dragTargetLnk = lnk;
  1587. this.dragPosition = "before";
  1588. break;
  1589. }else if (center<=current && bottom>=current){
  1590. this.dragTargetLnk = lnk;
  1591. this.dragPosition = "after";
  1592. break;
  1593. }
  1594. }
  1595. if (!this.layout.positionNode) this.layout.positionNode = new Element("div.layout_menu_lnk_item_position")
  1596. .setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex())
  1597. .inject(this.layout.node);
  1598. this.layout.positionNode.show();
  1599. if (!this.dragTargetLnk){
  1600. this.dragTargetLnk = this.layout.lnks[this.layout.lnks.length-1];
  1601. this.dragPosition = "after";
  1602. }
  1603. this.layout.positionNode.position({
  1604. relativeTo: this.dragTargetLnk.node,
  1605. position: (this.dragPosition=="before") ? 'topcenter' : 'bottomcenter',
  1606. edge: 'center'
  1607. });
  1608. }
  1609. }
  1610. if (this.dragStatus == "group"){
  1611. if (!this.onGroup) this.checkDargOver(dragging);
  1612. if (!this.overItem){
  1613. this.checkDargPosition(dragging);
  1614. }
  1615. }
  1616. },
  1617. checkDargOver: function(dragging){
  1618. var p = dragging.getPosition();
  1619. var s = dragging.getSize();
  1620. var x = p.x+s.x/2-1;
  1621. var y = p.y+s.y/2-1;
  1622. var ex = x+2;
  1623. var ey = y+2;
  1624. var overItem = null;
  1625. this.menu.items.each(function(item){
  1626. if (!item.isDrag){
  1627. if (item.iconAreaNode.isInPointInRect(x,y,ex,ey)){
  1628. item.dragOver();
  1629. overItem = item;
  1630. }else{
  1631. item.dragOut();
  1632. }
  1633. }
  1634. });
  1635. this.overItem = overItem;
  1636. },
  1637. checkDargPosition: function(dragging){
  1638. var p = dragging.getPosition();
  1639. var s = dragging.getSize();
  1640. 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 };
  1641. var leftP = { "x": p.x, "y": p.y+s.y/2-1, "ex": p.x+2, "ey": p.y+s.y/2+1 };
  1642. var moveFlag = false;
  1643. for (var i = 0; i<this.menu.items.length; i++){
  1644. var item = this.menu.items[i];
  1645. if (!item.isDrag){
  1646. if (item.iconAreaNode.isInPointInRect(rightP.x, rightP.y, rightP.ex, rightP.ey)){
  1647. moveFlag = true;
  1648. this.node.inject(item.node, "before");
  1649. break;
  1650. }else if (item.iconAreaNode.isInPointInRect(leftP.x, leftP.y, leftP.ex, leftP.ey)){
  1651. moveFlag = true;
  1652. this.node.inject(item.node, "after");
  1653. break;
  1654. }
  1655. }
  1656. }
  1657. //if (!moveFlag) this.node.inject(this.menu.appContentNode);
  1658. },
  1659. _drag_enter: function(el, inObj){
  1660. if (inObj.hasClass("layout_start_content_appContent") || inObj.hasClass("layout_start_groupItem_menu_content")){
  1661. this.dragStatus = "group";
  1662. this.node.setStyle("opacity", 0.2);
  1663. }else{
  1664. if (this.positionFlagNode) this.node.inject(this.positionFlagNode, "before");
  1665. this.dragStatus = "order";
  1666. this.node.setStyle("opacity", 1);
  1667. }
  1668. },
  1669. _drag_leave: function(el, inObj){
  1670. console.log("_drag_leave");
  1671. if (inObj.hasClass("layout_start_content_appContent")){
  1672. //this.node.inject(this.menu.appContentNode);
  1673. }else if (inObj.hasClass("layout_start_groupItem_menu_content")){
  1674. this.dragStatus = "ungroup";
  1675. this.node.setStyle("opacity", 0);
  1676. }else{
  1677. this.dragStatus = "remove";
  1678. if (this.layout.positionNode) this.layout.positionNode.hide();
  1679. }
  1680. },
  1681. _drag_drop: function(dragging, inObj){
  1682. if (this.dragStatus==="ungroup"){
  1683. this.removeFormGroup();
  1684. }else{
  1685. if (this.dragStatus == "order" && this.dragTargetLnk && this.dragTargetLnk!=this){
  1686. this.addLnk(this.dragTargetLnk, this.dragPosition);
  1687. }else if (this.dragStatus == "group" && this.overItem && this.overItem!=this){
  1688. this.overItem.dragOut();
  1689. this.addGroup();
  1690. }
  1691. this.node.setStyle("opacity", 1);
  1692. }
  1693. this.menu.resetMenuData();
  1694. },
  1695. _drag_cancel: function(dragging){
  1696. console.log("_drag_cancel");
  1697. dragging.hide();
  1698. if (this.layout.positionNode) this.layout.positionNode.hide();
  1699. if (this.dragRemoveNode) this.dragRemoveNode.hide();
  1700. this.node.setStyle("opacity", 1);
  1701. this.isDrag = false;
  1702. this.menu.resetMenuData();
  1703. },
  1704. _drag_complete: function(dragging) {
  1705. this._drag_cancel(dragging);
  1706. if (this.positionFlagNode) this.positionFlagNode.destroy();
  1707. this.positionFlagNode = null;
  1708. },
  1709. removeFormGroup: function(){
  1710. // this.menu.itemDataList.erase(this.data);
  1711. // this.menu.items.erase(this);
  1712. this.menu.data.itemDataList.erase(this.data);
  1713. switch (this.data.type){
  1714. case "portal":
  1715. this.layout.startMenu.createPortalMenuItem(this.data);
  1716. break;
  1717. case "process":
  1718. this.layout.startMenu.createProcessMenuItem(this.data);
  1719. break;
  1720. case "cms":
  1721. this.layout.startMenu.createInforMenuItem(this.data);
  1722. break;
  1723. case "query":
  1724. this.layout.startMenu.createQueryMenuItem(this.data);
  1725. break;
  1726. default:
  1727. this.layout.startMenu.createApplicationMenuItem(this.data);
  1728. }
  1729. debugger;
  1730. this.destroy();
  1731. if (!this.menu.data.itemDataList.length){
  1732. this.menu.hide(function(){
  1733. this.menu.destroy();
  1734. }.bind(this));
  1735. }else{
  1736. this.menu.resetSubItemIcon();
  1737. }
  1738. },
  1739. addGroup: function(){
  1740. debugger;
  1741. if (this.overItem.data.type==="group"){
  1742. this.overItem.addItem(this.data);
  1743. }else{
  1744. var v = {
  1745. name: "Group",
  1746. title: "Group",
  1747. type: "group",
  1748. visible: true
  1749. }
  1750. var group = new o2.xDesktop.Default.StartMenu.GroupItem(this.menu, this.container, v, this.overItem.node);
  1751. group.addItem(this.overItem.data);
  1752. group.addItem(this.data);
  1753. this.menu.items.push(group);
  1754. this.overItem.node.destroy();
  1755. group.open(null, function(){
  1756. group.editTitle();
  1757. });
  1758. }
  1759. this.node.destroy();
  1760. this.menu.resetMenuData();
  1761. },
  1762. destroy: function(){
  1763. this.menu.items.erase(this);
  1764. this.node.destroy();
  1765. }
  1766. });
  1767. o2.xDesktop.Default.StartMenu.GroupItem = new Class({
  1768. Extends: o2.xDesktop.Default.StartMenu.Item,
  1769. loadIcon: function(){
  1770. this.iconNode.addClass("layout_start_item_icon_group");
  1771. this.iconNode.addClass("grayColor_bg");
  1772. this.sunIconNodes = [];
  1773. var node = new Element("div.layout_start_item_icon_group_sub").inject(this.iconNode);
  1774. this.sunIconNodes.push(node);
  1775. node = new Element("div.layout_start_item_icon_group_sub").inject(this.iconNode);
  1776. this.sunIconNodes.push(node);
  1777. node = new Element("div.layout_start_item_icon_group_sub").inject(this.iconNode);
  1778. this.sunIconNodes.push(node);
  1779. node = new Element("div.layout_start_item_icon_group_sub").inject(this.iconNode);
  1780. this.sunIconNodes.push(node);
  1781. },
  1782. init: function(){
  1783. this.itemTempletedHtml = this.menu.itemTempletedHtml;
  1784. if (this.data.itemDataList && this.data.itemDataList.length){
  1785. for (var i=0; i<Math.min(this.data.itemDataList.length, 4); i++){
  1786. var icon = this.setSubItemIcon(this.data.itemDataList[i], this.sunIconNodes[i]);
  1787. }
  1788. }
  1789. },
  1790. resetSubItemIcon: function(){
  1791. this.sunIconNodes.each(function(e){
  1792. e.setStyle("background-image", "");
  1793. e.setStyle("background-color", "");
  1794. });
  1795. if (this.data.itemDataList && this.data.itemDataList.length){
  1796. for (var i=0; i<Math.min(this.data.itemDataList.length, 4); i++){
  1797. var icon = this.setSubItemIcon(this.data.itemDataList[i], this.sunIconNodes[i]);
  1798. }
  1799. }
  1800. },
  1801. open: function(e, callback){
  1802. if (!this.menuNode) this.createMenuNode();
  1803. this.maskNode = new Element("div.layout_start_groupItem_menuMask").inject(this.menuNode, "before");
  1804. this.maskNode.addEvent("click", function(e){
  1805. this.hide();
  1806. }.bind(this));
  1807. this.maskGroupNode = this.maskNode;
  1808. this.menuNode.show();
  1809. var styles = this.getMenuNodeOpenDimensions();
  1810. this.menuNode.morph.set("transition", Fx.Transitions.Quart.easeOut);
  1811. this.menuNode.morph.start(styles).chain(function(){
  1812. this.menuTitleNode.show();
  1813. this.menuScrollNode.show();
  1814. var s = this.menuNode.getSize();
  1815. var ts = this.menuTitleNode.getSize();
  1816. var h = s.y - ts.y;
  1817. this.menuContentNode.setStyle("height", ""+h+"px");
  1818. this.loadItems();
  1819. if (callback) callback();
  1820. }.bind(this));
  1821. this.menu.appAreaNode.setStyles({ "filter": "blur(5px)" });
  1822. },
  1823. hide: function(callback){
  1824. this.menuTitleNode.hide();
  1825. this.menuScrollNode.hide();
  1826. var styles = this.getMenuNodeCloseDimensions();
  1827. this.menuNode.morph.set("transition", Fx.Transitions.Quart.easeIn);
  1828. this.menuNode.morph.start(styles).chain(function(){
  1829. if (this.maskNode) this.maskNode.destroy();
  1830. if (this.menuNode) this.menuNode.hide();
  1831. if (callback) callback();
  1832. }.bind(this));
  1833. this.menu.appAreaNode.setStyles({ "filter": "" });
  1834. },
  1835. loadItems: function(){
  1836. if (!this.items) this.items = [];
  1837. this.data.itemDataList.each(function(data){
  1838. var item = this.items.find(function(i){
  1839. return i.data.id == data.id;
  1840. });
  1841. if (!item){
  1842. switch (data.type){
  1843. case "portal":
  1844. this.items.push(new o2.xDesktop.Default.StartMenu.PortalItem(this, this.menuContentNode, data));
  1845. break;
  1846. case "process":
  1847. this.items.push(new o2.xDesktop.Default.StartMenu.ProcessItem(this, this.menuContentNode, data));
  1848. break;
  1849. case "cms":
  1850. this.items.push(new o2.xDesktop.Default.StartMenu.InforItem(this, this.menuContentNode, data));
  1851. break;
  1852. case "query":
  1853. this.items.push(new o2.xDesktop.Default.StartMenu.QueryItem(this, this.menuContentNode, data));
  1854. break;
  1855. default:
  1856. this.items.push(new o2.xDesktop.Default.StartMenu.Item(this, this.menuContentNode, data));
  1857. }
  1858. }
  1859. }.bind(this));
  1860. },
  1861. getMenuNodeOpenDimensions: function(){
  1862. var size = this.menu.appAreaNode.getSize();
  1863. var w = size.x*0.94;
  1864. var h = size.y*0.7;
  1865. var x = (size.x*(1-0.94))/2;
  1866. var y = (size.y*(1-0.7))/2;
  1867. return {"width":w, "height": h, "left": x, "top": y}
  1868. },
  1869. getMenuNodeCloseDimensions: function(){
  1870. var size = this.iconNode.getSize();
  1871. var position = this.iconNode.getPosition(this.menu.node);
  1872. return {"width":size.x, "height": size.y, "left": position.x, "top": position.y}
  1873. },
  1874. createMenuNode: function(){
  1875. this.menuNode = new Element("div.layout_start_groupItem_menu").inject(this.menu.groupMenuArea);
  1876. this.menuNode.addClass("grayColor_bg");
  1877. this.menuTitleNode = new Element("div.layout_start_groupItem_menu_title").inject(this.menuNode);
  1878. this.menuTitleNode.set("text", this.data.name);
  1879. this.menuScrollNode = new Element("div.layout_start_groupItem_menu_scroll").inject(this.menuNode);
  1880. this.menuContentNode = new Element("div.layout_start_groupItem_menu_content").inject(this.menuScrollNode);
  1881. this.appContentNode = this.menuContentNode;
  1882. this.menuNode.position({
  1883. "relativeTo": this.iconNode,
  1884. "position": "upperLeft",
  1885. "edge": "upperLeft"
  1886. });
  1887. this.menuNode.morph = new Fx.Morph(this.menuNode, {
  1888. "duration": 200,
  1889. "transition": Fx.Transitions.Quart.easeOut
  1890. });
  1891. this.menuTitleNode.addEvent("click", function(){
  1892. var input = this.menuTitleNode.getElement("input");
  1893. if (!input) this.editTitle();
  1894. }.bind(this));
  1895. o2.require("o2.widget.ScrollBar", function(){
  1896. this.appScrollBar = new o2.widget.ScrollBar(this.menuContentNode, {
  1897. "style":"xDesktop_Message", "where": "before", "indent": false, "distance": 100, "friction": 6, "axis": {"x": false, "y": true}
  1898. });
  1899. }.bind(this));
  1900. },
  1901. destroy: function(){
  1902. this.menu.items.erase(this);
  1903. this.node.destroy();
  1904. this.menuNode.destroy();
  1905. },
  1906. editTitle: function(){
  1907. this.menuTitleNode.empty();
  1908. this.editotTitleNode = new Element("input.layout_start_groupItem_menu_title_edit", {"type": "text"}).inject(this.menuTitleNode);
  1909. this.editotTitleNode.set("value", this.data.name);
  1910. this.editotTitleNode.focus();
  1911. this.editotTitleNode.addEvent("blur", function(){
  1912. var name = this.editotTitleNode.get("value");
  1913. if (name) this.data.name = name;
  1914. this.menuTitleNode.empty();
  1915. this.menuTitleNode.set("text", this.data.name);
  1916. this.loadText();
  1917. }.bind(this));
  1918. },
  1919. addItem: function(data){
  1920. if (!this.data.itemDataList) this.data.itemDataList = [];
  1921. if (this.data.itemDataList.length<4){
  1922. this.setSubItemIcon(data, this.sunIconNodes[this.data.itemDataList.length]);
  1923. }
  1924. this.data.itemDataList.push(data);
  1925. },
  1926. setSubItemIcon: function(data, node){
  1927. switch (data.type){
  1928. case "process":
  1929. this.setAppSubItemIcon(node, data.icon, "processDefault", "../x_component_process_ApplicationExplorer/$Main/default/icon/application.png");
  1930. break;
  1931. case "portal":
  1932. this.setAppSubItemIcon(node, data.icon, "portalDefault", "../x_component_portal_PortalExplorer/$Main/default/icon/application.png");
  1933. break;
  1934. case "cms":
  1935. this.setAppSubItemIcon(node, data.icon, "cmsDefault", "../x_component_cms_Index/$Main/default/icon/column.png");
  1936. break;
  1937. case "query":
  1938. this.setAppSubItemIcon(node, data.icon, "queryDefault", "../x_component_query_Query/$Main/appicon.png");
  1939. break;
  1940. default:
  1941. this.setDefaultSubItemIcon(data, node);
  1942. }
  1943. },
  1944. setAppSubItemIcon: function(node, iconData, defaultIcon, defaultUrl){
  1945. var icon = "";
  1946. var bgcolor = "";
  1947. if (iconData){
  1948. icon = "data:image/png;base64,"+iconData+"";
  1949. bgcolor = "";
  1950. node.addClass("layout_start_item_icon_group_subIcon");
  1951. }else{
  1952. var p = defaultIcon;
  1953. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  1954. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  1955. bgcolor = this.layout.iconsJson[p].color;
  1956. }else{
  1957. icon = defaultUrl;
  1958. bgcolor = "";
  1959. }
  1960. }
  1961. if (icon && bgcolor) node.setStyle("background-color", bgcolor);
  1962. node.setStyle("background-image", "url("+icon+")");
  1963. },
  1964. setDefaultSubItemIcon: function(data, node){
  1965. var icon;
  1966. var bgcolor = "";
  1967. if (data.path.substring(0, 4)==="@url"){
  1968. if (data.iconPath){
  1969. icon = data.iconPath;
  1970. }else{
  1971. if (this.layout.iconsJson["Url"] && this.layout.iconsJson["Url"].icon){
  1972. icon = this.layout.path+"appicons/"+this.layout.iconsJson["Url"].icon;
  1973. bgcolor = this.layout.iconsJson["Url"].color;
  1974. }else{
  1975. icon = "../x_component_Setting/$Main/default/icon/site.png";
  1976. bgcolor = "";
  1977. }
  1978. }
  1979. }else{
  1980. if (this.layout.iconsJson[data.path] && this.layout.iconsJson[data.path].icon){
  1981. icon = this.layout.path+"appicons/"+this.layout.iconsJson[data.path].icon;
  1982. bgcolor = this.layout.iconsJson[data.path].color;
  1983. }else{
  1984. icon = "../x_component_"+data.path.replace(/\./g, "_")+"/$Main/"+data.iconPath;
  1985. bgcolor = "";
  1986. }
  1987. }
  1988. if (icon && bgcolor){
  1989. node.setStyle("background-color", bgcolor);
  1990. }
  1991. node.setStyle("background-image", "url("+icon+")");
  1992. },
  1993. resetMenuData: function(){
  1994. debugger;
  1995. var nodes = this.menuContentNode.getChildren(".layout_start_item");
  1996. var data = [];
  1997. nodes.each(function(node){
  1998. var item = node.retrieve("item");
  1999. if (item){
  2000. data.push(item.data);
  2001. }
  2002. }.bind(this));
  2003. this.data.itemDataList = data;
  2004. }
  2005. });
  2006. o2.xDesktop.Default.StartMenu.PortalItem = new Class({
  2007. Extends: o2.xDesktop.Default.StartMenu.Item,
  2008. loadIcon: function(){
  2009. var icon = "";
  2010. var bgcolor = "";
  2011. if (this.data.icon){
  2012. icon = "data:image/png;base64,"+this.data.icon+"";
  2013. }else{
  2014. var p = "portalDefault";
  2015. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  2016. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  2017. bgcolor = this.layout.iconsJson[p].color;
  2018. }else{
  2019. icon = "../x_component_portal_PortalExplorer/$Main/default/icon/application.png";
  2020. bgcolor = "";
  2021. }
  2022. }
  2023. if (icon && bgcolor){
  2024. this.iconNode.addClass("layout_start_item_icon_flat");
  2025. this.iconNode.setStyle("background-color", bgcolor);
  2026. }
  2027. this.iconNode.setStyle("background-image", "url("+icon+")");
  2028. this.icon = icon;
  2029. },
  2030. loadText: function(){
  2031. this.textNode.set("text", this.data.name);
  2032. },
  2033. addLnk: function(dragTargetLnk, dragPosition){
  2034. var options = {"portalId": this.data.id, "appId": "portal.Portal"+this.data.id};
  2035. lnkdata = {
  2036. "name": "portal.Portal",
  2037. "title": this.data.name,
  2038. "iconData": (this.data.icon) || "",
  2039. "icon": null,
  2040. "appType": "portal",
  2041. "options": options
  2042. }
  2043. this.layout.addLnk(lnkdata, dragTargetLnk, dragPosition);
  2044. },
  2045. open: function(e){
  2046. var options = {"portalId": this.data.id, "appId": "portal.Portal"+this.data.id};
  2047. this.menu.hide(function(){
  2048. if (this.menu.menu){
  2049. this.menu.menu.hide(function(){
  2050. layout.openApplication(e, "portal.Portal", options);
  2051. }.bind(this));
  2052. }else{
  2053. layout.openApplication(e, "portal.Portal", options);
  2054. }
  2055. }.bind(this));
  2056. }
  2057. // makeLnk: function(){
  2058. // //@todo
  2059. // // this.node.makeLnk({
  2060. // // "par": {"icon": this.icon, "color": this.color, "title": this.data.title, "par": this.data.path},
  2061. // // });
  2062. // }
  2063. });
  2064. o2.xDesktop.Default.StartMenu.ProcessItem = new Class({
  2065. Extends: o2.xDesktop.Default.StartMenu.PortalItem,
  2066. loadIcon: function(){
  2067. var icon = "";
  2068. var bgcolor = "";
  2069. if (this.data.icon){
  2070. icon = "data:image/png;base64,"+this.data.icon+"";
  2071. bgcolor = "";
  2072. }else{
  2073. var p = "processDefault";
  2074. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  2075. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  2076. bgcolor = this.layout.iconsJson[p].color;
  2077. }else{
  2078. icon = "../x_component_process_ApplicationExplorer/$Main/default/icon/application.png";
  2079. bgcolor = "";
  2080. }
  2081. }
  2082. if (icon && bgcolor){
  2083. this.iconNode.addClass("layout_start_item_icon_flat");
  2084. this.iconNode.setStyle("background-color", bgcolor);
  2085. }
  2086. this.iconNode.setStyle("background-image", "url("+icon+")");
  2087. this.icon = icon;
  2088. },
  2089. addLnk: function(dragTargetLnk, dragPosition){
  2090. var options = {"id": this.data.id, "appId": "process.Application"+this.data.id};
  2091. lnkdata = {
  2092. "name": "process.Application",
  2093. "title": this.data.name,
  2094. "iconData": (this.data.icon) || "",
  2095. "icon": null,
  2096. "appType": "process",
  2097. "options": options
  2098. }
  2099. this.layout.addLnk(lnkdata, dragTargetLnk, dragPosition);
  2100. },
  2101. open: function(e){
  2102. var options = {"id": this.data.id, "appId": "process.Application"+this.data.id};
  2103. this.menu.hide(function(){
  2104. if (this.menu.menu){
  2105. this.menu.menu.hide(function(){
  2106. layout.openApplication(e, "process.Application", options);
  2107. }.bind(this));
  2108. }else{
  2109. layout.openApplication(e, "process.Application", options);
  2110. }
  2111. }.bind(this));
  2112. }
  2113. // makeLnk: function(){
  2114. // //@todo
  2115. // // this.node.makeLnk({
  2116. // // "par": {"icon": this.icon, "color": this.color, "title": this.data.title, "par": this.data.path},
  2117. // // });
  2118. // }
  2119. });
  2120. o2.xDesktop.Default.StartMenu.InforItem = new Class({
  2121. Extends: o2.xDesktop.Default.StartMenu.PortalItem,
  2122. loadIcon: function(){
  2123. var icon = "";
  2124. var bgcolor = "";
  2125. if (this.data.appIcon){
  2126. icon = "data:image/png;base64,"+this.data.appIcon+"";
  2127. bgcolor = "";
  2128. }else{
  2129. var p = "cmsDefault";
  2130. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  2131. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  2132. bgcolor = this.layout.iconsJson[p].color;
  2133. }else{
  2134. icon = "../x_component_cms_Index/$Main/default/icon/column.png";
  2135. bgcolor = "";
  2136. }
  2137. }
  2138. if (icon && bgcolor){
  2139. this.iconNode.addClass("layout_start_item_icon_flat");
  2140. this.iconNode.setStyle("background-color", bgcolor);
  2141. }
  2142. this.iconNode.setStyle("background-image", "url("+icon+")");
  2143. this.icon = icon;
  2144. },
  2145. loadText: function(){
  2146. this.textNode.set("text", this.data.appName);
  2147. },
  2148. addLnk: function(dragTargetLnk, dragPosition){
  2149. lnkdata = {
  2150. "name": "cms.Module",
  2151. "title": this.data.appName,
  2152. "iconData": (this.data.appIcon) || "",
  2153. "icon": null,
  2154. "appType": "cms",
  2155. "options": {"columnData": this.data, "appId": "cms.Module"+this.data.id}
  2156. }
  2157. this.layout.addLnk(lnkdata, dragTargetLnk, dragPosition);
  2158. },
  2159. open: function(e){
  2160. this.menu.hide(function(){
  2161. if (this.menu.menu){
  2162. this.menu.menu.hide(function(){
  2163. layout.openApplication(e, "cms.Module", {"columnData": this.data, "appId": "cms.Module"+this.data.id});
  2164. }.bind(this));
  2165. }else{
  2166. layout.openApplication(e, "cms.Module", {"columnData": this.data, "appId": "cms.Module"+this.data.id});
  2167. }
  2168. }.bind(this));
  2169. }
  2170. // makeLnk: function(){
  2171. // //@todo
  2172. // // this.node.makeLnk({
  2173. // // "par": {"icon": this.icon, "color": this.color, "title": this.data.title, "par": this.data.path},
  2174. // // });
  2175. // }
  2176. });
  2177. o2.xDesktop.Default.StartMenu.QueryItem = new Class({
  2178. Extends: o2.xDesktop.Default.StartMenu.PortalItem,
  2179. loadIcon: function(){
  2180. var icon = "";
  2181. var bgcolor = "";
  2182. if (this.data.icon){
  2183. icon = "data:image/png;base64,"+this.data.icon+"";
  2184. bgcolor = "";
  2185. }else{
  2186. var p = "queryDefault";
  2187. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  2188. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  2189. bgcolor = this.layout.iconsJson[p].color;
  2190. }else{
  2191. icon = "../x_component_query_Query/$Main/appicon.png";
  2192. bgcolor = "";
  2193. }
  2194. }
  2195. if (icon && bgcolor){
  2196. this.iconNode.addClass("layout_start_item_icon_flat");
  2197. this.iconNode.setStyle("background-color", bgcolor);
  2198. }
  2199. this.iconNode.setStyle("background-image", "url("+icon+")");
  2200. this.icon = icon;
  2201. },
  2202. addLnk: function(){
  2203. lnkdata = {
  2204. "name": "query.Query",
  2205. "title": this.data.name,
  2206. "iconData": (this.data.icon)||"",
  2207. "icon": null,
  2208. "appType": "query",
  2209. "options": {"id": this.data.id, "appId": "query.Query"+this.data.id}
  2210. }
  2211. this.layout.addLnk(lnkdata, dragTargetLnk, dragPosition);
  2212. },
  2213. open: function(e){
  2214. this.menu.hide(function(){
  2215. if (this.menu.menu){
  2216. this.menu.menu.hide(function(){
  2217. layout.openApplication(e, "query.Query", {"id": this.data.id, "appId": "query.Query"+this.data.id});
  2218. }.bind(this));
  2219. }else{
  2220. layout.openApplication(e, "query.Query", {"id": this.data.id, "appId": "query.Query"+this.data.id});
  2221. }
  2222. }.bind(this));
  2223. }
  2224. // makeLnk: function(){
  2225. // //@todo
  2226. // // this.node.makeLnk({
  2227. // // "par": {"icon": this.icon, "color": this.color, "title": this.data.title, "par": this.data.path},
  2228. // // });
  2229. // }
  2230. });
  2231. o2.xDesktop.Default.TaskItem = new Class({
  2232. initialize: function(desktop, app){
  2233. this.desktop = desktop;
  2234. this.container = this.desktop.taskContentNode;
  2235. this.app = app;
  2236. this.load();
  2237. },
  2238. load: function(){
  2239. this.node = new Element("div.layout_content_taskbar_item").inject(this.container);
  2240. this.iconNode = new Element("div");
  2241. this.closeNode = new Element("div.layout_content_taskbar_item_icon", {"title": o2.LP.widget.close}).inject(this.node);
  2242. this.closeNode.addClass("icon_close");
  2243. if (this.app.options.appId==this.desktop.options.index){
  2244. this.closeNode.hide();
  2245. this.noCloseNode = true;
  2246. }
  2247. this.refreshNode = new Element("div.layout_content_taskbar_item_refresh", {"title": o2.LP.widget.refresh}).inject(this.node);;
  2248. this.refreshNode.addClass("icon_refresh");
  2249. this.refreshNode.addClass("animation_taskItemLoading");
  2250. this.actionNode = new Element("div.layout_content_taskbar_item_action").inject(this.node);;
  2251. this.actionNode.addClass("icon_taskitem_down");
  2252. this.textNode = new Element("div.layout_content_taskbar_item_text").inject(this.node);;
  2253. this.setText(this.app.options.title);
  2254. //this.desktop.checkTaskBarSize();
  2255. this.setEvent();
  2256. this.unSelected();
  2257. },
  2258. setEvent: function(){
  2259. this.textNode.addEvents({
  2260. "click": function(){
  2261. if (this.desktop.currentApp!=this.app){
  2262. if (!this.app.window){
  2263. this.desktop.apps[this.app.options.appId] = null;
  2264. layout.openApplication(null, this.app.options.name, this.app.options, this.app.options.app, false, this, false);
  2265. }else{
  2266. this.app.setCurrent();
  2267. }
  2268. }else{
  2269. // this.app.refresh();
  2270. }
  2271. }.bind(this),
  2272. "dblclick": function(){
  2273. this.app.openInNewBrowser((this.app.options.appId==this.desktop.options.index));
  2274. }.bind(this)
  2275. });
  2276. this.closeNode.addEvents({
  2277. "mouseover": function(){
  2278. // if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode_over);
  2279. }.bind(this),
  2280. "mouseout": function(){
  2281. // if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode);
  2282. }.bind(this),
  2283. "click": function(){
  2284. if (!this.app.window){
  2285. this.desktop.apps[this.app.options.appId] = null;
  2286. delete this.desktop.apps[this.app.options.appId];
  2287. this.destroy();
  2288. }else{
  2289. this.app.close();
  2290. }
  2291. }.bind(this)
  2292. });
  2293. this.refreshNode.addEvents({
  2294. "mouseover": function(){
  2295. // if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode_over);
  2296. }.bind(this),
  2297. "mouseout": function(){
  2298. // if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode);
  2299. }.bind(this),
  2300. "click": function(){
  2301. this.app.refresh();
  2302. }.bind(this)
  2303. });
  2304. this.loadTaskItemMenu();
  2305. if (this.desktop && this.desktop.checkTaskBarSize) this.desktop.checkTaskBarSize();
  2306. },
  2307. loadTaskItemMenu: function(){
  2308. if (!this.taskitemMenu){
  2309. this.taskitemMenu = new o2.xDesktop.Menu(this.actionNode, {
  2310. "event": "click", "style": "flatUser", "offsetX": -10, "offsetY":6, "container": this.node
  2311. });
  2312. this.taskitemMenu.load();
  2313. this.loadTaskItemMenuItems();
  2314. }
  2315. },
  2316. loadTaskItemMenuItems: function(){
  2317. var img = this.desktop.path+this.desktop.options.style+"/icons/menu_refresh.png";
  2318. this.taskitemMenu.addMenuItem(o2.LP.desktop.refresh, "click", function(e){this.app.refresh(e);}.bind(this), img);
  2319. this.taskitemMenu.addMenuLine();
  2320. //img = this.path+this.options.style+"/icons/logout.png";
  2321. if (this.app.options.appId!==this.desktop.options.index){
  2322. img = this.desktop.path+this.desktop.options.style+"/icons/menu_close.png";
  2323. this.taskitemMenu.addMenuItem(o2.LP.desktop.close, "click", function(){
  2324. if (!this.app.window){
  2325. this.desktop.apps[this.app.options.appId] = null;
  2326. delete this.desktop.apps[this.app.options.appId];
  2327. this.destroy();
  2328. }else{
  2329. this.app.close();
  2330. }
  2331. }.bind(this), img);
  2332. }
  2333. img = this.desktop.path+this.desktop.options.style+"/icons/menu_closeall.png";
  2334. this.taskitemMenu.addMenuItem(o2.LP.desktop.closeAll, "click", function(){
  2335. var keys = Array.clone(Object.keys(this.desktop.apps));
  2336. keys.each(function(key){
  2337. if (!this.desktop.apps[key].isIndex && !this.desktop.apps[key].options.isIndex) this.desktop.apps[key].close();
  2338. }.bind(this));
  2339. keys = null;
  2340. }.bind(this), img);
  2341. img = this.desktop.path+this.desktop.options.style+"/icons/menu_closeother.png";
  2342. this.taskitemMenu.addMenuItem(o2.LP.desktop.closeOther, "click", function(){
  2343. var keys = Array.clone(Object.keys(this.desktop.apps));
  2344. keys.each(function(key){
  2345. if (!this.desktop.apps[key].isIndex &&
  2346. !this.desktop.apps[key].options.isIndex &&
  2347. this.desktop.apps[key].options.appId!=this.app.options.appId) this.desktop.apps[key].close();
  2348. }.bind(this));
  2349. keys = null;
  2350. }.bind(this), img);
  2351. },
  2352. setText: function(str){
  2353. this.textNode.set("text", str || this.app.options.title);
  2354. },
  2355. unSelected: function(){
  2356. this.node.removeClass("mainColor_bg");
  2357. if (!this.noCloseNode) {
  2358. this.closeNode.addClass("icon_close");
  2359. this.closeNode.removeClass("icon_close_focus");
  2360. //this.closeNode.hide();
  2361. }
  2362. if (this.refreshNode) this.refreshNode.hide();
  2363. if (this.actionNode) this.actionNode.hide();
  2364. },
  2365. selected: function(){
  2366. this.node.addClass("mainColor_bg");
  2367. if (!this.noCloseNode){
  2368. this.closeNode.removeClass("icon_close");
  2369. this.closeNode.addClass("icon_close_focus");
  2370. //this.closeNode.show();
  2371. }
  2372. this.desktop.checkTaskBarScrollTo(this.app);
  2373. //this.refreshNode.show();
  2374. if (this.actionNode) this.actionNode.show();
  2375. },
  2376. destroy: function(){
  2377. this.iconNode.destroy();
  2378. this.node.destroy();
  2379. if (this.desktop && this.desktop.checkTaskBarSize) this.desktop.checkTaskBarSize();
  2380. if (this.app.options && this.app.options.appId) delete this.desktop.apps[this.app.options.appId];
  2381. o2.release(this);
  2382. },
  2383. setTaskitemSize: function(){
  2384. this.desktop.checkTaskBarSize();
  2385. this.desktop.checkTaskBarScrollTo();
  2386. }
  2387. });
  2388. o2.xDesktop.Default.Lnk = new Class({
  2389. initialize: function(layout, data, targetLnk, position){
  2390. this.layout = layout;
  2391. this.container = this.layout.lnkAreaNode;
  2392. this.data = data;
  2393. this.load(targetLnk, position);
  2394. },
  2395. load: function(targetLnk, position){
  2396. this.node = new Element("div.layout_menu_lnk_item");
  2397. if (targetLnk){
  2398. if (!position) position = "before";
  2399. this.node.inject(targetLnk.node, position);
  2400. }else{
  2401. this.node.inject(this.container);
  2402. }
  2403. this.iconNode = new Element("div.layout_menu_lnk_item_icon").inject(this.node);
  2404. this.textNode = new Element("div.layout_menu_lnk_item_text", {"text": this.data.title}).inject(this.node);
  2405. this.actionNode = new Element("div.layout_menu_lnk_item_action", {"title": o2.LP.desktop.deleteLnk}).inject(this.node);
  2406. this.actionNode.addClass("icon_off_light");
  2407. var icon = this.getIcon();
  2408. this.iconNode.setStyle("background-image", "url("+icon+")");
  2409. this.setEvent();
  2410. },
  2411. setEvent: function(){
  2412. this.node.addEvents({
  2413. "click": function(){
  2414. if (this.data.name=="Homepage"){
  2415. var name = this.data.name;
  2416. var options = this.data.options;
  2417. if (layout.config.indexPage && layout.config.indexPage.enable && layout.config.indexPage.portal){
  2418. name = "portal.Portal";
  2419. var appId = "portal.Portal"+layout.config.indexPage.portal;
  2420. options = {"name": "portal.Portal", "portalId": layout.config.indexPage.portal, "pageId": layout.config.indexPage.page, "appId": appId};
  2421. }
  2422. layout.openApplication(null, name, options);
  2423. }else{
  2424. layout.openApplication(null, this.data.name, this.data.options);
  2425. }
  2426. }.bind(this),
  2427. "mouseover": function(){
  2428. this.actionNode.fade("in");
  2429. this.node.addClass("overColor_bg");
  2430. this.textNode.fade("in");
  2431. }.bind(this),
  2432. "mouseout": function(){
  2433. this.actionNode.fade("out");
  2434. this.node.removeClass("overColor_bg");
  2435. this.textNode.fade("out");
  2436. }.bind(this)
  2437. });
  2438. this.actionNode.addEvents({
  2439. "click": function(e){
  2440. this.destroy();
  2441. e.stopPropagation();
  2442. }.bind(this),
  2443. "mouseover": function(){
  2444. this.actionNode.addClass("layout_menu_lnk_item_action_shadow");
  2445. }.bind(this),
  2446. "mouseout": function(){
  2447. this.actionNode.removeClass("layout_menu_lnk_item_action_shadow");
  2448. }.bind(this)
  2449. });
  2450. var drag = new Drag(this.node, {
  2451. "stopPropagation": true,
  2452. "compensateScroll": true,
  2453. "onStart": function(el, e){
  2454. this.doDragMove(e);
  2455. drag.stop();
  2456. }.bind(this)
  2457. });
  2458. },
  2459. getDragNode: function(){
  2460. if (!this.dragNode){
  2461. this.dragNode = new Element("div.layout_menu_lnk_item_drag")
  2462. .setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex())
  2463. .inject(this.layout.node);
  2464. var dragIconNode = this.iconNode.clone(true).inject(this.dragNode)
  2465. .removeClass("layout_menu_lnk_item_icon")
  2466. .addClass("layout_menu_lnk_item_icon_drag");
  2467. var p = (this.data.appType) ? this.data.appType+"Default" : this.data.name;
  2468. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].color){
  2469. dragIconNode.setStyle("background-color", this.layout.iconsJson[p].color)
  2470. }
  2471. this.dragRemoveNode = new Element("div.layout_menu_lnk_item_icon_drag_del").inject(this.dragNode)
  2472. .addClass("icon_remove_badge")
  2473. .hide();
  2474. }
  2475. var ps = this.iconNode.getPosition(this.dragNode.getOffsetParent());
  2476. this.dragNode.show().setStyles({
  2477. "left": ""+ps.x+"px", "top": ""+ps.y+"px"
  2478. });
  2479. },
  2480. doDragMove: function(e){
  2481. this.getDragNode();
  2482. var drag = new Drag.Move(this.dragNode, {
  2483. "stopPropagation": true,
  2484. "compensateScroll": true,
  2485. "droppables": [this.container.getParent()],
  2486. "onStart": function(){ this._drag_start(); }.bind(this),
  2487. "onDrag": function(dragging,e){ this._drag_drag(dragging, e); }.bind(this),
  2488. "onEnter": function(dragging, inObj){ this._drag_enter(dragging, inObj); }.bind(this),
  2489. "onLeave": function(dragging, obj){ this._drag_leave(dragging, obj); }.bind(this),
  2490. "onDrop": function(dragging, inObj){ this._drag_drop(dragging, inObj); }.bind(this),
  2491. "onCancel": function(dragging){ this._drag_cancel(dragging); }.bind(this),
  2492. "onComplete": function(dragging, e){ this._drag_complete(dragging, e); }.bind(this),
  2493. });
  2494. drag.start(e);
  2495. this.dragStatus = "order";
  2496. },
  2497. _drag_start: function(){
  2498. this.node.addClass("overColor_bg");
  2499. this.node.addClass("opacity50");
  2500. this.dragTargetLnk = null;
  2501. this.dragPosition = "before";
  2502. },
  2503. _drag_drag: function(dragging, e){
  2504. if (this.dragStatus == "order"){
  2505. if (this.layout.lnks && this.layout.lnks.length){
  2506. var current = e.page.y;
  2507. for (var i=0; i<this.layout.lnks.length; i++){
  2508. var lnk = this.layout.lnks[i];
  2509. var y = lnk.node.getSize().y;
  2510. var top = lnk.node.getPosition(this.layout.node).y;
  2511. var center = top+y/2;
  2512. var bottom = top+y;
  2513. if (top<=current && center>=current){
  2514. this.dragTargetLnk = lnk;
  2515. this.dragPosition = "before";
  2516. break;
  2517. }else if (center<=current && bottom>=current){
  2518. this.dragTargetLnk = lnk;
  2519. this.dragPosition = "after";
  2520. break;
  2521. }
  2522. }
  2523. if (!this.layout.positionNode) this.layout.positionNode = new Element("div.layout_menu_lnk_item_position")
  2524. .setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex())
  2525. .inject(this.layout.node);
  2526. this.layout.positionNode.show();
  2527. if (!this.dragTargetLnk){
  2528. this.dragTargetLnk = this.layout.lnks[this.layout.lnks.length-1];
  2529. this.dragPosition = "after";
  2530. }
  2531. this.layout.positionNode.position({
  2532. relativeTo: this.dragTargetLnk.node,
  2533. position: (this.dragPosition=="before") ? 'topcenter' : 'bottomcenter',
  2534. edge: 'center'
  2535. });
  2536. }
  2537. }
  2538. },
  2539. _drag_enter: function(){
  2540. this.dragStatus = "order";
  2541. if (this.dragRemoveNode) this.dragRemoveNode.hide();
  2542. },
  2543. _drag_leave: function(){
  2544. this.dragStatus = "remove";
  2545. if (this.dragRemoveNode) this.dragRemoveNode.show();
  2546. if (this.layout.positionNode) this.layout.positionNode.hide();
  2547. },
  2548. _drag_drop: function(dragging, inObj){
  2549. if (this.dragStatus == "order" && this.dragTargetLnk && this.dragTargetLnk!=this){
  2550. this.node.inject(this.dragTargetLnk.node, this.dragPosition);
  2551. this.layout.lnks.erase(this);
  2552. var idx = this.layout.lnks.indexOf(this.dragTargetLnk);
  2553. if (this.dragPosition=="before"){
  2554. this.layout.lnks.splice(idx, 0, this);
  2555. }else{
  2556. this.layout.lnks.splice(idx+1, 0, this);
  2557. }
  2558. }
  2559. },
  2560. _drag_cancel: function(dragging){
  2561. dragging.hide();
  2562. if (this.node) {
  2563. this.node.removeClass("overColor_bg");
  2564. this.node.removeClass("opacity50");
  2565. }
  2566. if (this.layout.positionNode) this.layout.positionNode.hide();
  2567. if (this.dragRemoveNode) this.dragRemoveNode.hide();
  2568. },
  2569. _drag_complete: function(dragging){
  2570. if (this.dragStatus == "remove"){
  2571. this.destroy();
  2572. }else{
  2573. this._drag_cancel(dragging);
  2574. }
  2575. },
  2576. destroy: function(){
  2577. this.layout.lnks.erase(this);
  2578. if (this.dragNode) this.dragNode.destroy();
  2579. //if (this.positionNode) this.positionNode.destroy();
  2580. this.node.destroy();
  2581. o2.release(this);
  2582. },
  2583. getIcon: function(){
  2584. if (this.data.icon) return this.data.icon;
  2585. var icon;
  2586. if (this.data.name.substring(0, 4)==="@url"){
  2587. if (this.layout.iconsJson["Url"] && this.layout.iconsJson["Url"].icon){
  2588. icon = this.layout.path+"appicons/"+this.layout.iconsJson["Url"].icon;
  2589. }else{
  2590. icon = this.layout.path+"appicons/url.png";
  2591. }
  2592. }else{
  2593. if (this.data.iconData){
  2594. icon = "data:image/png;base64,"+this.data.iconData+"";
  2595. }else if (this.data.iconPath){
  2596. icon = this.data.iconPath;
  2597. }else{
  2598. var p = (this.data.appType) ? this.data.appType+"Default" : this.data.name;
  2599. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  2600. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  2601. }else{
  2602. icon = "../x_component_"+this.data.name.replace(/\./g, "_")+"/$Main/appicon.png";
  2603. }
  2604. }
  2605. }
  2606. return icon;
  2607. }
  2608. });
  2609. o2.xDesktop.zIndexPool = {
  2610. zIndex: 102,
  2611. applyZindex: function(){
  2612. var i = this.zIndex;
  2613. this.zIndex = this.zIndex+2;
  2614. return i;
  2615. }
  2616. };