Default.js 80 KB

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