Main.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. MWF.xApplication.ControlPanel.Main = new Class({
  2. Extends: MWF.xApplication.Common.Main,
  3. Implements: [Options, Events],
  4. options: {
  5. "style": "default",
  6. "name": "ControlPanel",
  7. "icon": "icon.png",
  8. "width": "840",
  9. "isResize": false,
  10. "isMax": false,
  11. "height": "280",
  12. "title": MWF.xApplication.ControlPanel.LP.title
  13. },
  14. loadWindow: function(isCurrent){
  15. debugger;
  16. this.fireAppEvent("queryLoadWindow");
  17. this.window = new MWF.xDesktop.WindowTransparent(this, {"container": this.desktop.node});
  18. this.fireAppEvent("loadWindow");
  19. this.window.show();
  20. this.content = this.window.content;
  21. if (isCurrent) this.setCurrent();
  22. this.fireAppEvent("postLoadWindow");
  23. this.fireAppEvent("queryLoadApplication");
  24. this.loadApplication(function(){
  25. this.fireAppEvent("postLoadApplication");
  26. }.bind(this));
  27. },
  28. loadWindowFlat: function (isCurrent) {
  29. this.window = {
  30. "isHide": false,
  31. "isMax": true,
  32. "maxSize": function () { },
  33. "restore": function () { },
  34. "setCurrent": function () {
  35. //this.content.show();
  36. this.content.removeClass("layout_component_content_hide");
  37. this.content.addClass("layout_component_content_show");
  38. }.bind(this),
  39. "setUncurrent": function () {
  40. //this.content.hide();
  41. debugger;
  42. this.content.addClass("layout_component_content_hide");
  43. this.content.removeClass("layout_component_content_show");
  44. }.bind(this),
  45. "hide": function () { },
  46. "maxOrRestoreSize": function () { },
  47. "restoreSize": function () { },
  48. "close": function (callback) {
  49. this.content.destroy();
  50. if (callback) callback();
  51. }.bind(this)
  52. };
  53. this.window.content = new Element("div.layout_component_content").inject(layout.desktop.contentNode);
  54. this.content = this.window.content;
  55. layout.desktop.addEvent("resize", function () {
  56. this.fireAppEvent("resize");
  57. }.bind(this));
  58. if (isCurrent){
  59. this.setCurrent();
  60. }else{
  61. this.setUncurrent();
  62. }
  63. this.fireAppEvent("postLoadWindow");
  64. this.fireAppEvent("queryLoadApplication");
  65. //load css
  66. if (this.stylePath) this.content.loadCss(this.stylePath);
  67. this.setContentEvent();
  68. this.loadApplication(function () {
  69. this.fireAppEvent("postLoadApplication");
  70. }.bind(this));
  71. this.fireAppEvent("postLoad");
  72. },
  73. setNodeResize: function(){
  74. this.setNodePositionAndSizeFun = this.setNodePositionAndSize.bind(this);
  75. this.setNodePositionAndSizeFun();
  76. this.addEvent("resize", this.setNodePositionAndSizeFun);
  77. // $(window).addEvent("resize", this.setNodePositionAndSizeFun);
  78. // this.addEvent("queryClose", function(){
  79. // $(window).removeEvent("resize", this.setNodePositionAndSizeFun);
  80. // }.bind(this));
  81. },
  82. setNodePositionAndSize: function(){
  83. // if (this.status && this.status.size){
  84. // this.node.setStyles({
  85. // "top": this.status.size.y,
  86. // "left": this.status.size.x
  87. // });
  88. // }else{
  89. this.node.position({
  90. relativeTo: this.desktop.node,
  91. position: 'center',
  92. edge: 'center',
  93. "offset": {
  94. "y": "-120"
  95. }
  96. });
  97. // }
  98. },
  99. recordStatus: function(){
  100. return {"size": this.node.getPosition()};
  101. },
  102. onQueryLoad: function(){
  103. this.lp = MWF.xApplication.ControlPanel.LP;
  104. },
  105. loadApplication: function(callback){
  106. this.layout = this.desktop;
  107. this.apps = [];
  108. //this.loadTitle();
  109. //this.content.setStyle("background-color", "#555555");
  110. if (layout.viewMode==="Default") this.css.contentNode = this.css.contentNodeFlat;
  111. if (this.options.event){
  112. this.css.contentNode.left = this.options.event.page.x;
  113. this.css.contentNode.top = this.options.event.page.y;
  114. // options.fromTop = this.options.event.page.y;
  115. // options.fromLeft = this.options.event.page.x;
  116. }
  117. this.node = new Element("div", {"styles": this.css.contentNode}).inject(this.content);
  118. var morph = new Fx.Morph(this.node, {
  119. "duration": "100",
  120. "transition": Fx.Transitions.Sine.easeOut
  121. });
  122. debugger;
  123. morph.start(this.css.contentNodeTo).chain(function(){
  124. this.setNodeResize();
  125. this.node.addEvent("selectstart", function(e){e.target.setStyle("-webkit-user-select", "none")}.bind(this));
  126. if (layout.viewMode==="Layout"){
  127. this.titleAreaNode = new Element("div", {"styles": this.css.titleAreaNode}).inject(this.node);
  128. this.closeNode = new Element("div", {"styles": this.css.closeNode}).inject(this.titleAreaNode);
  129. this.closeNode.addEvent("click", function(){this.close();}.bind(this));
  130. this.titleNode = new Element("div", {"styles": this.css.titleAreaTextNode, "text": this.lp.titleInfor}).inject(this.titleAreaNode);
  131. }
  132. this.contentNode = new Element("div", {"styles": this.css.contentAreaNode}).inject(this.node);
  133. this.loadApplications();
  134. }.bind(this));
  135. },
  136. loadTitle: function(){
  137. this.titleBar = new Element("div", {"styles": this.css.titleBar}).inject(this.content);
  138. this.taskTitleTextNode = new Element("div", {"styles": this.css.titleTextNode,"text": this.lp.title}).inject(this.titleBar);
  139. },
  140. setContentSize: function(){
  141. var size = this.node.getSize();
  142. var w = size.x*0.9;
  143. var count = (w/120).toInt();
  144. w = Math.min(count, this.apps.length)*120;
  145. this.contentNode.setStyles({"width": ""+w+"px"});
  146. },
  147. loadApplications: function(){
  148. COMMON.JSON.get(this.path+"applications.json", function(catalog){
  149. var user = this.layout.session.user;
  150. var currentNames = [user.name, user.distinguishedName, user.id, user.unique];
  151. if (user.roleList){
  152. user.roleList.each(function(role){
  153. currentNames.push(MWF.name.cn(role));
  154. currentNames.push(role);
  155. });
  156. }
  157. //currentNames = currentNames.concat(user.roleList);
  158. if (user.groupList){
  159. user.groupList.each(function(group){
  160. currentNames.push(MWF.name.cn(group));
  161. currentNames.push(group);
  162. });
  163. }
  164. //currentNames = currentNames.concat(user.groupList);
  165. catalog.each(function(value, key){
  166. var isAllow = true;
  167. if (value.allowList) isAllow = (value.allowList.length) ? (value.allowList.isIntersect(currentNames)) : true;
  168. var isDeny = false;
  169. if (value.denyList) isDeny = (value.denyList.length) ? (value.denyList.isIntersect(currentNames)!==-1) : false;
  170. if ((!isDeny && isAllow)){
  171. this.apps.push({"value":value, "key":key});
  172. this.createApplicationMenu(value, key);
  173. }
  174. this.setContentSize();
  175. this.addEvent("resize", this.setContentSize);
  176. }.bind(this));
  177. }.bind(this));
  178. },
  179. createApplicationMenu: function(value, key){
  180. var applicationMenuNode = new Element("div", {
  181. "styles": this.css.applicationMenuNode,
  182. "title": value.title
  183. }).inject(this.contentNode);
  184. var applicationMenuIconNode = new Element("div", {
  185. "styles": this.css.applicationMenuIconNode
  186. }).inject(applicationMenuNode);
  187. var icon = "../x_component_"+value.path.replace(/\./g, "_")+"/$Main/"+value.iconPath;
  188. applicationMenuIconNode.setStyle("background-image", "url("+icon+")");
  189. new Element("div", {
  190. "styles": this.css.applicationMenuTextNode,
  191. "text": value.title
  192. }).inject(applicationMenuNode);
  193. applicationMenuNode.addEvent("click", function(e){
  194. this.layout.openApplication(e, value.path);
  195. //this.closeApplicationMenu();
  196. }.bind(this));
  197. applicationMenuNode.makeLnk({
  198. "par": {"icon": icon, "title": value.title, "par": value.path},
  199. "onStart": function(){
  200. this.applicationMenuAreaMark.fade("out");
  201. this.applicationMenuArea.fade("out");
  202. }.bind(this),
  203. "onComplete": function(){
  204. //this.showApplicationMenu();
  205. }.bind(this)
  206. });
  207. var appName = value.path;
  208. }
  209. });