Default.js 79 KB

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