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