Actionbar.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. MWF.xApplication.cms.FormDesigner.Module = MWF.xApplication.cms.FormDesigner.Module || {};
  2. MWF.xDesktop.requireApp("process.FormDesigner", "Module.Actionbar", null, false);
  3. MWF.require("MWF.widget.SimpleToolbar", null, false);
  4. MWF.xApplication.cms.FormDesigner.Module.Actionbar = MWF.CMSFCActionbar = new Class({
  5. Extends: MWF.FCActionbar,
  6. options: {
  7. "style": "default",
  8. "propertyPath": "/x_component_cms_FormDesigner/Module/Actionbar/actionbar.html"
  9. },
  10. Implements : [MWF.CMSFCMI],
  11. initialize: function(form, options){
  12. this.setOptions(options);
  13. this.path = "/x_component_cms_FormDesigner/Module/Actionbar/";
  14. this.cssPath = "/x_component_cms_FormDesigner/Module/Actionbar/"+this.options.style+"/css.wcss";
  15. this._loadCss();
  16. this.moduleType = "component";
  17. this.moduleName = "actionbar";
  18. this.Node = null;
  19. this.form = form;
  20. this.container = null;
  21. this.containerNode = null;
  22. this.systemTools = [];
  23. this.customTools = [];
  24. },
  25. _createNode: function(callback){
  26. this.node = new Element("div", {
  27. "id": this.json.id,
  28. "MWFType": "actionbar",
  29. "styles": this.css.moduleNode,
  30. "events": {
  31. "selectstart": function(e){
  32. e.preventDefault();
  33. }
  34. }
  35. }).inject(this.form.node);
  36. if (this.form.options.mode == "Mobile"){
  37. this.node.set("text", MWF.APPFD.LP.notice.notUseModuleInMobile+"("+this.moduleName+")");
  38. this.node.setStyles({"height": "24px", "line-height": "24px", "background-color": "#999"});
  39. }else{
  40. this.toolbarNode = new Element("div").inject(this.node);
  41. this.toolbarWidget = new MWF.widget.SimpleToolbar(this.toolbarNode, {"style": this.json.style}, this);
  42. MWF.getJSON(this.path+"toolbars.json", function(json){
  43. this.setToolbars(json, this.toolbarNode);
  44. this.toolbarWidget.load();
  45. this._setEditStyle_custom( "hideSystemTools" );
  46. this._setEditStyle_custom( "hideSetPopularDocumentTool" );
  47. }.bind(this), false);
  48. // if (this.json.sysTools.editTools){
  49. // this.setToolbars(this.json.sysTools.editTools, this.toolbarNode);
  50. //// this.setToolbars(this.json.tools.editTools, this.toolbarNode);
  51. // }else{
  52. // this.setToolbars(this.json.sysTools, this.toolbarNode);
  53. //// this.setToolbars(this.json.tools, this.toolbarNode);
  54. // }
  55. // this.resetIcons();
  56. }
  57. },
  58. _refreshActionbar: function(){
  59. if (this.form.options.mode == "Mobile"){
  60. this.node.set("text", MWF.APPFD.LP.notice.notUseModuleInMobile+"("+this.moduleName+")");
  61. this.node.setStyles({"height": "24px", "line-height": "24px", "background-color": "#999"});
  62. }else{
  63. this.toolbarNode = this.node.getFirst("div");
  64. this.toolbarNode.empty();
  65. this.toolbarWidget = new MWF.widget.SimpleToolbar(this.toolbarNode, {"style": this.json.style}, this);
  66. if (this.json.defaultTools){
  67. var json = Array.clone(this.json.defaultTools);
  68. this.setToolbars(json, this.toolbarNode);
  69. //if (this.json.tools) json.append(this.json.tools);
  70. //this.setToolbars(json, this.toolbarNode);
  71. if (this.json.tools){
  72. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  73. }
  74. this.toolbarWidget.load();
  75. this._setEditStyle_custom( "hideSystemTools" );
  76. this._setEditStyle_custom( "hideSetPopularDocumentTool" );
  77. //json = null;
  78. }else{
  79. MWF.getJSON(this.path+"toolbars.json", function(json){
  80. this.json.defaultTools = json;
  81. var json = Array.clone(this.json.defaultTools);
  82. this.setToolbars(json, this.toolbarNode);
  83. //if (this.json.tools) json.append(this.json.tools);
  84. //this.setToolbars(json, this.toolbarNode);
  85. if (this.json.tools){
  86. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  87. }
  88. this.toolbarWidget.load();
  89. this._setEditStyle_custom( "hideSystemTools" );
  90. this._setEditStyle_custom( "hideSetPopularDocumentTool" );
  91. //json = null;
  92. }.bind(this), false);
  93. }
  94. // if (this.json.sysTools.editTools){
  95. // this.setToolbars(this.json.sysTools.editTools, this.toolbarNode);
  96. //// this.setToolbars(this.json.tools.editTools, this.toolbarNode);
  97. // }else{
  98. // this.setToolbars(this.json.sysTools, this.toolbarNode);
  99. //// this.setToolbars(this.json.tools, this.toolbarNode);
  100. // }
  101. }
  102. },
  103. //_refreshActionbar: function(){
  104. // if (this.form.options.mode == "Mobile"){
  105. // this.node.set("text", MWF.APPFD.LP.notice.notUseModuleInMobile+"("+this.moduleName+")");
  106. // this.node.setStyles({"height": "24px", "line-height": "24px", "background-color": "#999"});
  107. // }else{
  108. // this.toolbarNode = this.node.getFirst("div");
  109. // this.toolbarNode.empty();
  110. // this.toolbarWidget = new MWF.widget.SimpleToolbar(this.toolbarNode, {"style": this.json.style}, this);
  111. //
  112. // MWF.getJSON(this.path+"toolbars.json", function(json){
  113. // this.setToolbars(json, this.toolbarNode);
  114. // this.toolbarWidget.load();
  115. // this._setEditStyle_custom( "hideSetPopularDocumentTool" );
  116. // }.bind(this), false);
  117. // }
  118. //
  119. //},
  120. setToolbars: function(tools, node){
  121. tools.each(function(tool){
  122. var actionNode = new Element("div", {
  123. "MWFnodetype": tool.type,
  124. "MWFButtonImage": this.path+""+this.options.style +"/tools/"+ (this.json.style || "default") +"/"+tool.img,
  125. "MWFButtonImageOver": this.path+""+this.options.style+"/tools/"+ (this.json.style || "default") +"/"+tool.img_over,
  126. "title": tool.title,
  127. "MWFButtonAction": tool.action,
  128. "MWFButtonText": tool.text
  129. }).inject(node);
  130. this.systemTools.push(actionNode);
  131. if (tool.sub){
  132. var subNode = node.getLast();
  133. this.setToolbars(tool.sub, subNode);
  134. }
  135. }.bind(this));
  136. },
  137. setCustomToolbars: function(tools, node){
  138. var style = (this.json.style || "default").indexOf("red") > -1 ? "red" : "blue";
  139. tools.each(function(tool){
  140. var actionNode = new Element("div", {
  141. "MWFnodetype": tool.type,
  142. "MWFButtonImage": this.path+""+this.options.style +"/custom/"+ style +"/"+tool.img,
  143. "MWFButtonImageOver": this.path+""+this.options.style+"/custom/white/"+tool.img,
  144. "title": tool.title,
  145. "MWFButtonAction": tool.action,
  146. "MWFButtonText": tool.text
  147. }).inject(node);
  148. this.customTools.push(actionNode);
  149. if (tool.sub){
  150. var subNode = node.getLast();
  151. this.setToolbars(tool.sub, subNode);
  152. }
  153. }.bind(this));
  154. },
  155. _setEditStyle_custom: function(name){
  156. if (name=="hideSystemTools"){
  157. if (this.json.hideSystemTools){
  158. this.systemTools.each(function(tool){
  159. tool.setStyle("display", "none");
  160. });
  161. }else{
  162. this.systemTools.each(function(tool){
  163. tool.setStyle("display", "block");
  164. });
  165. }
  166. }
  167. if (name=="hideSetPopularDocumentTool"){
  168. if (this.json.hideSetPopularDocumentTool){
  169. this.systemTools.each(function(tool){
  170. if( tool.get("MWFButtonAction") == "setPopularDocument" ){
  171. tool.setStyle("display", "none");
  172. }
  173. });
  174. }else{
  175. this.systemTools.each(function(tool){
  176. if( tool.get("MWFButtonAction") == "setPopularDocument" ){
  177. tool.setStyle("display", "block");
  178. }
  179. });
  180. }
  181. }
  182. if (name=="defaultTools" || name=="tools"){
  183. this._refreshActionbar();
  184. }
  185. }
  186. });