Default.js 116 KB

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