Default.js 121 KB

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