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