Default.js 115 KB

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