Default.js 108 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738
  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. this.menuData = this.status.menuData;
  265. var keys = Object.keys(this.status.apps);
  266. if (this.status.apps && keys.length){
  267. if (this.status.currentApp == "Note"){
  268. var idx = keys.length-1;
  269. while (idx>-1 && keys[idx]=="Note") idx--;
  270. this.status.currentApp = (idx>-1) ? this.status.apps[keys[idx]].appId : "";
  271. }
  272. var currentTaskitem = null;
  273. Object.each(this.status.apps, function(appStatus, id){
  274. var app = {
  275. "options": appStatus,
  276. "close": function(){
  277. this.taskitem.destroy();
  278. },
  279. "setCurrent": function(){
  280. if (this.taskitem.textNode) this.taskitem.textNode.click();
  281. }
  282. };
  283. taskitem = layout.desktop.createTaskItem(app);
  284. app.taskitem = taskitem;
  285. this.apps[appStatus.appId] = app;
  286. if ((this.status.currentApp === appStatus.appId)) currentTaskitem=taskitem;
  287. }.bind(this));
  288. if (currentTaskitem) {
  289. currentTaskitem.textNode.click();
  290. }
  291. }
  292. if (this.status.widgets){/* nothing to do */}
  293. if (this.status.flatLnks && this.status.flatLnks.length){
  294. this.status.flatLnks.each(function(lnkJson){
  295. this.addLnk(lnkJson);
  296. }.bind(this));
  297. }
  298. }
  299. },
  300. addLnk: function(lnkData, targetLnk, position){
  301. var lnk = new o2.xDesktop.Default.Lnk(this, lnkData, targetLnk, position);
  302. if (targetLnk){
  303. var idx = this.lnks.indexOf(targetLnk);
  304. if (position=="before"){
  305. this.lnks.splice(idx, 0, lnk);
  306. }else{
  307. this.lnks.splice(idx+1, 0, lnk);
  308. }
  309. }else{
  310. this.lnks.push(lnk);
  311. }
  312. },
  313. openWebSocket: function(){
  314. MWF.require("MWF.xDesktop.WebSocket", function(){
  315. this.socket = new MWF.xDesktop.WebSocket();
  316. }.bind(this));
  317. },
  318. closeWebSocket: function(){
  319. if (this.socket) this.socket.close();
  320. },
  321. //******* begin page skin ****************************************************
  322. loadSkinMenu: function(){
  323. if (!this.styleMenu){
  324. this.styleMenu = new o2.xDesktop.Menu(this.skinActionNode, {
  325. "event": "click", "style": "flatStyle", "offsetX": -10, "offsetY": 26, "container": this.node,
  326. "onQueryShow": this.showSkinMenu.bind(this),
  327. "onQueryHide": function(){
  328. this.skinActionNode.removeClass("icon_skin_focus");
  329. this.skinActionNode.removeClass("mainColor_bg");
  330. }.bind(this)
  331. });
  332. this.styleMenu.load();
  333. this.loadSkinMenuItems();
  334. }
  335. },
  336. showSkinMenu: function(){
  337. this.styleMenu.items.each(function(item){
  338. if (this.options.style==item.styleName){
  339. item.setDisable(true);
  340. if (item.text) item.text.setStyles({ "background": "url("+this.path+this.options.style+"/icons/icon_gouxuan.png) right center no-repeat" });
  341. }else{
  342. item.setDisable(false);
  343. if (item.text) item.text.setStyles({ "background": "transparent" });
  344. }
  345. }.bind(this));
  346. this.skinActionNode.addClass("icon_skin_focus");
  347. this.skinActionNode.addClass("mainColor_bg");
  348. },
  349. loadSkinMenuItems: function(){
  350. o2.JSON.get(this.path+"styles.json", function(json){
  351. json.each(function(style){
  352. var color = style.color;
  353. var memuItem = this.styleMenu.addMenuItem(style.title, "click", function(){this.changeLayoutSkin(style.style);}.bind(this));
  354. memuItem.styleName = style.style;
  355. var imgDiv = memuItem.item.getFirst();
  356. var imgNode = new Element("div", {"styles": memuItem.menu.css.menuItemImg}).inject(imgDiv);
  357. imgNode.setStyle("background-color", color);
  358. }.bind(this));
  359. this.styleMenu.addMenuLine();
  360. var img = o2.defaultPath+"/xDesktop/$Layout/default/preview.jpg";
  361. var memuItem = this.styleMenu.addMenuItem(o2.LP.desktop_style, "click", function(e){this.changeToDesktopStyle(e);}.bind(this), img);
  362. memuItem.styleName = "desktop";
  363. }.bind(this));
  364. },
  365. changeLayoutSkin: function(style){
  366. var skinCss = this.path+this.options.style+ "/style-skin.css";
  367. o2.removeCss(skinCss);
  368. this.options.style = style;
  369. skinCss = this.path+this.options.style+"/style-skin.css";
  370. this.node.loadCss(skinCss);
  371. },
  372. changeToDesktopStyle: function(e){
  373. //MWF.xDesktop.confirm("infor", e, o2.LP.desktop.changeViewTitle, {"html": o2.LP.desktop.changeView}, 500, 100, function(){
  374. // this.close();
  375. var uri = new URI(window.location.href);
  376. uri.setData("view", "layout");
  377. uri.go();
  378. // }, function(){
  379. // this.close();
  380. // }, null, null, "o2"
  381. // );
  382. },
  383. //******* end page skin ****************************************************
  384. //******* begin user menu ****************************************************
  385. loadUserMenu: function(){
  386. if (!this.userMenu){
  387. this.userMenu = new o2.xDesktop.Menu(this.userInforNode, {
  388. "event": "click", "style": "flatUser", "offsetX": 30, "offsetY":6, "container": this.node
  389. // "onQueryShow": this.showSkinMenu.bind(this),
  390. // "onQueryHide": function(){
  391. // this.skinActionNode.removeClass("icon_skin_focus");
  392. // this.skinActionNode.removeClass("mainColor_bg");
  393. // }.bind(this),
  394. });
  395. this.userMenu.load();
  396. this.loadUserMenuItems();
  397. }
  398. },
  399. loadUserMenuItems: function(){
  400. var img = this.path+this.options.style+"/icons/config.png";
  401. this.userMenu.addMenuItem(o2.LP.desktop.userConfig, "click", function(e){this.userConfig(e);}.bind(this), img);
  402. this.userMenu.addMenuLine();
  403. img = this.path+this.options.style+"/icons/logout.png";
  404. this.userMenu.addMenuItem(o2.LP.desktop.logout, "click", function(){this.logout();}.bind(this), img);
  405. },
  406. userConfig: function(e){
  407. layout.openApplication(e, "Profile");
  408. },
  409. logout: function(){
  410. this.isLogout = true;
  411. if (!this.notRecordStatus){
  412. this.recordDesktopStatus(function(){
  413. (layout.authentication || new o2.xDesktop.Authentication()).logout();
  414. }.bind(this.layout));
  415. }else{
  416. (layout.authentication || new o2.xDesktop.Authentication()).logout();
  417. }
  418. },
  419. //******* end user menu ****************************************************
  420. //******* begin search *****************************************************
  421. focusSearch: function(){
  422. this.searchBoxNode.addClass("layout_content_taskbar_area_search_box_focus");
  423. this.searchBoxNode.addClass("mainColor_border");
  424. this.searchIconNode.addClass("icon_search_focus");
  425. },
  426. blurSearch: function(){
  427. this.searchBoxNode.removeClass("layout_content_taskbar_area_search_box_focus");
  428. this.searchBoxNode.removeClass("mainColor_border");
  429. this.searchIconNode.removeClass("icon_search_focus");
  430. },
  431. searchInputKeyDown: function(e){
  432. if (this.searchInputNode.get("value")){
  433. this.searchClearNode.addClass("icon_clear");
  434. }else{
  435. this.searchClearNode.removeClass("icon_clear");
  436. }
  437. if (e.keyCode===13) this.doSearch();
  438. },
  439. clearSearch: function(){
  440. this.searchInputNode.set("value", "");
  441. this.searchClearNode.removeClass("icon_clear");
  442. this.clearSearchResult();
  443. },
  444. doSearch: function(){
  445. var key = this.searchInputNode.get("value");
  446. if (key){
  447. if (this.apps["Search"]){
  448. this.apps["Search"].input.setValue(key);
  449. this.apps["Search"].input.doSearch();
  450. }
  451. layout.openApplication(null,"Search", {"key": key});
  452. }
  453. },
  454. clearSearchResult: function(){
  455. //alert("clear search result");
  456. // @todo
  457. },
  458. //******* end search*******************************************************
  459. //******* begin record status *********************************************
  460. recordDesktopStatus: function(callback){
  461. Object.each(this.apps, function(app, id){
  462. if (!app.options.desktopReload){
  463. this.closeApp(app);
  464. }
  465. }.bind(this));
  466. var status = this.getLayoutStatusData();
  467. // if (navigator.sendBeacon) {
  468. // var obj = this.personalAction.action.actions["putUserData"];
  469. // var url = this.personalAction.action.address + obj.uri;
  470. // url = url.replace("{name}", "layout");
  471. // navigator.sendBeacon(url, status);
  472. // } else {
  473. try{
  474. o2.UD.putData("layout", status, function(){
  475. if (callback) callback();
  476. });
  477. }catch(e){};
  478. // }
  479. },
  480. getLayoutStatusData: function(){
  481. var status = {
  482. "viewMode": "Default",
  483. "style": this.status.style,
  484. "flatStyle": this.options.style,
  485. "styleType": this.status.styleType || "",
  486. "currentApp": (this.currentApp) ? this.currentApp.appId : "Homepage",
  487. "apps": {},
  488. "lnks": (this.status.lnks && o2.typeOf(this.status.lnks)==="array") ? this.status.lnks : [],
  489. //"lnks": [],
  490. "flatLnks": [],
  491. "widgets": {},
  492. "menuData": this.menuData
  493. };
  494. // this.appArr.each(function(app){
  495. // if (app.options.appId!==this.options.index){
  496. // var appStatus = this.getAppStatusData(app, app.appId);
  497. // if (appStatus) status.apps[id] = appStatus;
  498. // }
  499. // }.bind(this));
  500. Object.each(this.apps, function(app, id){
  501. if (app.options.appId!==this.options.index){
  502. var appStatus = this.getAppStatusData(app, id);
  503. if (appStatus) status.apps[id] = appStatus;
  504. }
  505. if (app.isIndex){
  506. if (!status.apps[id]) status.apps[id] = {};
  507. status.apps[id].isIndex = true;
  508. }
  509. }.bind(this));
  510. this.lnks.each(function(lnk){
  511. status.flatLnks.push(lnk.data);
  512. //status.flatLnks.push({"icon": lnk.icon, "color": lnk.color, "title": lnk.title,"par": lnk.par});
  513. });
  514. Object.each(this.widgets, function(widget, id){
  515. var widgetStatus = this.getWidgetStatusData(widget, id);
  516. if (widgetStatus) status.widgets[id] = widgetStatus;
  517. }.bind(this));
  518. return status;
  519. },
  520. getAppStatusData: function(app, id){
  521. var appStatus = null;
  522. if (app.window){
  523. if (app.options.desktopReload){
  524. appStatus ={
  525. "appId": app.appId,
  526. "name": app.options.name,
  527. "style": app.options.style,
  528. "title": app.options.title,
  529. "window": {
  530. // //"size": app.window.node.getSize(),
  531. // "size": {"x": app.window.css.to.width.toFloat(), "y": app.window.css.to.height.toFloat()},
  532. // "position": {"x": app.window.css.to.left.toFloat(), "y": app.window.css.to.top.toFloat()},
  533. // "isMax": app.window.isMax,
  534. // "isHide": app.window.isHide,
  535. // "style": app.window.options.style
  536. },
  537. "app": null
  538. };
  539. if (app.recordStatus) appStatus.app = app.recordStatus();
  540. }
  541. }else{
  542. if (app.options){
  543. appStatus = app.options;
  544. }
  545. }
  546. return appStatus;
  547. },
  548. getWidgetStatusData: function(widget, id){
  549. var widgetStatus ={
  550. "name": widget.options.name,
  551. "appName": widget.options.appName,
  552. "position": widget.options.position,
  553. "widget": null
  554. };
  555. if (widget.recordStatus) widgetStatus.widget = widget.recordStatus();
  556. return widgetStatus;
  557. },
  558. //******* end record status ***********************************************
  559. //******* begin start menu ************************************************
  560. showStartMenu: function(){
  561. this.loadStartMenu(function(){
  562. if (!this.startMenu.isShow){
  563. this.startMenuNode.addClass("overColor_bg");
  564. this.startMenu.show();
  565. }
  566. }.bind(this));
  567. },
  568. loadStartMenu: function(callback){
  569. if (!this.startMenu){
  570. this.startMenu = new o2.xDesktop.Default.StartMenu(this);
  571. this.startMenu.addEvents({
  572. "onHide": function(){
  573. this.startMenuNode.removeClass("overColor_bg");
  574. }.bind(this),
  575. "onLoad": function(){
  576. if (callback) callback();
  577. }
  578. });
  579. this.startMenu.load();
  580. }else{
  581. if (this.startMenu.isLoaded) if (callback) callback();
  582. }
  583. },
  584. //******* end start menu **************************************************
  585. //******* begin message menu **********************************************
  586. showDesktopMessage: function(){
  587. if (!this.message){
  588. this.loadMessageMenu(function(){
  589. this.showMessage();
  590. }.bind(this));
  591. }else{
  592. this.showMessage();
  593. }
  594. },
  595. loadMessageMenu: function(callback){
  596. o2.require("o2.xDesktop.MessageV2", function(){
  597. this.message = new o2.xDesktop.MessageV2(this);
  598. this.message.addEvents({
  599. "onLoad": function(){ if (callback) callback(); }.bind(this),
  600. "onHide": function(){
  601. this.msgActionNode.removeClass("icon_msg_focus");
  602. this.msgActionNode.removeClass("mainColor_bg");
  603. }.bind(this),
  604. });
  605. this.message.load();
  606. }.bind(this));
  607. },
  608. showMessage: function(){
  609. if (!this.message.isShow){
  610. this.msgActionNode.addClass("icon_msg_focus");
  611. this.msgActionNode.addClass("mainColor_bg");
  612. this.message.show();
  613. }
  614. },
  615. //******* end message menu ************************************************
  616. //******* begin task item *************************************************
  617. createTaskItem: function(app){
  618. return new o2.xDesktop.Default.TaskItem(this, app);
  619. },
  620. //******* end task item ***************************************************
  621. closeApp: function(app, hasTaskitem) {
  622. var appId = app.appId;
  623. this.appCurrentList.erase(app);
  624. this.appArr.erase(app);
  625. this.apps[appId] = null;
  626. delete this.apps[appId];
  627. if (!hasTaskitem){
  628. var i = this.appCurrentList.length;
  629. if (i && this.appCurrentList[i-1]){
  630. this.appCurrentList[i-1].setCurrent();
  631. }else{
  632. var keys = Object.keys(this.apps);
  633. i = keys.length;
  634. if (i && this.apps[keys[i-1]] && this.apps[keys[i-1]].setCurrent){
  635. this.apps[keys[i-1]].setCurrent();
  636. }else{
  637. //if (app.appId!=="Homepage") layout.openApplication(null, "Homepage");
  638. layout.openApplication(null, "Homepage");
  639. }
  640. }
  641. this.checkTaskBarSize();
  642. this.checkTaskBarScrollTo();
  643. }
  644. },
  645. refreshApp:function(app){
  646. if (app.window){
  647. var taskitem = app.taskitem;
  648. var appStatus ={
  649. "id": app.appId,
  650. "name": app.options.name,
  651. "style": app.options.style,
  652. "appId": app.appId
  653. };
  654. var status = (app.recordStatus) ? app.recordStatus() : null;
  655. app.close(true);
  656. layout.openApplication(null, appStatus.name, appStatus, status, false, taskitem);
  657. //this.openApplicationWithStatus(appStatus);
  658. }
  659. },
  660. getPageDesignerStyle: function(callback){
  661. if (!this.pageDesignerStyle){
  662. this.pageDesignerStyle = "default";
  663. MWF.UD.getData("pageDesignerStyle", function(json) {
  664. if (json.data) {
  665. var styles = JSON.decode(json.data);
  666. this.pageDesignerStyle = styles.style;
  667. }
  668. if (callback) callback();
  669. }.bind(this));
  670. }else{
  671. if (callback) callback();
  672. }
  673. },
  674. getFormDesignerStyle: function(callback){
  675. if (!this.formDesignerStyle){
  676. this.formDesignerStyle = "default";
  677. MWF.UD.getData("formDesignerStyle", function(json) {
  678. if (json.data) {
  679. var styles = JSON.decode(json.data);
  680. this.formDesignerStyle = styles.style;
  681. }
  682. if (callback) callback();
  683. }.bind(this));
  684. }else{
  685. if (callback) callback();
  686. }
  687. },
  688. createRefreshNode: function(){
  689. this.refreshNode = new Element("div.layout_refresh_node.icon_refresh").inject(this.desktopNode);
  690. this.refreshNode.set("morph", {
  691. "duration": 100,
  692. "transition": Fx.Transitions.Quart.easeOut
  693. });
  694. this.refreshNode.addEvent("click", function(){
  695. if (this.currentApp) this.currentApp.refresh();
  696. this.hideRefresh();
  697. }.bind(this));
  698. },
  699. showRefresh: function(){
  700. if (!this.refreshNodeShow){
  701. if (!this.refreshNode) this.createRefreshNode();
  702. var size = this.taskbarNode.getSize();
  703. var nodeSize = this.refreshNode.getSize();
  704. var top = size.y;
  705. var left = size.x/2-nodeSize.x/2;
  706. this.refreshNode.setStyles({
  707. "left": left,
  708. "top": 0-nodeSize.y,
  709. "opacity": 0
  710. });
  711. this.refreshNode.morph({
  712. "top": top,
  713. "left": left,
  714. "opacity": 0.9
  715. });
  716. this.refreshNodeShow = true;
  717. this.refreshTimeoutId = window.setTimeout(function(){
  718. this.hideRefresh();
  719. }.bind(this), 2000);
  720. }
  721. },
  722. hideRefresh: function(){
  723. if (this.refreshNodeShow){
  724. if (this.refreshNode){
  725. var size = this.taskbarNode.getSize();
  726. var nodeSize = this.refreshNode.getSize();
  727. var top = size.y;
  728. var left = size.x/2-nodeSize.x/2;
  729. this.refreshNode.morph({
  730. "top": 0-nodeSize.y,
  731. "left": left,
  732. "opacity": 0
  733. });
  734. window.setTimeout(function(){
  735. this.refreshNodeShow = false;
  736. }.bind(this), 100);
  737. }
  738. }
  739. if (this.refreshTimeoutId){
  740. window.clearTimeout(this.refreshTimeoutId);
  741. this.refreshTimeoutId = "";
  742. }
  743. }
  744. });
  745. o2.xDesktop.Default.StartMenu = new Class({
  746. Implements: [Events],
  747. initialize: function(layout){
  748. this.layout = layout;
  749. this.container = this.layout.startMenuArea;
  750. this.actionNode = this.layout.startMenuNode;
  751. this.isLoaded = false;
  752. this.isShow = false;
  753. this.isMorph = false;
  754. this.items = [];
  755. this.menuData = (this.layout.status && this.layout.status.menuData) ? this.layout.status.menuData : {
  756. "appList": [],
  757. "processList": [],
  758. "inforList": [],
  759. "queryList": []
  760. };
  761. this.itemTempletedHtml = "" +
  762. " <div class='layout_start_item_iconArea'>" +
  763. " <div class='layout_start_item_icon'></div>" +
  764. " </div>" +
  765. " <div class='layout_start_item_text'></div>"+
  766. " <div class='layout_start_item_badge'></div>";
  767. },
  768. load: function(){
  769. var view = this.layout.path+this.layout.options.style+((o2.session.isMobile || layout.mobile) ? "/layout-menu-mobile.html" : "/layout-menu-pc.html");
  770. this.container.loadHtml(view, {"module": this}, function(){
  771. this.maskNode.setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex());
  772. this.node.setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex());
  773. this.layout.menuNode.setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex());
  774. this.node.addEvent("mousedown", function(e){
  775. e.stopPropagation();
  776. e.preventDefault();
  777. });
  778. this.triangleNode = new Element("div.layout_menu_start_triangle").inject(this.layout.menuNode, "after");
  779. this.hideMessage = function(){ this.hide(); }.bind(this);
  780. this.fireEvent("load");
  781. this.layout.addEvent("resize", this.setSize.bind(this));
  782. this.loadTitle();
  783. this.loadLnks();
  784. this.isLoaded = true;
  785. this.fireEvent("load");
  786. }.bind(this));
  787. },
  788. resetMenuData: function(){
  789. if (!this.menuData) this.menuData = {
  790. "appList": [],
  791. "processList": [],
  792. "inforList": [],
  793. "queryList": []
  794. }
  795. var nodes = this.appContentNode.getChildren();
  796. var data = [];
  797. nodes.each(function(node){
  798. var item = node.retrieve("item");
  799. if (item){
  800. if (item.data.type==="group"){
  801. var d = {
  802. "id": item.data.id,
  803. "name": item.data.name,
  804. "type": item.data.type,
  805. "itemDataList": []
  806. }
  807. if (item.data.itemDataList) item.data.itemDataList.each(function(i){
  808. d.itemDataList.push(i);
  809. });
  810. data.push(d);
  811. }else{
  812. data.push({
  813. "id": item.data.id,
  814. "name": item.data.name,
  815. "type": item.data.type,
  816. });
  817. }
  818. }
  819. }.bind(this));
  820. if (this.currentTab === this.appCategoryTab){
  821. this.menuData.appList = data;
  822. }else if (this.currentTab === this.processCategoryTab){
  823. this.menuData.processList = data;
  824. }else if (this.currentTab === this.inforCategoryTab){
  825. this.menuData.inforList = data;
  826. }else if (this.currentTab === this.queryCategoryTab){
  827. this.menuData.queryList = data;
  828. }
  829. this.layout.menuData = this.menuData;
  830. },
  831. setScroll: function(){
  832. o2.require("o2.widget.ScrollBar", function(){
  833. this.appScrollBar = new o2.widget.ScrollBar(this.appScrollNode, {
  834. "style":"xDesktop_Message", "where": "before", "indent": false, "distance": 100, "friction": 6, "axis": {"x": false, "y": true}
  835. });
  836. }.bind(this));
  837. },
  838. loadTitle: function(){
  839. this.lnkTitleNode.set("text", o2.LP.desktop.lnkAppTitle);
  840. this.appCategoryTab = new Element("div.layout_start_tab", {"text": o2.LP.desktop.message.application}).inject(this.appTitleNode);
  841. this.processCategoryTab = new Element("div.layout_start_tab", {"text": o2.LP.desktop.message.process}).inject(this.appTitleNode);
  842. this.inforCategoryTab = new Element("div.layout_start_tab", {"text": o2.LP.desktop.message.infor}).inject(this.appTitleNode);
  843. this.queryCategoryTab = new Element("div.layout_start_tab", {"text": o2.LP.desktop.message.query}).inject(this.appTitleNode);
  844. this.searchNode = new Element("div.layout_start_search").inject(this.appTitleNode);
  845. this.searchIconNode = new Element("div.layout_start_search_icon").inject(this.searchNode);
  846. this.searchIconNode.addClass("icon_startMenu_search");
  847. var currentWidth = this.searchNode.getSize().x;
  848. this.searchNode.store("currentWidth", currentWidth);
  849. this.appCategoryTab.addEvent("click", function(){
  850. this.appTitleNode.getElements(".layout_start_tab").removeClass("mainColor_bg");
  851. this.appCategoryTab.addClass("mainColor_bg");
  852. this.currentTab = this.appCategoryTab;
  853. this.loadApplications();
  854. }.bind(this));
  855. this.processCategoryTab.addEvent("click", function(){
  856. this.appTitleNode.getElements(".layout_start_tab").removeClass("mainColor_bg");
  857. this.processCategoryTab.addClass("mainColor_bg");
  858. this.currentTab = this.processCategoryTab;
  859. this.loadProcesses();
  860. }.bind(this));
  861. this.inforCategoryTab.addEvent("click", function(){
  862. this.appTitleNode.getElements(".layout_start_tab").removeClass("mainColor_bg");
  863. this.inforCategoryTab.addClass("mainColor_bg");
  864. this.currentTab = this.inforCategoryTab;
  865. this.loadInfors();
  866. }.bind(this));
  867. this.queryCategoryTab.addEvent("click", function(){
  868. this.appTitleNode.getElements(".layout_start_tab").removeClass("mainColor_bg");
  869. this.queryCategoryTab.addClass("mainColor_bg");
  870. this.currentTab = this.queryCategoryTab;
  871. this.loadQuerys();
  872. }.bind(this));
  873. this.searchIconNode.addEvent("click", this.searchIconAction.bind(this));
  874. },
  875. searchIconAction: function(){
  876. if (!this.isMorph){
  877. if (this.isSearch){
  878. this.doSearch();
  879. }else{
  880. this.loadSearch()
  881. }
  882. }
  883. },
  884. loadSearch: function(){
  885. this.isSearch = true;
  886. this.searchNode.addClass("mainColor_border");
  887. this.appCategoryTab.hide();
  888. this.processCategoryTab.hide();
  889. this.inforCategoryTab.hide();
  890. this.queryCategoryTab.hide();
  891. var size = this.appTitleNode.getSize();
  892. var pr = this.appTitleNode.getStyle("padding-right").toInt() || 0;
  893. var pl = this.appTitleNode.getStyle("padding-left").toInt() || 0;
  894. var margin = this.searchNode.getStyle("margin-right").toInt() || 0;
  895. var w = size.x-margin*2-pr-pl;
  896. this.isMorph = true;
  897. this.searchNode.set("morph", {"duration": 200});
  898. this.searchNode.morph({"width": ""+w+"px"});
  899. window.setTimeout(function(){
  900. this.isMorph = false;
  901. }.bind(this), 220);
  902. if (!this.searchClearNode){
  903. this.searchClearNode = new Element("div.layout_start_search_clear").inject(this.searchNode);
  904. this.searchClearNode.addClass("icon_clear");
  905. this.searchClearNode.addEvent("click", this.hideSearch.bind(this));
  906. }
  907. this.searchClearNode.show();
  908. if (!this.searchAreaNode) this.searchAreaNode = new Element("div.layout_start_search_area").inject(this.searchNode);
  909. this.searchAreaNode.show();
  910. if (!this.searchInputNode){
  911. this.searchInputNode = new Element("input.layout_start_search_input", {"placeholder": o2.LP.searchKey}).inject(this.searchAreaNode);
  912. this.searchInputNode.addEvent("keydown", function(e){
  913. if (e.code==13) this.doSearch();
  914. }.bind(this));
  915. }
  916. this.searchInputNode.show();
  917. this.searchInputNode.focus();
  918. //this.searchNode.addClass("layout_start_search_load");
  919. },
  920. hideSearch: function(){
  921. if (this.isSearch){
  922. if (this.searchInputNode){
  923. this.searchInputNode.set("value", "");
  924. this.searchInputNode.hide();
  925. }
  926. if (this.searchAreaNode) this.searchAreaNode.hide();
  927. if (this.searchClearNode) this.searchClearNode.hide();
  928. this.isMorph = true;
  929. var currentWidth = this.searchNode.retrieve("currentWidth");
  930. this.searchNode.morph({"width": ""+currentWidth+"px"});
  931. window.setTimeout(function(){
  932. if (this.currentTab && this.isSearchResult) this.currentTab.click();
  933. this.searchNode.removeClass("mainColor_border");
  934. this.appCategoryTab.show();
  935. this.processCategoryTab.show();
  936. this.inforCategoryTab.show();
  937. this.queryCategoryTab.show();
  938. this.isSearch = false;
  939. this.isMorph = false;
  940. this.isSearchResult = false;
  941. }.bind(this), 220);
  942. }
  943. },
  944. doSearch: function(){
  945. var key = this.searchInputNode.get("value").toLowerCase();
  946. if (key){
  947. this.isSearchResult = true;
  948. this.appContentNode.empty();
  949. this.searchApplicatins(key);
  950. this.searchProcesses(key);
  951. this.searchInfors(key);
  952. this.searchQuerys(key);
  953. }
  954. },
  955. searchApplicatins: function(value){
  956. var user = this.layout.session.user;
  957. var currentNames = [user.name, user.distinguishedName, user.id, user.unique];
  958. if (user.roleList) currentNames = currentNames.concat(user.roleList);
  959. if (user.groupList) currentNames = currentNames.concat(user.groupList);
  960. if (this.layoutJson && this.layoutJson.length) this.layoutJson.each(function(v){
  961. if ( this.checkMenuItem(v, currentNames) ){
  962. if ((v.title.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.title.toPY().toLowerCase().indexOf(value)!==-1) || (v.title.indexOf(value)!==-1)){
  963. this.createApplicationMenuItem(v);
  964. }
  965. }
  966. }.bind(this));
  967. if (this.componentJson && this.componentJson.length) this.componentJson.each(function(v){
  968. if ( this.checkMenuItem(v, currentNames) ){
  969. if ((v.title.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.title.toPY().toLowerCase().indexOf(value)!==-1) || (v.title.indexOf(value)!==-1)){
  970. this.createApplicationMenuItem(v);
  971. }
  972. }
  973. }.bind(this));
  974. if (this.portalJson && this.portalJson.length) this.portalJson.each(function(v){
  975. if ((v.name.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.name.toPY().toLowerCase().indexOf(value)!==-1) || (v.name.indexOf(value)!==-1)){
  976. this.createPortalMenuItem(v);
  977. }
  978. }.bind(this));
  979. },
  980. searchProcesses: function(value){
  981. if (this.processJson && this.processJson.length) this.processJson.each(function(v){
  982. if ((v.name.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.name.toPY().toLowerCase().indexOf(value)!==-1) || (v.name.indexOf(value)!==-1)){
  983. this.createProcessMenuItem(v);
  984. }
  985. }.bind(this));
  986. },
  987. searchInfors: function(value){
  988. if (this.inforJson && this.inforJson.length) this.inforJson.each(function(v){
  989. if ((v.appName.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.appName.toPY().toLowerCase().indexOf(value)!==-1) || (v.appName.indexOf(value)!==-1)){
  990. this.createInforMenuItem(v);
  991. }
  992. }.bind(this));
  993. },
  994. searchQuerys: function(value){
  995. if (this.queryJson && this.queryJson.length) this.queryJson.each(function(v){
  996. if ((v.name.toPYFirst().toLowerCase().indexOf(value)!==-1) || (v.name.toPY().toLowerCase().indexOf(value)!==-1) || (v.name.indexOf(value)!==-1)){
  997. this.createQueryMenuItem(v);
  998. }
  999. }.bind(this));
  1000. },
  1001. loadJsons: function(callback){
  1002. this.clearAppContentNode();
  1003. this.loadLayoutApplications(function(json_layout){
  1004. var componentAction = o2.Actions.get("x_component_assemble_control");
  1005. var portalAction = o2.Actions.get("x_portal_assemble_surface");
  1006. var processAction = o2.Actions.get("x_processplatform_assemble_surface");
  1007. var inforAction = o2.Actions.get("x_cms_assemble_control");
  1008. var queryAction = o2.Actions.get("x_query_assemble_surface");
  1009. var iconsPath = this.layout.path+"icons.json";
  1010. this.getIconsJson(function(){
  1011. o2.Actions.invokeAsync([
  1012. {"action": componentAction, "name": "listComponent"},
  1013. {"action": portalAction, "name": "listApplication"},
  1014. {"action": processAction, "name": "listApplication"},
  1015. {"action": inforAction, "name": "listColumn"},
  1016. {"action": queryAction, "name": "listQuery"},
  1017. ], {"success": function(json_component, json_portal, json_process, json_infor, json_query){
  1018. this.layoutJson = json_layout;
  1019. this.componentJson = json_component.data;
  1020. this.portalJson = json_portal.data;
  1021. this.processJson = json_process.data;
  1022. this.inforJson = json_infor.data;
  1023. this.queryJson = json_query.data;
  1024. if (callback) callback();
  1025. }.bind(this), "failure": function(){}}
  1026. );
  1027. }.bind(this));
  1028. }.bind(this));
  1029. },
  1030. getIconsJson: function(callback){
  1031. if (this.layout.iconsJson){
  1032. if (callback) callback();
  1033. }else{
  1034. o2.JSON.get(iconsPath, function(json){
  1035. this.layout.iconsJson = json;
  1036. if (callback) callback();
  1037. }.bind(this));
  1038. }
  1039. },
  1040. setPosition: function(){
  1041. //var size = this.container.getSize();
  1042. var index = o2.xDesktop.zIndexPool.zIndex;
  1043. var nodeSize = this.node.getSize();
  1044. var left = 0-nodeSize.x;
  1045. this.maskNode.setStyles({"left": ""+left+"px"});
  1046. this.node.setStyles({"left": ""+left+"px"});
  1047. },
  1048. setSize: function(){
  1049. if (this.appScrollBar && this.appScrollBar.scrollVNode) this.appScrollBar.scrollVNode.setStyle("margin-top", "0px");
  1050. var isLnk = false;
  1051. if (false && this.layout.lnks && this.layout.lnks.length){
  1052. this.lnkAreaNode.show();
  1053. this.lineNode.show();
  1054. var h = 100*3;
  1055. this.lnkScrollNode.setStyle("height", ""+h+"px");
  1056. isLnk = true;
  1057. }else{
  1058. this.lnkAreaNode.hide();
  1059. this.lineNode.hide();
  1060. }
  1061. var size = this.node.getSize();
  1062. var lnkSizeY = (isLnk) ? this.lnkAreaNode.getSize().y : 0;
  1063. var lineSizeY = (isLnk) ? this.lineNode.getSize().y : 0;
  1064. var mt = (isLnk) ? (this.lineNode.getStyle("margin-top").toInt() || 0) : 0;
  1065. var mb = (isLnk) ? (this.lineNode.getStyle("margin-bottom").toInt() || 0) : 0;
  1066. var titleSize = this.appTitleNode.getSize();
  1067. var y = size.y-lnkSizeY-lineSizeY-mt-mb-titleSize.y;
  1068. this.appScrollNode.setStyle("height", ""+y+"px");
  1069. },
  1070. loadLnks: function(){
  1071. // if (this.layout.lnks && this.layout.lnks.length){
  1072. // this.lnkAreaNode.show();
  1073. // this.lineNode.show();
  1074. // this.lnkContentNode.empty();
  1075. // this.createLnkMenuItem();
  1076. // }else{
  1077. this.lnkAreaNode.hide();
  1078. this.lineNode.hide();
  1079. //}
  1080. },
  1081. createLnkMenuItem: function(){
  1082. //this.templetedHtml
  1083. },
  1084. clearAppContentNode: function(){
  1085. this.appContentNode.empty();
  1086. this.appContentNode.addClass("icon_loading");
  1087. },
  1088. loadApplications: function(callback){
  1089. this.clearAppContentNode();
  1090. // this.loadLayoutApplications(function(json_layout){
  1091. // var componentAction = o2.Actions.get("x_component_assemble_control");
  1092. // var portalAction = o2.Actions.get("x_portal_assemble_surface");
  1093. // o2.Actions.invokeAsync([
  1094. // {"action": componentAction, "name": "listComponent"},
  1095. // {"action": portalAction, "name": "listApplication"},
  1096. // ], {"success": function(json_component, json_portal){
  1097. // this.loadApplicationsItem(json_layout, json_component.data, json_portal.data);
  1098. // }.bind(this), "failure": function(){}}
  1099. // );
  1100. // }.bind(this));
  1101. this.loadApplicationsItem(this.layoutJson, this.componentJson, this.portalJson);
  1102. },
  1103. loadLayoutApplications: function(callback){
  1104. var url = this.layout.path+"applications.json";
  1105. o2.getJSON(url, function(json){
  1106. if (callback) callback(json);
  1107. }.bind(this));
  1108. },
  1109. loadApplicationsItem: function(layoutJson, componentJson, portalJson){
  1110. debugger;
  1111. var user = this.layout.session.user;
  1112. var currentNames = [user.name, user.distinguishedName, user.id, user.unique];
  1113. if (user.roleList) currentNames = currentNames.concat(user.roleList);
  1114. if (user.groupList) currentNames = currentNames.concat(user.groupList);
  1115. var json_layout = Array.clone(layoutJson);
  1116. var json_component = Array.clone(componentJson);
  1117. var json_portal = Array.clone(portalJson);
  1118. this.appContentNode.removeClass("icon_loading");
  1119. var loadedApps = {};
  1120. if (this.menuData && this.menuData.appList && this.menuData.appList.length){
  1121. this.menuData.appList.each(function(app){
  1122. if (app.type==="group"){
  1123. this.createGroupMenuItem(app);
  1124. app.itemDataList.each(function(a){
  1125. var d = json_layout.find(function(i){ return (i.id === a.id); });
  1126. if (d) json_layout.erase(d);
  1127. d = json_component.find(function(i){ return (i.id === a.id); });
  1128. if (d) json_component.erase(d);
  1129. d = json_portal.find(function(i){ return (i.id === a.id); });
  1130. if (d) json_portal.erase(d);
  1131. }.bind(this));
  1132. }else{
  1133. var appData = null;
  1134. if (!appData && json_layout && json_layout.length){
  1135. appData = json_layout.find(function(i){ return (i.id === app.id); });
  1136. if (appData){
  1137. json_layout.erase(appData);
  1138. if ( this.checkMenuItem(appData, currentNames) ) this.createApplicationMenuItem(appData);
  1139. }
  1140. }
  1141. if (!appData && json_component && json_component.length){
  1142. appData = json_component.find(function(i){ return (i.id === app.id); });
  1143. if (appData){
  1144. json_component.erase(appData);
  1145. if ( this.checkMenuItem(appData, currentNames) ) this.createApplicationMenuItem(appData);
  1146. }
  1147. }
  1148. if (!appData && json_portal && json_portal.length){
  1149. appData = json_portal.find(function(i){ return (i.id === app.id); });
  1150. if (appData){
  1151. json_portal.erase(appData);
  1152. appData.type = "portal";
  1153. this.createPortalMenuItem(appData);
  1154. }
  1155. }
  1156. }
  1157. }.bind(this));
  1158. }
  1159. if (json_layout && json_layout.length) json_layout.each(function(value){
  1160. if ( this.checkMenuItem(value, currentNames) ) this.createApplicationMenuItem(value);
  1161. }.bind(this));
  1162. if (json_component && json_component.length) json_component.each(function(value){
  1163. if ( this.checkMenuItem(value, currentNames) ) this.createApplicationMenuItem(value);
  1164. }.bind(this));
  1165. if (json_portal && json_portal.length) json_portal.each(function(value){
  1166. value.type = "portal";
  1167. this.createPortalMenuItem(value);
  1168. }.bind(this));
  1169. },
  1170. loadProcesses: function(){
  1171. this.clearAppContentNode();
  1172. // o2.Actions.get("x_processplatform_assemble_surface").listApplication(this.loadProcessesItem.bind(this));
  1173. this.loadProcessesItem(this.processJson)
  1174. },
  1175. loadProcessesItem: function(list){
  1176. this.appContentNode.removeClass("icon_loading");
  1177. var json = Array.clone(list);
  1178. if (this.menuData && this.menuData.processList && this.menuData.processList.length){
  1179. this.menuData.processList.each(function(app){
  1180. if (app.type==="group"){
  1181. this.createGroupMenuItem(app);
  1182. app.itemDataList.each(function(a){
  1183. var d = json.find(function(i){ return (i.id === a.id); });
  1184. if (d) json.erase(d);
  1185. }.bind(this));
  1186. }else{
  1187. var appData = null;
  1188. if (!appData && json && json.length){
  1189. appData = json.find(function(i){ return (i.id === app.id); });
  1190. if (appData){
  1191. json.erase(appData);
  1192. appData.type = "process";
  1193. this.createProcessMenuItem(appData);
  1194. }
  1195. }
  1196. }
  1197. }.bind(this));
  1198. }
  1199. if (json && json.length) json.each(function(value){
  1200. value.type = "process";
  1201. this.createProcessMenuItem(value);
  1202. }.bind(this));
  1203. },
  1204. loadInfors: function(){
  1205. this.clearAppContentNode();
  1206. //o2.Actions.get("x_cms_assemble_control").listColumn(this.loadInforsItem.bind(this));
  1207. this.loadInforsItem(this.inforJson)
  1208. },
  1209. loadInforsItem: function(list){
  1210. this.appContentNode.removeClass("icon_loading");
  1211. var json = Array.clone(list);
  1212. if (this.menuData && this.menuData.inforList && this.menuData.inforList.length){
  1213. this.menuData.inforList.each(function(app){
  1214. if (app.type==="group"){
  1215. this.createGroupMenuItem(app);
  1216. app.itemDataList.each(function(a){
  1217. var d = json.find(function(i){ return (i.id === a.id); });
  1218. if (d) json.erase(d);
  1219. }.bind(this));
  1220. }else{
  1221. var appData = null;
  1222. if (!appData && json && json.length){
  1223. appData = json.find(function(i){ return (i.id === app.id); });
  1224. if (appData){
  1225. json.erase(appData);
  1226. appData.type = "cms";
  1227. this.createInforMenuItem(appData);
  1228. }
  1229. }
  1230. }
  1231. }.bind(this));
  1232. }
  1233. if (json && json.length) json.each(function(value){
  1234. value.type = "cms";
  1235. this.createInforMenuItem(value);
  1236. }.bind(this));
  1237. },
  1238. loadQuerys: function(){
  1239. this.clearAppContentNode();
  1240. // o2.Actions.get("x_query_assemble_surface").listQuery(this.loadQuerysItem.bind(this));
  1241. this.loadQuerysItem(this.queryJson)
  1242. },
  1243. loadQuerysItem: function(list){
  1244. this.appContentNode.removeClass("icon_loading");
  1245. var json = Array.clone(list);
  1246. if (this.menuData && this.menuData.queryList && this.menuData.queryList.length){
  1247. this.menuData.queryList.each(function(app){
  1248. if (app.type==="group"){
  1249. this.createGroupMenuItem(app);
  1250. app.itemDataList.each(function(a){
  1251. var d = json.find(function(i){ return (i.id === a.id); });
  1252. if (d) json.erase(d);
  1253. }.bind(this));
  1254. }else{
  1255. var appData = null;
  1256. if (!appData && json && json.length){
  1257. appData = json.find(function(i){ return (i.id === app.id); });
  1258. if (appData){
  1259. json.erase(appData);
  1260. appData.type = "query";
  1261. this.createQueryMenuItem(appData);
  1262. }
  1263. }
  1264. }
  1265. }.bind(this));
  1266. }
  1267. if (json && json.length) json.each(function(value){
  1268. value.type = "query";
  1269. this.createQueryMenuItem(value);
  1270. }.bind(this));
  1271. },
  1272. checkMenuItem: function(value, currentNames){
  1273. if (value.visible===false) return false;
  1274. var isAllow = true;
  1275. if (value.allowList) isAllow = (value.allowList.length) ? (value.allowList.isIntersect(currentNames)) : true;
  1276. var isDeny = false;
  1277. if (value.denyList) isDeny = (value.denyList.length) ? (value.denyList.isIntersect(currentNames)) : false;
  1278. return ((!isDeny && isAllow) || o2.AC.isAdministrator());
  1279. },
  1280. createApplicationMenuItem: function(value){
  1281. this.items.push(new o2.xDesktop.Default.StartMenu.Item(this, this.appContentNode, value));
  1282. },
  1283. createPortalMenuItem: function(value){
  1284. this.items.push(new o2.xDesktop.Default.StartMenu.PortalItem(this, this.appContentNode, value));
  1285. },
  1286. createProcessMenuItem: function(value){
  1287. this.items.push(new o2.xDesktop.Default.StartMenu.ProcessItem(this, this.appContentNode, value));
  1288. },
  1289. createInforMenuItem: function(value){
  1290. this.items.push(new o2.xDesktop.Default.StartMenu.InforItem(this, this.appContentNode, value));
  1291. },
  1292. createQueryMenuItem: function(value){
  1293. this.items.push(new o2.xDesktop.Default.StartMenu.QueryItem(this, this.appContentNode, value));
  1294. },
  1295. createGroupMenuItem: function(value){
  1296. this.items.push(new o2.xDesktop.Default.StartMenu.GroupItem(this, this.appContentNode, value));
  1297. },
  1298. show: function(){
  1299. if (!this.isMorph){
  1300. this.isMorph = true;
  1301. if (!this.morph){
  1302. this.maskMorph = new Fx.Morph(this.maskNode, {
  1303. duration: "200",
  1304. transition: Fx.Transitions.Sine.easeOut
  1305. });
  1306. this.morph = new Fx.Morph(this.node, {
  1307. duration: "200",
  1308. transition: Fx.Transitions.Sine.easeOut
  1309. });
  1310. }
  1311. this.maskNode.setStyles({"display": "block"});
  1312. this.node.setStyles({"display": "block"});
  1313. this.triangleNode.setStyles({"display": "block"});
  1314. this.appAreaNode.setStyles({ "filter": "" });
  1315. this.setSize();
  1316. this.setPosition();
  1317. var size = this.layout.menuNode.getSize();
  1318. var left = size.x;
  1319. this.loadJsons(function(){
  1320. (this.currentTab || this.appCategoryTab).click();
  1321. }.bind(this));
  1322. //this.loadContent();
  1323. this.maskMorph.start({"left": ""+left+"px"});
  1324. this.morph.start({"left": ""+left+"px"}).chain(function(){
  1325. this.isShow = true;
  1326. this.isMorph = false;
  1327. this.layout.desktopNode.addEvent("mousedown", this.hideMessage);
  1328. this.setScroll();
  1329. this.fireEvent("show");
  1330. }.bind(this));
  1331. }
  1332. },
  1333. hide: function(callback){
  1334. if (!this.isMorph){
  1335. this.isMorph = true;
  1336. if (!this.morph){
  1337. this.maskMorph = new Fx.Morph(this.maskNode, {
  1338. duration: "200",
  1339. transition: Fx.Transitions.Sine.easeOut
  1340. });
  1341. this.morph = new Fx.Morph(this.node, {
  1342. duration: "200",
  1343. transition: Fx.Transitions.Sine.easeOut
  1344. });
  1345. }
  1346. var nodeSize = this.node.getSize();
  1347. var left = 0-nodeSize.x;
  1348. // var position = this.node.getPosition();
  1349. // var size = this.node.getSize();
  1350. // var left = position.x+size.x;
  1351. this.isSearchResult = false;
  1352. this.hideSearch();
  1353. this.lnkContentNode.empty();
  1354. this.appContentNode.empty();
  1355. this.groupMenuArea.empty();
  1356. if (this.appScrollBar) this.appScrollBar.destroy();
  1357. this.maskMorph.start({"left": ""+left+"px"}).chain(function(){
  1358. this.maskNode.setStyle("display", "none");
  1359. this.triangleNode.setStyles({"display": "none"});
  1360. }.bind(this));
  1361. this.morph.start({"left": ""+left+"px"}).chain(function(){
  1362. this.node.setStyle("display", "none");
  1363. this.isShow = false;
  1364. this.isMorph = false;
  1365. this.layout.desktopNode.removeEvent("mousedown", this.hideMessage);
  1366. this.fireEvent("hide");
  1367. if (callback) callback();
  1368. }.bind(this));
  1369. }
  1370. },
  1371. defaultMenu: function(){
  1372. this.layout.menuData = null;
  1373. if (this.layout.status) this.layout.status.menuData = null;
  1374. this.menuData = null;
  1375. this.hide();
  1376. }
  1377. });
  1378. o2.xDesktop.Default.StartMenu.Item = new Class({
  1379. initialize: function (menu, container, data, positionNode) {
  1380. this.menu = menu;
  1381. this.layout = this.menu.layout;
  1382. this.data = data;
  1383. this.container = $(container);
  1384. this.load(positionNode);
  1385. this.init();
  1386. },
  1387. load: function(positionNode){
  1388. this.node = new Element("div.layout_start_item");
  1389. if (positionNode){
  1390. this.node.inject(positionNode, "before");
  1391. }else{
  1392. this.node.inject(this.container);
  1393. }
  1394. this.node.set("html", this.menu.itemTempletedHtml);
  1395. this.iconAreaNode = this.node.getElement(".layout_start_item_iconArea");
  1396. this.iconNode = this.node.getElement(".layout_start_item_icon");
  1397. this.badgeNode = this.node.getElement(".layout_start_item_badge");
  1398. this.textNode = this.node.getElement(".layout_start_item_text");
  1399. this.loadIcon();
  1400. this.loadBadge();
  1401. this.loadText();
  1402. this.setEvent();
  1403. this.node.store("item", this);
  1404. if (this.menu.data && this.menu.data.type==="group"){
  1405. this.node.addClass("layout_start_item_sub");
  1406. }
  1407. },
  1408. init: function(){},
  1409. dragOver: function(){
  1410. if (!this.overNode){
  1411. this.overNode = new Element("div.layout_start_item_over").inject(this.container);
  1412. this.overNode.addClass("mainColor_bg");
  1413. }
  1414. this.overNode.position({
  1415. "relativeTo": this.iconAreaNode,
  1416. "position": "leftTop",
  1417. "edge": "leftTop",
  1418. "offset": {
  1419. "x": -6, "y":-6
  1420. }
  1421. });
  1422. this.overNode.show();
  1423. },
  1424. dragOut: function(){
  1425. if (this.overNode) this.overNode.hide();
  1426. },
  1427. loadIcon: function(){
  1428. var icon;
  1429. var bgcolor = "";
  1430. if (this.data.path.substring(0, 4)==="@url"){
  1431. if (this.data.iconPath){
  1432. icon = this.data.iconPath;
  1433. }else{
  1434. if (this.layout.iconsJson["Url"] && this.layout.iconsJson["Url"].icon){
  1435. icon = this.layout.path+"appicons/"+this.layout.iconsJson["Url"].icon;
  1436. bgcolor = this.layout.iconsJson["Url"].color;
  1437. }else{
  1438. icon = "../x_component_Setting/$Main/default/icon/site.png";
  1439. bgcolor = "";
  1440. }
  1441. }
  1442. }else{
  1443. if (this.layout.iconsJson[this.data.path] && this.layout.iconsJson[this.data.path].icon){
  1444. icon = this.layout.path+"appicons/"+this.layout.iconsJson[this.data.path].icon;
  1445. bgcolor = this.layout.iconsJson[this.data.path].color;
  1446. }else{
  1447. icon = "../x_component_"+this.data.path.replace(/\./g, "_")+"/$Main/"+this.data.iconPath;
  1448. bgcolor = "";
  1449. }
  1450. }
  1451. if (icon && bgcolor){
  1452. this.iconNode.addClass("layout_start_item_icon_flat");
  1453. this.iconNode.setStyle("background-color", bgcolor);
  1454. }
  1455. this.iconNode.setStyle("background-image", "url("+icon+")");
  1456. this.icon = icon;
  1457. this.bgcolor = bgcolor;
  1458. },
  1459. loadBadge: function(){
  1460. this.badgeNode.set("title", o2.LP.desktop.addLnk).addClass("icon_add_red");
  1461. },
  1462. loadText: function(){
  1463. this.textNode.set("text", this.data.title || this.data.name);
  1464. },
  1465. setEvent: function(){
  1466. this.node.addEvents({
  1467. "mouseover": function(){ this.badgeNode.fade("in"); }.bind(this),
  1468. "mouseout": function(){ this.badgeNode.fade("out"); }.bind(this),
  1469. "click": function(e){
  1470. //this.menu.hide(function(){
  1471. this.open(e);
  1472. //}.bind(this));
  1473. }.bind(this)
  1474. });
  1475. this.badgeNode.addEvent("click", function(e){
  1476. this.addLnk();
  1477. e.stopPropagation();
  1478. }.bind(this));
  1479. this.makeLnk();
  1480. },
  1481. addLnk: function(dragTargetLnk, dragPosition){
  1482. lnkdata = {
  1483. "name": this.data.path,
  1484. "title": this.data.title,
  1485. "iconData": this.data.iconData || null,
  1486. "icon": this.iconData || null,
  1487. "appType": null,
  1488. "options": null
  1489. }
  1490. this.layout.addLnk(lnkdata, dragTargetLnk, dragPosition);
  1491. },
  1492. open: function(e){
  1493. this.menu.hide(function(){
  1494. if (this.menu.menu){
  1495. this.menu.menu.hide(function(){
  1496. layout.openApplication(e, this.data.path);
  1497. }.bind(this));
  1498. }else{
  1499. layout.openApplication(e, this.data.path);
  1500. }
  1501. }.bind(this));
  1502. },
  1503. makeLnk: function(){
  1504. var drag = new Drag(this.node, {
  1505. "stopPropagation": true,
  1506. "compensateScroll": true,
  1507. "onStart": function(el, e){
  1508. this.doDragMove(e);
  1509. drag.stop();
  1510. }.bind(this)
  1511. });
  1512. },
  1513. getDragNode: function(){
  1514. if (!this.dragNode){
  1515. this.dragNode = new Element("div.layout_menu_lnk_item_drag")
  1516. .setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex())
  1517. .inject(this.layout.node);
  1518. var dragIconNode = this.iconNode.clone(true).inject(this.dragNode)
  1519. .removeClass("layout_menu_lnk_item_icon")
  1520. .addClass("layout_menu_lnk_item_icon_drag");
  1521. if (this.bgcolor) dragIconNode.setStyle("background-color", this.bgcolor);
  1522. }
  1523. var p = this.iconNode.getPosition(this.dragNode.getOffsetParent());
  1524. this.dragNode.show().setStyles({
  1525. "left": ""+p.x+"px", "top": ""+p.y+"px"
  1526. });
  1527. },
  1528. doDragMove: function(e){
  1529. this.getDragNode();
  1530. var droppables = [this.layout.lnkContentNode, this.menu.appContentNode];
  1531. if (this.menu.appContentNode.hasClass("layout_start_groupItem_menu_content")){
  1532. this.onGroup = true;
  1533. }
  1534. //if (this.menu.maskGroupNode) droppables.push(this.menu.maskGroupNode);
  1535. var drag = new Drag.Move(this.dragNode, {
  1536. "stopPropagation": true,
  1537. "compensateScroll": true,
  1538. "droppables": droppables,
  1539. "onStart": function(el){ this._drag_start(el); }.bind(this),
  1540. "onDrag": function(dragging,e){ this._drag_drag(dragging, e); }.bind(this),
  1541. "onEnter": function(dragging, inObj){ this._drag_enter(dragging, inObj); }.bind(this),
  1542. "onLeave": function(dragging, obj){ this._drag_leave(dragging, obj); }.bind(this),
  1543. "onDrop": function(dragging, inObj){ this._drag_drop(dragging, inObj); }.bind(this),
  1544. "onCancel": function(dragging){ this._drag_cancel(dragging); }.bind(this),
  1545. "onComplete": function(dragging, e){ this._drag_complete(dragging, e); }.bind(this),
  1546. });
  1547. drag.start(e);
  1548. this.dragStatus == "remove";
  1549. },
  1550. _drag_start: function(el){
  1551. this.isDrag = true;
  1552. this.dragTargetLnk = null;
  1553. this.dragPosition = "before";
  1554. this.node.setStyle("opacity", 0.1);
  1555. this.positionFlagNode = new Element("div", {"styles": {"display": "none"}}).inject(this.node, "after");
  1556. },
  1557. _drag_drag: function(dragging, e){
  1558. console.log(this.dragStatus);
  1559. if (this.dragStatus == "order"){
  1560. if (this.layout.lnks && this.layout.lnks.length){
  1561. var current = e.page.y;
  1562. for (var i=0; i<this.layout.lnks.length; i++){
  1563. var lnk = this.layout.lnks[i];
  1564. var y = lnk.node.getSize().y;
  1565. var top = lnk.node.getPosition(this.layout.node).y;
  1566. var center = top+y/2;
  1567. var bottom = top+y;
  1568. if (top<=current && center>=current){
  1569. this.dragTargetLnk = lnk;
  1570. this.dragPosition = "before";
  1571. break;
  1572. }else if (center<=current && bottom>=current){
  1573. this.dragTargetLnk = lnk;
  1574. this.dragPosition = "after";
  1575. break;
  1576. }
  1577. }
  1578. if (!this.layout.positionNode) this.layout.positionNode = new Element("div.layout_menu_lnk_item_position")
  1579. .setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex())
  1580. .inject(this.layout.node);
  1581. this.layout.positionNode.show();
  1582. if (!this.dragTargetLnk){
  1583. this.dragTargetLnk = this.layout.lnks[this.layout.lnks.length-1];
  1584. this.dragPosition = "after";
  1585. }
  1586. this.layout.positionNode.position({
  1587. relativeTo: this.dragTargetLnk.node,
  1588. position: (this.dragPosition=="before") ? 'topcenter' : 'bottomcenter',
  1589. edge: 'center'
  1590. });
  1591. }
  1592. }
  1593. if (this.dragStatus == "group"){
  1594. if (!this.onGroup) this.checkDargOver(dragging);
  1595. if (!this.overItem){
  1596. this.checkDargPosition(dragging);
  1597. }
  1598. }
  1599. },
  1600. checkDargOver: function(dragging){
  1601. var p = dragging.getPosition();
  1602. var s = dragging.getSize();
  1603. var x = p.x+s.x/2-1;
  1604. var y = p.y+s.y/2-1;
  1605. var ex = x+2;
  1606. var ey = y+2;
  1607. var overItem = null;
  1608. this.menu.items.each(function(item){
  1609. if (!item.isDrag){
  1610. if (item.iconAreaNode.isInPointInRect(x,y,ex,ey)){
  1611. item.dragOver();
  1612. overItem = item;
  1613. }else{
  1614. item.dragOut();
  1615. }
  1616. }
  1617. });
  1618. this.overItem = overItem;
  1619. },
  1620. checkDargPosition: function(dragging){
  1621. var p = dragging.getPosition();
  1622. var s = dragging.getSize();
  1623. var rightP = { "x": p.x+s.x-2, "y": p.y+s.y/2-1, "ex": p.x+s.x, "ey": p.y+s.y/2+1 };
  1624. var leftP = { "x": p.x, "y": p.y+s.y/2-1, "ex": p.x+2, "ey": p.y+s.y/2+1 };
  1625. var moveFlag = false;
  1626. for (var i = 0; i<this.menu.items.length; i++){
  1627. var item = this.menu.items[i];
  1628. if (!item.isDrag){
  1629. if (item.iconAreaNode.isInPointInRect(rightP.x, rightP.y, rightP.ex, rightP.ey)){
  1630. moveFlag = true;
  1631. this.node.inject(item.node, "before");
  1632. break;
  1633. }else if (item.iconAreaNode.isInPointInRect(leftP.x, leftP.y, leftP.ex, leftP.ey)){
  1634. moveFlag = true;
  1635. this.node.inject(item.node, "after");
  1636. break;
  1637. }
  1638. }
  1639. }
  1640. //if (!moveFlag) this.node.inject(this.menu.appContentNode);
  1641. },
  1642. _drag_enter: function(el, inObj){
  1643. if (inObj.hasClass("layout_start_content_appContent") || inObj.hasClass("layout_start_groupItem_menu_content")){
  1644. this.dragStatus = "group";
  1645. this.node.setStyle("opacity", 0.1);
  1646. }else{
  1647. if (this.positionFlagNode) this.node.inject(this.positionFlagNode, "before");
  1648. this.dragStatus = "order";
  1649. this.node.setStyle("opacity", 1);
  1650. }
  1651. },
  1652. _drag_leave: function(el, inObj){
  1653. if (inObj.hasClass("layout_start_content_appContent")){
  1654. //this.node.inject(this.menu.appContentNode);
  1655. }else if (inObj.hasClass("layout_start_groupItem_menu_content")){
  1656. this.dragStatus = "ungroup";
  1657. this.node.setStyle("opacity", 0.1);
  1658. }else{
  1659. this.dragStatus = "remove";
  1660. if (this.layout.positionNode) this.layout.positionNode.hide();
  1661. }
  1662. },
  1663. _drag_drop: function(dragging, inObj){
  1664. if (this.dragStatus == "order" && this.dragTargetLnk && this.dragTargetLnk!=this){
  1665. this.addLnk(this.dragTargetLnk, this.dragPosition);
  1666. }else if (this.dragStatus == "group" && this.overItem && this.overItem!=this){
  1667. this.overItem.dragOut();
  1668. this.addGroup();
  1669. }
  1670. this.node.setStyle("opacity", 1);
  1671. this.menu.resetMenuData();
  1672. },
  1673. _drag_cancel: function(dragging){
  1674. dragging.hide();
  1675. if (this.layout.positionNode) this.layout.positionNode.hide();
  1676. if (this.dragRemoveNode) this.dragRemoveNode.hide();
  1677. this.node.setStyle("opacity", 1);
  1678. this.isDrag = false;
  1679. this.menu.resetMenuData();
  1680. },
  1681. _drag_complete: function(dragging) {
  1682. this._drag_cancel(dragging);
  1683. if (this.positionFlagNode) this.positionFlagNode.destroy();
  1684. this.positionFlagNode = null;
  1685. },
  1686. addGroup: function(){
  1687. debugger;
  1688. if (this.overItem.data.type==="group"){
  1689. this.overItem.addItem(this.data);
  1690. }else{
  1691. var v = {
  1692. name: "Group",
  1693. title: "Group",
  1694. type: "group",
  1695. visible: true
  1696. }
  1697. var group = new o2.xDesktop.Default.StartMenu.GroupItem(this.menu, this.container, v, this.overItem.node);
  1698. group.addItem(this.overItem.data);
  1699. group.addItem(this.data);
  1700. this.menu.items.push(group);
  1701. this.overItem.node.destroy();
  1702. group.open();
  1703. }
  1704. this.node.destroy();
  1705. this.menu.resetMenuData();
  1706. }
  1707. });
  1708. o2.xDesktop.Default.StartMenu.GroupItem = new Class({
  1709. Extends: o2.xDesktop.Default.StartMenu.Item,
  1710. loadIcon: function(){
  1711. this.iconNode.addClass("layout_start_item_icon_group");
  1712. this.iconNode.addClass("grayColor_bg");
  1713. this.sunIconNodes = [];
  1714. var node = new Element("div.layout_start_item_icon_group_sub").inject(this.iconNode);
  1715. this.sunIconNodes.push(node);
  1716. node = new Element("div.layout_start_item_icon_group_sub").inject(this.iconNode);
  1717. this.sunIconNodes.push(node);
  1718. node = new Element("div.layout_start_item_icon_group_sub").inject(this.iconNode);
  1719. this.sunIconNodes.push(node);
  1720. node = new Element("div.layout_start_item_icon_group_sub").inject(this.iconNode);
  1721. this.sunIconNodes.push(node);
  1722. },
  1723. init: function(){
  1724. this.itemTempletedHtml = this.menu.itemTempletedHtml;
  1725. if (this.data.itemDataList && this.data.itemDataList.length){
  1726. for (var i=0; i<Math.min(this.data.itemDataList.length, 4); i++){
  1727. var icon = this.setSubItemIcon(this.data.itemDataList[i], this.sunIconNodes[i]);
  1728. }
  1729. }
  1730. },
  1731. open: function(e, callback){
  1732. if (!this.menuNode) this.createMenuNode();
  1733. this.maskNode = new Element("div.layout_start_groupItem_menuMask").inject(this.menuNode, "before");
  1734. this.maskNode.addEvent("click", function(e){
  1735. this.hide();
  1736. }.bind(this));
  1737. this.maskGroupNode = this.maskNode;
  1738. this.menuNode.show();
  1739. var styles = this.getMenuNodeOpenDimensions();
  1740. this.menuNode.morph.set("transition", Fx.Transitions.Quart.easeOut);
  1741. this.menuNode.morph.start(styles).chain(function(){
  1742. this.menuTitleNode.show();
  1743. this.menuScrollNode.show();
  1744. var s = this.menuNode.getSize();
  1745. var ts = this.menuTitleNode.getSize();
  1746. var h = s.y - ts.y;
  1747. this.menuContentNode.setStyle("height", ""+h+"px");
  1748. this.loadItems();
  1749. if (callback) callback();
  1750. }.bind(this));
  1751. this.menu.appAreaNode.setStyles({ "filter": "blur(5px)" });
  1752. },
  1753. hide: function(callback){
  1754. this.menuTitleNode.hide();
  1755. this.menuScrollNode.hide();
  1756. var styles = this.getMenuNodeCloseDimensions();
  1757. this.menuNode.morph.set("transition", Fx.Transitions.Quart.easeIn);
  1758. this.menuNode.morph.start(styles).chain(function(){
  1759. if (this.maskNode) this.maskNode.destroy();
  1760. if (this.menuNode) this.menuNode.hide();
  1761. if (callback) callback();
  1762. }.bind(this));
  1763. this.menu.appAreaNode.setStyles({ "filter": "" });
  1764. },
  1765. loadItems: function(){
  1766. if (!this.items) this.items = [];
  1767. this.data.itemDataList.each(function(data){
  1768. var item = this.items.find(function(i){
  1769. return i.data.id == data.id;
  1770. });
  1771. if (!item){
  1772. switch (data.type){
  1773. case "portal":
  1774. this.items.push(new o2.xDesktop.Default.StartMenu.PortalItem(this, this.menuContentNode, data));
  1775. break;
  1776. case "process":
  1777. this.items.push(new o2.xDesktop.Default.StartMenu.ProcessItem(this, this.menuContentNode, data));
  1778. break;
  1779. case "cms":
  1780. this.items.push(new o2.xDesktop.Default.StartMenu.InforItem(this, this.menuContentNode, data));
  1781. break;
  1782. case "query":
  1783. this.items.push(new o2.xDesktop.Default.StartMenu.QueryItem(this, this.menuContentNode, data));
  1784. break;
  1785. default:
  1786. this.items.push(new o2.xDesktop.Default.StartMenu.Item(this, this.menuContentNode, data));
  1787. }
  1788. }
  1789. }.bind(this));
  1790. },
  1791. getMenuNodeOpenDimensions: function(){
  1792. var size = this.menu.appAreaNode.getSize();
  1793. var w = size.x*0.94;
  1794. var h = size.y*0.7;
  1795. var x = (size.x*(1-0.94))/2;
  1796. var y = (size.y*(1-0.7))/2;
  1797. return {"width":w, "height": h, "left": x, "top": y}
  1798. },
  1799. getMenuNodeCloseDimensions: function(){
  1800. var size = this.iconNode.getSize();
  1801. var position = this.iconNode.getPosition(this.menu.node);
  1802. return {"width":size.x, "height": size.y, "left": position.x, "top": position.y}
  1803. },
  1804. createMenuNode: function(){
  1805. this.menuNode = new Element("div.layout_start_groupItem_menu").inject(this.menu.groupMenuArea);
  1806. this.menuNode.addClass("grayColor_bg");
  1807. this.menuTitleNode = new Element("div.layout_start_groupItem_menu_title").inject(this.menuNode);
  1808. this.menuTitleNode.set("text", this.data.name);
  1809. this.menuScrollNode = new Element("div.layout_start_groupItem_menu_scroll").inject(this.menuNode);
  1810. this.menuContentNode = new Element("div.layout_start_groupItem_menu_content").inject(this.menuScrollNode);
  1811. this.appContentNode = this.menuContentNode;
  1812. this.menuNode.position({
  1813. "relativeTo": this.iconNode,
  1814. "position": "upperLeft",
  1815. "edge": "upperLeft"
  1816. });
  1817. this.menuNode.morph = new Fx.Morph(this.menuNode, {
  1818. "duration": 200,
  1819. "transition": Fx.Transitions.Quart.easeOut
  1820. });
  1821. this.menuTitleNode.addEvent("click", function(){
  1822. var input = this.menuTitleNode.getElement("input");
  1823. if (!input) this.editTitle();
  1824. }.bind(this))
  1825. },
  1826. editTitle: function(){
  1827. debugger;
  1828. this.menuTitleNode.empty();
  1829. this.editotTitleNode = new Element("input.layout_start_groupItem_menu_title_edit", {"type": "text"}).inject(this.menuTitleNode);
  1830. this.editotTitleNode.set("value", this.data.name);
  1831. this.editotTitleNode.focus();
  1832. },
  1833. addItem: function(data){
  1834. if (!this.data.itemDataList) this.data.itemDataList = [];
  1835. if (this.data.itemDataList.length<4){
  1836. this.setSubItemIcon(data, this.sunIconNodes[this.data.itemDataList.length]);
  1837. }
  1838. this.data.itemDataList.push(data);
  1839. },
  1840. setSubItemIcon: function(data, node){
  1841. switch (data.type){
  1842. case "process":
  1843. this.setAppSubItemIcon(node, data.icon, "processDefault", "../x_component_process_ApplicationExplorer/$Main/default/icon/application.png");
  1844. break;
  1845. case "portal":
  1846. this.setAppSubItemIcon(node, data.icon, "portalDefault", "../x_component_portal_PortalExplorer/$Main/default/icon/application.png");
  1847. break;
  1848. case "cms":
  1849. this.setAppSubItemIcon(node, data.icon, "cmsDefault", "../x_component_cms_Index/$Main/default/icon/column.png");
  1850. break;
  1851. case "query":
  1852. this.setAppSubItemIcon(node, data.icon, "queryDefault", "../x_component_query_Query/$Main/appicon.png");
  1853. break;
  1854. default:
  1855. this.setDefaultSubItemIcon(data, node);
  1856. }
  1857. },
  1858. setAppSubItemIcon: function(node, iconData, defaultIcon, defaultUrl){
  1859. var icon = "";
  1860. var bgcolor = "";
  1861. if (iconData){
  1862. icon = "data:image/png;base64,"+iconData+"";
  1863. bgcolor = "";
  1864. node.addClass("layout_start_item_icon_group_subIcon");
  1865. }else{
  1866. var p = defaultIcon;
  1867. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  1868. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  1869. bgcolor = this.layout.iconsJson[p].color;
  1870. }else{
  1871. icon = defaultUrl;
  1872. bgcolor = "";
  1873. }
  1874. }
  1875. if (icon && bgcolor) node.setStyle("background-color", bgcolor);
  1876. node.setStyle("background-image", "url("+icon+")");
  1877. },
  1878. setDefaultSubItemIcon: function(data, node){
  1879. var icon;
  1880. var bgcolor = "";
  1881. if (data.path.substring(0, 4)==="@url"){
  1882. if (data.iconPath){
  1883. icon = data.iconPath;
  1884. }else{
  1885. if (this.layout.iconsJson["Url"] && this.layout.iconsJson["Url"].icon){
  1886. icon = this.layout.path+"appicons/"+this.layout.iconsJson["Url"].icon;
  1887. bgcolor = this.layout.iconsJson["Url"].color;
  1888. }else{
  1889. icon = "../x_component_Setting/$Main/default/icon/site.png";
  1890. bgcolor = "";
  1891. }
  1892. }
  1893. }else{
  1894. if (this.layout.iconsJson[data.path] && this.layout.iconsJson[data.path].icon){
  1895. icon = this.layout.path+"appicons/"+this.layout.iconsJson[data.path].icon;
  1896. bgcolor = this.layout.iconsJson[data.path].color;
  1897. }else{
  1898. icon = "../x_component_"+data.path.replace(/\./g, "_")+"/$Main/"+data.iconPath;
  1899. bgcolor = "";
  1900. }
  1901. }
  1902. if (icon && bgcolor){
  1903. node.setStyle("background-color", bgcolor);
  1904. }
  1905. node.setStyle("background-image", "url("+icon+")");
  1906. },
  1907. resetMenuData: function(){
  1908. debugger;
  1909. var nodes = this.menuContentNode.getChildren(".layout_start_item");
  1910. var data = [];
  1911. nodes.each(function(node){
  1912. var item = node.retrieve("item");
  1913. if (item){
  1914. data.push(item.data);
  1915. }
  1916. }.bind(this));
  1917. this.data.itemDataList = data;
  1918. }
  1919. });
  1920. o2.xDesktop.Default.StartMenu.PortalItem = new Class({
  1921. Extends: o2.xDesktop.Default.StartMenu.Item,
  1922. loadIcon: function(){
  1923. var icon = "";
  1924. var bgcolor = "";
  1925. if (this.data.icon){
  1926. icon = "data:image/png;base64,"+this.data.icon+"";
  1927. }else{
  1928. var p = "portalDefault";
  1929. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  1930. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  1931. bgcolor = this.layout.iconsJson[p].color;
  1932. }else{
  1933. icon = "../x_component_portal_PortalExplorer/$Main/default/icon/application.png";
  1934. bgcolor = "";
  1935. }
  1936. }
  1937. if (icon && bgcolor){
  1938. this.iconNode.addClass("layout_start_item_icon_flat");
  1939. this.iconNode.setStyle("background-color", bgcolor);
  1940. }
  1941. this.iconNode.setStyle("background-image", "url("+icon+")");
  1942. this.icon = icon;
  1943. },
  1944. loadText: function(){
  1945. this.textNode.set("text", this.data.name);
  1946. },
  1947. addLnk: function(dragTargetLnk, dragPosition){
  1948. var options = {"portalId": this.data.id, "appId": "portal.Portal"+this.data.id};
  1949. lnkdata = {
  1950. "name": "portal.Portal",
  1951. "title": this.data.name,
  1952. "iconData": (this.data.icon) || "",
  1953. "icon": null,
  1954. "appType": "portal",
  1955. "options": options
  1956. }
  1957. this.layout.addLnk(lnkdata, dragTargetLnk, dragPosition);
  1958. },
  1959. open: function(e){
  1960. var options = {"portalId": this.data.id, "appId": "portal.Portal"+this.data.id};
  1961. this.menu.hide(function(){
  1962. if (this.menu.menu){
  1963. this.menu.menu.hide(function(){
  1964. layout.openApplication(e, "portal.Portal", options);
  1965. }.bind(this));
  1966. }else{
  1967. layout.openApplication(e, "portal.Portal", options);
  1968. }
  1969. }.bind(this));
  1970. }
  1971. // makeLnk: function(){
  1972. // //@todo
  1973. // // this.node.makeLnk({
  1974. // // "par": {"icon": this.icon, "color": this.color, "title": this.data.title, "par": this.data.path},
  1975. // // });
  1976. // }
  1977. });
  1978. o2.xDesktop.Default.StartMenu.ProcessItem = new Class({
  1979. Extends: o2.xDesktop.Default.StartMenu.PortalItem,
  1980. loadIcon: function(){
  1981. var icon = "";
  1982. var bgcolor = "";
  1983. if (this.data.icon){
  1984. icon = "data:image/png;base64,"+this.data.icon+"";
  1985. bgcolor = "";
  1986. }else{
  1987. var p = "processDefault";
  1988. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  1989. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  1990. bgcolor = this.layout.iconsJson[p].color;
  1991. }else{
  1992. icon = "../x_component_process_ApplicationExplorer/$Main/default/icon/application.png";
  1993. bgcolor = "";
  1994. }
  1995. }
  1996. if (icon && bgcolor){
  1997. this.iconNode.addClass("layout_start_item_icon_flat");
  1998. this.iconNode.setStyle("background-color", bgcolor);
  1999. }
  2000. this.iconNode.setStyle("background-image", "url("+icon+")");
  2001. this.icon = icon;
  2002. },
  2003. addLnk: function(dragTargetLnk, dragPosition){
  2004. var options = {"id": this.data.id, "appId": "process.Application"+this.data.id};
  2005. lnkdata = {
  2006. "name": "process.Application",
  2007. "title": this.data.name,
  2008. "iconData": (this.data.icon) || "",
  2009. "icon": null,
  2010. "appType": "process",
  2011. "options": options
  2012. }
  2013. this.layout.addLnk(lnkdata, dragTargetLnk, dragPosition);
  2014. },
  2015. open: function(e){
  2016. var options = {"id": this.data.id, "appId": "process.Application"+this.data.id};
  2017. this.menu.hide(function(){
  2018. if (this.menu.menu){
  2019. this.menu.menu.hide(function(){
  2020. layout.openApplication(e, "process.Application", options);
  2021. }.bind(this));
  2022. }else{
  2023. layout.openApplication(e, "process.Application", options);
  2024. }
  2025. }.bind(this));
  2026. }
  2027. // makeLnk: function(){
  2028. // //@todo
  2029. // // this.node.makeLnk({
  2030. // // "par": {"icon": this.icon, "color": this.color, "title": this.data.title, "par": this.data.path},
  2031. // // });
  2032. // }
  2033. });
  2034. o2.xDesktop.Default.StartMenu.InforItem = new Class({
  2035. Extends: o2.xDesktop.Default.StartMenu.PortalItem,
  2036. loadIcon: function(){
  2037. var icon = "";
  2038. var bgcolor = "";
  2039. if (this.data.appIcon){
  2040. icon = "data:image/png;base64,"+this.data.appIcon+"";
  2041. bgcolor = "";
  2042. }else{
  2043. var p = "cmsDefault";
  2044. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  2045. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  2046. bgcolor = this.layout.iconsJson[p].color;
  2047. }else{
  2048. icon = "../x_component_cms_Index/$Main/default/icon/column.png";
  2049. bgcolor = "";
  2050. }
  2051. }
  2052. if (icon && bgcolor){
  2053. this.iconNode.addClass("layout_start_item_icon_flat");
  2054. this.iconNode.setStyle("background-color", bgcolor);
  2055. }
  2056. this.iconNode.setStyle("background-image", "url("+icon+")");
  2057. this.icon = icon;
  2058. },
  2059. loadText: function(){
  2060. this.textNode.set("text", this.data.appName);
  2061. },
  2062. addLnk: function(dragTargetLnk, dragPosition){
  2063. lnkdata = {
  2064. "name": "cms.Module",
  2065. "title": this.data.appName,
  2066. "iconData": (this.data.appIcon) || "",
  2067. "icon": null,
  2068. "appType": "cms",
  2069. "options": {"columnData": this.data, "appId": "cms.Module"+this.data.id}
  2070. }
  2071. this.layout.addLnk(lnkdata, dragTargetLnk, dragPosition);
  2072. },
  2073. open: function(e){
  2074. this.menu.hide(function(){
  2075. if (this.menu.menu){
  2076. this.menu.menu.hide(function(){
  2077. layout.openApplication(e, "cms.Module", {"columnData": this.data, "appId": "cms.Module"+this.data.id});
  2078. }.bind(this));
  2079. }else{
  2080. layout.openApplication(e, "cms.Module", {"columnData": this.data, "appId": "cms.Module"+this.data.id});
  2081. }
  2082. }.bind(this));
  2083. }
  2084. // makeLnk: function(){
  2085. // //@todo
  2086. // // this.node.makeLnk({
  2087. // // "par": {"icon": this.icon, "color": this.color, "title": this.data.title, "par": this.data.path},
  2088. // // });
  2089. // }
  2090. });
  2091. o2.xDesktop.Default.StartMenu.QueryItem = new Class({
  2092. Extends: o2.xDesktop.Default.StartMenu.PortalItem,
  2093. loadIcon: function(){
  2094. var icon = "";
  2095. var bgcolor = "";
  2096. if (this.data.icon){
  2097. icon = "data:image/png;base64,"+this.data.icon+"";
  2098. bgcolor = "";
  2099. }else{
  2100. var p = "queryDefault";
  2101. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  2102. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  2103. bgcolor = this.layout.iconsJson[p].color;
  2104. }else{
  2105. icon = "../x_component_query_Query/$Main/appicon.png";
  2106. bgcolor = "";
  2107. }
  2108. }
  2109. if (icon && bgcolor){
  2110. this.iconNode.addClass("layout_start_item_icon_flat");
  2111. this.iconNode.setStyle("background-color", bgcolor);
  2112. }
  2113. this.iconNode.setStyle("background-image", "url("+icon+")");
  2114. this.icon = icon;
  2115. },
  2116. addLnk: function(){
  2117. lnkdata = {
  2118. "name": "query.Query",
  2119. "title": this.data.name,
  2120. "iconData": (this.data.icon)||"",
  2121. "icon": null,
  2122. "appType": "query",
  2123. "options": {"id": this.data.id, "appId": "query.Query"+this.data.id}
  2124. }
  2125. this.layout.addLnk(lnkdata, dragTargetLnk, dragPosition);
  2126. },
  2127. open: function(e){
  2128. this.menu.hide(function(){
  2129. if (this.menu.menu){
  2130. this.menu.menu.hide(function(){
  2131. layout.openApplication(e, "query.Query", {"id": this.data.id, "appId": "query.Query"+this.data.id});
  2132. }.bind(this));
  2133. }else{
  2134. layout.openApplication(e, "query.Query", {"id": this.data.id, "appId": "query.Query"+this.data.id});
  2135. }
  2136. }.bind(this));
  2137. }
  2138. // makeLnk: function(){
  2139. // //@todo
  2140. // // this.node.makeLnk({
  2141. // // "par": {"icon": this.icon, "color": this.color, "title": this.data.title, "par": this.data.path},
  2142. // // });
  2143. // }
  2144. });
  2145. o2.xDesktop.Default.TaskItem = new Class({
  2146. initialize: function(desktop, app){
  2147. this.desktop = desktop;
  2148. this.container = this.desktop.taskContentNode;
  2149. this.app = app;
  2150. this.load();
  2151. },
  2152. load: function(){
  2153. this.node = new Element("div.layout_content_taskbar_item").inject(this.container);
  2154. this.iconNode = new Element("div");
  2155. this.closeNode = new Element("div.layout_content_taskbar_item_icon", {"title": o2.LP.widget.close}).inject(this.node);
  2156. this.closeNode.addClass("icon_close");
  2157. if (this.app.options.appId==this.desktop.options.index){
  2158. this.closeNode.hide();
  2159. this.noCloseNode = true;
  2160. }
  2161. this.refreshNode = new Element("div.layout_content_taskbar_item_refresh", {"title": o2.LP.widget.refresh}).inject(this.node);;
  2162. this.refreshNode.addClass("icon_refresh");
  2163. this.refreshNode.addClass("animation_taskItemLoading");
  2164. this.actionNode = new Element("div.layout_content_taskbar_item_action").inject(this.node);;
  2165. this.actionNode.addClass("icon_taskitem_down");
  2166. this.textNode = new Element("div.layout_content_taskbar_item_text").inject(this.node);;
  2167. this.setText(this.app.options.title);
  2168. //this.desktop.checkTaskBarSize();
  2169. this.setEvent();
  2170. this.unSelected();
  2171. },
  2172. setEvent: function(){
  2173. this.textNode.addEvents({
  2174. "click": function(){
  2175. if (this.desktop.currentApp!=this.app){
  2176. if (!this.app.window){
  2177. this.desktop.apps[this.app.options.appId] = null;
  2178. layout.openApplication(null, this.app.options.name, this.app.options, this.app.options.app, false, this, false);
  2179. }else{
  2180. this.app.setCurrent();
  2181. }
  2182. }else{
  2183. // this.app.refresh();
  2184. }
  2185. }.bind(this),
  2186. "dblclick": function(){
  2187. this.app.openInNewBrowser((this.app.options.appId==this.desktop.options.index));
  2188. }.bind(this)
  2189. });
  2190. this.closeNode.addEvents({
  2191. "mouseover": function(){
  2192. // if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode_over);
  2193. }.bind(this),
  2194. "mouseout": function(){
  2195. // if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode);
  2196. }.bind(this),
  2197. "click": function(){
  2198. if (!this.app.window){
  2199. this.desktop.apps[this.app.options.appId] = null;
  2200. delete this.desktop.apps[this.app.options.appId];
  2201. this.destroy();
  2202. }else{
  2203. this.app.close();
  2204. }
  2205. }.bind(this)
  2206. });
  2207. this.refreshNode.addEvents({
  2208. "mouseover": function(){
  2209. // if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode_over);
  2210. }.bind(this),
  2211. "mouseout": function(){
  2212. // if (!this.layout.currentApp || this.layout.currentApp.taskitem!=this) this.node.setStyles(this.layout.css.taskItemNode);
  2213. }.bind(this),
  2214. "click": function(){
  2215. this.app.refresh();
  2216. }.bind(this)
  2217. });
  2218. this.loadTaskItemMenu();
  2219. if (this.desktop && this.desktop.checkTaskBarSize) this.desktop.checkTaskBarSize();
  2220. },
  2221. loadTaskItemMenu: function(){
  2222. if (!this.taskitemMenu){
  2223. this.taskitemMenu = new o2.xDesktop.Menu(this.actionNode, {
  2224. "event": "click", "style": "flatUser", "offsetX": -10, "offsetY":6, "container": this.node
  2225. });
  2226. this.taskitemMenu.load();
  2227. this.loadTaskItemMenuItems();
  2228. }
  2229. },
  2230. loadTaskItemMenuItems: function(){
  2231. var img = this.desktop.path+this.desktop.options.style+"/icons/menu_refresh.png";
  2232. this.taskitemMenu.addMenuItem(o2.LP.desktop.refresh, "click", function(e){this.app.refresh(e);}.bind(this), img);
  2233. this.taskitemMenu.addMenuLine();
  2234. //img = this.path+this.options.style+"/icons/logout.png";
  2235. if (this.app.options.appId!==this.desktop.options.index){
  2236. img = this.desktop.path+this.desktop.options.style+"/icons/menu_close.png";
  2237. this.taskitemMenu.addMenuItem(o2.LP.desktop.close, "click", function(){
  2238. if (!this.app.window){
  2239. this.desktop.apps[this.app.options.appId] = null;
  2240. delete this.desktop.apps[this.app.options.appId];
  2241. this.destroy();
  2242. }else{
  2243. this.app.close();
  2244. }
  2245. }.bind(this), img);
  2246. }
  2247. img = this.desktop.path+this.desktop.options.style+"/icons/menu_closeall.png";
  2248. this.taskitemMenu.addMenuItem(o2.LP.desktop.closeAll, "click", function(){
  2249. var keys = Array.clone(Object.keys(this.desktop.apps));
  2250. keys.each(function(key){
  2251. if (!this.desktop.apps[key].isIndex && !this.desktop.apps[key].options.isIndex) this.desktop.apps[key].close();
  2252. }.bind(this));
  2253. keys = null;
  2254. }.bind(this), img);
  2255. img = this.desktop.path+this.desktop.options.style+"/icons/menu_closeother.png";
  2256. this.taskitemMenu.addMenuItem(o2.LP.desktop.closeOther, "click", function(){
  2257. var keys = Array.clone(Object.keys(this.desktop.apps));
  2258. keys.each(function(key){
  2259. if (!this.desktop.apps[key].isIndex &&
  2260. !this.desktop.apps[key].options.isIndex &&
  2261. this.desktop.apps[key].options.appId!=this.app.options.appId) this.desktop.apps[key].close();
  2262. }.bind(this));
  2263. keys = null;
  2264. }.bind(this), img);
  2265. },
  2266. setText: function(str){
  2267. this.textNode.set("text", str || this.app.options.title);
  2268. },
  2269. unSelected: function(){
  2270. this.node.removeClass("mainColor_bg");
  2271. if (!this.noCloseNode) {
  2272. this.closeNode.addClass("icon_close");
  2273. this.closeNode.removeClass("icon_close_focus");
  2274. //this.closeNode.hide();
  2275. }
  2276. if (this.refreshNode) this.refreshNode.hide();
  2277. if (this.actionNode) this.actionNode.hide();
  2278. },
  2279. selected: function(){
  2280. this.node.addClass("mainColor_bg");
  2281. if (!this.noCloseNode){
  2282. this.closeNode.removeClass("icon_close");
  2283. this.closeNode.addClass("icon_close_focus");
  2284. //this.closeNode.show();
  2285. }
  2286. this.desktop.checkTaskBarScrollTo(this.app);
  2287. //this.refreshNode.show();
  2288. if (this.actionNode) this.actionNode.show();
  2289. },
  2290. destroy: function(){
  2291. this.iconNode.destroy();
  2292. this.node.destroy();
  2293. if (this.desktop && this.desktop.checkTaskBarSize) this.desktop.checkTaskBarSize();
  2294. if (this.app.options && this.app.options.appId) delete this.desktop.apps[this.app.options.appId];
  2295. o2.release(this);
  2296. },
  2297. setTaskitemSize: function(){
  2298. this.desktop.checkTaskBarSize();
  2299. this.desktop.checkTaskBarScrollTo();
  2300. }
  2301. });
  2302. o2.xDesktop.Default.Lnk = new Class({
  2303. initialize: function(layout, data, targetLnk, position){
  2304. this.layout = layout;
  2305. this.container = this.layout.lnkAreaNode;
  2306. this.data = data;
  2307. this.load(targetLnk, position);
  2308. },
  2309. load: function(targetLnk, position){
  2310. this.node = new Element("div.layout_menu_lnk_item");
  2311. if (targetLnk){
  2312. if (!position) position = "before";
  2313. this.node.inject(targetLnk.node, position);
  2314. }else{
  2315. this.node.inject(this.container);
  2316. }
  2317. this.iconNode = new Element("div.layout_menu_lnk_item_icon").inject(this.node);
  2318. this.textNode = new Element("div.layout_menu_lnk_item_text", {"text": this.data.title}).inject(this.node);
  2319. this.actionNode = new Element("div.layout_menu_lnk_item_action", {"title": o2.LP.desktop.deleteLnk}).inject(this.node);
  2320. this.actionNode.addClass("icon_off_light");
  2321. var icon = this.getIcon();
  2322. this.iconNode.setStyle("background-image", "url("+icon+")");
  2323. this.setEvent();
  2324. },
  2325. setEvent: function(){
  2326. this.node.addEvents({
  2327. "click": function(){
  2328. if (this.data.name=="Homepage"){
  2329. var name = this.data.name;
  2330. var options = this.data.options;
  2331. if (layout.config.indexPage && layout.config.indexPage.enable && layout.config.indexPage.portal){
  2332. name = "portal.Portal";
  2333. var appId = "portal.Portal"+layout.config.indexPage.portal;
  2334. options = {"name": "portal.Portal", "portalId": layout.config.indexPage.portal, "pageId": layout.config.indexPage.page, "appId": appId};
  2335. }
  2336. layout.openApplication(null, name, options);
  2337. }else{
  2338. layout.openApplication(null, this.data.name, this.data.options);
  2339. }
  2340. }.bind(this),
  2341. "mouseover": function(){
  2342. this.actionNode.fade("in");
  2343. this.node.addClass("overColor_bg");
  2344. this.textNode.fade("in");
  2345. }.bind(this),
  2346. "mouseout": function(){
  2347. this.actionNode.fade("out");
  2348. this.node.removeClass("overColor_bg");
  2349. this.textNode.fade("out");
  2350. }.bind(this)
  2351. });
  2352. this.actionNode.addEvents({
  2353. "click": function(e){
  2354. this.destroy();
  2355. e.stopPropagation();
  2356. }.bind(this),
  2357. "mouseover": function(){
  2358. this.actionNode.addClass("layout_menu_lnk_item_action_shadow");
  2359. }.bind(this),
  2360. "mouseout": function(){
  2361. this.actionNode.removeClass("layout_menu_lnk_item_action_shadow");
  2362. }.bind(this)
  2363. });
  2364. var drag = new Drag(this.node, {
  2365. "stopPropagation": true,
  2366. "compensateScroll": true,
  2367. "onStart": function(el, e){
  2368. this.doDragMove(e);
  2369. drag.stop();
  2370. }.bind(this)
  2371. });
  2372. },
  2373. getDragNode: function(){
  2374. if (!this.dragNode){
  2375. this.dragNode = new Element("div.layout_menu_lnk_item_drag")
  2376. .setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex())
  2377. .inject(this.layout.node);
  2378. var dragIconNode = this.iconNode.clone(true).inject(this.dragNode)
  2379. .removeClass("layout_menu_lnk_item_icon")
  2380. .addClass("layout_menu_lnk_item_icon_drag");
  2381. var p = (this.data.appType) ? this.data.appType+"Default" : this.data.name;
  2382. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].color){
  2383. dragIconNode.setStyle("background-color", this.layout.iconsJson[p].color)
  2384. }
  2385. this.dragRemoveNode = new Element("div.layout_menu_lnk_item_icon_drag_del").inject(this.dragNode)
  2386. .addClass("icon_remove_badge")
  2387. .hide();
  2388. }
  2389. var ps = this.iconNode.getPosition(this.dragNode.getOffsetParent());
  2390. this.dragNode.show().setStyles({
  2391. "left": ""+ps.x+"px", "top": ""+ps.y+"px"
  2392. });
  2393. },
  2394. doDragMove: function(e){
  2395. this.getDragNode();
  2396. var drag = new Drag.Move(this.dragNode, {
  2397. "stopPropagation": true,
  2398. "compensateScroll": true,
  2399. "droppables": [this.container.getParent()],
  2400. "onStart": function(){ this._drag_start(); }.bind(this),
  2401. "onDrag": function(dragging,e){ this._drag_drag(dragging, e); }.bind(this),
  2402. "onEnter": function(dragging, inObj){ this._drag_enter(dragging, inObj); }.bind(this),
  2403. "onLeave": function(dragging, obj){ this._drag_leave(dragging, obj); }.bind(this),
  2404. "onDrop": function(dragging, inObj){ this._drag_drop(dragging, inObj); }.bind(this),
  2405. "onCancel": function(dragging){ this._drag_cancel(dragging); }.bind(this),
  2406. "onComplete": function(dragging, e){ this._drag_complete(dragging, e); }.bind(this),
  2407. });
  2408. drag.start(e);
  2409. this.dragStatus = "order";
  2410. },
  2411. _drag_start: function(){
  2412. this.node.addClass("overColor_bg");
  2413. this.node.addClass("opacity50");
  2414. this.dragTargetLnk = null;
  2415. this.dragPosition = "before";
  2416. },
  2417. _drag_drag: function(dragging, e){
  2418. if (this.dragStatus == "order"){
  2419. if (this.layout.lnks && this.layout.lnks.length){
  2420. var current = e.page.y;
  2421. for (var i=0; i<this.layout.lnks.length; i++){
  2422. var lnk = this.layout.lnks[i];
  2423. var y = lnk.node.getSize().y;
  2424. var top = lnk.node.getPosition(this.layout.node).y;
  2425. var center = top+y/2;
  2426. var bottom = top+y;
  2427. if (top<=current && center>=current){
  2428. this.dragTargetLnk = lnk;
  2429. this.dragPosition = "before";
  2430. break;
  2431. }else if (center<=current && bottom>=current){
  2432. this.dragTargetLnk = lnk;
  2433. this.dragPosition = "after";
  2434. break;
  2435. }
  2436. }
  2437. if (!this.layout.positionNode) this.layout.positionNode = new Element("div.layout_menu_lnk_item_position")
  2438. .setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex())
  2439. .inject(this.layout.node);
  2440. this.layout.positionNode.show();
  2441. if (!this.dragTargetLnk){
  2442. this.dragTargetLnk = this.layout.lnks[this.layout.lnks.length-1];
  2443. this.dragPosition = "after";
  2444. }
  2445. this.layout.positionNode.position({
  2446. relativeTo: this.dragTargetLnk.node,
  2447. position: (this.dragPosition=="before") ? 'topcenter' : 'bottomcenter',
  2448. edge: 'center'
  2449. });
  2450. }
  2451. }
  2452. },
  2453. _drag_enter: function(){
  2454. this.dragStatus = "order";
  2455. if (this.dragRemoveNode) this.dragRemoveNode.hide();
  2456. },
  2457. _drag_leave: function(){
  2458. this.dragStatus = "remove";
  2459. if (this.dragRemoveNode) this.dragRemoveNode.show();
  2460. if (this.layout.positionNode) this.layout.positionNode.hide();
  2461. },
  2462. _drag_drop: function(dragging, inObj){
  2463. if (this.dragStatus == "order" && this.dragTargetLnk && this.dragTargetLnk!=this){
  2464. this.node.inject(this.dragTargetLnk.node, this.dragPosition);
  2465. this.layout.lnks.erase(this);
  2466. var idx = this.layout.lnks.indexOf(this.dragTargetLnk);
  2467. if (this.dragPosition=="before"){
  2468. this.layout.lnks.splice(idx, 0, this);
  2469. }else{
  2470. this.layout.lnks.splice(idx+1, 0, this);
  2471. }
  2472. }
  2473. },
  2474. _drag_cancel: function(dragging){
  2475. dragging.hide();
  2476. if (this.node) {
  2477. this.node.removeClass("overColor_bg");
  2478. this.node.removeClass("opacity50");
  2479. }
  2480. if (this.layout.positionNode) this.layout.positionNode.hide();
  2481. if (this.dragRemoveNode) this.dragRemoveNode.hide();
  2482. },
  2483. _drag_complete: function(dragging){
  2484. if (this.dragStatus == "remove"){
  2485. this.destroy();
  2486. }else{
  2487. this._drag_cancel(dragging);
  2488. }
  2489. },
  2490. destroy: function(){
  2491. this.layout.lnks.erase(this);
  2492. if (this.dragNode) this.dragNode.destroy();
  2493. //if (this.positionNode) this.positionNode.destroy();
  2494. this.node.destroy();
  2495. o2.release(this);
  2496. },
  2497. getIcon: function(){
  2498. if (this.data.icon) return this.data.icon;
  2499. var icon;
  2500. if (this.data.name.substring(0, 4)==="@url"){
  2501. if (this.layout.iconsJson["Url"] && this.layout.iconsJson["Url"].icon){
  2502. icon = this.layout.path+"appicons/"+this.layout.iconsJson["Url"].icon;
  2503. }else{
  2504. icon = this.layout.path+"appicons/url.png";
  2505. }
  2506. }else{
  2507. if (this.data.iconData){
  2508. icon = "data:image/png;base64,"+this.data.iconData+"";
  2509. }else if (this.data.iconPath){
  2510. icon = this.data.iconPath;
  2511. }else{
  2512. var p = (this.data.appType) ? this.data.appType+"Default" : this.data.name;
  2513. if (this.layout.iconsJson[p] && this.layout.iconsJson[p].icon){
  2514. icon = this.layout.path+"appicons/"+this.layout.iconsJson[p].icon;
  2515. }else{
  2516. icon = "../x_component_"+this.data.name.replace(/\./g, "_")+"/$Main/appicon.png";
  2517. }
  2518. }
  2519. }
  2520. return icon;
  2521. }
  2522. });
  2523. o2.xDesktop.zIndexPool = {
  2524. zIndex: 102,
  2525. applyZindex: function(){
  2526. var i = this.zIndex;
  2527. this.zIndex = this.zIndex+2;
  2528. return i;
  2529. }
  2530. };