Default.js 148 KB

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