Default.js 82 KB

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