SettingModuleUI_bak.js 8.8 KB

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