Actionbar.js 6.6 KB

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