Default.js 128 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211
  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. zoomOut: function(){
  13. if (!layout.userLayout.scale) layout.userLayout.scale = 1;
  14. layout.userLayout.scale = layout.userLayout.scale-0.1;
  15. if (layout.userLayout.scale<0.4) layout.userLayout.scale = 0.4;
  16. this.zoom();
  17. },
  18. zoomIn: function(){
  19. if (!layout.userLayout.scale) layout.userLayout.scale = 1;
  20. layout.userLayout.scale = layout.userLayout.scale+0.1;
  21. if (layout.userLayout.scale>5) layout.userLayout.scale = 5;
  22. this.zoom();
  23. },
  24. zoom: function(v){
  25. if (v){
  26. layout.userLayout.scale = v;
  27. if (layout.userLayout.scale<0.4) layout.userLayout.scale = 0.4;
  28. if (layout.userLayout.scale>5) layout.userLayout.scale = 5;
  29. }
  30. if (layout.userLayout.scale){
  31. // var s = (1/layout.userLayout.scale)*100;
  32. // var p = s+"%";
  33. // document.id(document.documentElement).setStyles({
  34. // "transform": "scale("+layout.userLayout.scale+")",
  35. // "transform-origin": "0 0",
  36. // "width": p,
  37. // "height":p
  38. // });
  39. document.body.style.zoom = layout.userLayout.scale;
  40. // if (layout.desktop){
  41. // if (layout.desktop.setSize) layout.desktop.setSize();
  42. // }
  43. this.fireEvent("resize");
  44. this.setZoomValue();
  45. }
  46. },
  47. setZoomValue: function(){
  48. if (!layout.userLayout.scale) layout.userLayout.scale = 1;
  49. var scaleP = Math.round(layout.userLayout.scale*100);
  50. if (this.zoomValueNode) this.zoomValueNode.set("text", scaleP+"%");
  51. },
  52. returnZoom: function(){
  53. this.zoom(1);
  54. if (this.zoomSlider){
  55. this.zoomSlider.set(100);
  56. }
  57. },
  58. zoomMenuShow: function(){
  59. this.sliderNode.show();
  60. this.sliderNode.set('tween', {duration: 100});
  61. this.sliderNode.tween('width', '160');
  62. if (!this.zoomSlider){
  63. if (!layout.userLayout.scale) layout.userLayout.scale = 1;
  64. this.sliderNode.addEvent("mousedown", function (e){
  65. e.stopPropagation();
  66. e.preventDefault();
  67. });
  68. this.zoomSlider = new Slider(this.zoomSliderNode, this.zoomSliderKnobNode, {
  69. range: [30, 300],
  70. wheel: false,
  71. snap: true,
  72. //mode: "vertical",
  73. steps: 27,
  74. initialStep: layout.userLayout.scale*100,
  75. onChange: function(step){
  76. if (this.zoomValueNode) this.zoomValueNode.set("text", step+"%");
  77. }.bind(this),
  78. onComplete: function(step){
  79. var scale = step/100;
  80. this.zoom(scale);
  81. this.zoomMenuHide();
  82. }.bind(this)
  83. });
  84. }
  85. this.hideZoom = this.zoomMenuHide.bind(this);
  86. this.desktopNode.addEvent("mousedown", this.hideZoom);
  87. },
  88. zoomMenuHide: function(){
  89. this.sliderNode.set('tween', {duration: 100});
  90. this.sliderNode.tween('width', '0');
  91. if (this.hideZoom) this.desktopNode.removeEvent("mousedown", this.hideZoom);
  92. },
  93. initialize: function(node, options){
  94. this.setOptions(options);
  95. this.type = "layout";
  96. this.path = o2.session.path+"/xDesktop/$Default/";
  97. this.node = $(node);
  98. this.node.empty();
  99. this.options.style = layout.config.defaultSkin || "blue";
  100. this.initData();
  101. this.zoom(layout.config.scaleConfig===false ? 1 : 0);
  102. },
  103. initData: function(){
  104. this.apps = {};
  105. this.appArr = [];
  106. this.appCurrentList = [];
  107. this.lnks = [];
  108. this.currentApp = null;
  109. this.session = {};
  110. this.serviceAddressList = layout.serviceAddressList;
  111. this.centerServer = layout.centerServer;
  112. this.session.user = layout.session.user;
  113. this.status = layout.userLayout;
  114. if (layout.config.openStatus==="index"){
  115. this.status.apps = {};
  116. }
  117. var uri = new URI(window.location.href);
  118. var df = uri.getData("default") || "";
  119. this.noDefault = df.toString().toLowerCase()==="false";
  120. var appNames = uri.getData("app");
  121. var optionsStr = uri.getData("option");
  122. var options = (optionsStr) ? JSON.decode(optionsStr) : null;
  123. if (appNames){
  124. this.status.apps = {};
  125. this.status.apps[appNames] = options || {};
  126. this.status.apps[appNames].name = appNames;
  127. this.status.apps[appNames].appId = appNames;
  128. this.status.apps[appNames].isIndex = true;
  129. this.status.forceCurrentApp = appNames;
  130. }
  131. if (layout.config.skinConfig!==false && this.status && this.status.flatStyle) this.options.style = this.status.flatStyle;
  132. },
  133. load: function(cb){
  134. this.loadLayout(function(){
  135. this.setEvent();
  136. if (!this.noDefault) this.loadDefaultPage();
  137. window.setTimeout(function(){
  138. var iconsPath = this.path+"icons.json";
  139. o2.JSON.get(iconsPath, function(json) {
  140. this.iconsJson = json;
  141. this.loadStatus();
  142. if (cb) cb();
  143. }.bind(this));
  144. this.openWebSocket();
  145. this.checkTaskBarSize();
  146. this.addEvent("resize", this.checkTaskBarSize.bind(this));
  147. }.bind(this), 0);
  148. this.loadMessageMenu();
  149. this.setZoomValue();
  150. this.fireEvent("load");
  151. MWF.require("MWF.xDesktop.shortcut");
  152. }.bind(this));
  153. },
  154. resizeHeight: function(){
  155. var y = this.menuNode.getSize().y;
  156. var y1 = this.startMenuNode.getParent().getSize().y;
  157. var o1 = this.startMenuNode.getParent().getStyles("border-top-width", "margin-top", "padding-top", "border-bottom-width", "margin-bottom", "padding-bottom");
  158. var y2 = this.settingNode.getParent().getSize().y;
  159. var o2 = this.settingNode.getParent().getStyles("border-top-width", "margin-top", "padding-top", "border-bottom-width", "margin-bottom", "padding-bottom");
  160. 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();
  161. 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();
  162. var height = y-y1-y2-oy1-oy2;
  163. this.lnkContentNode.setStyle("height", ""+height+"px");
  164. },
  165. checkTaskBarSize: function(){
  166. window.setTimeout(function(){
  167. var size = this.taskContentAreaNode.getSize();
  168. var contentSize = this.taskContentNode.getSize();
  169. if (size.y<contentSize.y){
  170. this.taskActionUp.show();
  171. this.taskActionDown.show();
  172. }else{
  173. this.taskActionUp.hide();
  174. this.taskActionDown.hide();
  175. }
  176. }.bind(this), 50);
  177. },
  178. checkTaskBarScrollTo: function(app){
  179. var currentApp = app || this.currentApp;
  180. if (currentApp && currentApp.taskitem){
  181. var size = this.taskContentAreaNode.getSize();
  182. var scroll = this.taskContentAreaNode.getScroll();
  183. var scrollSize = this.taskContentAreaNode.getScrollSize();
  184. var p = currentApp.taskitem.node.getPosition(this.taskContentNode);
  185. if (p.y!=scroll.y){
  186. var scrollTo = p.y;
  187. if (scrollTo<scrollSize.y-size.y){
  188. this.taskActionDown.addClass("icon_down");
  189. this.taskActionDown.removeClass("icon_down_gray");
  190. }else{
  191. this.taskActionDown.removeClass("icon_down");
  192. this.taskActionDown.addClass("icon_down_gray");
  193. }
  194. if (scrollTo<=0){
  195. scrollTo = 0;
  196. this.taskActionUp.removeClass("icon_up");
  197. this.taskActionUp.addClass("icon_up_gray");
  198. }else{
  199. this.taskActionUp.addClass("icon_up");
  200. this.taskActionUp.removeClass("icon_up_gray");
  201. }
  202. this.taskContentAreaNode.scrollTo(0, p.y);
  203. }
  204. }
  205. },
  206. toolbarUp: function(){
  207. var size = this.taskContentAreaNode.getSize();
  208. var scroll = this.taskContentAreaNode.getScroll();
  209. var scrollSize = this.taskContentAreaNode.getScrollSize();
  210. var scrollTo = scroll.y-size.y;
  211. if (scrollTo<scrollSize.y-size.y){
  212. this.taskActionDown.addClass("icon_down");
  213. this.taskActionDown.removeClass("icon_down_gray");
  214. }
  215. if (scrollTo<=0){
  216. scrollTo = 0;
  217. this.taskActionUp.removeClass("icon_up");
  218. this.taskActionUp.addClass("icon_up_gray");
  219. }
  220. this.taskContentAreaNode.scrollTo(0,scrollTo);
  221. },
  222. toolbarDown: function(){
  223. var size = this.taskContentAreaNode.getSize();
  224. var scroll = this.taskContentAreaNode.getScroll();
  225. var scrollSize = this.taskContentAreaNode.getScrollSize();
  226. var scrollTo = scroll.y+size.y;
  227. if (scrollTo+size.y>=scrollSize.y){
  228. scrollTo=scrollSize.y-size.y;
  229. this.taskActionDown.removeClass("icon_down");
  230. this.taskActionDown.addClass("icon_down_gray");
  231. }
  232. if (scrollTo>0){
  233. this.taskActionUp.addClass("icon_up");
  234. this.taskActionUp.removeClass("icon_up_gray");
  235. }
  236. this.taskContentAreaNode.scrollTo(0, scrollTo);
  237. },
  238. loadLayout: function(callback){
  239. this.session.user.iconUrl = o2.filterUrl(o2.Actions.get("x_organization_assemble_control").getPersonIcon(this.session.user.id));
  240. var css = this.path+this.options.style+ ((o2.session.isMobile || layout.mobile) ? "/style-pc.css" : "/style-pc.css");
  241. var skinCss = this.path+this.options.style+ "/style-skin.css";
  242. var html = this.path+this.options.style+((o2.session.isMobile || layout.mobile) ? "/layout-pc.html" : "/layout-pc.html");
  243. this.node.loadAll({ "css": [css], "html": [html]}, {"bind": {"user": this.session.user}, "module": this},function(){
  244. var oReq = new XMLHttpRequest();
  245. oReq.addEventListener("load", function(){
  246. var reader = new FileReader();
  247. reader.addEventListener("load", function () {
  248. this.userInforNode.getFirst().setStyle("background-image", "url("+reader.result+")");
  249. }.bind(this), false);
  250. reader.readAsDataURL(oReq.response);
  251. }.bind(this));
  252. oReq.open("GET", this.session.user.iconUrl);
  253. oReq.setRequestHeader("authorization", layout.session.user.token);
  254. oReq.responseType = "blob";
  255. oReq.withCredentials = true;
  256. oReq.send();
  257. if (layout.config.scaleConfig===false && this.zoomValueNode){
  258. this.zoomValueNode.hide()
  259. }
  260. if(layout.config.searchEnable===false && this.searchBoxNode){
  261. this.searchBoxNode.getParent().hide();
  262. }
  263. this.sliderNode.getLast().set("title", o2.LP.desktop.returnZoom);
  264. this.node.loadCss(skinCss);
  265. if (callback) callback();
  266. }.bind(this));
  267. },
  268. setEvent: function(){
  269. this.loadSkinMenu();
  270. this.loadUserMenu();
  271. window.onbeforeunload = function(e){
  272. if (!this.isLogout){
  273. if (this.apps["Note"]){
  274. if (this.apps["Note"].notes){
  275. this.apps["Note"].notes.each(function(note){
  276. note.save();
  277. });
  278. }
  279. }
  280. if (!this.notRecordStatus) this.recordDesktopStatus();
  281. this.closeWebSocket();
  282. //if (this.socket && this.socket.webSocket) this.socket.close();
  283. this.fireEvent("unload");
  284. e = e || window.event;
  285. e.returnValue = o2.LP.desktop.notice.unload;
  286. return o2.LP.desktop.notice.unload;
  287. }
  288. }.bind(this);
  289. $(window).addEvent("resize", function(){
  290. this.fireEvent("resize");
  291. }.bind(this));
  292. this.resizeHeight();
  293. this.addEvent("resize", this.resizeHeight.bind(this));
  294. o2.require("o2.widget.ScrollBar", function(){
  295. this.appScrollBar = new o2.widget.ScrollBar(this.lnkContentNode, {
  296. "style":"hide", "where": "before", "indent": true, "distance": 100, "friction": 0, "axis": {"x": false, "y": true}
  297. });
  298. }.bind(this));
  299. },
  300. loadDefaultPage: function(){
  301. //默认载入首页
  302. var app;
  303. if (layout.config.indexPage && layout.config.indexPage.enable && layout.config.indexPage.portal){
  304. appId = "portal.Portal"+layout.config.indexPage.portal;
  305. this.options.index = appId;
  306. //var options = {"portalId": layout.config.indexPage.portal, "pageId": layout.config.indexPage.page, "appId": appId};
  307. app = {
  308. "options": {"name": "portal.Portal", "portalId": layout.config.indexPage.portal, "pageId": layout.config.indexPage.page, "appId": appId},
  309. "close": function(){
  310. this.taskitem.destroy();
  311. },
  312. "setCurrent": function(){
  313. if (this.taskitem.textNode) this.taskitem.textNode.click();
  314. }
  315. };
  316. //layout.openApplication(null, "portal.Portal", options);
  317. }else{
  318. app = {
  319. "options": {"name": "Homepage", "appId": "Homepage", "title": o2.LP.desktop.homepage},
  320. "close": function(){
  321. this.taskitem.destroy();
  322. },
  323. "setCurrent": function(){
  324. if (this.taskitem.textNode) this.taskitem.textNode.click();
  325. }
  326. };
  327. //layout.openApplication(null, "Homepage");
  328. }
  329. taskitem = layout.desktop.createTaskItem(app);
  330. app.taskitem = taskitem;
  331. app.options.isIndex = true;
  332. this.apps[app.options.appId] = app;
  333. taskitem.textNode.click();
  334. },
  335. loadDefaultLnk: function(){
  336. if (this.status && this.status.flatLnks && this.status.flatLnks.length){
  337. this.status.flatLnks.each(function(lnkJson){
  338. //console.log(lnkJson.name)
  339. this.addLnk(lnkJson);
  340. }.bind(this));
  341. }else{
  342. o2.JSON.get(this.path+"defaultLnk.json", function(defaultLnk){
  343. defaultLnk.each(function(lnkJson){
  344. this.addLnk(lnkJson);
  345. }.bind(this));
  346. }.bind(this));
  347. }
  348. },
  349. loadMenuData: function(callback){
  350. this.menuData = this.status.menuData;
  351. o2.UD.getPublicData("clearCustomMenuDataFlag", function(data){
  352. if (data && !!data.id && data.id != this.status.clearCustomMenuDataFlag){
  353. this.status.menuData = null;
  354. this.menuData = null;
  355. this.status.clearCustomMenuDataFlag = data.id;
  356. }
  357. o2.UD.getPublicData("forceMainMenuData", function(fData){
  358. if (fData){
  359. this.isUseForceMainMenuData = true;
  360. this.status.menuData=fData;
  361. this.menuData = this.status.menuData;
  362. if (this.menuData.linkList) this.status.flatLnks = this.menuData.linkList;
  363. if (callback) callback();
  364. }else{
  365. if (!this.status.menuData){
  366. o2.UD.getPublicData("defaultMainMenuData", function(dData){
  367. if (dData){
  368. this.status.menuData=dData;
  369. this.menuData = this.status.menuData;
  370. }
  371. if (this.status.menuData && this.status.menuData.linkList) this.status.flatLnks = this.status.menuData.linkList;
  372. if (callback) callback();
  373. }.bind(this));
  374. }else{
  375. if (callback) callback();
  376. }
  377. }
  378. }.bind(this));
  379. }.bind(this));
  380. },
  381. loadStatus: function(){
  382. if (this.status){
  383. this.loadMenuData(function(){
  384. this.loadDefaultLnk();
  385. }.bind(this));
  386. //this.menuData = this.status.menuData;
  387. var keys = Object.keys(this.status.apps);
  388. if (this.status.apps && keys.length){
  389. if (this.status.currentApp == "Note"){
  390. var idx = keys.length-1;
  391. while (idx>-1 && keys[idx]=="Note") idx--;
  392. this.status.currentApp = (idx>-1) ? this.status.apps[keys[idx]].appId : "";
  393. }
  394. var currentTaskitem = null;
  395. Object.each(this.status.apps, function(appStatus, id){
  396. var app = {
  397. "options": appStatus,
  398. "close": function(){
  399. this.taskitem.destroy();
  400. },
  401. "setCurrent": function(){
  402. if (this.taskitem.textNode) this.taskitem.textNode.click();
  403. }
  404. };
  405. taskitem = layout.desktop.createTaskItem(app);
  406. app.taskitem = taskitem;
  407. this.apps[appStatus.appId] = app;
  408. if ((this.status.currentApp === appStatus.appId && layout.config.openStatus!=="indexWithApp") || this.status.forceCurrentApp === appStatus.appId ) currentTaskitem=taskitem;
  409. if (appStatus.appId=="Note") app.setCurrent();
  410. }.bind(this));
  411. if (currentTaskitem) {
  412. currentTaskitem.textNode.click();
  413. }
  414. }
  415. if (this.status.widgets){/* nothing to do */}
  416. // if (this.status.flatLnks && this.status.flatLnks.length){
  417. // this.status.flatLnks.each(function(lnkJson){
  418. // this.addLnk(lnkJson);
  419. // }.bind(this));
  420. // }
  421. }
  422. },
  423. addLnk: function(lnkData, targetLnk, position){
  424. var lnk = new o2.xDesktop.Default.Lnk(this, lnkData, targetLnk, position);
  425. if (targetLnk){
  426. var idx = this.lnks.indexOf(targetLnk);
  427. if (position=="before"){
  428. this.lnks.splice(idx, 0, lnk);
  429. }else{
  430. this.lnks.splice(idx+1, 0, lnk);
  431. }
  432. }else{
  433. this.lnks.push(lnk);
  434. }
  435. },
  436. openWebSocket: function(){
  437. MWF.require("MWF.xDesktop.WebSocket", function(){
  438. this.socket = new MWF.xDesktop.WebSocket();
  439. }.bind(this));
  440. },
  441. closeWebSocket: function(){
  442. if (this.socket) this.socket.close();
  443. },
  444. //******* begin page skin ****************************************************
  445. loadSkinMenu: function(){
  446. if (!this.styleMenu){
  447. if (layout.config.skinConfig===false){
  448. if (this.skinActionNode) this.skinActionNode.destroy();
  449. }else{
  450. this.styleMenu = new o2.xDesktop.Menu(this.skinActionNode, {
  451. "event": "click", "style": "flatStyle", "offsetX": -10, "offsetY": 26, "container": this.node,
  452. "onQueryShow": this.showSkinMenu.bind(this),
  453. "onQueryHide": function(){
  454. this.skinActionNode.removeClass("icon_skin_focus");
  455. this.skinActionNode.removeClass("mainColor_bg");
  456. }.bind(this)
  457. });
  458. this.styleMenu.load();
  459. this.loadSkinMenuItems();
  460. }
  461. }
  462. },
  463. showSkinMenu: function(){
  464. this.styleMenu.items.each(function(item){
  465. if (this.options.style==item.styleName){
  466. item.setDisable(true);
  467. if (item.text) item.text.setStyles({ "background": "url("+this.path+this.options.style+"/icons/icon_gouxuan.png) right center no-repeat" });
  468. }else{
  469. item.setDisable(false);
  470. if (item.text) item.text.setStyles({ "background": "transparent" });
  471. }
  472. }.bind(this));
  473. this.skinActionNode.addClass("icon_skin_focus");
  474. this.skinActionNode.addClass("mainColor_bg");
  475. },
  476. loadSkinMenuItems: function(){
  477. o2.JSON.get(this.path+"styles.json", function(json){
  478. json.each(function(style){
  479. var color = style.color;
  480. var memuItem = this.styleMenu.addMenuItem(style.title, "click", function(){this.changeLayoutSkin(style.style);}.bind(this));
  481. memuItem.styleName = style.style;
  482. var imgDiv = memuItem.item.getFirst();
  483. var imgNode = new Element("div", {"styles": memuItem.menu.css.menuItemImg}).inject(imgDiv);
  484. imgNode.setStyle("background-color", color);
  485. }.bind(this));
  486. this.styleMenu.addMenuLine();
  487. var img = o2.defaultPath+"/xDesktop/$Layout/default/preview.jpg";
  488. var memuItem = this.styleMenu.addMenuItem(o2.LP.desktop_style, "click", function(e){this.changeToDesktopStyle(e);}.bind(this), img);
  489. memuItem.styleName = "desktop";
  490. }.bind(this));
  491. },
  492. changeLayoutSkin: function(style){
  493. var skinCss = this.path+this.options.style+ "/style-skin.css";
  494. o2.removeCss(skinCss);
  495. this.options.style = style;
  496. skinCss = this.path+this.options.style+"/style-skin.css";
  497. this.node.loadCss(skinCss);
  498. },
  499. changeToDesktopStyle: function(e){
  500. //MWF.xDesktop.confirm("infor", e, o2.LP.desktop.changeViewTitle, {"html": o2.LP.desktop.changeView}, 500, 100, function(){
  501. // this.close();
  502. var uri = new URI(window.location.href);
  503. uri.setData("view", "layout");
  504. uri.go();
  505. // }, function(){
  506. // this.close();
  507. // }, null, null, "o2"
  508. // );
  509. },
  510. //******* end page skin ****************************************************
  511. //******* begin user menu ****************************************************
  512. loadUserMenu: function(){
  513. if (!this.userMenu){
  514. this.userMenu = new o2.xDesktop.Menu(this.userInforNode, {
  515. "event": "click", "style": "flatUser", "offsetX": 30, "offsetY":6, "container": this.node
  516. // "onQueryShow": this.showSkinMenu.bind(this),
  517. // "onQueryHide": function(){
  518. // this.skinActionNode.removeClass("icon_skin_focus");
  519. // this.skinActionNode.removeClass("mainColor_bg");
  520. // }.bind(this),
  521. });
  522. this.userMenu.load();
  523. this.loadUserMenuItems();
  524. }
  525. },
  526. loadUserMenuItems: function(){
  527. var img = this.path+this.options.style+"/icons/config.png";
  528. this.userMenu.addMenuItem(o2.LP.desktop.userConfig, "click", function(e){this.userConfig(e);}.bind(this), img);
  529. // var lpMenu = new o2.xDesktop.Menu(this.userInforNode, {
  530. // "event": "click", "style": "flatUser", "offsetX": 30, "offsetY":6, "container": this.node
  531. // });
  532. //
  533. // img = this.path+"/lp/zh-cn.png";
  534. // var lp = this.userMenu.addMenuMenu(o2.LP.desktop.userLanguage, "click", function(e){this.userConfig(e);}.bind(this), img);
  535. this.userMenu.addMenuLine();
  536. img = this.path+this.options.style+"/icons/logout.png";
  537. this.userMenu.addMenuItem(o2.LP.desktop.logout, "click", function(){this.logout();}.bind(this), img);
  538. if (layout.config.enableSafeLogout) this.userMenu.addMenuItem(o2.LP.desktop.safeLogout, "click", function(e){this.safeLogout(e);}.bind(this), img);
  539. },
  540. userConfig: function(e){
  541. layout.openApplication(e, "Profile");
  542. },
  543. logout: function(){
  544. this.isLogout = true;
  545. if (!this.notRecordStatus){
  546. this.recordDesktopStatus(function(){
  547. (layout.authentication || new o2.xDesktop.Authentication()).logout();
  548. }.bind(this.layout));
  549. }else{
  550. (layout.authentication || new o2.xDesktop.Authentication()).logout();
  551. }
  552. },
  553. safeLogout: function(e){
  554. var _self = this;
  555. o2.xDesktop.confirm("warn", e, o2.LP.desktop.safeLogoutTitle, {"html": o2.LP.desktop.safeLogoutMessage}, 460, 100, function(){
  556. _self.isLogout = true;
  557. if (!_self.notRecordStatus){
  558. _self.recordDesktopStatus(function(){
  559. (layout.authentication || new o2.xDesktop.Authentication()).safeLogout();
  560. }.bind(_self.layout));
  561. }else{
  562. (layout.authentication || new o2.xDesktop.Authentication()).safeLogout();
  563. }
  564. }, function(){
  565. this.close();
  566. });
  567. },
  568. //******* end user menu ****************************************************
  569. //******* begin search *****************************************************
  570. focusSearch: function(){
  571. this.searchBoxNode.addClass("layout_content_taskbar_area_search_box_focus");
  572. this.searchBoxNode.addClass("mainColor_border");
  573. this.searchIconNode.addClass("icon_search_focus");
  574. },
  575. blurSearch: function(){
  576. this.searchBoxNode.removeClass("layout_content_taskbar_area_search_box_focus");
  577. this.searchBoxNode.removeClass("mainColor_border");
  578. this.searchIconNode.removeClass("icon_search_focus");
  579. },
  580. searchInputKeyDown: function(e){
  581. if (this.searchInputNode.get("value")){
  582. this.searchClearNode.addClass("icon_clear");
  583. }else{
  584. this.searchClearNode.removeClass("icon_clear");
  585. }
  586. if (e.keyCode===13) this.doSearch();
  587. },
  588. clearSearch: function(){
  589. this.searchInputNode.set("value", "");
  590. this.searchClearNode.removeClass("icon_clear");
  591. this.clearSearchResult();
  592. },
  593. doSearch: function(){
  594. var key = this.searchInputNode.get("value");
  595. if (key){
  596. if (this.apps["ftsearch"]){
  597. var app = this.apps["ftsearch"];
  598. if( app.window ){
  599. app.setCurrent();
  600. app.doSearch( key );
  601. }else{
  602. app.close();
  603. }
  604. }
  605. layout.openApplication(null,"ftsearch", {"query": key});
  606. // if (this.apps["Search"]){
  607. // this.apps["Search"].input.setValue(key);
  608. // this.apps["Search"].input.doSearch();
  609. // }
  610. // layout.openApplication(null,"Search", {"key": key});
  611. }
  612. },
  613. clearSearchResult: function(){
  614. //alert("clear search result");
  615. // @todo
  616. },
  617. //******* end search*******************************************************
  618. //******* begin record status *********************************************
  619. recordDesktopStatus: function(callback){
  620. Object.each(this.apps, function(app, id){
  621. if (!app.options.desktopReload){
  622. this.closeApp(app);
  623. }
  624. }.bind(this));
  625. var status = this.getLayoutStatusData();
  626. console.log(status);
  627. // if (navigator.sendBeacon) {
  628. // var obj = this.personalAction.action.actions["putUserData"];
  629. // var url = this.personalAction.action.address + obj.uri;
  630. // url = url.replace("{name}", "layout");
  631. // navigator.sendBeacon(url, status);
  632. // } else {
  633. try{
  634. o2.UD.putData("layout", status, function(){
  635. if (callback) callback();
  636. });
  637. }catch(e){};
  638. // }
  639. },
  640. getLayoutStatusData: function(){
  641. var status = {
  642. "viewMode": "Default",
  643. "style": this.status.style,
  644. "flatStyle": this.options.style,
  645. "styleType": this.status.styleType || "",
  646. "currentApp": (this.currentApp) ? this.currentApp.appId : "Homepage",
  647. "apps": {},
  648. "lnks": (this.status.lnks && o2.typeOf(this.status.lnks)==="array") ? this.status.lnks : [],
  649. //"lnks": [],
  650. "flatLnks": [],
  651. "widgets": {},
  652. "menuData": this.menuData,
  653. "scale": layout.userLayout.scale || 1,
  654. "clearCustomMenuDataFlag": this.status.clearCustomMenuDataFlag || "",
  655. "gotoWorkcenterConfirm": layout.userLayout.gotoWorkcenterConfirm || false
  656. };
  657. // this.appArr.each(function(app){
  658. // if (app.options.appId!==this.options.index){
  659. // var appStatus = this.getAppStatusData(app, app.appId);
  660. // if (appStatus) status.apps[id] = appStatus;
  661. // }
  662. // }.bind(this));
  663. Object.each(this.apps, function(app, id){
  664. if (app.options.appId!==this.options.index){
  665. var appStatus = this.getAppStatusData(app, id);
  666. if (appStatus) status.apps[id] = appStatus;
  667. }
  668. if (app.isIndex){
  669. if (!status.apps[id]) status.apps[id] = {};
  670. status.apps[id].isIndex = true;
  671. }
  672. }.bind(this));
  673. this.lnks.each(function(lnk){
  674. status.flatLnks.push(lnk.data);
  675. //status.flatLnks.push({"icon": lnk.icon, "color": lnk.color, "title": lnk.title,"par": lnk.par});
  676. });
  677. Object.each(this.widgets, function(widget, id){
  678. var widgetStatus = this.getWidgetStatusData(widget, id);
  679. if (widgetStatus) status.widgets[id] = widgetStatus;
  680. }.bind(this));
  681. return status;
  682. },
  683. getAppStatusData: function(app, id){
  684. var appStatus = null;
  685. if (app.window){
  686. if (app.options.desktopReload){
  687. appStatus ={
  688. "appId": app.appId,
  689. "name": app.options.name,
  690. "style": app.options.style,
  691. "title": app.options.title,
  692. "window": {
  693. // //"size": app.window.node.getSize(),
  694. // "size": {"x": app.window.css.to.width.toFloat(), "y": app.window.css.to.height.toFloat()},
  695. // "position": {"x": app.window.css.to.left.toFloat(), "y": app.window.css.to.top.toFloat()},
  696. // "isMax": app.window.isMax,
  697. // "isHide": app.window.isHide,
  698. // "style": app.window.options.style
  699. },
  700. "app": null
  701. };
  702. if (app.recordStatus) appStatus.app = app.recordStatus();
  703. }
  704. }else{
  705. if (app.options){
  706. appStatus = app.options;
  707. }
  708. }
  709. return appStatus;
  710. },
  711. getWidgetStatusData: function(widget, id){
  712. var widgetStatus ={
  713. "name": widget.options.name,
  714. "appName": widget.options.appName,
  715. "position": widget.options.position,
  716. "widget": null
  717. };
  718. if (widget.recordStatus) widgetStatus.widget = widget.recordStatus();
  719. return widgetStatus;
  720. },
  721. //******* end record status ***********************************************
  722. //******* begin start menu ************************************************
  723. showStartMenu: function(){
  724. this.loadStartMenu(function(){
  725. if (!this.startMenu.isShow){
  726. this.startMenuNode.addClass("overColor_bg");
  727. this.startMenu.show();
  728. }
  729. }.bind(this));
  730. },
  731. loadStartMenu: function(callback){
  732. if (!this.startMenu){
  733. this.startMenu = new o2.xDesktop.Default.StartMenu(this);
  734. this.startMenu.addEvents({
  735. "onHide": function(){
  736. this.startMenuNode.removeClass("overColor_bg");
  737. }.bind(this),
  738. "onLoad": function(){
  739. if (callback) callback();
  740. }
  741. });
  742. this.startMenu.load();
  743. }else{
  744. if (this.startMenu.isLoaded) if (callback) callback();
  745. }
  746. },
  747. //******* end start menu **************************************************
  748. //******* begin message menu **********************************************
  749. showDesktopMessage: function(){
  750. if (!this.message){
  751. this.loadMessageMenu(function(){
  752. this.showMessage();
  753. }.bind(this));
  754. }else{
  755. this.showMessage();
  756. }
  757. },
  758. loadMessageMenu: function(callback){
  759. o2.require("o2.xDesktop.MessageV2", function(){
  760. this.message = new o2.xDesktop.MessageV2(this);
  761. this.message.addEvents({
  762. "onLoad": function(){ if (callback) callback(); }.bind(this),
  763. "onHide": function(){
  764. this.msgActionNode.removeClass("icon_msg_focus");
  765. this.msgActionNode.removeClass("mainColor_bg");
  766. }.bind(this),
  767. });
  768. this.message.load();
  769. }.bind(this));
  770. },
  771. showMessage: function(){
  772. if (!this.message.isShow){
  773. this.msgActionNode.addClass("icon_msg_focus");
  774. this.msgActionNode.addClass("mainColor_bg");
  775. this.message.show();
  776. }
  777. },
  778. //******* end message menu ************************************************
  779. //******* begin task item *************************************************
  780. createTaskItem: function(app){
  781. return new o2.xDesktop.Default.TaskItem(this, app);
  782. },
  783. //******* end task item ***************************************************
  784. closeApp: function(app, hasTaskitem) {
  785. var appId = app.appId;
  786. this.appCurrentList.erase(app);
  787. this.appArr.erase(app);
  788. this.apps[appId] = null;
  789. delete this.apps[appId];
  790. if (!hasTaskitem){
  791. var i = this.appCurrentList.length;
  792. if (i && this.appCurrentList[i-1]){
  793. this.appCurrentList[i-1].setCurrent();
  794. }else{
  795. var keys = Object.keys(this.apps);
  796. i = keys.length;
  797. if (i && this.apps[keys[i-1]] && this.apps[keys[i-1]].setCurrent){
  798. this.apps[keys[i-1]].setCurrent();
  799. }else{
  800. this.loadDefaultPage()
  801. }
  802. }
  803. this.checkTaskBarSize();
  804. this.checkTaskBarScrollTo();
  805. }
  806. },
  807. refreshApp:function(app){
  808. if (app.window){
  809. var taskitem = app.taskitem;
  810. var appStatus ={
  811. "id": app.appId,
  812. "name": app.options.name,
  813. "style": app.options.style,
  814. "appId": app.appId
  815. };
  816. var status = (app.recordStatus) ? app.recordStatus() : null;
  817. app.close(true);
  818. layout.openApplication(null, appStatus.name, appStatus, status, false, taskitem);
  819. //this.openApplicationWithStatus(appStatus);
  820. }
  821. },
  822. getPageDesignerStyle: function(callback){
  823. if (!this.pageDesignerStyle){
  824. this.pageDesignerStyle = "default";
  825. MWF.UD.getData("pageDesignerStyle", function(json) {
  826. if (json.data) {
  827. var styles = JSON.decode(json.data);
  828. this.pageDesignerStyle = styles.style;
  829. }
  830. if (callback) callback();
  831. }.bind(this));
  832. }else{
  833. if (callback) callback();
  834. }
  835. },
  836. getFormDesignerStyle: function(callback){
  837. if (!this.formDesignerStyle){
  838. this.formDesignerStyle = "default";
  839. MWF.UD.getData("formDesignerStyle", function(json) {
  840. if (json.data) {
  841. var styles = JSON.decode(json.data);
  842. this.formDesignerStyle = styles.style;
  843. }
  844. if (callback) callback();
  845. }.bind(this));
  846. }else{
  847. if (callback) callback();
  848. }
  849. },
  850. createRefreshNode: function(){
  851. this.refreshNode = new Element("div.layout_refresh_node.icon_refresh").inject(this.desktopNode);
  852. this.refreshNode.set("morph", {
  853. "duration": 100,
  854. "transition": Fx.Transitions.Quart.easeOut
  855. });
  856. this.refreshNode.addEvent("click", function(){
  857. if (this.currentApp) this.currentApp.refresh();
  858. this.hideRefresh();
  859. }.bind(this));
  860. },
  861. showRefresh: function(){
  862. if (!this.refreshNodeShow){
  863. if (!this.refreshNode) this.createRefreshNode();
  864. var size = this.taskbarNode.getSize();
  865. var nodeSize = this.refreshNode.getSize();
  866. var top = size.y;
  867. var left = size.x/2-nodeSize.x/2;
  868. this.refreshNode.setStyles({
  869. "left": left,
  870. "top": 0-nodeSize.y,
  871. "opacity": 0
  872. });
  873. this.refreshNode.morph({
  874. "top": top,
  875. "left": left,
  876. "opacity": 0.9
  877. });
  878. this.refreshNodeShow = true;
  879. this.refreshTimeoutId = window.setTimeout(function(){
  880. this.hideRefresh();
  881. }.bind(this), 2000);
  882. }
  883. },
  884. hideRefresh: function(){
  885. if (this.refreshNodeShow){
  886. if (this.refreshNode){
  887. var size = this.taskbarNode.getSize();
  888. var nodeSize = this.refreshNode.getSize();
  889. var top = size.y;
  890. var left = size.x/2-nodeSize.x/2;
  891. this.refreshNode.morph({
  892. "top": 0-nodeSize.y,
  893. "left": left,
  894. "opacity": 0
  895. });
  896. window.setTimeout(function(){
  897. this.refreshNodeShow = false;
  898. }.bind(this), 100);
  899. }
  900. }
  901. if (this.refreshTimeoutId){
  902. window.clearTimeout(this.refreshTimeoutId);
  903. this.refreshTimeoutId = "";
  904. }
  905. }
  906. });
  907. o2.xDesktop.Default.StartMenu = new Class({
  908. Implements: [Events],
  909. initialize: function(layout){
  910. this.layout = layout;
  911. this.container = this.layout.startMenuArea;
  912. this.actionNode = this.layout.startMenuNode;
  913. this.isLoaded = false;
  914. this.isShow = false;
  915. this.isMorph = false;
  916. this.items = [];
  917. this.menuData = (this.layout.status && this.layout.status.menuData) ? this.layout.status.menuData : {
  918. "appList": [],
  919. "processList": [],
  920. "inforList": [],
  921. "queryList": []
  922. };
  923. this.itemTempletedHtml = "" +
  924. " <div class='layout_start_item_iconArea'>" +
  925. " <div class='layout_start_item_icon'></div>" +
  926. " </div>" +
  927. " <div class='layout_start_item_text'></div>"+
  928. " <div class='layout_start_item_badge'></div>";
  929. },
  930. load: function(){
  931. //var view = this.layout.path+this.layout.options.style+((o2.session.isMobile || layout.mobile) ? "/layout-menu-mobile.html" : "/layout-menu-pc.html");
  932. var view = this.layout.path+this.layout.options.style+ "/layout-menu-pc.html";
  933. this.container.loadHtml(view, {"module": this}, function(){
  934. this.maskNode.setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex());
  935. this.node.setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex());
  936. this.layout.menuNode.setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex());
  937. this.node.addEvent("mousedown", function(e){
  938. e.stopPropagation();
  939. e.preventDefault();
  940. });
  941. this.triangleNode = new Element("div.layout_menu_start_triangle").inject(this.layout.menuNode, "after");
  942. this.hideMessage = function(){ this.hide(); }.bind(this);
  943. this.layout.addEvent("resize", this.setSize.bind(this));
  944. this.loadTitle();
  945. this.loadLnks();
  946. this.isLoaded = true;
  947. this.fireEvent("load");
  948. }.bind(this));
  949. },
  950. resetMenuData: function(){
  951. if (!this.menuData) this.menuData = {
  952. "appList": [],
  953. "processList": [],
  954. "inforList": [],
  955. "queryList": []
  956. }
  957. var nodes = this.appContentNode.getChildren();
  958. var data = [];
  959. nodes.each(function(node){
  960. var item = node.retrieve("item");
  961. if (item){
  962. if (item.data.type==="group"){
  963. var d = {
  964. "id": item.data.id,
  965. "name": item.data.name,
  966. "type": item.data.type,
  967. "itemDataList": []
  968. }
  969. if (item.data.itemDataList) item.data.itemDataList.each(function(i){
  970. d.itemDataList.push(i);
  971. });
  972. data.push(d);
  973. }else{
  974. data.push({
  975. "id": item.data.id,
  976. "name": item.data.name,
  977. "type": item.data.type,
  978. });
  979. }
  980. }
  981. }.bind(this));
  982. if (this.currentTab === this.appCategoryTab){
  983. this.menuData.appList = data;
  984. }else if (this.currentTab === this.processCategoryTab){
  985. this.menuData.processList = data;
  986. }else if (this.currentTab === this.inforCategoryTab){
  987. this.menuData.inforList = data;
  988. }else if (this.currentTab === this.queryCategoryTab){
  989. this.menuData.queryList = data;
  990. }
  991. this.layout.menuData = this.menuData;
  992. },
  993. setScroll: function(){
  994. // o2.require("o2.widget.ScrollBar", function(){
  995. // this.appScrollBar = new o2.widget.ScrollBar(this.appScrollNode, {
  996. // "style":"xDesktop_Message", "where": "before", "indent": false, "distance": 100, "friction": 6, "axis": {"x": false, "y": true}
  997. // });
  998. // }.bind(this));
  999. },
  1000. loadTitle: function(){
  1001. this.lnkTitleNode.set("text", o2.LP.desktop.lnkAppTitle);
  1002. this.appCategoryTab = new Element("div.layout_start_tab", {"text": o2.LP.desktop.message.application}).inject(this.appTitleNode);
  1003. this.processCategoryTab = new Element("div.layout_start_tab", {"text": o2.LP.desktop.message.process}).inject(this.appTitleNode);
  1004. this.inforCategoryTab = new Element("div.layout_start_tab", {"text": o2.LP.desktop.message.infor}).inject(this.appTitleNode);
  1005. this.queryCategoryTab = new Element("div.layout_start_tab", {"text": o2.LP.desktop.message.query}).inject(this.appTitleNode);
  1006. this.refreshAreaNode = new Element("div.layout_start_search", {"title": o2.LP.desktop.message.refreshMenu}).inject(this.appTitleNode);
  1007. this.refreshNode = new Element("div.layout_start_search_icon").inject(this.refreshAreaNode);
  1008. this.refreshNode.addClass("icon_startMenu_refresh");
  1009. this.searchNode = new Element("div.layout_start_search").inject(this.appTitleNode);
  1010. this.searchIconNode = new Element("div.layout_start_search_icon").inject(this.searchNode);
  1011. this.searchIconNode.addClass("icon_startMenu_search");
  1012. var currentWidth = this.searchNode.getSize().x;
  1013. this.searchNode.store("currentWidth", currentWidth);
  1014. this.appCategoryTab.addEvent("click", function(){
  1015. this.appTitleNode.getElements(".layout_start_tab").removeClass("mainColor_bg");
  1016. this.appCategoryTab.addClass("mainColor_bg");
  1017. this.currentTab = this.appCategoryTab;
  1018. this.loadApplications();
  1019. }.bind(this));
  1020. this.processCategoryTab.addEvent("click", function(){
  1021. this.appTitleNode.getElements(".layout_start_tab").removeClass("mainColor_bg");
  1022. this.processCategoryTab.addClass("mainColor_bg");
  1023. this.currentTab = this.processCategoryTab;
  1024. this.loadProcesses();
  1025. }.bind(this));
  1026. this.inforCategoryTab.addEvent("click", function(){
  1027. this.appTitleNode.getElements(".layout_start_tab").removeClass("mainColor_bg");
  1028. this.inforCategoryTab.addClass("mainColor_bg");
  1029. this.currentTab = this.inforCategoryTab;
  1030. this.loadInfors();
  1031. }.bind(this));
  1032. this.queryCategoryTab.addEvent("click", function(){
  1033. this.appTitleNode.getElements(".layout_start_tab").removeClass("mainColor_bg");
  1034. this.queryCategoryTab.addClass("mainColor_bg");
  1035. this.currentTab = this.queryCategoryTab;
  1036. this.loadQuerys();
  1037. }.bind(this));
  1038. this.searchIconNode.addEvent("click", this.searchIconAction.bind(this));
  1039. this.refreshNode.addEvent("click", function(e){
  1040. var _self = this;
  1041. MWF.xDesktop.confirm("infor", e, o2.LP.desktop.defaultMenuTitle, o2.LP.desktop.defaultMenuInfor, 420, 100, function(){
  1042. _self.defaultMenu();
  1043. this.close();
  1044. }, function(){
  1045. this.close();
  1046. }, null, null, "o2"
  1047. );
  1048. }.bind(this));
  1049. },
  1050. searchIconAction: function(){
  1051. if (!this.isMorph){
  1052. if (this.isSearch){
  1053. this.doSearch();
  1054. }else{
  1055. this.loadSearch()
  1056. }
  1057. }
  1058. },
  1059. loadSearch: function(){
  1060. this.isSearch = true;
  1061. this.searchNode.addClass("mainColor_border");
  1062. this.appCategoryTab.hide();
  1063. this.processCategoryTab.hide();
  1064. this.inforCategoryTab.hide();
  1065. this.queryCategoryTab.hide();
  1066. this.refreshAreaNode.hide();
  1067. var size = this.appTitleNode.getSize();
  1068. var pr = this.appTitleNode.getStyle("padding-right").toInt() || 0;
  1069. var pl = this.appTitleNode.getStyle("padding-left").toInt() || 0;
  1070. var margin = this.searchNode.getStyle("margin-right").toInt() || 0;
  1071. var w = size.x-margin*2-pr-pl;
  1072. this.isMorph = true;
  1073. this.searchNode.set("morph", {"duration": 200});
  1074. this.searchNode.morph({"width": ""+w+"px"});
  1075. window.setTimeout(function(){
  1076. this.isMorph = false;
  1077. }.bind(this), 220);
  1078. if (!this.searchClearNode){
  1079. this.searchClearNode = new Element("div.layout_start_search_clear").inject(this.searchNode);
  1080. this.searchClearNode.addClass("icon_clear");
  1081. this.searchClearNode.addEvent("click", this.hideSearch.bind(this));
  1082. }
  1083. this.searchClearNode.show();
  1084. if (!this.searchAreaNode) this.searchAreaNode = new Element("div.layout_start_search_area").inject(this.searchNode);
  1085. this.searchAreaNode.show();
  1086. if (!this.searchInputNode){
  1087. this.searchInputNode = new Element("input.layout_start_search_input", {"placeholder": o2.LP.searchKey}).inject(this.searchAreaNode);
  1088. this.searchInputNode.addEvent("keydown", function(e){
  1089. if (e.code==13) this.doSearch();
  1090. }.bind(this));
  1091. }
  1092. this.searchInputNode.show();
  1093. this.searchInputNode.focus();
  1094. //this.searchNode.addClass("layout_start_search_load");
  1095. },
  1096. hideSearch: function(){
  1097. if (this.isSearch){
  1098. if (this.searchInputNode){
  1099. this.searchInputNode.set("value", "");
  1100. this.searchInputNode.hide();
  1101. }
  1102. if (this.searchAreaNode) this.searchAreaNode.hide();
  1103. if (this.searchClearNode) this.searchClearNode.hide();
  1104. this.isMorph = true;
  1105. var currentWidth = this.searchNode.retrieve("currentWidth");
  1106. this.searchNode.morph({"width": ""+currentWidth+"px"});
  1107. window.setTimeout(function(){
  1108. if (this.currentTab && this.isSearchResult) this.currentTab.click();
  1109. this.searchNode.removeClass("mainColor_border");
  1110. this.appCategoryTab.show();
  1111. this.processCategoryTab.show();
  1112. this.inforCategoryTab.show();
  1113. this.queryCategoryTab.show();
  1114. this.refreshAreaNode.show();
  1115. this.isSearch = false;
  1116. this.isMorph = false;
  1117. this.isSearchResult = false;
  1118. }.bind(this), 220);
  1119. }
  1120. },
  1121. doSearch: function(){
  1122. var key = this.searchInputNode.get("value").toLowerCase();
  1123. if (key){
  1124. this.isSearchResult = true;
  1125. this.appContentNode.empty();
  1126. this.searchApplicatins(key);
  1127. this.searchProcesses(key);
  1128. this.searchInfors(key);
  1129. this.searchQuerys(key);
  1130. }
  1131. },
  1132. searchApplicatins: function(value){
  1133. // var user = this.layout.session.user;
  1134. // // var currentNames = [user.name, user.distinguishedName, user.id, user.unique];
  1135. // // if (user.roleList) currentNames = currentNames.concat(user.roleList);
  1136. // // if (user.groupList) currentNames = currentNames.concat(user.groupList);
  1137. var user = this.layout.session.user;
  1138. var currentNames = [user.name, user.distinguishedName, user.id, user.unique];
  1139. if (user.roleList) currentNames = currentNames.concat(user.roleList);
  1140. if (user.groupList) currentNames = currentNames.concat(user.groupList);
  1141. //this.getCurrentName( function (currentNames) {
  1142. if (this.layoutJson && this.layoutJson.length) this.layoutJson.each(function(v){
  1143. if ( this.checkMenuItem(v, currentNames) ){
  1144. if ((v.title.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.title.toPY().toLowerCase().indexOf(value)!==-1) || (v.title.indexOf(value)!==-1)){
  1145. this.createApplicationMenuItem(v);
  1146. }
  1147. }
  1148. }.bind(this));
  1149. if (this.componentJson && this.componentJson.length) this.componentJson.each(function(v){
  1150. if ( this.checkMenuItem(v, currentNames) ){
  1151. if ((v.title.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.title.toPY().toLowerCase().indexOf(value)!==-1) || (v.title.indexOf(value)!==-1)){
  1152. this.createApplicationMenuItem(v);
  1153. }
  1154. }
  1155. }.bind(this));
  1156. if (this.portalJson && this.portalJson.length) this.portalJson.each(function(v){
  1157. if ((v.name.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.name.toPY().toLowerCase().indexOf(value)!==-1) || (v.name.indexOf(value)!==-1)){
  1158. this.createPortalMenuItem(v);
  1159. }
  1160. }.bind(this));
  1161. //})
  1162. },
  1163. searchProcesses: function(value){
  1164. if (this.processJson && this.processJson.length) this.processJson.each(function(v){
  1165. if ((v.name.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.name.toPY().toLowerCase().indexOf(value)!==-1) || (v.name.indexOf(value)!==-1)){
  1166. this.createProcessMenuItem(v);
  1167. }
  1168. }.bind(this));
  1169. },
  1170. searchInfors: function(value){
  1171. if (this.inforJson && this.inforJson.length) this.inforJson.each(function(v){
  1172. if ((v.appName.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.appName.toPY().toLowerCase().indexOf(value)!==-1) || (v.appName.indexOf(value)!==-1)){
  1173. this.createInforMenuItem(v);
  1174. }
  1175. }.bind(this));
  1176. },
  1177. searchQuerys: function(value){
  1178. if (this.queryJson && this.queryJson.length) this.queryJson.each(function(v){
  1179. if ((v.name.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.name.toPY().toLowerCase().indexOf(value)!==-1) || (v.name.indexOf(value)!==-1)){
  1180. this.createQueryMenuItem(v);
  1181. }
  1182. }.bind(this));
  1183. },
  1184. loadGroup: function(callback){
  1185. if( this.layout.session.user.groupList ){
  1186. if(callback) callback()
  1187. }else{
  1188. o2.Actions.load("x_organization_assemble_express").GroupAction.listWithPerson({
  1189. personList: [this.layout.session.user.unique],
  1190. recursiveGroupFlag: true,
  1191. referenceFlag: true,
  1192. recursiveOrgFlag: true
  1193. }, function (json) {
  1194. this.layout.session.user.groupList = json.data.groupList || [];
  1195. if(callback) callback()
  1196. }.bind(this))
  1197. }
  1198. },
  1199. loadJsons: function(callback){
  1200. this.clearAppContentNode();
  1201. this.loadLayoutApplications(function(json_layout){
  1202. var componentAction = o2.Actions.get("x_component_assemble_control");
  1203. var portalAction = o2.Actions.get("x_portal_assemble_surface");
  1204. var processAction = o2.Actions.get("x_processplatform_assemble_surface");
  1205. var inforAction = o2.Actions.get("x_cms_assemble_control");
  1206. var queryAction = o2.Actions.get("x_query_assemble_surface");
  1207. var iconsPath = this.layout.path+"icons.json";
  1208. this.getIconsJson(function(){
  1209. o2.Actions.invokeAsync([
  1210. {"action": componentAction, "name": "listComponent"},
  1211. {"action": portalAction, "name": "listApplication"},
  1212. {"action": processAction, "name": "listApplication"},
  1213. {"action": inforAction, "name": "listColumn"},
  1214. {"action": queryAction, "name": "listQuery"},
  1215. ], {"success": function(json_component, json_portal, json_process, json_infor, json_query){
  1216. this.layoutJson = json_layout;
  1217. this.componentJson = json_component.data;
  1218. this.portalJson = json_portal.data;
  1219. this.processJson = json_process.data;
  1220. this.inforJson = json_infor.data;
  1221. this.queryJson = json_query.data;
  1222. if (callback) callback();
  1223. }.bind(this), "failure": function(){}}
  1224. );
  1225. }.bind(this), iconsPath);
  1226. }.bind(this));
  1227. },
  1228. getIconsJson: function(callback, iconsPath){
  1229. if (this.layout.iconsJson){
  1230. if (callback) callback();
  1231. }else{
  1232. o2.JSON.get(iconsPath, function(json){
  1233. this.layout.iconsJson = json;
  1234. if (callback) callback();
  1235. }.bind(this));
  1236. }
  1237. },
  1238. setPosition: function(){
  1239. //var size = this.container.getSize();
  1240. var index = o2.xDesktop.zIndexPool.zIndex;
  1241. var nodeSize = this.node.getSize();
  1242. var left = 0-nodeSize.x;
  1243. this.maskNode.setStyles({"left": ""+left+"px"});
  1244. this.node.setStyles({"left": ""+left+"px"});
  1245. },
  1246. setSize: function(){
  1247. if (this.appScrollBar && this.appScrollBar.scrollVNode) this.appScrollBar.scrollVNode.setStyle("margin-top", "0px");
  1248. var isLnk = false;
  1249. if (false && this.layout.lnks && this.layout.lnks.length){
  1250. this.lnkAreaNode.show();
  1251. this.lineNode.show();
  1252. var h = 100*3;
  1253. this.lnkScrollNode.setStyle("height", ""+h+"px");
  1254. isLnk = true;
  1255. }else{
  1256. this.lnkAreaNode.hide();
  1257. this.lineNode.hide();
  1258. }
  1259. var size = this.node.getSize();
  1260. var lnkSizeY = (isLnk) ? this.lnkAreaNode.getSize().y : 0;
  1261. var lineSizeY = (isLnk) ? this.lineNode.getSize().y : 0;
  1262. var mt = (isLnk) ? (this.lineNode.getStyle("margin-top").toInt() || 0) : 0;
  1263. var mb = (isLnk) ? (this.lineNode.getStyle("margin-bottom").toInt() || 0) : 0;
  1264. var titleSize = this.appTitleNode.getSize();
  1265. var y = size.y-lnkSizeY-lineSizeY-mt-mb-titleSize.y;
  1266. this.appScrollNode.setStyle("height", ""+y+"px");
  1267. },
  1268. loadLnks: function(){
  1269. // if (this.layout.lnks && this.layout.lnks.length){
  1270. // this.lnkAreaNode.show();
  1271. // this.lineNode.show();
  1272. // this.lnkContentNode.empty();
  1273. // this.createLnkMenuItem();
  1274. // }else{
  1275. this.lnkAreaNode.hide();
  1276. this.lineNode.hide();
  1277. //}
  1278. },
  1279. createLnkMenuItem: function(){
  1280. //this.templetedHtml
  1281. },
  1282. clearAppContentNode: function(){
  1283. this.appContentNode.empty();
  1284. this.appContentNode.addClass("icon_loading");
  1285. },
  1286. loadApplications: function(callback){
  1287. this.clearAppContentNode();
  1288. // this.loadLayoutApplications(function(json_layout){
  1289. // var componentAction = o2.Actions.get("x_component_assemble_control");
  1290. // var portalAction = o2.Actions.get("x_portal_assemble_surface");
  1291. // o2.Actions.invokeAsync([
  1292. // {"action": componentAction, "name": "listComponent"},
  1293. // {"action": portalAction, "name": "listApplication"},
  1294. // ], {"success": function(json_component, json_portal){
  1295. // this.loadApplicationsItem(json_layout, json_component.data, json_portal.data);
  1296. // }.bind(this), "failure": function(){}}
  1297. // );
  1298. // }.bind(this));
  1299. this.loadApplicationsItem(this.layoutJson, this.componentJson, this.portalJson);
  1300. },
  1301. loadLayoutApplications: function(callback){
  1302. var url = this.layout.path+"applications.json";
  1303. o2.getJSON(url, function(json){
  1304. if (callback) callback(json);
  1305. }.bind(this));
  1306. },
  1307. loadApplicationsItem: function(layoutJson, componentJson, portalJson){
  1308. var user = this.layout.session.user;
  1309. var currentNames = [user.name, user.distinguishedName, user.id, user.unique];
  1310. if (user.roleList) currentNames = currentNames.concat(user.roleList);
  1311. if (user.groupList) currentNames = currentNames.concat(user.groupList);
  1312. var json_layout = Array.clone(layoutJson);
  1313. var json_component = Array.clone(componentJson);
  1314. var json_portal = Array.clone(portalJson);
  1315. this.appContentNode.removeClass("icon_loading");
  1316. var loadedApps = {};
  1317. if (this.menuData && this.menuData.appList && this.menuData.appList.length){
  1318. this.menuData.appList.each(function(app){
  1319. if (app.type==="group"){
  1320. this.createGroupMenuItem(app);
  1321. app.itemDataList.each(function(a){
  1322. var d = json_layout.find(function(i){ return (i.id === a.id); });
  1323. if (d) json_layout.erase(d);
  1324. d = json_component.find(function(i){ return (i.id === a.id); });
  1325. if (d) json_component.erase(d);
  1326. d = json_portal.find(function(i){ return (i.id === a.id); });
  1327. if (d) json_portal.erase(d);
  1328. }.bind(this));
  1329. }else {
  1330. var appData = null;
  1331. if (!appData && json_layout && json_layout.length) {
  1332. appData = json_layout.find(function (i) {
  1333. return (i.id === app.id);
  1334. });
  1335. if (appData) {
  1336. json_layout.erase(appData);
  1337. if (this.checkMenuItem(appData, currentNames)) this.createApplicationMenuItem(appData);
  1338. }
  1339. }
  1340. if (!appData && json_component && json_component.length) {
  1341. appData = json_component.find(function (i) {
  1342. return (i.id === app.id);
  1343. });
  1344. if (appData) {
  1345. json_component.erase(appData);
  1346. if (this.checkMenuItem(appData, currentNames)) this.createApplicationMenuItem(appData);
  1347. }
  1348. }
  1349. if (!appData && json_portal && json_portal.length) {
  1350. appData = json_portal.find(function (i) {
  1351. return (i.id === app.id);
  1352. });
  1353. if (appData) {
  1354. json_portal.erase(appData);
  1355. appData.type = "portal";
  1356. this.createPortalMenuItem(appData);
  1357. }
  1358. }
  1359. }
  1360. }.bind(this));
  1361. }
  1362. if (json_layout && json_layout.length) json_layout.each(function(value){
  1363. if ( this.checkMenuItem(value, currentNames) ) this.createApplicationMenuItem(value);
  1364. }.bind(this));
  1365. if (json_component && json_component.length) json_component.each(function(value){
  1366. if ( this.checkMenuItem(value, currentNames) ) this.createApplicationMenuItem(value);
  1367. }.bind(this));
  1368. // if (json_portal && json_portal.length) json_portal.each(function(value){
  1369. // this.createPortalMenuItem(value);
  1370. // }.bind(this));
  1371. if (json_portal && json_portal.length) json_portal.each(function(value){
  1372. value.type = "portal";
  1373. this.createPortalMenuItem(value);
  1374. }.bind(this));
  1375. },
  1376. loadProcesses: function(){
  1377. this.clearAppContentNode();
  1378. // o2.Actions.get("x_processplatform_assemble_surface").listApplication(this.loadProcessesItem.bind(this));
  1379. this.loadProcessesItem(this.processJson)
  1380. },
  1381. loadProcessesItem: function(list){
  1382. this.appContentNode.removeClass("icon_loading");
  1383. var json = Array.clone(list);
  1384. if (this.menuData && this.menuData.processList && this.menuData.processList.length){
  1385. this.menuData.processList.each(function(app){
  1386. if (app.type==="group"){
  1387. this.createGroupMenuItem(app);
  1388. app.itemDataList.each(function(a){
  1389. var d = json.find(function(i){ return (i.id === a.id); });
  1390. if (d) json.erase(d);
  1391. }.bind(this));
  1392. }else{
  1393. var appData = null;
  1394. if (!appData && json && json.length){
  1395. appData = json.find(function(i){ return (i.id === app.id); });
  1396. if (appData){
  1397. json.erase(appData);
  1398. appData.type = "process";
  1399. this.createProcessMenuItem(appData);
  1400. }
  1401. }
  1402. }
  1403. }.bind(this));
  1404. }
  1405. if (json && json.length) json.each(function(value){
  1406. value.type = "process";
  1407. this.createProcessMenuItem(value);
  1408. }.bind(this));
  1409. },
  1410. loadInfors: function(){
  1411. this.clearAppContentNode();
  1412. //o2.Actions.get("x_cms_assemble_control").listColumn(this.loadInforsItem.bind(this));
  1413. this.loadInforsItem(this.inforJson)
  1414. },
  1415. loadInforsItem: function(list){
  1416. this.appContentNode.removeClass("icon_loading");
  1417. var json = Array.clone(list);
  1418. if (this.menuData && this.menuData.inforList && this.menuData.inforList.length){
  1419. this.menuData.inforList.each(function(app){
  1420. if (app.type==="group"){
  1421. this.createGroupMenuItem(app);
  1422. app.itemDataList.each(function(a){
  1423. var d = json.find(function(i){ return (i.id === a.id); });
  1424. if (d) json.erase(d);
  1425. }.bind(this));
  1426. }else{
  1427. var appData = null;
  1428. if (!appData && json && json.length){
  1429. appData = json.find(function(i){ return (i.id === app.id); });
  1430. if (appData){
  1431. json.erase(appData);
  1432. appData.type = "cms";
  1433. this.createInforMenuItem(appData);
  1434. }
  1435. }
  1436. }
  1437. }.bind(this));
  1438. }
  1439. if (json && json.length) json.each(function(value){
  1440. value.type = "cms";
  1441. this.createInforMenuItem(value);
  1442. }.bind(this));
  1443. },
  1444. loadQuerys: function(){
  1445. this.clearAppContentNode();
  1446. // o2.Actions.get("x_query_assemble_surface").listQuery(this.loadQuerysItem.bind(this));
  1447. this.loadQuerysItem(this.queryJson)
  1448. },
  1449. loadQuerysItem: function(list){
  1450. this.appContentNode.removeClass("icon_loading");
  1451. var json = Array.clone(list);
  1452. if (this.menuData && this.menuData.queryList && this.menuData.queryList.length){
  1453. this.menuData.queryList.each(function(app){
  1454. if (app.type==="group"){
  1455. this.createGroupMenuItem(app);
  1456. app.itemDataList.each(function(a){
  1457. var d = json.find(function(i){ return (i.id === a.id); });
  1458. if (d) json.erase(d);
  1459. }.bind(this));
  1460. }else{
  1461. var appData = null;
  1462. if (!appData && json && json.length){
  1463. appData = json.find(function(i){ return (i.id === app.id); });
  1464. if (appData){
  1465. json.erase(appData);
  1466. appData.type = "query";
  1467. this.createQueryMenuItem(appData);
  1468. }
  1469. }
  1470. }
  1471. }.bind(this));
  1472. }
  1473. if (json && json.length) json.each(function(value){
  1474. value.type = "query";
  1475. this.createQueryMenuItem(value);
  1476. }.bind(this));
  1477. },
  1478. checkMenuItem: function(value, currentNames){
  1479. if( value.path === "AuditLog" && ["securityManager","auditManager"].isIntersect(currentNames) )return true;
  1480. if (value.visible===false) return false;
  1481. var isAllow = true;
  1482. if (value.allowList) isAllow = (value.allowList.length) ? (value.allowList.isIntersect(currentNames)) : true;
  1483. var isDeny = false;
  1484. if (value.denyList) isDeny = (value.denyList.length) ? (value.denyList.isIntersect(currentNames)) : false;
  1485. return ((!isDeny && isAllow) || o2.AC.isAdministrator());
  1486. },
  1487. createApplicationMenuItem: function(value){
  1488. this.items.push(new o2.xDesktop.Default.StartMenu.Item(this, this.appContentNode, value));
  1489. },
  1490. createPortalMenuItem: function(value){
  1491. this.items.push(new o2.xDesktop.Default.StartMenu.PortalItem(this, this.appContentNode, value));
  1492. },
  1493. createProcessMenuItem: function(value){
  1494. this.items.push(new o2.xDesktop.Default.StartMenu.ProcessItem(this, this.appContentNode, value));
  1495. },
  1496. createInforMenuItem: function(value){
  1497. this.items.push(new o2.xDesktop.Default.StartMenu.InforItem(this, this.appContentNode, value));
  1498. },
  1499. createQueryMenuItem: function(value){
  1500. this.items.push(new o2.xDesktop.Default.StartMenu.QueryItem(this, this.appContentNode, value));
  1501. },
  1502. createGroupMenuItem: function(value){
  1503. this.items.push(new o2.xDesktop.Default.StartMenu.GroupItem(this, this.appContentNode, value));
  1504. },
  1505. show: function(){
  1506. if (!this.isMorph){
  1507. this.isMorph = true;
  1508. if (!this.morph){
  1509. this.maskMorph = new Fx.Morph(this.maskNode, {
  1510. duration: "200",
  1511. transition: Fx.Transitions.Sine.easeOut
  1512. });
  1513. this.morph = new Fx.Morph(this.node, {
  1514. duration: "200",
  1515. transition: Fx.Transitions.Sine.easeOut
  1516. });
  1517. }
  1518. this.maskNode.setStyles({"display": "block"});
  1519. this.node.setStyles({"display": "block"});
  1520. this.triangleNode.setStyles({"display": "block"});
  1521. this.appAreaNode.setStyles({ "filter": "" });
  1522. this.setSize();
  1523. this.setPosition();
  1524. var size = this.layout.menuNode.getSize();
  1525. var left = size.x;
  1526. var jsonLoaded = false, groupLoaded = false;
  1527. var checkLoad = function () {
  1528. if(jsonLoaded && groupLoaded){
  1529. (this.currentTab || this.appCategoryTab).click();
  1530. }
  1531. }.bind(this);
  1532. this.loadJsons(function(){
  1533. jsonLoaded = true;
  1534. checkLoad();
  1535. }.bind(this));
  1536. this.loadGroup(function(){
  1537. groupLoaded = true;
  1538. checkLoad();
  1539. }.bind(this));
  1540. //this.loadContent();
  1541. this.maskMorph.start({"left": ""+left+"px"});
  1542. this.morph.start({"left": ""+left+"px"}).chain(function(){
  1543. this.isShow = true;
  1544. this.isMorph = false;
  1545. this.layout.desktopNode.addEvent("mousedown", this.hideMessage);
  1546. // this.setScroll();
  1547. this.fireEvent("show");
  1548. }.bind(this));
  1549. }
  1550. },
  1551. hide: function(callback){
  1552. if (!this.isMorph){
  1553. this.isMorph = true;
  1554. if (!this.morph){
  1555. this.maskMorph = new Fx.Morph(this.maskNode, {
  1556. duration: "200",
  1557. transition: Fx.Transitions.Sine.easeOut
  1558. });
  1559. this.morph = new Fx.Morph(this.node, {
  1560. duration: "200",
  1561. transition: Fx.Transitions.Sine.easeOut
  1562. });
  1563. }
  1564. var nodeSize = this.node.getSize();
  1565. var left = 0-nodeSize.x;
  1566. // var position = this.node.getPosition();
  1567. // var size = this.node.getSize();
  1568. // var left = position.x+size.x;
  1569. this.isSearchResult = false;
  1570. this.hideSearch();
  1571. this.lnkContentNode.empty();
  1572. this.appContentNode.empty();
  1573. this.groupMenuArea.empty();
  1574. if (this.appScrollBar) this.appScrollBar.destroy();
  1575. this.maskMorph.start({"left": ""+left+"px"}).chain(function(){
  1576. this.maskNode.setStyle("display", "none");
  1577. this.triangleNode.setStyles({"display": "none"});
  1578. }.bind(this));
  1579. this.morph.start({"left": ""+left+"px"}).chain(function(){
  1580. this.node.setStyle("display", "none");
  1581. this.isShow = false;
  1582. this.isMorph = false;
  1583. this.layout.desktopNode.removeEvent("mousedown", this.hideMessage);
  1584. this.fireEvent("hide");
  1585. if (callback) callback();
  1586. }.bind(this));
  1587. }
  1588. },
  1589. defaultMenu: function(){
  1590. this.layout.menuData = null;
  1591. if (this.layout.status) this.layout.status.menuData = null;
  1592. this.menuData = null;
  1593. this.hide();
  1594. }
  1595. });
  1596. o2.xDesktop.Default.StartMenu.Item = new Class({
  1597. initialize: function (menu, container, data, positionNode) {
  1598. this.menu = menu;
  1599. this.layout = this.menu.layout;
  1600. this.data = data;
  1601. this.container = $(container);
  1602. this.load(positionNode);
  1603. this.init();
  1604. },
  1605. load: function(positionNode){
  1606. this.node = new Element("div.layout_start_item");
  1607. if (positionNode){
  1608. this.node.inject(positionNode, "before");
  1609. }else{
  1610. this.node.inject(this.container);
  1611. }
  1612. this.node.set("html", this.menu.itemTempletedHtml);
  1613. this.iconAreaNode = this.node.getElement(".layout_start_item_iconArea");
  1614. this.iconNode = this.node.getElement(".layout_start_item_icon");
  1615. this.badgeNode = this.node.getElement(".layout_start_item_badge");
  1616. this.textNode = this.node.getElement(".layout_start_item_text");
  1617. this.loadIcon();
  1618. this.loadBadge();
  1619. this.loadText();
  1620. this.setEvent();
  1621. this.node.store("item", this);
  1622. if (this.menu.data && this.menu.data.type==="group"){
  1623. this.node.addClass("layout_start_item_sub");
  1624. }
  1625. },
  1626. init: function(){},
  1627. dragOver: function(){
  1628. if (!this.overNode){
  1629. this.overNode = new Element("div.layout_start_item_over").inject(this.container);
  1630. this.overNode.addClass("mainColor_bg");
  1631. }
  1632. this.overNode.position({
  1633. "relativeTo": this.iconAreaNode,
  1634. "position": "leftTop",
  1635. "edge": "leftTop",
  1636. "offset": {
  1637. "x": -6, "y":-6
  1638. }
  1639. });
  1640. this.overNode.show();
  1641. },
  1642. dragOut: function(){
  1643. if (this.overNode) this.overNode.hide();
  1644. },
  1645. loadIcon: function(){
  1646. var icon;
  1647. var bgcolor = "";
  1648. if( this.data.path ){
  1649. if (this.data.path.substring(0, 4)==="@url"){
  1650. if (this.data.iconPath){
  1651. icon = this.data.iconPath;
  1652. }else{
  1653. if (this.layout.iconsJson["Url"] && this.layout.iconsJson["Url"].icon){
  1654. icon = this.layout.path+"appicons/"+this.layout.iconsJson["Url"].icon;
  1655. bgcolor = this.layout.iconsJson["Url"].color;
  1656. }else{
  1657. icon = "../x_component_Setting/$Main/default/icon/site.png";
  1658. bgcolor = "";
  1659. }
  1660. }
  1661. }else{
  1662. if (this.layout.iconsJson[this.data.path] && this.layout.iconsJson[this.data.path].icon){
  1663. icon = this.layout.path+"appicons/"+this.layout.iconsJson[this.data.path].icon;
  1664. bgcolor = this.layout.iconsJson[this.data.path].color;
  1665. }else{
  1666. icon = "../x_component_"+this.data.path.replace(/\./g, "_")+"/$Main/"+this.data.iconPath;
  1667. bgcolor = "";
  1668. }
  1669. }
  1670. if (icon && bgcolor){
  1671. this.iconNode.addClass("layout_start_item_icon_flat");
  1672. this.iconNode.setStyle("background-color", bgcolor);
  1673. }
  1674. this.iconNode.setStyle("background-image", "url("+icon+")");
  1675. this.icon = icon;
  1676. this.bgcolor = bgcolor;
  1677. }
  1678. },
  1679. loadBadge: function(){
  1680. if( this.layout.isUseForceMainMenuData ){
  1681. this.badgeNode.hide();
  1682. }else{
  1683. this.badgeNode.set("title", o2.LP.desktop.addLnk).addClass("icon_add_red");
  1684. }
  1685. },
  1686. loadText: function(){
  1687. if (this.data.path && this.data.path.indexOf("@url") !== 0 ){
  1688. var appNames = this.data.path.split(".");
  1689. var o = o2.xApplication;
  1690. appNames.each(function(name){
  1691. if (!o[name]) o[name] = {};
  1692. o = o[name];
  1693. });
  1694. id = this.data.id;
  1695. if (this.menu.layoutJson) var d = this.menu.layoutJson.find(function(i){ return (i.id === id); });
  1696. if (!d && this.menu.componentJson) d = this.menu.componentJson.find(function(i){ return (i.id === id); });
  1697. o2.xDesktop.requireApp(this.data.path, "lp." + o2.language, {
  1698. "onSuccess": function(){
  1699. if (o.LP && o.LP.title) {
  1700. this.textNode.set("text", o.LP.title);
  1701. if (d) d.title = o.LP.title;
  1702. }else{
  1703. this.textNode.set("text", this.data.title || this.data.name);
  1704. }
  1705. }.bind(this),
  1706. "onFailure": function () {
  1707. this.textNode.set("text", this.data.title || this.data.name);
  1708. }.bind(this)
  1709. }, false);
  1710. }else{
  1711. this.textNode.set("text", this.data.title || this.data.name);
  1712. }
  1713. },
  1714. setEvent: function(){
  1715. this.node.addEvents({
  1716. "mouseover": function(){ this.badgeNode.fade("in"); }.bind(this),
  1717. "mouseout": function(){ this.badgeNode.fade("out"); }.bind(this),
  1718. "click": function(e){
  1719. //this.menu.hide(function(){
  1720. this.open(e);
  1721. //}.bind(this));
  1722. }.bind(this)
  1723. });
  1724. this.badgeNode.addEvent("click", function(e){
  1725. this.addLnk();
  1726. e.stopPropagation();
  1727. }.bind(this));
  1728. this.makeLnk();
  1729. },
  1730. addLnk: function(dragTargetLnk, dragPosition){
  1731. debugger;
  1732. lnkdata = {
  1733. "name": this.data.path,
  1734. "title": this.data.title,
  1735. "appName": this.data.name,
  1736. "iconData": this.data.iconData || null,
  1737. "icon": this.iconData || null,
  1738. "appType": null,
  1739. "options": null
  1740. }
  1741. this.layout.addLnk(lnkdata, dragTargetLnk, dragPosition);
  1742. },
  1743. open: function(e){
  1744. this.menu.hide(function(){
  1745. if (this.menu.menu){
  1746. this.menu.menu.hide(function(){
  1747. layout.openApplication(e, this.data.path);
  1748. }.bind(this));
  1749. }else{
  1750. layout.openApplication(e, this.data.path);
  1751. }
  1752. }.bind(this));
  1753. },
  1754. makeLnk: function(){
  1755. if( !this.layout.isUseForceMainMenuData ) {
  1756. var drag = new Drag(this.node, {
  1757. "stopPropagation": true,
  1758. "compensateScroll": true,
  1759. "onStart": function (el, e) {
  1760. this.doDragMove(e);
  1761. drag.stop();
  1762. }.bind(this)
  1763. });
  1764. }
  1765. },
  1766. getDragNode: function(){
  1767. if (!this.dragNode){
  1768. this.dragNode = new Element("div.layout_menu_lnk_item_drag")
  1769. .setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex())
  1770. .inject(this.layout.node);
  1771. var dragIconNode = this.iconNode.clone(true).inject(this.dragNode)
  1772. .removeClass("layout_menu_lnk_item_icon")
  1773. .addClass("layout_menu_lnk_item_icon_drag");
  1774. if (this.bgcolor) dragIconNode.setStyle("background-color", this.bgcolor);
  1775. }
  1776. var p = this.iconNode.getPosition(this.dragNode.getOffsetParent());
  1777. this.dragNode.show().setStyles({
  1778. "left": ""+p.x+"px", "top": ""+p.y+"px"
  1779. });
  1780. },
  1781. getMoveDroppables: function(){
  1782. return [this.layout.lnkContentNode, this.menu.appContentNode];
  1783. },
  1784. doDragMove: function(e){
  1785. this.getDragNode();
  1786. var droppables = this.getMoveDroppables();
  1787. if (this.menu.appContentNode.hasClass("layout_start_groupItem_menu_content")){
  1788. this.onGroup = true;
  1789. }
  1790. //if (this.menu.maskGroupNode) droppables.push(this.menu.maskGroupNode);
  1791. var drag = new Drag.Move(this.dragNode, {
  1792. "stopPropagation": true,
  1793. "compensateScroll": true,
  1794. "droppables": droppables,
  1795. "onStart": function (el) {
  1796. this._drag_start(el);
  1797. }.bind(this),
  1798. "onDrag": function (dragging, e) {
  1799. this._drag_drag(dragging, e);
  1800. }.bind(this),
  1801. "onEnter": function (dragging, inObj) {
  1802. this._drag_enter(dragging, inObj);
  1803. }.bind(this),
  1804. "onLeave": function (dragging, obj) {
  1805. this._drag_leave(dragging, obj);
  1806. }.bind(this),
  1807. "onDrop": function (dragging, inObj) {
  1808. this._drag_drop(dragging, inObj);
  1809. }.bind(this),
  1810. "onCancel": function (dragging) {
  1811. this._drag_cancel(dragging);
  1812. }.bind(this),
  1813. "onComplete": function (dragging, e) {
  1814. this._drag_complete(dragging, e);
  1815. }.bind(this),
  1816. });
  1817. drag.start(e);
  1818. this.dragStatus == "remove";
  1819. },
  1820. _drag_start: function(el){
  1821. this.isDrag = true;
  1822. this.dragTargetLnk = null;
  1823. this.dragPosition = "before";
  1824. this.node.setStyle("opacity", 0.2);
  1825. this.positionFlagNode = new Element("div", {"styles": {"display": "none"}}).inject(this.node, "after");
  1826. },
  1827. _drag_drag: function(dragging, e){
  1828. if (this.dragStatus == "order"){
  1829. if (this.layout.lnks && this.layout.lnks.length){
  1830. var current = e.page.y;
  1831. for (var i=0; i<this.layout.lnks.length; i++){
  1832. var lnk = this.layout.lnks[i];
  1833. var y = lnk.node.getSize().y;
  1834. var top = lnk.node.getPosition(this.layout.node).y;
  1835. var center = top+y/2;
  1836. var bottom = top+y;
  1837. if (top<=current && center>=current){
  1838. this.dragTargetLnk = lnk;
  1839. this.dragPosition = "before";
  1840. break;
  1841. }else if (center<=current && bottom>=current){
  1842. this.dragTargetLnk = lnk;
  1843. this.dragPosition = "after";
  1844. break;
  1845. }
  1846. }
  1847. if (!this.layout.positionNode) this.layout.positionNode = new Element("div.layout_menu_lnk_item_position")
  1848. .setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex())
  1849. .inject(this.layout.node);
  1850. this.layout.positionNode.show();
  1851. if (!this.dragTargetLnk){
  1852. this.dragTargetLnk = this.layout.lnks[this.layout.lnks.length-1];
  1853. this.dragPosition = "after";
  1854. }
  1855. this.layout.positionNode.position({
  1856. relativeTo: this.dragTargetLnk.node,
  1857. position: (this.dragPosition=="before") ? 'topcenter' : 'bottomcenter',
  1858. edge: 'center'
  1859. });
  1860. }
  1861. }
  1862. if (this.dragStatus == "group"){
  1863. if (!this.onGroup) this.checkDargOver(dragging);
  1864. if (!this.overItem){
  1865. this.checkDargPosition(dragging);
  1866. }
  1867. }
  1868. },
  1869. checkDargOver: function(dragging){
  1870. var p = dragging.getPosition();
  1871. var s = dragging.getSize();
  1872. var x = p.x+s.x/2-1;
  1873. var y = p.y+s.y/2-1;
  1874. var ex = x+2;
  1875. var ey = y+2;
  1876. var overItem = null;
  1877. var thisItem = this;
  1878. this.menu.items.each(function(item){
  1879. if (!item.isDrag){
  1880. if (item.iconAreaNode.isInPointInRect(x,y,ex,ey)){
  1881. if (thisItem.data.type!=="group"){
  1882. item.dragOver();
  1883. overItem = item;
  1884. }
  1885. }else{
  1886. item.dragOut();
  1887. }
  1888. }
  1889. });
  1890. this.overItem = overItem;
  1891. },
  1892. checkDargPosition: function(dragging){
  1893. var p = dragging.getPosition();
  1894. var s = dragging.getSize();
  1895. 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 };
  1896. var leftP = { "x": p.x, "y": p.y+s.y/2-1, "ex": p.x+2, "ey": p.y+s.y/2+1 };
  1897. var moveFlag = false;
  1898. for (var i = 0; i<this.menu.items.length; i++){
  1899. var item = this.menu.items[i];
  1900. if (!item.isDrag){
  1901. if (item.iconAreaNode.isInPointInRect(rightP.x, rightP.y, rightP.ex, rightP.ey)){
  1902. moveFlag = true;
  1903. this.node.inject(item.node, "before");
  1904. break;
  1905. }else if (item.iconAreaNode.isInPointInRect(leftP.x, leftP.y, leftP.ex, leftP.ey)){
  1906. moveFlag = true;
  1907. this.node.inject(item.node, "after");
  1908. break;
  1909. }
  1910. }
  1911. }
  1912. //if (!moveFlag) this.node.inject(this.menu.appContentNode);
  1913. },
  1914. _drag_enter: function(el, inObj){
  1915. if (inObj.hasClass("layout_start_content_appContent") || inObj.hasClass("layout_start_groupItem_menu_content")){
  1916. this.dragStatus = "group";
  1917. this.node.setStyle("opacity", 0.2);
  1918. }else{
  1919. if (this.positionFlagNode) this.node.inject(this.positionFlagNode, "before");
  1920. this.dragStatus = "order";
  1921. this.node.setStyle("opacity", 1);
  1922. }
  1923. },
  1924. _drag_leave: function(el, inObj){
  1925. //console.log("_drag_leave");
  1926. if (inObj.hasClass("layout_start_content_appContent")){
  1927. //this.node.inject(this.menu.appContentNode);
  1928. }else if (inObj.hasClass("layout_start_groupItem_menu_content")){
  1929. this.dragStatus = "ungroup";
  1930. this.node.setStyle("opacity", 0);
  1931. }else{
  1932. this.dragStatus = "remove";
  1933. if (this.layout.positionNode) this.layout.positionNode.hide();
  1934. }
  1935. },
  1936. _drag_drop: function(dragging, inObj){
  1937. if (this.dragStatus==="ungroup"){
  1938. this.removeFormGroup();
  1939. }else{
  1940. if (this.dragStatus == "order" && this.dragTargetLnk && this.dragTargetLnk!=this){
  1941. this.addLnk(this.dragTargetLnk, this.dragPosition);
  1942. }else if (this.dragStatus == "group" && this.overItem && this.overItem!=this){
  1943. this.overItem.dragOut();
  1944. this.addGroup();
  1945. }
  1946. this.node.setStyle("opacity", 1);
  1947. }
  1948. this.menu.resetMenuData();
  1949. },
  1950. _drag_cancel: function(dragging){
  1951. //console.log("_drag_cancel");
  1952. dragging.hide();
  1953. if (this.layout.positionNode) this.layout.positionNode.hide();
  1954. if (this.dragRemoveNode) this.dragRemoveNode.hide();
  1955. this.node.setStyle("opacity", 1);
  1956. this.isDrag = false;
  1957. this.menu.resetMenuData();
  1958. },
  1959. _drag_complete: function(dragging) {
  1960. this._drag_cancel(dragging);
  1961. if (this.positionFlagNode) this.positionFlagNode.destroy();
  1962. this.positionFlagNode = null;
  1963. },
  1964. getItemType: function( data ){
  1965. if( data.type === "group" ){
  1966. return "group";
  1967. }else if( data.type==='system' || data.type==='custom' ){
  1968. return "component";
  1969. }else if( data.hasOwnProperty('portalCategory') ){
  1970. return "portal";
  1971. }else if( data.hasOwnProperty('documentType') ){
  1972. return "cms";
  1973. }else if( data.hasOwnProperty('queryCategory') ){
  1974. return "query"
  1975. }else if( data.hasOwnProperty('applicationCategory') ){
  1976. return "process";
  1977. }else{
  1978. return data.type || "";
  1979. }
  1980. },
  1981. removeFormGroup: function(){
  1982. // this.menu.itemDataList.erase(this.data);
  1983. // this.menu.items.erase(this);
  1984. this.menu.data.itemDataList.erase(this.data);
  1985. switch (this.getItemType(this.data)){
  1986. case "portal":
  1987. this.layout.startMenu.createPortalMenuItem(this.data);
  1988. break;
  1989. case "process":
  1990. this.layout.startMenu.createProcessMenuItem(this.data);
  1991. break;
  1992. case "cms":
  1993. this.layout.startMenu.createInforMenuItem(this.data);
  1994. break;
  1995. case "query":
  1996. this.layout.startMenu.createQueryMenuItem(this.data);
  1997. break;
  1998. default:
  1999. this.layout.startMenu.createApplicationMenuItem(this.data);
  2000. }
  2001. this.destroy();
  2002. if (!this.menu.data.itemDataList.length){
  2003. this.menu.hide(function(){
  2004. this.menu.destroy();
  2005. }.bind(this));
  2006. }else{
  2007. this.menu.resetSubItemIcon();
  2008. }
  2009. },
  2010. addGroup: function(){
  2011. if (this.overItem.data.type==="group"){
  2012. this.overItem.addItem(this.data);
  2013. }else{
  2014. var v = {
  2015. name: "Group",
  2016. title: "Group",
  2017. type: "group",
  2018. visible: true
  2019. }
  2020. var group = new o2.xDesktop.Default.StartMenu.GroupItem(this.menu, this.container, v, this.overItem.node);
  2021. group.addItem(this.overItem.data);
  2022. group.addItem(this.data);
  2023. this.menu.items.push(group);
  2024. this.overItem.node.destroy();
  2025. group.open(null, function(){
  2026. group.editTitle();
  2027. });
  2028. }
  2029. this.node.destroy();
  2030. this.menu.resetMenuData();
  2031. },
  2032. destroy: function(){
  2033. this.menu.items.erase(this);
  2034. this.node.destroy();
  2035. }
  2036. });
  2037. o2.xDesktop.Default.StartMenu.GroupItem = new Class({
  2038. Extends: o2.xDesktop.Default.StartMenu.Item,
  2039. loadIcon: function(){
  2040. this.iconNode.addClass("layout_start_item_icon_group");
  2041. this.iconNode.addClass("grayColor_bg");
  2042. this.sunIconNodes = [];
  2043. var node = new Element("div.layout_start_item_icon_group_sub").inject(this.iconNode);
  2044. this.sunIconNodes.push(node);
  2045. node = new Element("div.layout_start_item_icon_group_sub").inject(this.iconNode);
  2046. this.sunIconNodes.push(node);
  2047. node = new Element("div.layout_start_item_icon_group_sub").inject(this.iconNode);
  2048. this.sunIconNodes.push(node);
  2049. node = new Element("div.layout_start_item_icon_group_sub").inject(this.iconNode);
  2050. this.sunIconNodes.push(node);
  2051. },
  2052. init: function(){
  2053. this.itemTempletedHtml = this.menu.itemTempletedHtml;
  2054. var user = this.menu.layout.session.user;
  2055. var currentNames = [user.name, user.distinguishedName, user.id, user.unique];
  2056. if (user.roleList) currentNames = currentNames.concat(user.roleList);
  2057. if (user.groupList) currentNames = currentNames.concat(user.groupList);
  2058. // console.log('this.data.itemDataList', this.data.itemDataList);
  2059. // console.log('this.menu.portalJson', this.menu.portalJson);
  2060. // console.log('this.menu.processJson', this.menu.processJson);
  2061. // console.log('this.menu.inforJson', this.menu.inforJson);
  2062. // console.log('this.menu.queryJson', this.menu.queryJson);
  2063. // console.log('this.menu.componentJson', this.menu.componentJson);
  2064. // console.log('this.menu.layoutJson', this.menu.layoutJson);
  2065. var itemDataList = (this.data.itemDataList || []).filter(function(data){
  2066. var json;
  2067. switch (data.type){
  2068. case "portal":
  2069. return this.checkPermission(data, this.menu.portalJson);
  2070. case "process":
  2071. return this.checkPermission(data, this.menu.processJson);
  2072. case "cms":
  2073. return this.checkPermission(data, this.menu.inforJson);
  2074. case "query":
  2075. return this.checkPermission(data, this.menu.queryJson);
  2076. default:
  2077. var component = this.getComponent(data.path, this.menu.componentJson);
  2078. var layout = this.getComponent(data.path, this.menu.layoutJson);
  2079. if(!component && !layout)return false;
  2080. if (component){
  2081. return this.menu.checkMenuItem(component, currentNames);
  2082. }
  2083. if (layout){
  2084. return this.menu.checkMenuItem(layout, currentNames);
  2085. }
  2086. return false;
  2087. }
  2088. }.bind(this));
  2089. if (itemDataList && itemDataList.length){
  2090. for (var i=0; i<Math.min(itemDataList.length, 4); i++){
  2091. var icon = this.setSubItemIcon(itemDataList[i], this.sunIconNodes[i]);
  2092. }
  2093. }
  2094. if( !itemDataList.length ){
  2095. this.node.hide();
  2096. }else{
  2097. this.node.show();
  2098. }
  2099. this.availableItemDataList = itemDataList;
  2100. },
  2101. getComponent: function (path, array){
  2102. if( !array )array = [];
  2103. for( var i=0; i<array.length; i++ ){
  2104. if( path === array[i].path )return array[i];
  2105. }
  2106. return null;
  2107. },
  2108. checkPermission: function (itemData, array){
  2109. if( !array )array = [];
  2110. for( var i=0; i<array.length; i++ ){
  2111. if( itemData.id === array[i].id )return true;
  2112. }
  2113. return false;
  2114. },
  2115. resetSubItemIcon: function(){
  2116. this.sunIconNodes.each(function(e){
  2117. e.setStyle("background-image", "");
  2118. e.setStyle("background-color", "");
  2119. });
  2120. if (this.data.itemDataList && this.data.itemDataList.length){
  2121. for (var i=0; i<Math.min(this.data.itemDataList.length, 4); i++){
  2122. var icon = this.setSubItemIcon(this.data.itemDataList[i], this.sunIconNodes[i]);
  2123. }
  2124. }
  2125. },
  2126. open: function(e, callback){
  2127. if (!this.menuNode) this.createMenuNode();
  2128. this.maskNode = new Element("div.layout_start_groupItem_menuMask").inject(this.menuNode, "before");
  2129. this.maskNode.addEvent("click", function(e){
  2130. this.hide();
  2131. }.bind(this));
  2132. this.maskGroupNode = this.maskNode;
  2133. this.menuNode.show();
  2134. var styles = this.getMenuNodeOpenDimensions();
  2135. this.menuNode.morph.set("transition", Fx.Transitions.Quart.easeOut);
  2136. this.menuNode.morph.start(styles).chain(function(){
  2137. this.menuTitleNode.show();
  2138. this.menuScrollNode.show();
  2139. var s = this.menuNode.getSize();
  2140. var ts = this.menuTitleNode.getSize();
  2141. var h = s.y - ts.y;
  2142. this.menuContentNode.setStyle("height", ""+h+"px");
  2143. this.loadItems();
  2144. if (callback) callback();
  2145. }.bind(this));
  2146. this.menu.appAreaNode.setStyles({ "filter": "blur(5px)" });
  2147. },
  2148. hide: function(callback){
  2149. this.menuTitleNode.hide();
  2150. this.menuScrollNode.hide();
  2151. var styles = this.getMenuNodeCloseDimensions();
  2152. this.menuNode.morph.set("transition", Fx.Transitions.Quart.easeIn);
  2153. this.menuNode.morph.start(styles).chain(function(){
  2154. if (this.maskNode) this.maskNode.destroy();
  2155. if (this.menuNode) this.menuNode.hide();
  2156. if (callback) callback();
  2157. }.bind(this));
  2158. this.menu.appAreaNode.setStyles({ "filter": "" });
  2159. },
  2160. loadItems: function(){
  2161. if (!this.items) this.items = [];
  2162. //this.data.itemDataList
  2163. (this.availableItemDataList || this.data.itemDataList).each(function(data){
  2164. var item = this.items.find(function(i){
  2165. return i.data.id == data.id;
  2166. });
  2167. if (!item){
  2168. switch (this.getItemType(data)){
  2169. case "portal":
  2170. this.items.push(new o2.xDesktop.Default.StartMenu.PortalItem(this, this.menuContentNode, data));
  2171. break;
  2172. case "process":
  2173. this.items.push(new o2.xDesktop.Default.StartMenu.ProcessItem(this, this.menuContentNode, data));
  2174. break;
  2175. case "cms":
  2176. this.items.push(new o2.xDesktop.Default.StartMenu.InforItem(this, this.menuContentNode, data));
  2177. break;
  2178. case "query":
  2179. this.items.push(new o2.xDesktop.Default.StartMenu.QueryItem(this, this.menuContentNode, data));
  2180. break;
  2181. default:
  2182. this.items.push(new o2.xDesktop.Default.StartMenu.Item(this, this.menuContentNode, data));
  2183. }
  2184. }
  2185. }.bind(this));
  2186. },
  2187. getMenuNodeOpenDimensions: function(){
  2188. var size = this.menu.appAreaNode.getSize();
  2189. var w = size.x*0.94;
  2190. var h = size.y*0.7;
  2191. var x = (size.x*(1-0.94))/2;
  2192. var y = (size.y*(1-0.7))/2;
  2193. return {"width":w, "height": h, "left": x, "top": y}
  2194. },
  2195. getMenuNodeCloseDimensions: function(){
  2196. var size = this.iconNode.getSize();
  2197. var position = this.iconNode.getPosition(this.menu.node);
  2198. return {"width":size.x, "height": size.y, "left": position.x, "top": position.y}
  2199. },
  2200. createMenuNode: function(){
  2201. this.menuNode = new Element("div.layout_start_groupItem_menu").inject(this.menu.groupMenuArea);
  2202. this.menuNode.addClass("grayColor_bg");
  2203. this.menuTitleNode = new Element("div.layout_start_groupItem_menu_title").inject(this.menuNode);
  2204. this.menuTitleNode.set("text", this.data.name);
  2205. this.menuScrollNode = new Element("div.layout_start_groupItem_menu_scroll").inject(this.menuNode);
  2206. this.menuContentNode = new Element("div.layout_start_groupItem_menu_content").inject(this.menuScrollNode);
  2207. this.appContentNode = this.menuContentNode;
  2208. this.menuNode.position({
  2209. "relativeTo": this.iconNode,
  2210. "position": "upperLeft",
  2211. "edge": "upperLeft"
  2212. });
  2213. this.menuNode.morph = new Fx.Morph(this.menuNode, {
  2214. "duration": 200,
  2215. "transition": Fx.Transitions.Quart.easeOut
  2216. });
  2217. this.menuTitleNode.addEvent("click", function(){
  2218. var input = this.menuTitleNode.getElement("input");
  2219. if (!input) this.editTitle();
  2220. }.bind(this));
  2221. o2.require("o2.widget.ScrollBar", function(){
  2222. this.appScrollBar = new o2.widget.ScrollBar(this.menuContentNode, {
  2223. "style":"xDesktop_Message", "where": "before", "indent": false, "distance": 100, "friction": 6, "axis": {"x": false, "y": true}
  2224. });
  2225. }.bind(this));
  2226. },
  2227. destroy: function(){
  2228. this.menu.items.erase(this);
  2229. this.node.destroy();
  2230. this.menuNode.destroy();
  2231. },
  2232. editTitle: function(){
  2233. this.menuTitleNode.empty();
  2234. this.editotTitleNode = new Element("input.layout_start_groupItem_menu_title_edit", {"type": "text"}).inject(this.menuTitleNode);
  2235. this.editotTitleNode.set("value", this.data.name);
  2236. this.editotTitleNode.focus();
  2237. this.editotTitleNode.addEvent("blur", function(){
  2238. var name = this.editotTitleNode.get("value");
  2239. if (name) this.data.name = name;
  2240. this.data.title = this.data.name;
  2241. this.menuTitleNode.empty();
  2242. this.menuTitleNode.set("text", this.data.name);
  2243. this.loadText();
  2244. }.bind(this));
  2245. },
  2246. addItem: function(data){
  2247. if (!this.data.itemDataList) this.data.itemDataList = [];
  2248. if (this.data.itemDataList.length<4){
  2249. this.setSubItemIcon(data, this.sunIconNodes[this.data.itemDataList.length]);
  2250. }
  2251. this.data.itemDataList.push(data);
  2252. if(this.availableItemDataList)this.availableItemDataList.push(data);
  2253. this.node.show();
  2254. },
  2255. setSubItemIcon: function(data, node){
  2256. switch (this.getItemType(data)){
  2257. case "process":
  2258. this.setAppSubItemIcon(node, data.icon, "processDefault", "../x_component_process_ApplicationExplorer/$Main/default/icon/application.png");
  2259. break;
  2260. case "portal":
  2261. this.setAppSubItemIcon(node, data.icon, "portalDefault", "../x_component_portal_PortalExplorer/$Main/default/icon/application.png");
  2262. break;
  2263. case "cms":
  2264. this.setAppSubItemIcon(node, data.icon, "cmsDefault", "../x_component_cms_Index/$Main/default/icon/column.png");
  2265. break;
  2266. case "query":
  2267. this.setAppSubItemIcon(node, data.icon, "queryDefault", "../x_component_query_Query/$Main/appicon.png");
  2268. break;
  2269. default:
  2270. this.setDefaultSubItemIcon(data, node);
  2271. }
  2272. },
  2273. setAppSubItemIcon: function(node, iconData, defaultIcon, defaultUrl){
  2274. var icon = "";
  2275. var bgcolor = "";
  2276. if (iconData){
  2277. icon = "data:image/png;base64,"+iconData+"";
  2278. bgcolor = "";
  2279. node.addClass("layout_start_item_icon_group_subIcon");
  2280. }else{
  2281. var p = defaultIcon;
  2282. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  2283. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  2284. bgcolor = this.layout.iconsJson[p].color;
  2285. }else{
  2286. icon = defaultUrl;
  2287. bgcolor = "";
  2288. }
  2289. }
  2290. if (icon && bgcolor) node.setStyle("background-color", bgcolor);
  2291. node.setStyle("background-image", "url("+icon+")");
  2292. },
  2293. setDefaultSubItemIcon: function(data, node){
  2294. var icon;
  2295. var bgcolor = "";
  2296. if( data.path ){
  2297. if (data.path.substring(0, 4)==="@url"){
  2298. if (data.iconPath){
  2299. icon = data.iconPath;
  2300. }else{
  2301. if (this.layout.iconsJson["Url"] && this.layout.iconsJson["Url"].icon){
  2302. icon = this.layout.path+"appicons/"+this.layout.iconsJson["Url"].icon;
  2303. bgcolor = this.layout.iconsJson["Url"].color;
  2304. }else{
  2305. icon = "../x_component_Setting/$Main/default/icon/site.png";
  2306. bgcolor = "";
  2307. }
  2308. }
  2309. }else{
  2310. if (this.layout.iconsJson[data.path] && this.layout.iconsJson[data.path].icon){
  2311. icon = this.layout.path+"appicons/"+this.layout.iconsJson[data.path].icon;
  2312. bgcolor = this.layout.iconsJson[data.path].color;
  2313. }else{
  2314. icon = "../x_component_"+data.path.replace(/\./g, "_")+"/$Main/"+data.iconPath;
  2315. bgcolor = "";
  2316. }
  2317. }
  2318. if (icon && bgcolor){
  2319. node.setStyle("background-color", bgcolor);
  2320. }
  2321. node.setStyle("background-image", "url("+icon+")");
  2322. }
  2323. },
  2324. resetMenuData: function(){
  2325. var nodes = this.menuContentNode.getChildren(".layout_start_item");
  2326. var data = [];
  2327. nodes.each(function(node){
  2328. var item = node.retrieve("item");
  2329. if (item){
  2330. data.push(item.data);
  2331. }
  2332. }.bind(this));
  2333. this.data.itemDataList = data;
  2334. }
  2335. });
  2336. o2.xDesktop.Default.StartMenu.PortalItem = new Class({
  2337. Extends: o2.xDesktop.Default.StartMenu.Item,
  2338. loadIcon: function(){
  2339. var icon = "";
  2340. var bgcolor = "";
  2341. if (this.data.icon){
  2342. icon = "data:image/png;base64,"+this.data.icon+"";
  2343. }else{
  2344. var p = "portalDefault";
  2345. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  2346. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  2347. bgcolor = this.layout.iconsJson[p].color;
  2348. }else{
  2349. icon = "../x_component_portal_PortalExplorer/$Main/default/icon/application.png";
  2350. bgcolor = "";
  2351. }
  2352. }
  2353. if (icon && bgcolor){
  2354. this.iconNode.addClass("layout_start_item_icon_flat");
  2355. this.iconNode.setStyle("background-color", bgcolor);
  2356. }
  2357. this.iconNode.setStyle("background-image", "url("+icon+")");
  2358. this.icon = icon;
  2359. },
  2360. loadText: function(){
  2361. this.textNode.set("text", this.data.name);
  2362. },
  2363. addLnk: function(dragTargetLnk, dragPosition){
  2364. var options = {"portalId": this.data.id, "appId": "portal.Portal"+this.data.id};
  2365. lnkdata = {
  2366. "name": "portal.Portal",
  2367. "title": this.data.name,
  2368. "iconData": (this.data.icon) || "",
  2369. "icon": null,
  2370. "appType": "portal",
  2371. "options": options
  2372. }
  2373. this.layout.addLnk(lnkdata, dragTargetLnk, dragPosition);
  2374. },
  2375. open: function(e){
  2376. var options = {"portalId": this.data.id, "appId": "portal.Portal"+this.data.id};
  2377. this.menu.hide(function(){
  2378. if (this.menu.menu){
  2379. this.menu.menu.hide(function(){
  2380. layout.openApplication(e, "portal.Portal", options);
  2381. }.bind(this));
  2382. }else{
  2383. layout.openApplication(e, "portal.Portal", options);
  2384. }
  2385. }.bind(this));
  2386. }
  2387. // makeLnk: function(){
  2388. // //@todo
  2389. // // this.node.makeLnk({
  2390. // // "par": {"icon": this.icon, "color": this.color, "title": this.data.title, "par": this.data.path},
  2391. // // });
  2392. // }
  2393. });
  2394. o2.xDesktop.Default.StartMenu.ProcessItem = new Class({
  2395. Extends: o2.xDesktop.Default.StartMenu.PortalItem,
  2396. loadIcon: function(){
  2397. var icon = "";
  2398. var bgcolor = "";
  2399. if (this.data.icon){
  2400. icon = "data:image/png;base64,"+this.data.icon+"";
  2401. bgcolor = "";
  2402. }else{
  2403. var p = "processDefault";
  2404. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  2405. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  2406. bgcolor = this.layout.iconsJson[p].color;
  2407. }else{
  2408. icon = "../x_component_process_ApplicationExplorer/$Main/default/icon/application.png";
  2409. bgcolor = "";
  2410. }
  2411. }
  2412. if (icon && bgcolor){
  2413. this.iconNode.addClass("layout_start_item_icon_flat");
  2414. this.iconNode.setStyle("background-color", bgcolor);
  2415. }
  2416. this.iconNode.setStyle("background-image", "url("+icon+")");
  2417. this.icon = icon;
  2418. },
  2419. addLnk: function(dragTargetLnk, dragPosition){
  2420. var options = {"id": this.data.id, "appId": "process.Application"+this.data.id};
  2421. lnkdata = {
  2422. "name": "process.Application",
  2423. "title": this.data.name,
  2424. "iconData": (this.data.icon) || "",
  2425. "icon": null,
  2426. "appType": "process",
  2427. "options": options
  2428. }
  2429. this.layout.addLnk(lnkdata, dragTargetLnk, dragPosition);
  2430. },
  2431. open: function(e){
  2432. var options = {"id": this.data.id, "appId": "process.Application"+this.data.id};
  2433. this.menu.hide(function(){
  2434. if (this.menu.menu){
  2435. this.menu.menu.hide(function(){
  2436. layout.openApplication(e, "process.Application", options);
  2437. }.bind(this));
  2438. }else{
  2439. layout.openApplication(e, "process.Application", options);
  2440. }
  2441. }.bind(this));
  2442. }
  2443. // makeLnk: function(){
  2444. // //@todo
  2445. // // this.node.makeLnk({
  2446. // // "par": {"icon": this.icon, "color": this.color, "title": this.data.title, "par": this.data.path},
  2447. // // });
  2448. // }
  2449. });
  2450. o2.xDesktop.Default.StartMenu.InforItem = new Class({
  2451. Extends: o2.xDesktop.Default.StartMenu.PortalItem,
  2452. loadIcon: function(){
  2453. var icon = "";
  2454. var bgcolor = "";
  2455. if (this.data.appIcon){
  2456. icon = "data:image/png;base64,"+this.data.appIcon+"";
  2457. bgcolor = "";
  2458. }else{
  2459. var p = "cmsDefault";
  2460. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  2461. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  2462. bgcolor = this.layout.iconsJson[p].color;
  2463. }else{
  2464. icon = "../x_component_cms_Index/$Main/default/icon/column.png";
  2465. bgcolor = "";
  2466. }
  2467. }
  2468. if (icon && bgcolor){
  2469. this.iconNode.addClass("layout_start_item_icon_flat");
  2470. this.iconNode.setStyle("background-color", bgcolor);
  2471. }
  2472. this.iconNode.setStyle("background-image", "url("+icon+")");
  2473. this.icon = icon;
  2474. },
  2475. loadText: function(){
  2476. this.textNode.set("text", this.data.appName);
  2477. },
  2478. addLnk: function(dragTargetLnk, dragPosition){
  2479. lnkdata = {
  2480. "name": "cms.Module",
  2481. "title": this.data.appName,
  2482. "iconData": (this.data.appIcon) || "",
  2483. "icon": null,
  2484. "appType": "cms",
  2485. "options": {"columnData": this.data, "appId": "cms.Module"+this.data.id}
  2486. }
  2487. this.layout.addLnk(lnkdata, dragTargetLnk, dragPosition);
  2488. },
  2489. open: function(e){
  2490. this.menu.hide(function(){
  2491. if (this.menu.menu){
  2492. this.menu.menu.hide(function(){
  2493. layout.openApplication(e, "cms.Module", {"columnData": this.data, "appId": "cms.Module"+this.data.id});
  2494. }.bind(this));
  2495. }else{
  2496. layout.openApplication(e, "cms.Module", {"columnData": this.data, "appId": "cms.Module"+this.data.id});
  2497. }
  2498. }.bind(this));
  2499. }
  2500. // makeLnk: function(){
  2501. // //@todo
  2502. // // this.node.makeLnk({
  2503. // // "par": {"icon": this.icon, "color": this.color, "title": this.data.title, "par": this.data.path},
  2504. // // });
  2505. // }
  2506. });
  2507. o2.xDesktop.Default.StartMenu.QueryItem = new Class({
  2508. Extends: o2.xDesktop.Default.StartMenu.PortalItem,
  2509. loadIcon: function(){
  2510. var icon = "";
  2511. var bgcolor = "";
  2512. if (this.data.icon){
  2513. icon = "data:image/png;base64,"+this.data.icon+"";
  2514. bgcolor = "";
  2515. }else{
  2516. var p = "queryDefault";
  2517. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  2518. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  2519. bgcolor = this.layout.iconsJson[p].color;
  2520. }else{
  2521. icon = "../x_component_query_Query/$Main/appicon.png";
  2522. bgcolor = "";
  2523. }
  2524. }
  2525. if (icon && bgcolor){
  2526. this.iconNode.addClass("layout_start_item_icon_flat");
  2527. this.iconNode.setStyle("background-color", bgcolor);
  2528. }
  2529. this.iconNode.setStyle("background-image", "url("+icon+")");
  2530. this.icon = icon;
  2531. },
  2532. addLnk: function(dragTargetLnk, dragPosition){
  2533. lnkdata = {
  2534. "name": "query.Query",
  2535. "title": this.data.name,
  2536. "iconData": (this.data.icon)||"",
  2537. "icon": null,
  2538. "appType": "query",
  2539. "options": {"id": this.data.id, "appId": "query.Query"+this.data.id}
  2540. }
  2541. this.layout.addLnk(lnkdata, dragTargetLnk, dragPosition);
  2542. },
  2543. open: function(e){
  2544. this.menu.hide(function(){
  2545. if (this.menu.menu){
  2546. this.menu.menu.hide(function(){
  2547. layout.openApplication(e, "query.Query", {"id": this.data.id, "appId": "query.Query"+this.data.id});
  2548. }.bind(this));
  2549. }else{
  2550. layout.openApplication(e, "query.Query", {"id": this.data.id, "appId": "query.Query"+this.data.id});
  2551. }
  2552. }.bind(this));
  2553. }
  2554. // makeLnk: function(){
  2555. // //@todo
  2556. // // this.node.makeLnk({
  2557. // // "par": {"icon": this.icon, "color": this.color, "title": this.data.title, "par": this.data.path},
  2558. // // });
  2559. // }
  2560. });
  2561. o2.xDesktop.Default.TaskItem = new Class({
  2562. initialize: function(desktop, app){
  2563. this.desktop = desktop;
  2564. this.container = this.desktop.taskContentNode;
  2565. this.app = app;
  2566. this.load();
  2567. },
  2568. load: function(){
  2569. this.node = new Element("div.layout_content_taskbar_item").inject(this.container);
  2570. this.iconNode = new Element("div");
  2571. this.closeNode = new Element("div.layout_content_taskbar_item_icon", {"title": o2.LP.widget.close}).inject(this.node);
  2572. this.closeNode.addClass("icon_close");
  2573. if (this.app.options.appId==this.desktop.options.index){
  2574. this.closeNode.hide();
  2575. this.noCloseNode = true;
  2576. }
  2577. this.refreshNode = new Element("div.layout_content_taskbar_item_refresh", {"title": o2.LP.widget.refresh}).inject(this.node);;
  2578. this.refreshNode.addClass("icon_refresh");
  2579. this.refreshNode.addClass("animation_taskItemLoading");
  2580. this.actionNode = new Element("div.layout_content_taskbar_item_action").inject(this.node);;
  2581. this.actionNode.addClass("icon_taskitem_down");
  2582. this.textNode = new Element("div.layout_content_taskbar_item_text").inject(this.node);;
  2583. this.setText(this.app.options.title);
  2584. //this.desktop.checkTaskBarSize();
  2585. this.setEvent();
  2586. this.unSelected();
  2587. },
  2588. setEvent: function(){
  2589. this.textNode.addEvents({
  2590. "click": function(){
  2591. if (this.desktop.currentApp!=this.app){
  2592. if (!this.app.window){
  2593. this.desktop.apps[this.app.options.appId] = null;
  2594. layout.openApplication(null, this.app.options.name, this.app.options, this.app.options.app, false, this, false);
  2595. }else{
  2596. this.app.setCurrent();
  2597. }
  2598. }else{
  2599. // this.app.refresh();
  2600. }
  2601. }.bind(this),
  2602. "dblclick": function(){
  2603. this.app.openInNewBrowser((this.app.options.appId==this.desktop.options.index));
  2604. }.bind(this)
  2605. });
  2606. this.closeNode.addEvents({
  2607. "mouseover": function(){
  2608. // if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode_over);
  2609. }.bind(this),
  2610. "mouseout": function(){
  2611. // if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode);
  2612. }.bind(this),
  2613. "click": function(){
  2614. if (!this.app.window){
  2615. this.desktop.apps[this.app.options.appId] = null;
  2616. delete this.desktop.apps[this.app.options.appId];
  2617. this.destroy();
  2618. }else{
  2619. this.app.close();
  2620. }
  2621. }.bind(this)
  2622. });
  2623. this.refreshNode.addEvents({
  2624. "mouseover": function(){
  2625. // if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode_over);
  2626. }.bind(this),
  2627. "mouseout": function(){
  2628. // if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode);
  2629. }.bind(this),
  2630. "click": function(){
  2631. this.app.refresh();
  2632. }.bind(this)
  2633. });
  2634. this.loadTaskItemMenu();
  2635. if (this.desktop && this.desktop.checkTaskBarSize) this.desktop.checkTaskBarSize();
  2636. },
  2637. loadTaskItemMenu: function(){
  2638. if (!this.taskitemMenu){
  2639. this.taskitemMenu = new o2.xDesktop.Menu(this.actionNode, {
  2640. "event": "click", "style": "flatUser", "offsetX": -10, "offsetY":6, "container": this.node
  2641. });
  2642. this.taskitemMenu.load();
  2643. this.loadTaskItemMenuItems();
  2644. }
  2645. },
  2646. loadTaskItemMenuItems: function(){
  2647. var img = this.desktop.path+this.desktop.options.style+"/icons/menu_refresh.png";
  2648. this.taskitemMenu.addMenuItem(o2.LP.desktop.refresh, "click", function(e){this.app.refresh(e);}.bind(this), img);
  2649. this.taskitemMenu.addMenuLine();
  2650. //img = this.path+this.options.style+"/icons/logout.png";
  2651. if (this.app.options.appId!==this.desktop.options.index){
  2652. img = this.desktop.path+this.desktop.options.style+"/icons/menu_openInWindow.png";
  2653. this.taskitemMenu.addMenuItem(o2.LP.desktop.openInBrowser, "click", function(e){this.app.openInNewBrowser();}.bind(this), img);
  2654. img = this.desktop.path+this.desktop.options.style+"/icons/menu_close.png";
  2655. this.taskitemMenu.addMenuItem(o2.LP.desktop.close, "click", function(){
  2656. if (!this.app.window){
  2657. this.desktop.apps[this.app.options.appId] = null;
  2658. delete this.desktop.apps[this.app.options.appId];
  2659. this.destroy();
  2660. }else{
  2661. this.app.close();
  2662. }
  2663. }.bind(this), img);
  2664. }
  2665. img = this.desktop.path+this.desktop.options.style+"/icons/menu_closeall.png";
  2666. this.taskitemMenu.addMenuItem(o2.LP.desktop.closeAll, "click", function(){
  2667. var keys = Array.clone(Object.keys(this.desktop.apps));
  2668. keys.each(function(key){
  2669. if (!layout.desktop.apps[key].isIndex && !layout.desktop.apps[key].options.isIndex) layout.desktop.apps[key].close();
  2670. }.bind(this));
  2671. keys = null;
  2672. }.bind(this), img);
  2673. img = this.desktop.path+this.desktop.options.style+"/icons/menu_closeother.png";
  2674. this.taskitemMenu.addMenuItem(o2.LP.desktop.closeOther, "click", function(){
  2675. var keys = Array.clone(Object.keys(this.desktop.apps));
  2676. keys.each(function(key){
  2677. if (!this.desktop.apps[key].isIndex &&
  2678. !this.desktop.apps[key].options.isIndex &&
  2679. this.desktop.apps[key].options.appId!=this.app.options.appId) this.desktop.apps[key].close();
  2680. }.bind(this));
  2681. keys = null;
  2682. }.bind(this), img);
  2683. },
  2684. setText: function(str){
  2685. this.textNode.set("text", str || this.app.options.title);
  2686. },
  2687. unSelected: function(){
  2688. this.node.removeClass("mainColor_bg");
  2689. if (!this.noCloseNode) {
  2690. this.closeNode.addClass("icon_close");
  2691. this.closeNode.removeClass("icon_close_focus");
  2692. //this.closeNode.hide();
  2693. }
  2694. if (this.refreshNode) this.refreshNode.hide();
  2695. if (this.actionNode) this.actionNode.hide();
  2696. },
  2697. selected: function(){
  2698. this.node.addClass("mainColor_bg");
  2699. if (!this.noCloseNode){
  2700. this.closeNode.removeClass("icon_close");
  2701. this.closeNode.addClass("icon_close_focus");
  2702. //this.closeNode.show();
  2703. }
  2704. this.desktop.checkTaskBarScrollTo(this.app);
  2705. //this.refreshNode.show();
  2706. if (this.actionNode) this.actionNode.show();
  2707. },
  2708. destroy: function(){
  2709. this.iconNode.destroy();
  2710. this.node.destroy();
  2711. if (this.desktop && this.desktop.checkTaskBarSize) this.desktop.checkTaskBarSize();
  2712. if (this.app.options && this.app.options.appId) delete this.desktop.apps[this.app.options.appId];
  2713. o2.release(this);
  2714. },
  2715. setTaskitemSize: function(){
  2716. this.desktop.checkTaskBarSize();
  2717. this.desktop.checkTaskBarScrollTo();
  2718. }
  2719. });
  2720. o2.xDesktop.Default.Lnk = new Class({
  2721. initialize: function(layout, data, targetLnk, position){
  2722. this.layout = layout;
  2723. this.container = this.layout.lnkAreaNode;
  2724. this.data = data;
  2725. this.load(targetLnk, position);
  2726. },
  2727. load: function(targetLnk, position){
  2728. debugger;
  2729. this.node = new Element("div.layout_menu_lnk_item");
  2730. if (targetLnk){
  2731. if (!position) position = "before";
  2732. this.node.inject(targetLnk.node, position);
  2733. }else{
  2734. this.node.inject(this.container);
  2735. }
  2736. this.iconNode = new Element("div.layout_menu_lnk_item_icon").inject(this.node);
  2737. this.textNode = new Element("div.layout_menu_lnk_item_text", {"text": this.data.title}).inject(this.node);
  2738. this.actionNode = new Element("div.layout_menu_lnk_item_action", {"title": o2.LP.desktop.deleteLnk}).inject(this.node);
  2739. this.actionNode.addClass("icon_off_light");
  2740. this.getIcon(function (icon) {
  2741. this.iconNode.setStyle("background-image", "url("+icon+")");
  2742. this.setEvent();
  2743. }.bind(this));
  2744. },
  2745. setEvent: function(){
  2746. this.node.addEvents({
  2747. "click": function(){
  2748. if (this.data.name=="Homepage"){
  2749. var name = this.data.name;
  2750. var options = this.data.options;
  2751. if (layout.config.indexPage && layout.config.indexPage.enable && layout.config.indexPage.portal){
  2752. name = "portal.Portal";
  2753. var appId = "portal.Portal"+layout.config.indexPage.portal;
  2754. options = {"name": "portal.Portal", "portalId": layout.config.indexPage.portal, "pageId": layout.config.indexPage.page, "appId": appId};
  2755. }
  2756. layout.openApplication(null, name, options);
  2757. }else{
  2758. layout.openApplication(null, this.data.name, this.data.options);
  2759. }
  2760. }.bind(this),
  2761. "mouseover": function(){
  2762. if(!this.layout.isUseForceMainMenuData)this.actionNode.fade("in");
  2763. this.node.addClass("overColor_bg");
  2764. this.textNode.fade("in");
  2765. }.bind(this),
  2766. "mouseout": function(){
  2767. if(!this.layout.isUseForceMainMenuData)this.actionNode.fade("out");
  2768. this.node.removeClass("overColor_bg");
  2769. this.textNode.fade("out");
  2770. }.bind(this)
  2771. });
  2772. this.actionNode.addEvents({
  2773. "click": function(e){
  2774. this.destroy();
  2775. e.stopPropagation();
  2776. }.bind(this),
  2777. "mouseover": function(){
  2778. this.actionNode.addClass("layout_menu_lnk_item_action_shadow");
  2779. }.bind(this),
  2780. "mouseout": function(){
  2781. this.actionNode.removeClass("layout_menu_lnk_item_action_shadow");
  2782. }.bind(this)
  2783. });
  2784. if( !this.layout.isUseForceMainMenuData ){
  2785. var drag = new Drag(this.node, {
  2786. "stopPropagation": true,
  2787. "compensateScroll": true,
  2788. "onStart": function(el, e){
  2789. this.doDragMove(e);
  2790. drag.stop();
  2791. }.bind(this)
  2792. });
  2793. }
  2794. },
  2795. getDragNode: function(){
  2796. if (!this.dragNode){
  2797. this.dragNode = new Element("div.layout_menu_lnk_item_drag")
  2798. .setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex())
  2799. .inject(this.layout.node);
  2800. var dragIconNode = this.iconNode.clone(true).inject(this.dragNode)
  2801. .removeClass("layout_menu_lnk_item_icon")
  2802. .addClass("layout_menu_lnk_item_icon_drag");
  2803. var p = (this.data.appType) ? this.data.appType+"Default" : this.data.name;
  2804. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].color){
  2805. dragIconNode.setStyle("background-color", this.layout.iconsJson[p].color)
  2806. }
  2807. this.dragRemoveNode = new Element("div.layout_menu_lnk_item_icon_drag_del").inject(this.dragNode)
  2808. .addClass("icon_remove_badge")
  2809. .hide();
  2810. }
  2811. var ps = this.iconNode.getPosition(this.dragNode.getOffsetParent());
  2812. this.dragNode.show().setStyles({
  2813. "left": ""+ps.x+"px", "top": ""+ps.y+"px"
  2814. });
  2815. },
  2816. doDragMove: function(e){
  2817. this.getDragNode();
  2818. var drag = new Drag.Move(this.dragNode, {
  2819. "stopPropagation": true,
  2820. "compensateScroll": true,
  2821. "droppables": [this.container.getParent()],
  2822. "onStart": function(){ this._drag_start(); }.bind(this),
  2823. "onDrag": function(dragging,e){ this._drag_drag(dragging, e); }.bind(this),
  2824. "onEnter": function(dragging, inObj){ this._drag_enter(dragging, inObj); }.bind(this),
  2825. "onLeave": function(dragging, obj){ this._drag_leave(dragging, obj); }.bind(this),
  2826. "onDrop": function(dragging, inObj){ this._drag_drop(dragging, inObj); }.bind(this),
  2827. "onCancel": function(dragging){ this._drag_cancel(dragging); }.bind(this),
  2828. "onComplete": function(dragging, e){ this._drag_complete(dragging, e); }.bind(this),
  2829. });
  2830. drag.start(e);
  2831. this.dragStatus = "order";
  2832. },
  2833. _drag_start: function(){
  2834. this.node.addClass("overColor_bg");
  2835. this.node.addClass("opacity50");
  2836. this.dragTargetLnk = null;
  2837. this.dragPosition = "before";
  2838. },
  2839. _drag_drag: function(dragging, e){
  2840. if (this.dragStatus == "order"){
  2841. if (this.layout.lnks && this.layout.lnks.length){
  2842. var current = e.page.y;
  2843. for (var i=0; i<this.layout.lnks.length; i++){
  2844. var lnk = this.layout.lnks[i];
  2845. var y = lnk.node.getSize().y;
  2846. var top = lnk.node.getPosition(this.layout.node).y;
  2847. var center = top+y/2;
  2848. var bottom = top+y;
  2849. if (top<=current && center>=current){
  2850. this.dragTargetLnk = lnk;
  2851. this.dragPosition = "before";
  2852. break;
  2853. }else if (center<=current && bottom>=current){
  2854. this.dragTargetLnk = lnk;
  2855. this.dragPosition = "after";
  2856. break;
  2857. }
  2858. }
  2859. if (!this.layout.positionNode) this.layout.positionNode = new Element("div.layout_menu_lnk_item_position")
  2860. .setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex())
  2861. .inject(this.layout.node);
  2862. this.layout.positionNode.show();
  2863. if (!this.dragTargetLnk){
  2864. this.dragTargetLnk = this.layout.lnks[this.layout.lnks.length-1];
  2865. this.dragPosition = "after";
  2866. }
  2867. this.layout.positionNode.position({
  2868. relativeTo: this.dragTargetLnk.node,
  2869. position: (this.dragPosition=="before") ? 'topcenter' : 'bottomcenter',
  2870. edge: 'center'
  2871. });
  2872. }
  2873. }
  2874. },
  2875. _drag_enter: function(){
  2876. this.dragStatus = "order";
  2877. if (this.dragRemoveNode) this.dragRemoveNode.hide();
  2878. },
  2879. _drag_leave: function(){
  2880. this.dragStatus = "remove";
  2881. if (this.dragRemoveNode) this.dragRemoveNode.show();
  2882. if (this.layout.positionNode) this.layout.positionNode.hide();
  2883. },
  2884. _drag_drop: function(dragging, inObj){
  2885. if (this.dragStatus == "order" && this.dragTargetLnk && this.dragTargetLnk!=this){
  2886. this.node.inject(this.dragTargetLnk.node, this.dragPosition);
  2887. this.layout.lnks.erase(this);
  2888. var idx = this.layout.lnks.indexOf(this.dragTargetLnk);
  2889. if (this.dragPosition=="before"){
  2890. this.layout.lnks.splice(idx, 0, this);
  2891. }else{
  2892. this.layout.lnks.splice(idx+1, 0, this);
  2893. }
  2894. }
  2895. },
  2896. _drag_cancel: function(dragging){
  2897. dragging.hide();
  2898. if (this.node) {
  2899. this.node.removeClass("overColor_bg");
  2900. this.node.removeClass("opacity50");
  2901. }
  2902. if (this.layout.positionNode) this.layout.positionNode.hide();
  2903. if (this.dragRemoveNode) this.dragRemoveNode.hide();
  2904. },
  2905. _drag_complete: function(dragging){
  2906. if (this.dragStatus == "remove"){
  2907. this.destroy();
  2908. }else{
  2909. this._drag_cancel(dragging);
  2910. }
  2911. },
  2912. destroy: function(){
  2913. this.layout.lnks.erase(this);
  2914. if (this.dragNode) this.dragNode.destroy();
  2915. //if (this.positionNode) this.positionNode.destroy();
  2916. this.node.destroy();
  2917. o2.release(this);
  2918. },
  2919. getIcon: function( callback ){
  2920. if (this.data.icon) return this.data.icon;
  2921. var icon;
  2922. if (this.data.name.substring(0, 4)==="@url"){
  2923. if (this.data.iconData){
  2924. icon = "data:image/png;base64,"+this.data.iconData+"";
  2925. }else if (this.data.iconPath){
  2926. icon = this.data.iconPath;
  2927. }else {
  2928. o2.Actions.load("x_component_assemble_control").ComponentAction.get(this.data.appName || this.data.title, function(json){
  2929. if (json.data && json.data.iconData){
  2930. icon = "data:image/png;base64,"+json.data.iconData+"";
  2931. }else if (json.data && json.data.iconPath){
  2932. icon = json.data.iconPath;
  2933. }else if (this.layout.iconsJson["Url"] && this.layout.iconsJson["Url"].icon) {
  2934. icon = this.layout.path + "appicons/" + this.layout.iconsJson["Url"].icon;
  2935. } else {
  2936. icon = this.layout.path + "appicons/url.png";
  2937. }
  2938. if(callback)callback(icon)
  2939. }.bind(this), function(){
  2940. if (this.layout.iconsJson["Url"] && this.layout.iconsJson["Url"].icon) {
  2941. icon = this.layout.path + "appicons/" + this.layout.iconsJson["Url"].icon;
  2942. } else {
  2943. icon = this.layout.path + "appicons/url.png";
  2944. }
  2945. if(callback)callback(icon)
  2946. }.bind(this))
  2947. }
  2948. }else{
  2949. if (this.data.iconData){
  2950. icon = "data:image/png;base64,"+this.data.iconData+"";
  2951. }else if (this.data.iconPath){
  2952. icon = this.data.iconPath;
  2953. }else{
  2954. var p = (this.data.appType) ? this.data.appType+"Default" : this.data.name;
  2955. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  2956. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  2957. }else{
  2958. icon = "../x_component_"+this.data.name.replace(/\./g, "_")+"/$Main/appicon.png";
  2959. }
  2960. }
  2961. if(callback)callback(icon)
  2962. }
  2963. return icon;
  2964. }
  2965. });
  2966. o2.xDesktop.zIndexPool = {
  2967. zIndex: 102,
  2968. applyZindex: function(){
  2969. var i = this.zIndex;
  2970. this.zIndex = this.zIndex+2;
  2971. return i;
  2972. }
  2973. };