Default.js 112 KB

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