SettingModuleUI_bak.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. MWF.xDesktop.requireApp("Setting", "SettingLoginUI", null, false);
  2. MWF.xApplication.Setting.UIModuleDocument = new Class({
  3. Extends: MWF.xApplication.Setting.UILoginDocument,
  4. load: function(){
  5. this.node = new Element("div", {"styles": {"overflow": "hidden", "padding-bottom": "80px"}}).inject(this.contentAreaNode);
  6. this.titleName = new Element("div", {"styles": this.explorer.css.explorerContentTitleNode}).inject(this.node);
  7. this.titleName.set("text", this.lp.ui_moduleSetting);
  8. MWF.Actions.get("x_component_assemble_control").listComponent(function(json){
  9. this.moduleList = new MWF.xApplication.Setting.UIModuleDocument.ModuleList(this, this.node, json.data, {
  10. "title": this.lp.ui_module_modules,
  11. "infor": this.lp.ui_module_modules_infor,
  12. "actionTitle": this.lp.ui_module_modules_Action,
  13. "type": "loginStyle",
  14. "onCreateStyle": function(name, css){
  15. this.createStyle(name, css);
  16. }.bind(this)
  17. });
  18. }.bind(this));
  19. },
  20. createStyle: function(name, css){
  21. var id = (new MWF.widget.UUID()).id;
  22. var listItem = {
  23. "title": name,
  24. "name": "indexStyle_"+id,
  25. "id": "indexStyle_"+id,
  26. "preview": css.desktop.desktop.background,
  27. "enabled": true
  28. };
  29. var styleData = {
  30. "title": name,
  31. "name": "indexStyle_"+id,
  32. "id": "indexStyle_"+id,
  33. "data": css
  34. };
  35. this.indexStyleList.styleList.push(listItem);
  36. MWF.UD.putPublicData("indexStyle_"+id, styleData, function(){
  37. MWF.UD.putPublicData("indexStyleList", this.indexStyleList, {
  38. "success": function(){
  39. this.styleList.addItem(listItem);
  40. }.bind(this),
  41. "failure": function(){
  42. MWF.UD.deletePublicData("indexStyle_"+id);
  43. }.bind(this)
  44. });
  45. }.bind(this));
  46. }
  47. });
  48. MWF.xApplication.Setting.UIModuleDocument.ModuleList = new Class({
  49. Extends: MWF.xApplication.Setting.UILoginDocument.StyleList,
  50. addItem: function(item){
  51. this.items.push(new MWF.xApplication.Setting.UIModuleDocument.Item(this, item));
  52. },
  53. createNewCustomStyle: function(e){
  54. layout.desktop.openApplication(e, "Deployment");
  55. }
  56. });
  57. MWF.xApplication.Setting.UIModuleDocument.Item = new Class({
  58. Extends: MWF.xApplication.Setting.UILoginDocument.Style.Item,
  59. load: function(){
  60. this.itemArea = new Element("div", {"styles": this.css.explorerContentListModuleActionAreaNode}).inject(this.content);
  61. this.itemIconArea = new Element("div", {"styles": this.css.explorerContentListItemModuleIconAreaNode}).inject(this.itemArea);
  62. this.itemIcon = new Element("div", {"styles": this.css.explorerContentListItemModuleIconNode}).inject(this.itemIconArea);
  63. // if (this.data.enabled){
  64. // this.checkIcon = new Element("div", {"styles": this.css.explorerContentListCheckIconAreaNode}).inject(this.itemArea);
  65. // this.checkIcon.set("title", this.lp.ui_login_current);
  66. // }else{
  67. // this.checkIcon = new Element("div", {"styles": this.css.explorerContentListNotCheckIconAreaNode}).inject(this.itemArea);
  68. // this.checkIcon.set("title", this.lp.ui_login_setCurrent);
  69. // }
  70. this.itemTextArea = new Element("div", {"styles": this.css.explorerContentListModuleActionTextAreaNode}).inject(this.itemArea);
  71. var icon = "/x_component_"+this.data.path.replace(/\./g, "_")+"/$Main/"+this.data.iconPath;
  72. this.itemIcon.setStyle("background", "url("+icon+") no-repeat center center");
  73. this.itemTextArea.set("text", this.data.title);
  74. //if (this.data.name!="default"){
  75. // this.editAction = new Element("div", {"styles": this.css.explorerContentStyleActionNode, "text": this.lp.edit}).inject(this.content);
  76. //this.copyAction = new Element("div", {"styles": this.css.explorerContentStyleActionNode, "text": this.lp.copy}).inject(this.content);
  77. // this.deleteAction = new Element("div", {"styles": this.css.explorerContentStyleActionNode, "text": this.lp.delete}).inject(this.content);
  78. // }else{
  79. // this.copyAction = new Element("div", {"styles": this.css.explorerContentStyleActionNode, "text": this.lp.copy}).inject(this.content);
  80. // }
  81. //this.setEvents();
  82. }
  83. });
  84. MWF.xApplication.Setting.UIIndexDocument.Editor = new Class({
  85. Extends: MWF.xApplication.Setting.UILoginDocument.Style.Editor,
  86. createCssEditor: function(){
  87. var _self = this;
  88. MWF.require("MWF.widget.Maplist", function(){
  89. Object.each(this.styleCss.desktop, function(v, k){
  90. var mapListNode = new Element("div", {"styles": this.css.explorerContentStyleEditMapNode}).inject(this.editorArea);
  91. var mList = new MWF.widget.Maplist.Style(mapListNode, {"title": "desktop."+k, "style": "styleEditor",
  92. "onChange": function(){
  93. _self.styleCss.desktop[k] = this.toJson();
  94. if (k=="desktop"){
  95. _self.item.data.preview = _self.styleCss.desktop[k].background;
  96. MWF.UD.putPublicData("indexStyleList", _self.item.list.document.indexStyleList);
  97. }
  98. _self.showPreview();
  99. var o = {
  100. "name": _self.item.data.name,
  101. "title": _self.item.data.title,
  102. "id": _self.item.data.id,
  103. "data": _self.styleCss
  104. };
  105. MWF.UD.putPublicData(_self.item.data.id, o);
  106. }
  107. });
  108. mList.app = this.app;
  109. mList.load(v);
  110. }.bind(this));
  111. Object.each(this.styleCss.window, function(v, k){
  112. var mapListNode = new Element("div", {"styles": this.css.explorerContentStyleEditMapNode}).inject(this.editorArea);
  113. var mList = new MWF.widget.Maplist.Style(mapListNode, {"title": "window."+k, "style": "styleEditor",
  114. "onChange": function(){
  115. _self.styleCss.window[k] = this.toJson();
  116. _self.showPreview();
  117. var o = {
  118. "name": _self.item.data.name,
  119. "title": _self.item.data.title,
  120. "id": _self.item.data.id,
  121. "data": _self.styleCss
  122. };
  123. MWF.UD.putPublicData(_self.item.data.id, o);
  124. }
  125. });
  126. mList.app = this.app;
  127. mList.load(v);
  128. }.bind(this));
  129. }.bind(this));
  130. },
  131. showPreview: function(){
  132. this.previewArea.empty();
  133. this.previewNode = new Element("div", {"styles": {"position": "relative", "height": "216px"}}).inject(this.previewArea);
  134. //this.styleCss = this.getCss();
  135. // this.previewNode = new Element("div.previewNode", {"styles": {
  136. // "margin-top": "10px",
  137. // "position": "relative"
  138. // }}).inject(this.itemArea);
  139. MWF.xDesktop.requireApp("Setting", "preview.Layout", function(){
  140. var layout = new MWF.xApplication.Setting.preview.Layout(this.previewNode, {
  141. styles: {"position": "absolute", "height": "720px", "width": "960px", "box-shadow": "0px 0px 30px #666666"}
  142. });
  143. layout.app = this.app;
  144. layout.css = this.styleCss.desktop;
  145. layout.windowCss = this.styleCss.window;
  146. layout.load();
  147. this.previewMaskNode = new Element("div", {"styles": {"position": "absolute", "top": "0px", "left": "0px"}}).inject(this.previewNode);
  148. var size = layout.node.getSize();
  149. var zidx = layout.node.getStyle("z-index") || 0;
  150. if (MWF.xDesktop.zIndexPool) zidx = MWF.xDesktop.zIndexPool.applyZindex();
  151. this.previewMaskNode.setStyles({"width": ""+size.x+"px", "height": ""+size.y+"px", "z-index": zidx});
  152. this.previewMaskNode.addEvents({
  153. "click": function(e){
  154. window.open("/x_desktop/index.html?style="+this.item.data.id+"&styletype="+((this.item.data.name=="default") ? "default" : "custom"));
  155. e.stopPropagation();
  156. }.bind(this),
  157. "mousedown": function(e){e.stopPropagation();},
  158. "mouseup": function(e){e.stopPropagation();}
  159. });
  160. this.previewNode.setStyles({
  161. "transform-origin": "0px 0px",
  162. "transform": "scale(0.6)"
  163. })
  164. }.bind(this));
  165. }
  166. });