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