Default.js 121 KB

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