Default.js 78 KB

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