Default.js 81 KB

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