Default.js 127 KB

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