Default.js 115 KB

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