Default.js 92 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319
  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. initialize: function(node, options){
  13. this.setOptions(options);
  14. this.type = "layout";
  15. this.path = o2.session.path+"/xDesktop/$Default/";
  16. this.node = $(node);
  17. this.node.empty();
  18. this.initData();
  19. //this.load();
  20. },
  21. initData: function(){
  22. this.apps = {};
  23. this.appArr = [];
  24. this.appCurrentList = [];
  25. this.lnks = [];
  26. this.currentApp = null;
  27. this.session = {};
  28. this.serviceAddressList = layout.serviceAddressList;
  29. this.centerServer = layout.centerServer;
  30. this.session.user = layout.session.user;
  31. var uri = new URI(window.location.href);
  32. var df = uri.getData("default") || "";
  33. this.noDefault = df.toString().toLowerCase()==="false";
  34. var appNames = uri.getData("app");
  35. var optionsStr = uri.getData("option");
  36. var options = (optionsStr) ? JSON.decode(optionsStr) : null;
  37. if (appNames){
  38. this.status = layout.userLayout;
  39. this.status.apps = {};
  40. this.status.apps[appNames] = options || {};
  41. this.status.apps[appNames].name = appNames;
  42. this.status.apps[appNames].appId = appNames;
  43. this.status.apps[appNames].isIndex = true;
  44. this.status.currentApp = appNames;
  45. }else{
  46. this.status = layout.userLayout;
  47. }
  48. if (this.status && this.status.flatStyle) this.options.style = this.status.flatStyle;
  49. },
  50. load: function(cb){
  51. this.loadLayout(function(){
  52. this.setEvent();
  53. if (!this.noDefault) this.loadDefaultPage();
  54. window.setTimeout(function(){
  55. var iconsPath = this.path+"icons.json";
  56. o2.JSON.get(iconsPath, function(json) {
  57. this.iconsJson = json;
  58. this.loadDefaultLnk();
  59. this.loadStatus();
  60. if (cb) cb();
  61. }.bind(this));
  62. this.openWebSocket();
  63. this.checkTaskBarSize();
  64. this.addEvent("resize", this.checkTaskBarSize.bind(this));
  65. }.bind(this), 0);
  66. this.loadMessageMenu();
  67. this.fireEvent("load");
  68. MWF.require("MWF.xDesktop.shortcut");
  69. }.bind(this));
  70. },
  71. resizeHeight: function(){
  72. var y = this.menuNode.getSize().y;
  73. var y1 = this.startMenuNode.getParent().getSize().y;
  74. var o1 = this.startMenuNode.getParent().getStyles("border-top-width", "margin-top", "padding-top", "border-bottom-width", "margin-bottom", "padding-bottom");
  75. var y2 = this.settingNode.getParent().getSize().y;
  76. var o2 = this.settingNode.getParent().getStyles("border-top-width", "margin-top", "padding-top", "border-bottom-width", "margin-bottom", "padding-bottom");
  77. 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();
  78. 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();
  79. var height = y-y1-y2-oy1-oy2;
  80. this.lnkContentNode.setStyle("height", ""+height+"px");
  81. },
  82. checkTaskBarSize: function(){
  83. window.setTimeout(function(){
  84. var size = this.taskContentAreaNode.getSize();
  85. var contentSize = this.taskContentNode.getSize();
  86. if (size.y<contentSize.y){
  87. this.taskActionUp.show();
  88. this.taskActionDown.show();
  89. }else{
  90. this.taskActionUp.hide();
  91. this.taskActionDown.hide();
  92. }
  93. }.bind(this), 50);
  94. },
  95. checkTaskBarScrollTo: function(app){
  96. var currentApp = app || this.currentApp;
  97. if (currentApp && currentApp.taskitem){
  98. var size = this.taskContentAreaNode.getSize();
  99. var scroll = this.taskContentAreaNode.getScroll();
  100. var scrollSize = this.taskContentAreaNode.getScrollSize();
  101. var p = currentApp.taskitem.node.getPosition(this.taskContentNode);
  102. if (p.y!=scroll.y){
  103. var scrollTo = p.y;
  104. if (scrollTo<scrollSize.y-size.y){
  105. this.taskActionDown.addClass("icon_down");
  106. this.taskActionDown.removeClass("icon_down_gray");
  107. }else{
  108. this.taskActionDown.removeClass("icon_down");
  109. this.taskActionDown.addClass("icon_down_gray");
  110. }
  111. if (scrollTo<=0){
  112. scrollTo = 0;
  113. this.taskActionUp.removeClass("icon_up");
  114. this.taskActionUp.addClass("icon_up_gray");
  115. }else{
  116. this.taskActionUp.addClass("icon_up");
  117. this.taskActionUp.removeClass("icon_up_gray");
  118. }
  119. this.taskContentAreaNode.scrollTo(0, p.y);
  120. }
  121. }
  122. },
  123. toolbarUp: function(){
  124. var size = this.taskContentAreaNode.getSize();
  125. var scroll = this.taskContentAreaNode.getScroll();
  126. var scrollSize = this.taskContentAreaNode.getScrollSize();
  127. var scrollTo = scroll.y-size.y;
  128. if (scrollTo<scrollSize.y-size.y){
  129. this.taskActionDown.addClass("icon_down");
  130. this.taskActionDown.removeClass("icon_down_gray");
  131. }
  132. if (scrollTo<=0){
  133. scrollTo = 0;
  134. this.taskActionUp.removeClass("icon_up");
  135. this.taskActionUp.addClass("icon_up_gray");
  136. }
  137. this.taskContentAreaNode.scrollTo(0,scrollTo);
  138. },
  139. toolbarDown: function(){
  140. var size = this.taskContentAreaNode.getSize();
  141. var scroll = this.taskContentAreaNode.getScroll();
  142. var scrollSize = this.taskContentAreaNode.getScrollSize();
  143. var scrollTo = scroll.y+size.y;
  144. if (scrollTo+size.y>=scrollSize.y){
  145. scrollTo=scrollSize.y-size.y;
  146. this.taskActionDown.removeClass("icon_down");
  147. this.taskActionDown.addClass("icon_down_gray");
  148. }
  149. if (scrollTo>0){
  150. this.taskActionUp.addClass("icon_up");
  151. this.taskActionUp.removeClass("icon_up_gray");
  152. }
  153. this.taskContentAreaNode.scrollTo(0, scrollTo);
  154. },
  155. loadLayout: function(callback){
  156. this.session.user.iconUrl = o2.filterUrl(o2.Actions.get("x_organization_assemble_control").getPersonIcon(this.session.user.id));
  157. var css = this.path+this.options.style+ ((o2.session.isMobile || layout.mobile) ? "/style-pc.css" : "/style-pc.css");
  158. var skinCss = this.path+this.options.style+ "/style-skin.css";
  159. var html = this.path+this.options.style+((o2.session.isMobile || layout.mobile) ? "/layout-pc.html" : "/layout-pc.html");
  160. this.node.loadAll({ "css": [css], "html": [html]}, {"bind": {"user": this.session.user}, "module": this},function(){
  161. var oReq = new XMLHttpRequest();
  162. debugger;
  163. oReq.addEventListener("load", function(){
  164. var reader = new FileReader();
  165. reader.addEventListener("load", function () {
  166. this.userInforNode.getFirst().setStyle("background-image", "url("+reader.result+")");
  167. }.bind(this), false);
  168. reader.readAsDataURL(oReq.response);
  169. }.bind(this));
  170. oReq.open("GET", this.session.user.iconUrl);
  171. oReq.setRequestHeader("authorization", layout.session.user.token);
  172. oReq.responseType = "blob";
  173. oReq.withCredentials = true;
  174. oReq.send();
  175. // var res = new Request({
  176. // "url": this.session.user.iconUrl,
  177. // method: "get",
  178. // withCredentials: true,
  179. // onSuccess: function(response,a,s,d){
  180. //
  181. // }.bind(this)
  182. // });
  183. // res.setHeader("authorization", layout.session.user.token);
  184. // res.send();
  185. this.node.loadCss(skinCss);
  186. if (callback) callback();
  187. // this.node.load(html, {
  188. // "bind": {"user": this.session.user}
  189. // }, function(){});
  190. }.bind(this));
  191. },
  192. setEvent: function(){
  193. this.loadSkinMenu();
  194. this.loadUserMenu();
  195. window.onbeforeunload = function(e){
  196. if (!this.isLogout){
  197. if (!this.notRecordStatus) this.recordDesktopStatus();
  198. this.closeWebSocket();
  199. //if (this.socket && this.socket.webSocket) this.socket.close();
  200. this.fireEvent("unload");
  201. e = e || window.event;
  202. e.returnValue = o2.LP.desktop.notice.unload;
  203. return o2.LP.desktop.notice.unload;
  204. }
  205. }.bind(this);
  206. $(window).addEvent("resize", function(){
  207. this.fireEvent("resize");
  208. }.bind(this));
  209. this.resizeHeight();
  210. this.addEvent("resize", this.resizeHeight.bind(this));
  211. o2.require("o2.widget.ScrollBar", function(){
  212. this.appScrollBar = new o2.widget.ScrollBar(this.lnkContentNode, {
  213. "style":"hide", "where": "before", "indent": true, "distance": 100, "friction": 0, "axis": {"x": false, "y": true}
  214. });
  215. }.bind(this));
  216. },
  217. loadDefaultPage: function(){
  218. //默认载入首页
  219. var app;
  220. if (layout.config.indexPage && layout.config.indexPage.enable && layout.config.indexPage.portal){
  221. appId = "portal.Portal"+layout.config.indexPage.portal;
  222. this.options.index = appId;
  223. //var options = {"portalId": layout.config.indexPage.portal, "pageId": layout.config.indexPage.page, "appId": appId};
  224. app = {
  225. "options": {"name": "portal.Portal", "portalId": layout.config.indexPage.portal, "pageId": layout.config.indexPage.page, "appId": appId},
  226. "close": function(){
  227. this.taskitem.destroy();
  228. },
  229. "setCurrent": function(){
  230. if (this.taskitem.textNode) this.taskitem.textNode.click();
  231. }
  232. };
  233. //layout.openApplication(null, "portal.Portal", options);
  234. }else{
  235. app = {
  236. "options": {"name": "Homepage", "appId": "Homepage", "title": o2.LP.desktop.homepage},
  237. "close": function(){
  238. this.taskitem.destroy();
  239. },
  240. "setCurrent": function(){
  241. if (this.taskitem.textNode) this.taskitem.textNode.click();
  242. }
  243. };
  244. //layout.openApplication(null, "Homepage");
  245. }
  246. taskitem = layout.desktop.createTaskItem(app);
  247. app.taskitem = taskitem;
  248. app.options.isIndex = true;
  249. this.apps[app.options.appId] = app;
  250. taskitem.textNode.click();
  251. },
  252. loadDefaultLnk: function(){
  253. if (this.status && this.status.flatLnks && this.status.flatLnks.length){
  254. }else{
  255. o2.JSON.get(this.path+"defaultLnk.json", function(defaultLnk){
  256. defaultLnk.each(function(lnkJson){
  257. this.addLnk(lnkJson);
  258. }.bind(this));
  259. }.bind(this));
  260. }
  261. },
  262. loadStatus: function(){
  263. if (this.status){
  264. this.menuData = this.status.menuData;
  265. var keys = Object.keys(this.status.apps);
  266. if (this.status.apps && keys.length){
  267. if (this.status.currentApp == "Note"){
  268. var idx = keys.length-1;
  269. while (idx>-1 && keys[idx]=="Note") idx--;
  270. this.status.currentApp = (idx>-1) ? this.status.apps[keys[idx]].appId : "";
  271. }
  272. var currentTaskitem = null;
  273. Object.each(this.status.apps, function(appStatus, id){
  274. var app = {
  275. "options": appStatus,
  276. "close": function(){
  277. this.taskitem.destroy();
  278. },
  279. "setCurrent": function(){
  280. if (this.taskitem.textNode) this.taskitem.textNode.click();
  281. }
  282. };
  283. taskitem = layout.desktop.createTaskItem(app);
  284. app.taskitem = taskitem;
  285. this.apps[appStatus.appId] = app;
  286. if ((this.status.currentApp === appStatus.appId)) currentTaskitem=taskitem;
  287. }.bind(this));
  288. if (currentTaskitem) {
  289. currentTaskitem.textNode.click();
  290. }
  291. }
  292. if (this.status.widgets){/* nothing to do */}
  293. if (this.status.flatLnks && this.status.flatLnks.length){
  294. this.status.flatLnks.each(function(lnkJson){
  295. this.addLnk(lnkJson);
  296. }.bind(this));
  297. }
  298. }
  299. },
  300. addLnk: function(lnkData, targetLnk, position){
  301. var lnk = new o2.xDesktop.Default.Lnk(this, lnkData, targetLnk, position);
  302. if (targetLnk){
  303. var idx = this.lnks.indexOf(targetLnk);
  304. if (position=="before"){
  305. this.lnks.splice(idx, 0, lnk);
  306. }else{
  307. this.lnks.splice(idx+1, 0, lnk);
  308. }
  309. }else{
  310. this.lnks.push(lnk);
  311. }
  312. },
  313. openWebSocket: function(){
  314. MWF.require("MWF.xDesktop.WebSocket", function(){
  315. this.socket = new MWF.xDesktop.WebSocket();
  316. }.bind(this));
  317. },
  318. closeWebSocket: function(){
  319. if (this.socket) this.socket.close();
  320. },
  321. //******* begin page skin ****************************************************
  322. loadSkinMenu: function(){
  323. if (!this.styleMenu){
  324. this.styleMenu = new o2.xDesktop.Menu(this.skinActionNode, {
  325. "event": "click", "style": "flatStyle", "offsetX": -10, "offsetY": 26, "container": this.node,
  326. "onQueryShow": this.showSkinMenu.bind(this),
  327. "onQueryHide": function(){
  328. this.skinActionNode.removeClass("icon_skin_focus");
  329. this.skinActionNode.removeClass("mainColor_bg");
  330. }.bind(this)
  331. });
  332. this.styleMenu.load();
  333. this.loadSkinMenuItems();
  334. }
  335. },
  336. showSkinMenu: function(){
  337. this.styleMenu.items.each(function(item){
  338. if (this.options.style==item.styleName){
  339. item.setDisable(true);
  340. if (item.text) item.text.setStyles({ "background": "url("+this.path+this.options.style+"/icons/icon_gouxuan.png) right center no-repeat" });
  341. }else{
  342. item.setDisable(false);
  343. if (item.text) item.text.setStyles({ "background": "transparent" });
  344. }
  345. }.bind(this));
  346. this.skinActionNode.addClass("icon_skin_focus");
  347. this.skinActionNode.addClass("mainColor_bg");
  348. },
  349. loadSkinMenuItems: function(){
  350. o2.JSON.get(this.path+"styles.json", function(json){
  351. json.each(function(style){
  352. var color = style.color;
  353. var memuItem = this.styleMenu.addMenuItem(style.title, "click", function(){this.changeLayoutSkin(style.style);}.bind(this));
  354. memuItem.styleName = style.style;
  355. var imgDiv = memuItem.item.getFirst();
  356. var imgNode = new Element("div", {"styles": memuItem.menu.css.menuItemImg}).inject(imgDiv);
  357. imgNode.setStyle("background-color", color);
  358. }.bind(this));
  359. this.styleMenu.addMenuLine();
  360. var img = o2.defaultPath+"/xDesktop/$Layout/default/preview.jpg";
  361. var memuItem = this.styleMenu.addMenuItem(o2.LP.desktop_style, "click", function(e){this.changeToDesktopStyle(e);}.bind(this), img);
  362. memuItem.styleName = "desktop";
  363. }.bind(this));
  364. },
  365. changeLayoutSkin: function(style){
  366. var skinCss = this.path+this.options.style+ "/style-skin.css";
  367. o2.removeCss(skinCss);
  368. this.options.style = style;
  369. skinCss = this.path+this.options.style+"/style-skin.css";
  370. this.node.loadCss(skinCss);
  371. },
  372. changeToDesktopStyle: function(e){
  373. //MWF.xDesktop.confirm("infor", e, o2.LP.desktop.changeViewTitle, {"html": o2.LP.desktop.changeView}, 500, 100, function(){
  374. // this.close();
  375. var uri = new URI(window.location.href);
  376. uri.setData("view", "layout");
  377. uri.go();
  378. // }, function(){
  379. // this.close();
  380. // }, null, null, "o2"
  381. // );
  382. },
  383. //******* end page skin ****************************************************
  384. //******* begin user menu ****************************************************
  385. loadUserMenu: function(){
  386. if (!this.userMenu){
  387. this.userMenu = new o2.xDesktop.Menu(this.userInforNode, {
  388. "event": "click", "style": "flatUser", "offsetX": 30, "offsetY":6, "container": this.node
  389. // "onQueryShow": this.showSkinMenu.bind(this),
  390. // "onQueryHide": function(){
  391. // this.skinActionNode.removeClass("icon_skin_focus");
  392. // this.skinActionNode.removeClass("mainColor_bg");
  393. // }.bind(this),
  394. });
  395. this.userMenu.load();
  396. this.loadUserMenuItems();
  397. }
  398. },
  399. loadUserMenuItems: function(){
  400. var img = this.path+this.options.style+"/icons/config.png";
  401. this.userMenu.addMenuItem(o2.LP.desktop.userConfig, "click", function(e){this.userConfig(e);}.bind(this), img);
  402. this.userMenu.addMenuLine();
  403. img = this.path+this.options.style+"/icons/logout.png";
  404. this.userMenu.addMenuItem(o2.LP.desktop.logout, "click", function(){this.logout();}.bind(this), img);
  405. },
  406. userConfig: function(e){
  407. layout.openApplication(e, "Profile");
  408. },
  409. logout: function(){
  410. this.isLogout = true;
  411. if (!this.notRecordStatus){
  412. this.recordDesktopStatus(function(){
  413. (layout.authentication || new o2.xDesktop.Authentication()).logout();
  414. }.bind(this.layout));
  415. }else{
  416. (layout.authentication || new o2.xDesktop.Authentication()).logout();
  417. }
  418. },
  419. //******* end user menu ****************************************************
  420. //******* begin search *****************************************************
  421. focusSearch: function(){
  422. this.searchBoxNode.addClass("layout_content_taskbar_area_search_box_focus");
  423. this.searchBoxNode.addClass("mainColor_border");
  424. this.searchIconNode.addClass("icon_search_focus");
  425. },
  426. blurSearch: function(){
  427. this.searchBoxNode.removeClass("layout_content_taskbar_area_search_box_focus");
  428. this.searchBoxNode.removeClass("mainColor_border");
  429. this.searchIconNode.removeClass("icon_search_focus");
  430. },
  431. searchInputKeyDown: function(e){
  432. if (this.searchInputNode.get("value")){
  433. this.searchClearNode.addClass("icon_clear");
  434. }else{
  435. this.searchClearNode.removeClass("icon_clear");
  436. }
  437. if (e.keyCode===13) this.doSearch();
  438. },
  439. clearSearch: function(){
  440. this.searchInputNode.set("value", "");
  441. this.searchClearNode.removeClass("icon_clear");
  442. this.clearSearchResult();
  443. },
  444. doSearch: function(){
  445. var key = this.searchInputNode.get("value");
  446. if (key){
  447. if (this.apps["Search"]){
  448. this.apps["Search"].input.setValue(key);
  449. this.apps["Search"].input.doSearch();
  450. }
  451. layout.openApplication(null,"Search", {"key": key});
  452. }
  453. },
  454. clearSearchResult: function(){
  455. //alert("clear search result");
  456. // @todo
  457. },
  458. //******* end search*******************************************************
  459. //******* begin record status *********************************************
  460. recordDesktopStatus: function(callback){
  461. Object.each(this.apps, function(app, id){
  462. if (!app.options.desktopReload){
  463. this.closeApp(app);
  464. }
  465. }.bind(this));
  466. var status = this.getLayoutStatusData();
  467. // if (navigator.sendBeacon) {
  468. // var obj = this.personalAction.action.actions["putUserData"];
  469. // var url = this.personalAction.action.address + obj.uri;
  470. // url = url.replace("{name}", "layout");
  471. // navigator.sendBeacon(url, status);
  472. // } else {
  473. try{
  474. o2.UD.putData("layout", status, function(){
  475. if (callback) callback();
  476. });
  477. }catch(e){};
  478. // }
  479. },
  480. getLayoutStatusData: function(){
  481. var status = {
  482. "viewMode": "Default",
  483. "style": this.status.style,
  484. "flatStyle": this.options.style,
  485. "styleType": this.status.styleType || "",
  486. "currentApp": (this.currentApp) ? this.currentApp.appId : "Homepage",
  487. "apps": {},
  488. "lnks": (this.status.lnks && o2.typeOf(this.status.lnks)==="array") ? this.status.lnks : [],
  489. //"lnks": [],
  490. "flatLnks": [],
  491. "widgets": {},
  492. "menuData": this.menuData
  493. };
  494. // this.appArr.each(function(app){
  495. // if (app.options.appId!==this.options.index){
  496. // var appStatus = this.getAppStatusData(app, app.appId);
  497. // if (appStatus) status.apps[id] = appStatus;
  498. // }
  499. // }.bind(this));
  500. Object.each(this.apps, function(app, id){
  501. if (app.options.appId!==this.options.index){
  502. var appStatus = this.getAppStatusData(app, id);
  503. if (appStatus) status.apps[id] = appStatus;
  504. }
  505. if (app.isIndex){
  506. if (!status.apps[id]) status.apps[id] = {};
  507. status.apps[id].isIndex = true;
  508. }
  509. }.bind(this));
  510. this.lnks.each(function(lnk){
  511. status.flatLnks.push(lnk.data);
  512. //status.flatLnks.push({"icon": lnk.icon, "color": lnk.color, "title": lnk.title,"par": lnk.par});
  513. });
  514. Object.each(this.widgets, function(widget, id){
  515. var widgetStatus = this.getWidgetStatusData(widget, id);
  516. if (widgetStatus) status.widgets[id] = widgetStatus;
  517. }.bind(this));
  518. return status;
  519. },
  520. getAppStatusData: function(app, id){
  521. var appStatus = null;
  522. if (app.window){
  523. if (app.options.desktopReload){
  524. appStatus ={
  525. "appId": app.appId,
  526. "name": app.options.name,
  527. "style": app.options.style,
  528. "title": app.options.title,
  529. "window": {
  530. // //"size": app.window.node.getSize(),
  531. // "size": {"x": app.window.css.to.width.toFloat(), "y": app.window.css.to.height.toFloat()},
  532. // "position": {"x": app.window.css.to.left.toFloat(), "y": app.window.css.to.top.toFloat()},
  533. // "isMax": app.window.isMax,
  534. // "isHide": app.window.isHide,
  535. // "style": app.window.options.style
  536. },
  537. "app": null
  538. };
  539. if (app.recordStatus) appStatus.app = app.recordStatus();
  540. }
  541. }else{
  542. if (app.options){
  543. appStatus = app.options;
  544. }
  545. }
  546. return appStatus;
  547. },
  548. getWidgetStatusData: function(widget, id){
  549. var widgetStatus ={
  550. "name": widget.options.name,
  551. "appName": widget.options.appName,
  552. "position": widget.options.position,
  553. "widget": null
  554. };
  555. if (widget.recordStatus) widgetStatus.widget = widget.recordStatus();
  556. return widgetStatus;
  557. },
  558. //******* end record status ***********************************************
  559. //******* begin start menu ************************************************
  560. showStartMenu: function(){
  561. this.loadStartMenu(function(){
  562. if (!this.startMenu.isShow){
  563. this.startMenuNode.addClass("overColor_bg");
  564. this.startMenu.show();
  565. }
  566. }.bind(this));
  567. },
  568. loadStartMenu: function(callback){
  569. if (!this.startMenu){
  570. this.startMenu = new o2.xDesktop.Default.StartMenu(this);
  571. this.startMenu.addEvents({
  572. "onHide": function(){
  573. this.startMenuNode.removeClass("overColor_bg");
  574. }.bind(this),
  575. "onLoad": function(){
  576. if (callback) callback();
  577. }
  578. });
  579. this.startMenu.load();
  580. }else{
  581. if (this.startMenu.isLoaded) if (callback) callback();
  582. }
  583. },
  584. //******* end start menu **************************************************
  585. //******* begin message menu **********************************************
  586. showDesktopMessage: function(){
  587. if (!this.message){
  588. this.loadMessageMenu(function(){
  589. this.showMessage();
  590. }.bind(this));
  591. }else{
  592. this.showMessage();
  593. }
  594. },
  595. loadMessageMenu: function(callback){
  596. o2.require("o2.xDesktop.MessageV2", function(){
  597. this.message = new o2.xDesktop.MessageV2(this);
  598. this.message.addEvents({
  599. "onLoad": function(){ if (callback) callback(); }.bind(this),
  600. "onHide": function(){
  601. this.msgActionNode.removeClass("icon_msg_focus");
  602. this.msgActionNode.removeClass("mainColor_bg");
  603. }.bind(this),
  604. });
  605. this.message.load();
  606. }.bind(this));
  607. },
  608. showMessage: function(){
  609. if (!this.message.isShow){
  610. this.msgActionNode.addClass("icon_msg_focus");
  611. this.msgActionNode.addClass("mainColor_bg");
  612. this.message.show();
  613. }
  614. },
  615. //******* end message menu ************************************************
  616. //******* begin task item *************************************************
  617. createTaskItem: function(app){
  618. return new o2.xDesktop.Default.TaskItem(this, app);
  619. },
  620. //******* end task item ***************************************************
  621. closeApp: function(app, hasTaskitem) {
  622. var appId = app.appId;
  623. this.appCurrentList.erase(app);
  624. this.appArr.erase(app);
  625. this.apps[appId] = null;
  626. delete this.apps[appId];
  627. if (!hasTaskitem){
  628. var i = this.appCurrentList.length;
  629. if (i && this.appCurrentList[i-1]){
  630. this.appCurrentList[i-1].setCurrent();
  631. }else{
  632. var keys = Object.keys(this.apps);
  633. i = keys.length;
  634. if (i && this.apps[keys[i-1]] && this.apps[keys[i-1]].setCurrent){
  635. this.apps[keys[i-1]].setCurrent();
  636. }else{
  637. //if (app.appId!=="Homepage") layout.openApplication(null, "Homepage");
  638. layout.openApplication(null, "Homepage");
  639. }
  640. }
  641. this.checkTaskBarSize();
  642. this.checkTaskBarScrollTo();
  643. }
  644. },
  645. refreshApp:function(app){
  646. if (app.window){
  647. var taskitem = app.taskitem;
  648. var appStatus ={
  649. "id": app.appId,
  650. "name": app.options.name,
  651. "style": app.options.style,
  652. "appId": app.appId
  653. };
  654. var status = (app.recordStatus) ? app.recordStatus() : null;
  655. app.close(true);
  656. layout.openApplication(null, appStatus.name, appStatus, status, false, taskitem);
  657. //this.openApplicationWithStatus(appStatus);
  658. }
  659. },
  660. getPageDesignerStyle: function(callback){
  661. if (!this.pageDesignerStyle){
  662. this.pageDesignerStyle = "default";
  663. MWF.UD.getData("pageDesignerStyle", function(json) {
  664. if (json.data) {
  665. var styles = JSON.decode(json.data);
  666. this.pageDesignerStyle = styles.style;
  667. }
  668. if (callback) callback();
  669. }.bind(this));
  670. }else{
  671. if (callback) callback();
  672. }
  673. },
  674. getFormDesignerStyle: function(callback){
  675. if (!this.formDesignerStyle){
  676. this.formDesignerStyle = "default";
  677. MWF.UD.getData("formDesignerStyle", function(json) {
  678. if (json.data) {
  679. var styles = JSON.decode(json.data);
  680. this.formDesignerStyle = styles.style;
  681. }
  682. if (callback) callback();
  683. }.bind(this));
  684. }else{
  685. if (callback) callback();
  686. }
  687. },
  688. createRefreshNode: function(){
  689. this.refreshNode = new Element("div.layout_refresh_node.icon_refresh").inject(this.desktopNode);
  690. this.refreshNode.set("morph", {
  691. "duration": 100,
  692. "transition": Fx.Transitions.Quart.easeOut
  693. });
  694. this.refreshNode.addEvent("click", function(){
  695. if (this.currentApp) this.currentApp.refresh();
  696. this.hideRefresh();
  697. }.bind(this));
  698. },
  699. showRefresh: function(){
  700. if (!this.refreshNodeShow){
  701. if (!this.refreshNode) this.createRefreshNode();
  702. var size = this.taskbarNode.getSize();
  703. var nodeSize = this.refreshNode.getSize();
  704. var top = size.y;
  705. var left = size.x/2-nodeSize.x/2;
  706. this.refreshNode.setStyles({
  707. "left": left,
  708. "top": 0-nodeSize.y,
  709. "opacity": 0
  710. });
  711. this.refreshNode.morph({
  712. "top": top,
  713. "left": left,
  714. "opacity": 0.9
  715. });
  716. this.refreshNodeShow = true;
  717. this.refreshTimeoutId = window.setTimeout(function(){
  718. this.hideRefresh();
  719. }.bind(this), 2000);
  720. }
  721. },
  722. hideRefresh: function(){
  723. if (this.refreshNodeShow){
  724. if (this.refreshNode){
  725. var size = this.taskbarNode.getSize();
  726. var nodeSize = this.refreshNode.getSize();
  727. var top = size.y;
  728. var left = size.x/2-nodeSize.x/2;
  729. this.refreshNode.morph({
  730. "top": 0-nodeSize.y,
  731. "left": left,
  732. "opacity": 0
  733. });
  734. window.setTimeout(function(){
  735. this.refreshNodeShow = false;
  736. }.bind(this), 100);
  737. }
  738. }
  739. if (this.refreshTimeoutId){
  740. window.clearTimeout(this.refreshTimeoutId);
  741. this.refreshTimeoutId = "";
  742. }
  743. }
  744. });
  745. o2.xDesktop.Default.StartMenu = new Class({
  746. Implements: [Events],
  747. initialize: function(layout){
  748. this.layout = layout;
  749. this.container = this.layout.startMenuArea;
  750. this.actionNode = this.layout.startMenuNode;
  751. this.isLoaded = false;
  752. this.isShow = false;
  753. this.isMorph = false;
  754. this.items = [];
  755. this.menuData = (this.layout.status && this.layout.status.menuData) ? this.layout.status.menuData : {
  756. "appList": [],
  757. "processList": [],
  758. "inforList": [],
  759. "queryList": []
  760. };
  761. this.itemTempletedHtml = "" +
  762. " <div class='layout_start_item_iconArea'>" +
  763. " <div class='layout_start_item_icon'></div>" +
  764. " </div>" +
  765. " <div class='layout_start_item_text'></div>"+
  766. " <div class='layout_start_item_badge'></div>";
  767. },
  768. load: function(){
  769. var view = this.layout.path+this.layout.options.style+((o2.session.isMobile || layout.mobile) ? "/layout-menu-mobile.html" : "/layout-menu-pc.html");
  770. this.container.loadHtml(view, {"module": this}, function(){
  771. this.maskNode.setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex());
  772. this.node.setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex());
  773. this.layout.menuNode.setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex());
  774. this.node.addEvent("mousedown", function(e){
  775. e.stopPropagation();
  776. e.preventDefault();
  777. });
  778. this.triangleNode = new Element("div.layout_menu_start_triangle").inject(this.layout.menuNode, "after");
  779. this.hideMessage = function(){ this.hide(); }.bind(this);
  780. this.fireEvent("load");
  781. this.layout.addEvent("resize", this.setSize.bind(this));
  782. this.loadTitle();
  783. this.loadLnks();
  784. this.isLoaded = true;
  785. this.fireEvent("load");
  786. }.bind(this));
  787. },
  788. resetMenuData: function(){
  789. if (!this.menuData) this.menuData = {
  790. "appList": [],
  791. "processList": [],
  792. "inforList": [],
  793. "queryList": []
  794. }
  795. var nodes = this.appContentNode.getChildren();
  796. var data = [];
  797. nodes.each(function(node){
  798. var item = node.retrieve("item");
  799. if (item){
  800. data.push({
  801. "id": item.data.id,
  802. "name": item.data.name
  803. });
  804. }
  805. }.bind(this));
  806. if (this.currentTab === this.appCategoryTab){
  807. this.menuData.appList = data;
  808. }else if (this.currentTab === this.processCategoryTab){
  809. this.menuData.processList = data;
  810. }else if (this.currentTab === this.inforCategoryTab){
  811. this.menuData.inforList = data;
  812. }else if (this.currentTab === this.queryCategoryTab){
  813. this.menuData.queryList = data;
  814. }
  815. this.layout.menuData = this.menuData;
  816. },
  817. setScroll: function(){
  818. o2.require("o2.widget.ScrollBar", function(){
  819. this.appScrollBar = new o2.widget.ScrollBar(this.appScrollNode, {
  820. "style":"xDesktop_Message", "where": "before", "indent": false, "distance": 100, "friction": 6, "axis": {"x": false, "y": true}
  821. });
  822. }.bind(this));
  823. },
  824. loadTitle: function(){
  825. this.lnkTitleNode.set("text", o2.LP.desktop.lnkAppTitle);
  826. this.appCategoryTab = new Element("div.layout_start_tab", {"text": o2.LP.desktop.message.application}).inject(this.appTitleNode);
  827. this.processCategoryTab = new Element("div.layout_start_tab", {"text": o2.LP.desktop.message.process}).inject(this.appTitleNode);
  828. this.inforCategoryTab = new Element("div.layout_start_tab", {"text": o2.LP.desktop.message.infor}).inject(this.appTitleNode);
  829. this.queryCategoryTab = new Element("div.layout_start_tab", {"text": o2.LP.desktop.message.query}).inject(this.appTitleNode);
  830. this.searchNode = new Element("div.layout_start_search").inject(this.appTitleNode);
  831. this.searchIconNode = new Element("div.layout_start_search_icon").inject(this.searchNode);
  832. this.searchIconNode.addClass("icon_startMenu_search");
  833. var currentWidth = this.searchNode.getSize().x;
  834. this.searchNode.store("currentWidth", currentWidth);
  835. this.appCategoryTab.addEvent("click", function(){
  836. debugger;
  837. this.appTitleNode.getElements(".layout_start_tab").removeClass("mainColor_bg");
  838. this.appCategoryTab.addClass("mainColor_bg");
  839. this.currentTab = this.appCategoryTab;
  840. this.loadApplications();
  841. }.bind(this));
  842. this.processCategoryTab.addEvent("click", function(){
  843. this.appTitleNode.getElements(".layout_start_tab").removeClass("mainColor_bg");
  844. this.processCategoryTab.addClass("mainColor_bg");
  845. this.currentTab = this.processCategoryTab;
  846. this.loadProcesses();
  847. }.bind(this));
  848. this.inforCategoryTab.addEvent("click", function(){
  849. this.appTitleNode.getElements(".layout_start_tab").removeClass("mainColor_bg");
  850. this.inforCategoryTab.addClass("mainColor_bg");
  851. this.currentTab = this.inforCategoryTab;
  852. this.loadInfors();
  853. }.bind(this));
  854. this.queryCategoryTab.addEvent("click", function(){
  855. this.appTitleNode.getElements(".layout_start_tab").removeClass("mainColor_bg");
  856. this.queryCategoryTab.addClass("mainColor_bg");
  857. this.currentTab = this.queryCategoryTab;
  858. this.loadQuerys();
  859. }.bind(this));
  860. this.searchIconNode.addEvent("click", this.searchIconAction.bind(this));
  861. },
  862. searchIconAction: function(){
  863. if (!this.isMorph){
  864. if (this.isSearch){
  865. this.doSearch();
  866. }else{
  867. this.loadSearch()
  868. }
  869. }
  870. },
  871. loadSearch: function(){
  872. this.isSearch = true;
  873. this.searchNode.addClass("mainColor_border");
  874. this.appCategoryTab.hide();
  875. this.processCategoryTab.hide();
  876. this.inforCategoryTab.hide();
  877. this.queryCategoryTab.hide();
  878. var size = this.appTitleNode.getSize();
  879. var pr = this.appTitleNode.getStyle("padding-right").toInt() || 0;
  880. var pl = this.appTitleNode.getStyle("padding-left").toInt() || 0;
  881. var margin = this.searchNode.getStyle("margin-right").toInt() || 0;
  882. var w = size.x-margin*2-pr-pl;
  883. this.isMorph = true;
  884. this.searchNode.set("morph", {"duration": 200});
  885. this.searchNode.morph({"width": ""+w+"px"});
  886. window.setTimeout(function(){
  887. this.isMorph = false;
  888. }.bind(this), 220);
  889. if (!this.searchClearNode){
  890. this.searchClearNode = new Element("div.layout_start_search_clear").inject(this.searchNode);
  891. this.searchClearNode.addClass("icon_clear");
  892. this.searchClearNode.addEvent("click", this.hideSearch.bind(this));
  893. }
  894. this.searchClearNode.show();
  895. if (!this.searchAreaNode) this.searchAreaNode = new Element("div.layout_start_search_area").inject(this.searchNode);
  896. this.searchAreaNode.show();
  897. if (!this.searchInputNode){
  898. this.searchInputNode = new Element("input.layout_start_search_input", {"placeholder": o2.LP.searchKey}).inject(this.searchAreaNode);
  899. this.searchInputNode.addEvent("keydown", function(e){
  900. if (e.code==13) this.doSearch();
  901. }.bind(this));
  902. }
  903. this.searchInputNode.show();
  904. this.searchInputNode.focus();
  905. //this.searchNode.addClass("layout_start_search_load");
  906. },
  907. hideSearch: function(){
  908. if (this.isSearch){
  909. if (this.searchInputNode){
  910. this.searchInputNode.set("value", "");
  911. this.searchInputNode.hide();
  912. }
  913. if (this.searchAreaNode) this.searchAreaNode.hide();
  914. if (this.searchClearNode) this.searchClearNode.hide();
  915. this.isMorph = true;
  916. var currentWidth = this.searchNode.retrieve("currentWidth");
  917. this.searchNode.morph({"width": ""+currentWidth+"px"});
  918. window.setTimeout(function(){
  919. if (this.currentTab && this.isSearchResult) this.currentTab.click();
  920. this.searchNode.removeClass("mainColor_border");
  921. this.appCategoryTab.show();
  922. this.processCategoryTab.show();
  923. this.inforCategoryTab.show();
  924. this.queryCategoryTab.show();
  925. this.isSearch = false;
  926. this.isMorph = false;
  927. this.isSearchResult = false;
  928. }.bind(this), 220);
  929. }
  930. },
  931. doSearch: function(){
  932. var key = this.searchInputNode.get("value").toLowerCase();
  933. if (key){
  934. this.isSearchResult = true;
  935. this.appContentNode.empty();
  936. this.searchApplicatins(key);
  937. this.searchProcesses(key);
  938. this.searchInfors(key);
  939. this.searchQuerys(key);
  940. }
  941. },
  942. searchApplicatins: function(value){
  943. // var user = this.layout.session.user;
  944. // // var currentNames = [user.name, user.distinguishedName, user.id, user.unique];
  945. // // if (user.roleList) currentNames = currentNames.concat(user.roleList);
  946. // // if (user.groupList) currentNames = currentNames.concat(user.groupList);
  947. this.getCurrentName( function (currentNames) {
  948. if (this.layoutJson && this.layoutJson.length) this.layoutJson.each(function(v){
  949. if ( this.checkMenuItem(v, currentNames) ){
  950. if ((v.title.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.title.toPY().toLowerCase().indexOf(value)!==-1) || (v.title.indexOf(value)!==-1)){
  951. this.createApplicationMenuItem(v);
  952. }
  953. }
  954. }.bind(this));
  955. if (this.componentJson && this.componentJson.length) this.componentJson.each(function(v){
  956. if ( this.checkMenuItem(v, currentNames) ){
  957. if ((v.title.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.title.toPY().toLowerCase().indexOf(value)!==-1) || (v.title.indexOf(value)!==-1)){
  958. this.createApplicationMenuItem(v);
  959. }
  960. }
  961. }.bind(this));
  962. if (this.portalJson && this.portalJson.length) this.portalJson.each(function(v){
  963. if ((v.name.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.name.toPY().toLowerCase().indexOf(value)!==-1) || (v.name.indexOf(value)!==-1)){
  964. this.createPortalMenuItem(v);
  965. }
  966. }.bind(this));
  967. })
  968. },
  969. searchProcesses: function(value){
  970. if (this.processJson && this.processJson.length) this.processJson.each(function(v){
  971. if ((v.name.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.name.toPY().toLowerCase().indexOf(value)!==-1) || (v.name.indexOf(value)!==-1)){
  972. this.createProcessMenuItem(v);
  973. }
  974. }.bind(this));
  975. },
  976. searchInfors: function(value){
  977. if (this.inforJson && this.inforJson.length) this.inforJson.each(function(v){
  978. if ((v.appName.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.appName.toPY().toLowerCase().indexOf(value)!==-1) || (v.appName.indexOf(value)!==-1)){
  979. this.createInforMenuItem(v);
  980. }
  981. }.bind(this));
  982. },
  983. searchQuerys: function(value){
  984. if (this.queryJson && this.queryJson.length) this.queryJson.each(function(v){
  985. if ((v.name.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.name.toPY().toLowerCase().indexOf(value)!==-1) || (v.name.indexOf(value)!==-1)){
  986. this.createQueryMenuItem(v);
  987. }
  988. }.bind(this));
  989. },
  990. loadJsons: function(callback){
  991. this.clearAppContentNode();
  992. this.loadLayoutApplications(function(json_layout){
  993. var componentAction = o2.Actions.get("x_component_assemble_control");
  994. var portalAction = o2.Actions.get("x_portal_assemble_surface");
  995. var processAction = o2.Actions.get("x_processplatform_assemble_surface");
  996. var inforAction = o2.Actions.get("x_cms_assemble_control");
  997. var queryAction = o2.Actions.get("x_query_assemble_surface");
  998. var iconsPath = this.layout.path+"icons.json";
  999. this.getIconsJson(function(){
  1000. o2.Actions.invokeAsync([
  1001. {"action": componentAction, "name": "listComponent"},
  1002. {"action": portalAction, "name": "listApplication"},
  1003. {"action": processAction, "name": "listApplication"},
  1004. {"action": inforAction, "name": "listColumn"},
  1005. {"action": queryAction, "name": "listQuery"},
  1006. ], {"success": function(json_component, json_portal, json_process, json_infor, json_query){
  1007. this.layoutJson = json_layout;
  1008. this.componentJson = json_component.data;
  1009. this.portalJson = json_portal.data;
  1010. this.processJson = json_process.data;
  1011. this.inforJson = json_infor.data;
  1012. this.queryJson = json_query.data;
  1013. if (callback) callback();
  1014. }.bind(this), "failure": function(){}}
  1015. );
  1016. }.bind(this));
  1017. }.bind(this));
  1018. },
  1019. getIconsJson: function(callback){
  1020. if (this.layout.iconsJson){
  1021. if (callback) callback();
  1022. }else{
  1023. o2.JSON.get(iconsPath, function(json){
  1024. this.layout.iconsJson = json;
  1025. if (callback) callback();
  1026. }.bind(this));
  1027. }
  1028. },
  1029. setPosition: function(){
  1030. //var size = this.container.getSize();
  1031. var index = o2.xDesktop.zIndexPool.zIndex;
  1032. var nodeSize = this.node.getSize();
  1033. var left = 0-nodeSize.x;
  1034. this.maskNode.setStyles({"left": ""+left+"px"});
  1035. this.node.setStyles({"left": ""+left+"px"});
  1036. },
  1037. setSize: function(){
  1038. if (this.appScrollBar && this.appScrollBar.scrollVNode) this.appScrollBar.scrollVNode.setStyle("margin-top", "0px");
  1039. var isLnk = false;
  1040. if (false && this.layout.lnks && this.layout.lnks.length){
  1041. this.lnkAreaNode.show();
  1042. this.lineNode.show();
  1043. var h = 100*3;
  1044. this.lnkScrollNode.setStyle("height", ""+h+"px");
  1045. isLnk = true;
  1046. }else{
  1047. this.lnkAreaNode.hide();
  1048. this.lineNode.hide();
  1049. }
  1050. var size = this.node.getSize();
  1051. var lnkSizeY = (isLnk) ? this.lnkAreaNode.getSize().y : 0;
  1052. var lineSizeY = (isLnk) ? this.lineNode.getSize().y : 0;
  1053. var mt = (isLnk) ? (this.lineNode.getStyle("margin-top").toInt() || 0) : 0;
  1054. var mb = (isLnk) ? (this.lineNode.getStyle("margin-bottom").toInt() || 0) : 0;
  1055. var titleSize = this.appTitleNode.getSize();
  1056. var y = size.y-lnkSizeY-lineSizeY-mt-mb-titleSize.y;
  1057. this.appScrollNode.setStyle("height", ""+y+"px");
  1058. },
  1059. loadLnks: function(){
  1060. // if (this.layout.lnks && this.layout.lnks.length){
  1061. // this.lnkAreaNode.show();
  1062. // this.lineNode.show();
  1063. // this.lnkContentNode.empty();
  1064. // this.createLnkMenuItem();
  1065. // }else{
  1066. this.lnkAreaNode.hide();
  1067. this.lineNode.hide();
  1068. //}
  1069. },
  1070. createLnkMenuItem: function(){
  1071. //this.templetedHtml
  1072. },
  1073. clearAppContentNode: function(){
  1074. this.appContentNode.empty();
  1075. this.appContentNode.addClass("icon_loading");
  1076. },
  1077. loadApplications: function(callback){
  1078. this.clearAppContentNode();
  1079. // this.loadLayoutApplications(function(json_layout){
  1080. // var componentAction = o2.Actions.get("x_component_assemble_control");
  1081. // var portalAction = o2.Actions.get("x_portal_assemble_surface");
  1082. // o2.Actions.invokeAsync([
  1083. // {"action": componentAction, "name": "listComponent"},
  1084. // {"action": portalAction, "name": "listApplication"},
  1085. // ], {"success": function(json_component, json_portal){
  1086. // this.loadApplicationsItem(json_layout, json_component.data, json_portal.data);
  1087. // }.bind(this), "failure": function(){}}
  1088. // );
  1089. // }.bind(this));
  1090. this.loadApplicationsItem(this.layoutJson, this.componentJson, this.portalJson);
  1091. },
  1092. loadLayoutApplications: function(callback){
  1093. var url = this.layout.path+"applications.json";
  1094. o2.getJSON(url, function(json){
  1095. if (callback) callback(json);
  1096. }.bind(this));
  1097. },
  1098. getCurrentName : function( callback ){
  1099. var user = this.layout.session.user;
  1100. var currentNames = [user.name, user.distinguishedName, user.id, user.unique];
  1101. if (user.roleList) currentNames = currentNames.concat(user.roleList);
  1102. // if (user.groupList) currentNames = currentNames.concat(user.groupList);
  1103. o2.Actions.load("x_organization_assemble_express").GroupAction.listWithPerson(
  1104. {
  1105. personList: [user.distinguishedName],
  1106. recursiveGroupFlag : true,
  1107. referenceFlag : true,
  1108. recursiveOrgFlag : true
  1109. },
  1110. function(json) {
  1111. currentNames = currentNames.concat(json.data.groupList);
  1112. if( callback )callback( currentNames )
  1113. }
  1114. )
  1115. },
  1116. loadApplicationsItem: function(json_layout, json_component, json_portal){
  1117. // var user = this.layout.session.user;
  1118. // var currentNames = [user.name, user.distinguishedName, user.id, user.unique];
  1119. // if (user.roleList) currentNames = currentNames.concat(user.roleList);
  1120. // if (user.groupList) currentNames = currentNames.concat(user.groupList);
  1121. this.getCurrentName( function ( currentNames ) {
  1122. this.appContentNode.removeClass("icon_loading");
  1123. var loadedApps = {};
  1124. if (this.menuData && this.menuData.appList && this.menuData.appList.length){
  1125. this.menuData.appList.each(function(app){
  1126. var appData = null;
  1127. if (!appData && json_layout && json_layout.length){
  1128. appData = json_layout.find(function(i){ return (i.id === app.id); });
  1129. if (appData){
  1130. json_layout.erase(appData);
  1131. if ( this.checkMenuItem(appData, currentNames) ) this.createApplicationMenuItem(appData);
  1132. }
  1133. }
  1134. if (!appData && json_component && json_component.length){
  1135. appData = json_component.find(function(i){ return (i.id === app.id); });
  1136. if (appData){
  1137. json_component.erase(appData);
  1138. if ( this.checkMenuItem(appData, currentNames) ) this.createApplicationMenuItem(appData);
  1139. }
  1140. }
  1141. if (!appData && json_portal && json_portal.length){
  1142. appData = json_portal.find(function(i){ return (i.id === app.id); });
  1143. if (appData){
  1144. json_portal.erase(appData);
  1145. this.createPortalMenuItem(appData);
  1146. }
  1147. }
  1148. }.bind(this));
  1149. }
  1150. if (json_layout && json_layout.length) json_layout.each(function(value){
  1151. if ( this.checkMenuItem(value, currentNames) ) this.createApplicationMenuItem(value);
  1152. }.bind(this));
  1153. if (json_component && json_component.length) json_component.each(function(value){
  1154. if ( this.checkMenuItem(value, currentNames) ) this.createApplicationMenuItem(value);
  1155. }.bind(this));
  1156. if (json_portal && json_portal.length) json_portal.each(function(value){
  1157. this.createPortalMenuItem(value);
  1158. }.bind(this));
  1159. }.bind(this));
  1160. },
  1161. loadProcesses: function(){
  1162. this.clearAppContentNode();
  1163. // o2.Actions.get("x_processplatform_assemble_surface").listApplication(this.loadProcessesItem.bind(this));
  1164. this.loadProcessesItem(this.processJson)
  1165. },
  1166. loadProcessesItem: function(json){
  1167. this.appContentNode.removeClass("icon_loading");
  1168. if (json && json.length) json.each(function(value){
  1169. this.createProcessMenuItem(value);
  1170. }.bind(this));
  1171. },
  1172. loadInfors: function(){
  1173. this.clearAppContentNode();
  1174. //o2.Actions.get("x_cms_assemble_control").listColumn(this.loadInforsItem.bind(this));
  1175. this.loadInforsItem(this.inforJson)
  1176. },
  1177. loadInforsItem: function(json){
  1178. this.appContentNode.removeClass("icon_loading");
  1179. if (json && json.length) json.each(function(value){
  1180. this.createInforMenuItem(value);
  1181. }.bind(this));
  1182. },
  1183. loadQuerys: function(){
  1184. this.clearAppContentNode();
  1185. // o2.Actions.get("x_query_assemble_surface").listQuery(this.loadQuerysItem.bind(this));
  1186. this.loadQuerysItem(this.queryJson)
  1187. },
  1188. loadQuerysItem: function(json){
  1189. this.appContentNode.removeClass("icon_loading");
  1190. if (json && json.length) json.each(function(value){
  1191. this.createQueryMenuItem(value);
  1192. }.bind(this));
  1193. },
  1194. checkMenuItem: function(value, currentNames){
  1195. if (value.visible===false) return false;
  1196. var isAllow = true;
  1197. if (value.allowList) isAllow = (value.allowList.length) ? (value.allowList.isIntersect(currentNames)) : true;
  1198. var isDeny = false;
  1199. if (value.denyList) isDeny = (value.denyList.length) ? (value.denyList.isIntersect(currentNames)) : false;
  1200. return ((!isDeny && isAllow) || o2.AC.isAdministrator());
  1201. },
  1202. createApplicationMenuItem: function(value){
  1203. this.items.push(new o2.xDesktop.Default.StartMenu.Item(this, this.appContentNode, value));
  1204. },
  1205. createPortalMenuItem: function(value){
  1206. this.items.push(new o2.xDesktop.Default.StartMenu.PortalItem(this, this.appContentNode, value));
  1207. },
  1208. createProcessMenuItem: function(value){
  1209. this.items.push(new o2.xDesktop.Default.StartMenu.ProcessItem(this, this.appContentNode, value));
  1210. },
  1211. createInforMenuItem: function(value){
  1212. this.items.push(new o2.xDesktop.Default.StartMenu.InforItem(this, this.appContentNode, value));
  1213. },
  1214. createQueryMenuItem: function(value){
  1215. this.items.push(new o2.xDesktop.Default.StartMenu.QueryItem(this, this.appContentNode, value));
  1216. },
  1217. show: function(){
  1218. if (!this.isMorph){
  1219. this.isMorph = true;
  1220. if (!this.morph){
  1221. this.maskMorph = new Fx.Morph(this.maskNode, {
  1222. duration: "200",
  1223. transition: Fx.Transitions.Sine.easeOut
  1224. });
  1225. this.morph = new Fx.Morph(this.node, {
  1226. duration: "200",
  1227. transition: Fx.Transitions.Sine.easeOut
  1228. });
  1229. }
  1230. this.maskNode.setStyles({"display": "block"});
  1231. this.node.setStyles({"display": "block"});
  1232. this.triangleNode.setStyles({"display": "block"});
  1233. this.setSize();
  1234. this.setPosition();
  1235. var size = this.layout.menuNode.getSize();
  1236. var left = size.x;
  1237. this.loadJsons(function(){
  1238. (this.currentTab || this.appCategoryTab).click();
  1239. }.bind(this));
  1240. //this.loadContent();
  1241. this.maskMorph.start({"left": ""+left+"px"});
  1242. this.morph.start({"left": ""+left+"px"}).chain(function(){
  1243. this.isShow = true;
  1244. this.isMorph = false;
  1245. this.layout.desktopNode.addEvent("mousedown", this.hideMessage);
  1246. this.setScroll();
  1247. this.fireEvent("show");
  1248. }.bind(this));
  1249. }
  1250. },
  1251. hide: function(callback){
  1252. if (!this.isMorph){
  1253. this.isMorph = true;
  1254. if (!this.morph){
  1255. this.maskMorph = new Fx.Morph(this.maskNode, {
  1256. duration: "200",
  1257. transition: Fx.Transitions.Sine.easeOut
  1258. });
  1259. this.morph = new Fx.Morph(this.node, {
  1260. duration: "200",
  1261. transition: Fx.Transitions.Sine.easeOut
  1262. });
  1263. }
  1264. var nodeSize = this.node.getSize();
  1265. var left = 0-nodeSize.x;
  1266. // var position = this.node.getPosition();
  1267. // var size = this.node.getSize();
  1268. // var left = position.x+size.x;
  1269. this.isSearchResult = false;
  1270. this.hideSearch();
  1271. this.lnkContentNode.empty();
  1272. this.appContentNode.empty();
  1273. if (this.appScrollBar) this.appScrollBar.destroy();
  1274. this.maskMorph.start({"left": ""+left+"px"}).chain(function(){
  1275. this.maskNode.setStyle("display", "none");
  1276. this.triangleNode.setStyles({"display": "none"});
  1277. }.bind(this));
  1278. this.morph.start({"left": ""+left+"px"}).chain(function(){
  1279. this.node.setStyle("display", "none");
  1280. this.isShow = false;
  1281. this.isMorph = false;
  1282. this.layout.desktopNode.removeEvent("mousedown", this.hideMessage);
  1283. this.fireEvent("hide");
  1284. if (callback) callback();
  1285. }.bind(this));
  1286. }
  1287. },
  1288. });
  1289. o2.xDesktop.Default.StartMenu.Item = new Class({
  1290. initialize: function (menu, container, data) {
  1291. this.menu = menu;
  1292. this.layout = this.menu.layout;
  1293. this.data = data;
  1294. this.container = $(container);
  1295. this.load();
  1296. },
  1297. load: function(){
  1298. this.node = new Element("div.layout_start_item").inject(this.container);
  1299. this.node.set("html", this.menu.itemTempletedHtml);
  1300. this.iconAreaNode = this.node.getElement(".layout_start_item_iconArea");
  1301. this.iconNode = this.node.getElement(".layout_start_item_icon");
  1302. this.badgeNode = this.node.getElement(".layout_start_item_badge");
  1303. this.textNode = this.node.getElement(".layout_start_item_text");
  1304. this.loadIcon();
  1305. this.loadBadge();
  1306. this.loadText();
  1307. this.setEvent();
  1308. this.node.store("item", this);
  1309. },
  1310. dragOver: function(){
  1311. if (!this.overNode){
  1312. this.overNode = new Element("div.layout_start_item_over").inject(this.container);
  1313. this.overNode.addClass("mainColor_bg");
  1314. }
  1315. this.overNode.position({
  1316. "relativeTo": this.iconAreaNode,
  1317. "position": "leftTop",
  1318. "edge": "leftTop",
  1319. "offset": {
  1320. "x": -6, "y":-6
  1321. }
  1322. });
  1323. this.overNode.show();
  1324. },
  1325. dragOut: function(){
  1326. if (this.overNode) this.overNode.hide();
  1327. },
  1328. loadIcon: function(){
  1329. var icon;
  1330. var bgcolor = "";
  1331. if (this.data.path.substring(0, 4)==="@url"){
  1332. if (this.data.iconPath){
  1333. icon = this.data.iconPath;
  1334. }else{
  1335. if (this.layout.iconsJson["Url"] && this.layout.iconsJson["Url"].icon){
  1336. icon = this.layout.path+"appicons/"+this.layout.iconsJson["Url"].icon;
  1337. bgcolor = this.layout.iconsJson["Url"].color;
  1338. }else{
  1339. icon = "../x_component_Setting/$Main/default/icon/site.png";
  1340. bgcolor = "";
  1341. }
  1342. }
  1343. }else{
  1344. if (this.layout.iconsJson[this.data.path] && this.layout.iconsJson[this.data.path].icon){
  1345. icon = this.layout.path+"appicons/"+this.layout.iconsJson[this.data.path].icon;
  1346. bgcolor = this.layout.iconsJson[this.data.path].color;
  1347. }else{
  1348. icon = "../x_component_"+this.data.path.replace(/\./g, "_")+"/$Main/"+this.data.iconPath;
  1349. bgcolor = "";
  1350. }
  1351. }
  1352. if (icon && bgcolor){
  1353. this.iconNode.addClass("layout_start_item_icon_flat");
  1354. this.iconNode.setStyle("background-color", bgcolor);
  1355. }
  1356. this.iconNode.setStyle("background-image", "url("+icon+")");
  1357. this.icon = icon;
  1358. this.bgcolor = bgcolor;
  1359. },
  1360. loadBadge: function(){
  1361. this.badgeNode.set("title", o2.LP.desktop.addLnk).addClass("icon_add_red");
  1362. },
  1363. loadText: function(){
  1364. this.textNode.set("text", this.data.title);
  1365. },
  1366. setEvent: function(){
  1367. this.node.addEvents({
  1368. "mouseover": function(){ this.badgeNode.fade("in"); }.bind(this),
  1369. "mouseout": function(){ this.badgeNode.fade("out"); }.bind(this),
  1370. "click": function(e){
  1371. this.menu.hide(function(){
  1372. this.open(e);
  1373. }.bind(this));
  1374. }.bind(this)
  1375. });
  1376. this.badgeNode.addEvent("click", function(e){
  1377. this.addLnk();
  1378. e.stopPropagation();
  1379. }.bind(this));
  1380. this.makeLnk();
  1381. },
  1382. addLnk: function(dragTargetLnk, dragPosition){
  1383. lnkdata = {
  1384. "name": this.data.path,
  1385. "title": this.data.title,
  1386. "iconData": this.data.iconData || null,
  1387. "icon": this.iconData || null,
  1388. "appType": null,
  1389. "options": null
  1390. }
  1391. this.layout.addLnk(lnkdata, dragTargetLnk, dragPosition);
  1392. },
  1393. open: function(e){
  1394. layout.openApplication(e, this.data.path);
  1395. },
  1396. makeLnk: function(){
  1397. var drag = new Drag(this.node, {
  1398. "stopPropagation": true,
  1399. "compensateScroll": true,
  1400. "onStart": function(el, e){
  1401. this.doDragMove(e);
  1402. drag.stop();
  1403. }.bind(this)
  1404. });
  1405. },
  1406. getDragNode: function(){
  1407. if (!this.dragNode){
  1408. this.dragNode = new Element("div.layout_menu_lnk_item_drag")
  1409. .setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex())
  1410. .inject(this.layout.node);
  1411. var dragIconNode = this.iconNode.clone(true).inject(this.dragNode)
  1412. .removeClass("layout_menu_lnk_item_icon")
  1413. .addClass("layout_menu_lnk_item_icon_drag");
  1414. if (this.bgcolor) dragIconNode.setStyle("background-color", this.bgcolor);
  1415. }
  1416. var p = this.iconNode.getPosition(this.dragNode.getOffsetParent());
  1417. this.dragNode.show().setStyles({
  1418. "left": ""+p.x+"px", "top": ""+p.y+"px"
  1419. });
  1420. },
  1421. doDragMove: function(e){
  1422. this.getDragNode();
  1423. var drag = new Drag.Move(this.dragNode, {
  1424. "stopPropagation": true,
  1425. "compensateScroll": true,
  1426. "droppables": [this.layout.lnkContentNode, this.menu.appContentNode],
  1427. "onStart": function(el){ this._drag_start(el); }.bind(this),
  1428. "onDrag": function(dragging,e){ this._drag_drag(dragging, e); }.bind(this),
  1429. "onEnter": function(dragging, inObj){ this._drag_enter(dragging, inObj); }.bind(this),
  1430. "onLeave": function(dragging, obj){ this._drag_leave(dragging, obj); }.bind(this),
  1431. "onDrop": function(dragging, inObj){ this._drag_drop(dragging, inObj); }.bind(this),
  1432. "onCancel": function(dragging){ this._drag_cancel(dragging); }.bind(this),
  1433. "onComplete": function(dragging, e){ this._drag_complete(dragging, e); }.bind(this),
  1434. });
  1435. drag.start(e);
  1436. this.dragStatus == "remove";
  1437. },
  1438. _drag_start: function(el){
  1439. this.isDrag = true;
  1440. this.dragTargetLnk = null;
  1441. this.dragPosition = "before";
  1442. this.node.setStyle("opacity", 0);
  1443. },
  1444. _drag_drag: function(dragging, e){
  1445. if (this.dragStatus == "order"){
  1446. if (this.layout.lnks && this.layout.lnks.length){
  1447. var current = e.page.y;
  1448. for (var i=0; i<this.layout.lnks.length; i++){
  1449. var lnk = this.layout.lnks[i];
  1450. var y = lnk.node.getSize().y;
  1451. var top = lnk.node.getPosition(this.layout.node).y;
  1452. var center = top+y/2;
  1453. var bottom = top+y;
  1454. if (top<=current && center>=current){
  1455. this.dragTargetLnk = lnk;
  1456. this.dragPosition = "before";
  1457. break;
  1458. }else if (center<=current && bottom>=current){
  1459. this.dragTargetLnk = lnk;
  1460. this.dragPosition = "after";
  1461. break;
  1462. }
  1463. }
  1464. if (!this.layout.positionNode) this.layout.positionNode = new Element("div.layout_menu_lnk_item_position")
  1465. .setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex())
  1466. .inject(this.layout.node);
  1467. this.layout.positionNode.show();
  1468. if (!this.dragTargetLnk){
  1469. this.dragTargetLnk = this.layout.lnks[this.layout.lnks.length-1];
  1470. this.dragPosition = "after";
  1471. }
  1472. this.layout.positionNode.position({
  1473. relativeTo: this.dragTargetLnk.node,
  1474. position: (this.dragPosition=="before") ? 'topcenter' : 'bottomcenter',
  1475. edge: 'center'
  1476. });
  1477. }
  1478. }
  1479. if (this.dragStatus == "group"){
  1480. this.checkDargOver(dragging);
  1481. if (!this.overItem){
  1482. this.checkDargPosition(dragging);
  1483. }
  1484. }
  1485. },
  1486. checkDargOver: function(dragging){
  1487. var p = dragging.getPosition();
  1488. var s = dragging.getSize();
  1489. var x = p.x+s.x/2-1;
  1490. var y = p.y+s.y/2-1;
  1491. var ex = x+2;
  1492. var ey = y+2;
  1493. var overItem = null;
  1494. this.menu.items.each(function(item){
  1495. if (!item.isDrag){
  1496. if (item.iconAreaNode.isInPointInRect(x,y,ex,ey)){
  1497. item.dragOver();
  1498. overItem = item;
  1499. }else{
  1500. item.dragOut();
  1501. }
  1502. }
  1503. });
  1504. this.overItem = overItem;
  1505. },
  1506. checkDargPosition: function(dragging){
  1507. var p = dragging.getPosition();
  1508. var s = dragging.getSize();
  1509. 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 };
  1510. var leftP = { "x": p.x, "y": p.y+s.y/2-1, "ex": p.x+2, "ey": p.y+s.y/2+1 };
  1511. var moveFlag = false;
  1512. for (var i = 0; i<this.menu.items.length; i++){
  1513. var item = this.menu.items[i];
  1514. if (!item.isDrag){
  1515. if (item.iconAreaNode.isInPointInRect(rightP.x, rightP.y, rightP.ex, rightP.ey)){
  1516. moveFlag = true;
  1517. this.node.inject(item.node, "before");
  1518. break;
  1519. }else if (item.iconAreaNode.isInPointInRect(leftP.x, leftP.y, leftP.ex, leftP.ey)){
  1520. moveFlag = true;
  1521. this.node.inject(item.node, "after");
  1522. break;
  1523. }
  1524. }
  1525. }
  1526. //if (!moveFlag) this.node.inject(this.menu.appContentNode);
  1527. },
  1528. _drag_enter: function(el, inObj){
  1529. if (inObj.hasClass("layout_start_content_appContent")){
  1530. this.dragStatus = "group";
  1531. this.node.setStyle("opacity", 0);
  1532. }else{
  1533. this.dragStatus = "order";
  1534. this.node.setStyle("opacity", 1);
  1535. }
  1536. },
  1537. _drag_leave: function(el, inObj){
  1538. if (inObj.hasClass("layout_start_content_appContent")){
  1539. this.node.inject(this.menu.appContentNode);
  1540. }else{
  1541. this.dragStatus = "remove";
  1542. if (this.layout.positionNode) this.layout.positionNode.hide();
  1543. }
  1544. },
  1545. _drag_drop: function(dragging, inObj){
  1546. if (this.dragStatus == "order" && this.dragTargetLnk && this.dragTargetLnk!=this){
  1547. this.addLnk(this.dragTargetLnk, this.dragPosition);
  1548. }
  1549. this.node.setStyle("opacity", 1);
  1550. this.menu.resetMenuData();
  1551. },
  1552. _drag_cancel: function(dragging){
  1553. dragging.hide();
  1554. if (this.layout.positionNode) this.layout.positionNode.hide();
  1555. if (this.dragRemoveNode) this.dragRemoveNode.hide();
  1556. this.node.setStyle("opacity", 1);
  1557. this.isDrag = false;
  1558. this.menu.resetMenuData();
  1559. },
  1560. _drag_complete: function(dragging){
  1561. this._drag_cancel(dragging);
  1562. }
  1563. });
  1564. o2.xDesktop.Default.StartMenu.PortalItem = new Class({
  1565. Extends: o2.xDesktop.Default.StartMenu.Item,
  1566. loadIcon: function(){
  1567. var icon = "";
  1568. var bgcolor = "";
  1569. if (this.data.icon){
  1570. icon = "data:image/png;base64,"+this.data.icon+"";
  1571. }else{
  1572. var p = "portalDefault";
  1573. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  1574. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  1575. bgcolor = this.layout.iconsJson[p].color;
  1576. }else{
  1577. icon = "../x_component_portal_PortalExplorer/$Main/default/icon/application.png";
  1578. bgcolor = "";
  1579. }
  1580. }
  1581. if (icon && bgcolor){
  1582. this.iconNode.addClass("layout_start_item_icon_flat");
  1583. this.iconNode.setStyle("background-color", bgcolor);
  1584. }
  1585. this.iconNode.setStyle("background-image", "url("+icon+")");
  1586. this.icon = icon;
  1587. },
  1588. loadText: function(){
  1589. this.textNode.set("text", this.data.name);
  1590. },
  1591. addLnk: function(dragTargetLnk, dragPosition){
  1592. var options = {"portalId": this.data.id, "appId": "portal.Portal"+this.data.id};
  1593. lnkdata = {
  1594. "name": "portal.Portal",
  1595. "title": this.data.name,
  1596. "iconData": (this.data.icon) || "",
  1597. "icon": null,
  1598. "appType": "portal",
  1599. "options": options
  1600. }
  1601. this.layout.addLnk(lnkdata, dragTargetLnk, dragPosition);
  1602. },
  1603. open: function(e){
  1604. var options = {"portalId": this.data.id, "appId": "portal.Portal"+this.data.id};
  1605. layout.openApplication(e, "portal.Portal", options);
  1606. }
  1607. // makeLnk: function(){
  1608. // //@todo
  1609. // // this.node.makeLnk({
  1610. // // "par": {"icon": this.icon, "color": this.color, "title": this.data.title, "par": this.data.path},
  1611. // // });
  1612. // }
  1613. });
  1614. o2.xDesktop.Default.StartMenu.ProcessItem = new Class({
  1615. Extends: o2.xDesktop.Default.StartMenu.PortalItem,
  1616. loadIcon: function(){
  1617. var icon = "";
  1618. var bgcolor = "";
  1619. if (this.data.icon){
  1620. icon = "data:image/png;base64,"+this.data.icon+"";
  1621. bgcolor = "";
  1622. }else{
  1623. var p = "processDefault";
  1624. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  1625. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  1626. bgcolor = this.layout.iconsJson[p].color;
  1627. }else{
  1628. icon = "../x_component_process_ApplicationExplorer/$Main/default/icon/application.png";
  1629. bgcolor = "";
  1630. }
  1631. }
  1632. if (icon && bgcolor){
  1633. this.iconNode.addClass("layout_start_item_icon_flat");
  1634. this.iconNode.setStyle("background-color", bgcolor);
  1635. }
  1636. this.iconNode.setStyle("background-image", "url("+icon+")");
  1637. this.icon = icon;
  1638. },
  1639. addLnk: function(dragTargetLnk, dragPosition){
  1640. var options = {"id": this.data.id, "appId": "process.Application"+this.data.id};
  1641. lnkdata = {
  1642. "name": "process.Application",
  1643. "title": this.data.name,
  1644. "iconData": (this.data.icon) || "",
  1645. "icon": null,
  1646. "appType": "process",
  1647. "options": options
  1648. }
  1649. this.layout.addLnk(lnkdata, dragTargetLnk, dragPosition);
  1650. },
  1651. open: function(e){
  1652. var options = {"id": this.data.id, "appId": "process.Application"+this.data.id};
  1653. layout.openApplication(e, "process.Application", options);
  1654. }
  1655. // makeLnk: function(){
  1656. // //@todo
  1657. // // this.node.makeLnk({
  1658. // // "par": {"icon": this.icon, "color": this.color, "title": this.data.title, "par": this.data.path},
  1659. // // });
  1660. // }
  1661. });
  1662. o2.xDesktop.Default.StartMenu.InforItem = new Class({
  1663. Extends: o2.xDesktop.Default.StartMenu.PortalItem,
  1664. loadIcon: function(){
  1665. var icon = "";
  1666. var bgcolor = "";
  1667. if (this.data.appIcon){
  1668. icon = "data:image/png;base64,"+this.data.appIcon+"";
  1669. bgcolor = "";
  1670. }else{
  1671. var p = "cmsDefault";
  1672. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  1673. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  1674. bgcolor = this.layout.iconsJson[p].color;
  1675. }else{
  1676. icon = "../x_component_cms_Index/$Main/default/icon/column.png";
  1677. bgcolor = "";
  1678. }
  1679. }
  1680. if (icon && bgcolor){
  1681. this.iconNode.addClass("layout_start_item_icon_flat");
  1682. this.iconNode.setStyle("background-color", bgcolor);
  1683. }
  1684. this.iconNode.setStyle("background-image", "url("+icon+")");
  1685. this.icon = icon;
  1686. },
  1687. loadText: function(){
  1688. this.textNode.set("text", this.data.appName);
  1689. },
  1690. addLnk: function(dragTargetLnk, dragPosition){
  1691. lnkdata = {
  1692. "name": "cms.Module",
  1693. "title": this.data.appName,
  1694. "iconData": (this.data.appIcon) || "",
  1695. "icon": null,
  1696. "appType": "cms",
  1697. "options": {"columnData": this.data, "appId": "cms.Module"+this.data.id}
  1698. }
  1699. this.layout.addLnk(lnkdata, dragTargetLnk, dragPosition);
  1700. },
  1701. open: function(e){
  1702. layout.openApplication(e, "cms.Module", {"columnData": this.data, "appId": "cms.Module"+this.data.id});
  1703. }
  1704. // makeLnk: function(){
  1705. // //@todo
  1706. // // this.node.makeLnk({
  1707. // // "par": {"icon": this.icon, "color": this.color, "title": this.data.title, "par": this.data.path},
  1708. // // });
  1709. // }
  1710. });
  1711. o2.xDesktop.Default.StartMenu.QueryItem = new Class({
  1712. Extends: o2.xDesktop.Default.StartMenu.PortalItem,
  1713. loadIcon: function(){
  1714. var icon = "";
  1715. var bgcolor = "";
  1716. if (this.data.icon){
  1717. icon = "data:image/png;base64,"+this.data.icon+"";
  1718. bgcolor = "";
  1719. }else{
  1720. var p = "queryDefault";
  1721. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  1722. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  1723. bgcolor = this.layout.iconsJson[p].color;
  1724. }else{
  1725. icon = "../x_component_query_Query/$Main/appicon.png";
  1726. bgcolor = "";
  1727. }
  1728. }
  1729. if (icon && bgcolor){
  1730. this.iconNode.addClass("layout_start_item_icon_flat");
  1731. this.iconNode.setStyle("background-color", bgcolor);
  1732. }
  1733. this.iconNode.setStyle("background-image", "url("+icon+")");
  1734. this.icon = icon;
  1735. },
  1736. addLnk: function(){
  1737. lnkdata = {
  1738. "name": "query.Query",
  1739. "title": this.data.name,
  1740. "iconData": (this.data.icon)||"",
  1741. "icon": null,
  1742. "appType": "query",
  1743. "options": {"id": this.data.id, "appId": "query.Query"+this.data.id}
  1744. }
  1745. this.layout.addLnk(lnkdata, dragTargetLnk, dragPosition);
  1746. },
  1747. open: function(e){
  1748. layout.openApplication(e, "query.Query", {"id": this.data.id, "appId": "query.Query"+this.data.id});
  1749. }
  1750. // makeLnk: function(){
  1751. // //@todo
  1752. // // this.node.makeLnk({
  1753. // // "par": {"icon": this.icon, "color": this.color, "title": this.data.title, "par": this.data.path},
  1754. // // });
  1755. // }
  1756. });
  1757. o2.xDesktop.Default.TaskItem = new Class({
  1758. initialize: function(desktop, app){
  1759. this.desktop = desktop;
  1760. this.container = this.desktop.taskContentNode;
  1761. this.app = app;
  1762. this.load();
  1763. },
  1764. load: function(){
  1765. this.node = new Element("div.layout_content_taskbar_item").inject(this.container);
  1766. this.iconNode = new Element("div");
  1767. this.closeNode = new Element("div.layout_content_taskbar_item_icon", {"title": o2.LP.widget.close}).inject(this.node);
  1768. this.closeNode.addClass("icon_close");
  1769. if (this.app.options.appId==this.desktop.options.index){
  1770. this.closeNode.hide();
  1771. this.noCloseNode = true;
  1772. }
  1773. this.refreshNode = new Element("div.layout_content_taskbar_item_refresh", {"title": o2.LP.widget.refresh}).inject(this.node);;
  1774. this.refreshNode.addClass("icon_refresh");
  1775. this.refreshNode.addClass("animation_taskItemLoading");
  1776. this.actionNode = new Element("div.layout_content_taskbar_item_action").inject(this.node);;
  1777. this.actionNode.addClass("icon_taskitem_down");
  1778. this.textNode = new Element("div.layout_content_taskbar_item_text").inject(this.node);;
  1779. this.setText(this.app.options.title);
  1780. //this.desktop.checkTaskBarSize();
  1781. this.setEvent();
  1782. this.unSelected();
  1783. },
  1784. setEvent: function(){
  1785. this.textNode.addEvents({
  1786. "click": function(){
  1787. if (this.desktop.currentApp!=this.app){
  1788. if (!this.app.window){
  1789. this.desktop.apps[this.app.options.appId] = null;
  1790. layout.openApplication(null, this.app.options.name, this.app.options, this.app.options.app, false, this, false);
  1791. }else{
  1792. this.app.setCurrent();
  1793. }
  1794. }else{
  1795. // this.app.refresh();
  1796. }
  1797. }.bind(this),
  1798. "dblclick": function(){
  1799. this.app.openInNewBrowser((this.app.options.appId==this.desktop.options.index));
  1800. }.bind(this)
  1801. });
  1802. this.closeNode.addEvents({
  1803. "mouseover": function(){
  1804. // if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode_over);
  1805. }.bind(this),
  1806. "mouseout": function(){
  1807. // if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode);
  1808. }.bind(this),
  1809. "click": function(){
  1810. if (!this.app.window){
  1811. this.desktop.apps[this.app.options.appId] = null;
  1812. delete this.desktop.apps[this.app.options.appId];
  1813. this.destroy();
  1814. }else{
  1815. this.app.close();
  1816. }
  1817. }.bind(this)
  1818. });
  1819. this.refreshNode.addEvents({
  1820. "mouseover": function(){
  1821. // if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode_over);
  1822. }.bind(this),
  1823. "mouseout": function(){
  1824. // if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode);
  1825. }.bind(this),
  1826. "click": function(){
  1827. this.app.refresh();
  1828. }.bind(this)
  1829. });
  1830. this.loadTaskItemMenu();
  1831. if (this.desktop && this.desktop.checkTaskBarSize) this.desktop.checkTaskBarSize();
  1832. },
  1833. loadTaskItemMenu: function(){
  1834. if (!this.taskitemMenu){
  1835. this.taskitemMenu = new o2.xDesktop.Menu(this.actionNode, {
  1836. "event": "click", "style": "flatUser", "offsetX": -10, "offsetY":6, "container": this.node
  1837. });
  1838. this.taskitemMenu.load();
  1839. this.loadTaskItemMenuItems();
  1840. }
  1841. },
  1842. loadTaskItemMenuItems: function(){
  1843. var img = this.desktop.path+this.desktop.options.style+"/icons/menu_refresh.png";
  1844. this.taskitemMenu.addMenuItem(o2.LP.desktop.refresh, "click", function(e){this.app.refresh(e);}.bind(this), img);
  1845. this.taskitemMenu.addMenuLine();
  1846. //img = this.path+this.options.style+"/icons/logout.png";
  1847. if (this.app.options.appId!==this.desktop.options.index){
  1848. img = this.desktop.path+this.desktop.options.style+"/icons/menu_close.png";
  1849. this.taskitemMenu.addMenuItem(o2.LP.desktop.close, "click", function(){
  1850. if (!this.app.window){
  1851. this.desktop.apps[this.app.options.appId] = null;
  1852. delete this.desktop.apps[this.app.options.appId];
  1853. this.destroy();
  1854. }else{
  1855. this.app.close();
  1856. }
  1857. }.bind(this), img);
  1858. }
  1859. img = this.desktop.path+this.desktop.options.style+"/icons/menu_closeall.png";
  1860. this.taskitemMenu.addMenuItem(o2.LP.desktop.closeAll, "click", function(){
  1861. var keys = Array.clone(Object.keys(this.desktop.apps));
  1862. keys.each(function(key){
  1863. if (!this.desktop.apps[key].isIndex && !this.desktop.apps[key].options.isIndex) this.desktop.apps[key].close();
  1864. }.bind(this));
  1865. keys = null;
  1866. }.bind(this), img);
  1867. img = this.desktop.path+this.desktop.options.style+"/icons/menu_closeother.png";
  1868. this.taskitemMenu.addMenuItem(o2.LP.desktop.closeOther, "click", function(){
  1869. var keys = Array.clone(Object.keys(this.desktop.apps));
  1870. keys.each(function(key){
  1871. if (!this.desktop.apps[key].isIndex &&
  1872. !this.desktop.apps[key].options.isIndex &&
  1873. this.desktop.apps[key].options.appId!=this.app.options.appId) this.desktop.apps[key].close();
  1874. }.bind(this));
  1875. keys = null;
  1876. }.bind(this), img);
  1877. },
  1878. setText: function(str){
  1879. this.textNode.set("text", str || this.app.options.title);
  1880. },
  1881. unSelected: function(){
  1882. this.node.removeClass("mainColor_bg");
  1883. if (!this.noCloseNode) {
  1884. this.closeNode.addClass("icon_close");
  1885. this.closeNode.removeClass("icon_close_focus");
  1886. //this.closeNode.hide();
  1887. }
  1888. if (this.refreshNode) this.refreshNode.hide();
  1889. if (this.actionNode) this.actionNode.hide();
  1890. },
  1891. selected: function(){
  1892. this.node.addClass("mainColor_bg");
  1893. if (!this.noCloseNode){
  1894. this.closeNode.removeClass("icon_close");
  1895. this.closeNode.addClass("icon_close_focus");
  1896. //this.closeNode.show();
  1897. }
  1898. this.desktop.checkTaskBarScrollTo(this.app);
  1899. //this.refreshNode.show();
  1900. if (this.actionNode) this.actionNode.show();
  1901. },
  1902. destroy: function(){
  1903. this.iconNode.destroy();
  1904. this.node.destroy();
  1905. if (this.desktop && this.desktop.checkTaskBarSize) this.desktop.checkTaskBarSize();
  1906. if (this.app.options && this.app.options.appId) delete this.desktop.apps[this.app.options.appId];
  1907. o2.release(this);
  1908. },
  1909. setTaskitemSize: function(){
  1910. this.desktop.checkTaskBarSize();
  1911. this.desktop.checkTaskBarScrollTo();
  1912. }
  1913. });
  1914. o2.xDesktop.Default.Lnk = new Class({
  1915. initialize: function(layout, data, targetLnk, position){
  1916. this.layout = layout;
  1917. this.container = this.layout.lnkAreaNode;
  1918. this.data = data;
  1919. this.load(targetLnk, position);
  1920. },
  1921. load: function(targetLnk, position){
  1922. this.node = new Element("div.layout_menu_lnk_item");
  1923. if (targetLnk){
  1924. if (!position) position = "before";
  1925. this.node.inject(targetLnk.node, position);
  1926. }else{
  1927. this.node.inject(this.container);
  1928. }
  1929. this.iconNode = new Element("div.layout_menu_lnk_item_icon").inject(this.node);
  1930. this.textNode = new Element("div.layout_menu_lnk_item_text", {"text": this.data.title}).inject(this.node);
  1931. this.actionNode = new Element("div.layout_menu_lnk_item_action", {"title": o2.LP.desktop.deleteLnk}).inject(this.node);
  1932. this.actionNode.addClass("icon_off_light");
  1933. var icon = this.getIcon();
  1934. this.iconNode.setStyle("background-image", "url("+icon+")");
  1935. this.setEvent();
  1936. },
  1937. setEvent: function(){
  1938. this.node.addEvents({
  1939. "click": function(){
  1940. if (this.data.name=="Homepage"){
  1941. var name = this.data.name;
  1942. var options = this.data.options;
  1943. if (layout.config.indexPage && layout.config.indexPage.enable && layout.config.indexPage.portal){
  1944. name = "portal.Portal";
  1945. var appId = "portal.Portal"+layout.config.indexPage.portal;
  1946. options = {"name": "portal.Portal", "portalId": layout.config.indexPage.portal, "pageId": layout.config.indexPage.page, "appId": appId};
  1947. }
  1948. layout.openApplication(null, name, options);
  1949. }else{
  1950. layout.openApplication(null, this.data.name, this.data.options);
  1951. }
  1952. }.bind(this),
  1953. "mouseover": function(){
  1954. this.actionNode.fade("in");
  1955. this.node.addClass("overColor_bg");
  1956. this.textNode.fade("in");
  1957. }.bind(this),
  1958. "mouseout": function(){
  1959. this.actionNode.fade("out");
  1960. this.node.removeClass("overColor_bg");
  1961. this.textNode.fade("out");
  1962. }.bind(this)
  1963. });
  1964. this.actionNode.addEvents({
  1965. "click": function(e){
  1966. this.destroy();
  1967. e.stopPropagation();
  1968. }.bind(this),
  1969. "mouseover": function(){
  1970. this.actionNode.addClass("layout_menu_lnk_item_action_shadow");
  1971. }.bind(this),
  1972. "mouseout": function(){
  1973. this.actionNode.removeClass("layout_menu_lnk_item_action_shadow");
  1974. }.bind(this)
  1975. });
  1976. var drag = new Drag(this.node, {
  1977. "stopPropagation": true,
  1978. "compensateScroll": true,
  1979. "onStart": function(el, e){
  1980. this.doDragMove(e);
  1981. drag.stop();
  1982. }.bind(this)
  1983. });
  1984. },
  1985. getDragNode: function(){
  1986. if (!this.dragNode){
  1987. this.dragNode = new Element("div.layout_menu_lnk_item_drag")
  1988. .setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex())
  1989. .inject(this.layout.node);
  1990. var dragIconNode = this.iconNode.clone(true).inject(this.dragNode)
  1991. .removeClass("layout_menu_lnk_item_icon")
  1992. .addClass("layout_menu_lnk_item_icon_drag");
  1993. var p = (this.data.appType) ? this.data.appType+"Default" : this.data.name;
  1994. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].color){
  1995. dragIconNode.setStyle("background-color", this.layout.iconsJson[p].color)
  1996. }
  1997. this.dragRemoveNode = new Element("div.layout_menu_lnk_item_icon_drag_del").inject(this.dragNode)
  1998. .addClass("icon_remove_badge")
  1999. .hide();
  2000. }
  2001. var ps = this.iconNode.getPosition(this.dragNode.getOffsetParent());
  2002. this.dragNode.show().setStyles({
  2003. "left": ""+ps.x+"px", "top": ""+ps.y+"px"
  2004. });
  2005. },
  2006. doDragMove: function(e){
  2007. this.getDragNode();
  2008. var drag = new Drag.Move(this.dragNode, {
  2009. "stopPropagation": true,
  2010. "compensateScroll": true,
  2011. "droppables": [this.container.getParent()],
  2012. "onStart": function(){ this._drag_start(); }.bind(this),
  2013. "onDrag": function(dragging,e){ this._drag_drag(dragging, e); }.bind(this),
  2014. "onEnter": function(dragging, inObj){ this._drag_enter(dragging, inObj); }.bind(this),
  2015. "onLeave": function(dragging, obj){ this._drag_leave(dragging, obj); }.bind(this),
  2016. "onDrop": function(dragging, inObj){ this._drag_drop(dragging, inObj); }.bind(this),
  2017. "onCancel": function(dragging){ this._drag_cancel(dragging); }.bind(this),
  2018. "onComplete": function(dragging, e){ this._drag_complete(dragging, e); }.bind(this),
  2019. });
  2020. drag.start(e);
  2021. this.dragStatus = "order";
  2022. },
  2023. _drag_start: function(){
  2024. this.node.addClass("overColor_bg");
  2025. this.node.addClass("opacity50");
  2026. this.dragTargetLnk = null;
  2027. this.dragPosition = "before";
  2028. },
  2029. _drag_drag: function(dragging, e){
  2030. if (this.dragStatus == "order"){
  2031. if (this.layout.lnks && this.layout.lnks.length){
  2032. var current = e.page.y;
  2033. for (var i=0; i<this.layout.lnks.length; i++){
  2034. var lnk = this.layout.lnks[i];
  2035. var y = lnk.node.getSize().y;
  2036. var top = lnk.node.getPosition(this.layout.node).y;
  2037. var center = top+y/2;
  2038. var bottom = top+y;
  2039. if (top<=current && center>=current){
  2040. this.dragTargetLnk = lnk;
  2041. this.dragPosition = "before";
  2042. break;
  2043. }else if (center<=current && bottom>=current){
  2044. this.dragTargetLnk = lnk;
  2045. this.dragPosition = "after";
  2046. break;
  2047. }
  2048. }
  2049. if (!this.layout.positionNode) this.layout.positionNode = new Element("div.layout_menu_lnk_item_position")
  2050. .setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex())
  2051. .inject(this.layout.node);
  2052. this.layout.positionNode.show();
  2053. if (!this.dragTargetLnk){
  2054. this.dragTargetLnk = this.layout.lnks[this.layout.lnks.length-1];
  2055. this.dragPosition = "after";
  2056. }
  2057. this.layout.positionNode.position({
  2058. relativeTo: this.dragTargetLnk.node,
  2059. position: (this.dragPosition=="before") ? 'topcenter' : 'bottomcenter',
  2060. edge: 'center'
  2061. });
  2062. }
  2063. }
  2064. },
  2065. _drag_enter: function(){
  2066. this.dragStatus = "order";
  2067. if (this.dragRemoveNode) this.dragRemoveNode.hide();
  2068. },
  2069. _drag_leave: function(){
  2070. this.dragStatus = "remove";
  2071. if (this.dragRemoveNode) this.dragRemoveNode.show();
  2072. if (this.layout.positionNode) this.layout.positionNode.hide();
  2073. },
  2074. _drag_drop: function(dragging, inObj){
  2075. if (this.dragStatus == "order" && this.dragTargetLnk && this.dragTargetLnk!=this){
  2076. this.node.inject(this.dragTargetLnk.node, this.dragPosition);
  2077. this.layout.lnks.erase(this);
  2078. var idx = this.layout.lnks.indexOf(this.dragTargetLnk);
  2079. if (this.dragPosition=="before"){
  2080. this.layout.lnks.splice(idx, 0, this);
  2081. }else{
  2082. this.layout.lnks.splice(idx+1, 0, this);
  2083. }
  2084. }
  2085. },
  2086. _drag_cancel: function(dragging){
  2087. dragging.hide();
  2088. if (this.node) {
  2089. this.node.removeClass("overColor_bg");
  2090. this.node.removeClass("opacity50");
  2091. }
  2092. if (this.layout.positionNode) this.layout.positionNode.hide();
  2093. if (this.dragRemoveNode) this.dragRemoveNode.hide();
  2094. },
  2095. _drag_complete: function(dragging){
  2096. if (this.dragStatus == "remove"){
  2097. this.destroy();
  2098. }else{
  2099. this._drag_cancel(dragging);
  2100. }
  2101. },
  2102. destroy: function(){
  2103. this.layout.lnks.erase(this);
  2104. if (this.dragNode) this.dragNode.destroy();
  2105. //if (this.positionNode) this.positionNode.destroy();
  2106. this.node.destroy();
  2107. o2.release(this);
  2108. },
  2109. getIcon: function(){
  2110. if (this.data.icon) return this.data.icon;
  2111. var icon;
  2112. if (this.data.name.substring(0, 4)==="@url"){
  2113. if (this.layout.iconsJson["Url"] && this.layout.iconsJson["Url"].icon){
  2114. icon = this.layout.path+"appicons/"+this.layout.iconsJson["Url"].icon;
  2115. }else{
  2116. icon = this.layout.path+"appicons/url.png";
  2117. }
  2118. }else{
  2119. if (this.data.iconData){
  2120. icon = "data:image/png;base64,"+this.data.iconData+"";
  2121. }else if (this.data.iconPath){
  2122. icon = this.data.iconPath;
  2123. }else{
  2124. var p = (this.data.appType) ? this.data.appType+"Default" : this.data.name;
  2125. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  2126. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  2127. }else{
  2128. icon = "../x_component_"+this.data.name.replace(/\./g, "_")+"/$Main/appicon.png";
  2129. }
  2130. }
  2131. }
  2132. return icon;
  2133. }
  2134. });
  2135. o2.xDesktop.zIndexPool = {
  2136. zIndex: 102,
  2137. applyZindex: function(){
  2138. var i = this.zIndex;
  2139. this.zIndex = this.zIndex+2;
  2140. return i;
  2141. }
  2142. };