Actionbar.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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.containers = [];
  55. //this.elements = [];
  56. },
  57. setTemplateStyles: function(styles){
  58. this.json.style = styles.style;
  59. },
  60. clearTemplateStyles: function(styles){
  61. this.json.style = "form";
  62. },
  63. setAllStyles: function(){
  64. this._refreshActionbar();
  65. },
  66. _createMoveNode: function(){
  67. this.moveNode = new Element("div", {
  68. "MWFType": "actionbar",
  69. "id": this.json.id,
  70. "styles": this.css.moduleNodeMove,
  71. "events": {
  72. "selectstart": function(e){
  73. e.preventDefault();
  74. }
  75. }
  76. }).inject(this.form.container);
  77. },
  78. _createNode: function(callback){
  79. this.node = new Element("div", {
  80. "id": this.json.id,
  81. "MWFType": "actionbar",
  82. "styles": this.css.moduleNode,
  83. "events": {
  84. "selectstart": function(e){
  85. e.preventDefault();
  86. }
  87. }
  88. }).inject(this.form.node);
  89. if (this.form.options.mode == "Mobile"){
  90. this.node.set("text", MWF.APPFD.LP.notice.notUseModuleInMobile+"("+this.moduleName+")");
  91. this.node.setStyles({"height": "24px", "line-height": "24px", "background-color": "#999"});
  92. }else{
  93. this.toolbarNode = new Element("div").inject(this.node);
  94. this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
  95. MWF.getJSON(this.path+"toolbars.json", function(json){
  96. this.setToolbars(json, this.toolbarNode);
  97. this.toolbarWidget.load();
  98. }.bind(this), false);
  99. // if (this.json.sysTools.editTools){
  100. // this.setToolbars(this.json.sysTools.editTools, this.toolbarNode);
  101. //// this.setToolbars(this.json.tools.editTools, this.toolbarNode);
  102. // }else{
  103. // this.setToolbars(this.json.sysTools, this.toolbarNode);
  104. //// this.setToolbars(this.json.tools, this.toolbarNode);
  105. // }
  106. // this.resetIcons();
  107. }
  108. },
  109. _initModule: function(){
  110. this.setStyleTemplate();
  111. this._setNodeProperty();
  112. this._createIconAction();
  113. this._setNodeEvent();
  114. this._refreshActionbar();
  115. },
  116. _refreshActionbar: function(){
  117. if (this.form.options.mode == "Mobile"){
  118. this.node.set("text", MWF.APPFD.LP.notice.notUseModuleInMobile+"("+this.moduleName+")");
  119. this.node.setStyles({"height": "24px", "line-height": "24px", "background-color": "#999"});
  120. }else{
  121. this.toolbarNode = this.node.getFirst("div");
  122. this.toolbarNode.empty();
  123. this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
  124. MWF.getJSON(this.path+"toolbars.json", function(json){
  125. this.setToolbars(json, this.toolbarNode);
  126. this.toolbarWidget.load();
  127. }.bind(this), false);
  128. // if (this.json.sysTools.editTools){
  129. // this.setToolbars(this.json.sysTools.editTools, this.toolbarNode);
  130. //// this.setToolbars(this.json.tools.editTools, this.toolbarNode);
  131. // }else{
  132. // this.setToolbars(this.json.sysTools, this.toolbarNode);
  133. //// this.setToolbars(this.json.tools, this.toolbarNode);
  134. // }
  135. }
  136. },
  137. //resetIcons: function(){
  138. // var divs = this.toolbarNode.getElements("div");
  139. // divs.each(function(item, idx){
  140. // var img = item.get("MWFButtonImage");
  141. // if (img){
  142. // item.set("MWFButtonImage", this.path+""+this.options.style+"/tools/"+img);
  143. // }
  144. // }.bind(this));
  145. //
  146. //},
  147. setToolbars: function(tools, node){
  148. tools.each(function(tool){
  149. var actionNode = new Element("div", {
  150. "MWFnodetype": tool.type,
  151. "MWFButtonImage": this.path+""+this.options.style+"/tools/"+tool.img,
  152. "title": tool.title,
  153. "MWFButtonAction": tool.action,
  154. "MWFButtonText": tool.text,
  155. }).inject(node);
  156. if (tool.sub){
  157. var subNode = node.getLast();
  158. this.setToolbars(tool.sub, subNode);
  159. }
  160. }.bind(this));
  161. },
  162. _setEditStyle_custom: function(name){
  163. }
  164. });