Actionbar.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. },
  11. addAction: function(){
  12. },
  13. initialize: function(form, options){
  14. this.setOptions(options);
  15. this.path = "/x_component_process_FormDesigner/Module/Actionbar/";
  16. this.cssPath = "/x_component_process_FormDesigner/Module/Actionbar/"+this.options.style+"/css.wcss";
  17. this._loadCss();
  18. this.moduleType = "component";
  19. this.moduleName = "actionbar";
  20. this.Node = null;
  21. this.form = form;
  22. this.container = null;
  23. this.containerNode = null;
  24. this.systemTools = [];
  25. //this.containers = [];
  26. //this.elements = [];
  27. },
  28. setTemplateStyles: function(styles){
  29. this.json.style = styles.style;
  30. },
  31. clearTemplateStyles: function(styles){
  32. this.json.style = "form";
  33. },
  34. setAllStyles: function(){
  35. this._refreshActionbar();
  36. },
  37. _createMoveNode: function(){
  38. this.moveNode = new Element("div", {
  39. "MWFType": "actionbar",
  40. "id": this.json.id,
  41. "styles": this.css.moduleNodeMove,
  42. "events": {
  43. "selectstart": function(e){
  44. e.preventDefault();
  45. }
  46. }
  47. }).inject(this.form.container);
  48. },
  49. _createNode: function(callback){
  50. this.node = new Element("div", {
  51. "id": this.json.id,
  52. "MWFType": "actionbar",
  53. "styles": this.css.moduleNode,
  54. "events": {
  55. "selectstart": function(e){
  56. e.preventDefault();
  57. }
  58. }
  59. }).inject(this.form.node);
  60. if (this.form.options.mode == "Mobile"){
  61. this.node.set("text", MWF.APPFD.LP.notice.notUseModuleInMobile+"("+this.moduleName+")");
  62. this.node.setStyles({"height": "24px", "line-height": "24px", "background-color": "#999"});
  63. }else{
  64. this.toolbarNode = new Element("div").inject(this.node);
  65. this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
  66. MWF.getJSON(this.path+"toolbars.json", function(json){
  67. this.json.defaultTools = json;
  68. this.setToolbars(json, this.toolbarNode);
  69. this.toolbarWidget.load();
  70. }.bind(this), false);
  71. // if (this.json.sysTools.editTools){
  72. // this.setToolbars(this.json.sysTools.editTools, this.toolbarNode);
  73. //// this.setToolbars(this.json.tools.editTools, this.toolbarNode);
  74. // }else{
  75. // this.setToolbars(this.json.sysTools, this.toolbarNode);
  76. //// this.setToolbars(this.json.tools, this.toolbarNode);
  77. // }
  78. // this.resetIcons();
  79. }
  80. },
  81. _initModule: function(){
  82. this.setStyleTemplate();
  83. this._setNodeProperty();
  84. if (!this.form.isSubform) this._createIconAction();
  85. this._setNodeEvent();
  86. this._refreshActionbar();
  87. },
  88. _refreshActionbar: function(){
  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 = this.node.getFirst("div");
  94. this.toolbarNode.empty();
  95. this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
  96. if (!this.json.actionStyles) this.json.actionStyles = Object.clone(this.toolbarWidget.css);
  97. this.toolbarWidget.css = this.json.actionStyles;
  98. if (this.json.defaultTools){
  99. var json = Array.clone(this.json.defaultTools);
  100. if (this.json.tools) json.append(this.json.tools);
  101. this.setToolbars(json, this.toolbarNode);
  102. this.toolbarWidget.load();
  103. //json = null;
  104. }else{
  105. MWF.getJSON(this.path+"toolbars.json", function(json){
  106. this.json.defaultTools = json;
  107. var json = Array.clone(this.json.defaultTools);
  108. if (this.json.tools) json.append(this.json.tools);
  109. this.setToolbars(json, this.toolbarNode);
  110. this.toolbarWidget.load();
  111. //json = null;
  112. }.bind(this), false);
  113. }
  114. }
  115. },
  116. setToolbars: function(tools, node){
  117. tools.each(function(tool){
  118. var actionNode = new Element("div", {
  119. "MWFnodetype": tool.type,
  120. "MWFButtonImage": this.path+""+this.options.style+"/tools/"+tool.img,
  121. "title": tool.title,
  122. "MWFButtonAction": tool.action,
  123. "MWFButtonText": tool.text
  124. }).inject(node);
  125. this.systemTools.push(actionNode);
  126. if (tool.sub){
  127. var subNode = node.getLast();
  128. this.setToolbars(tool.sub, subNode);
  129. }
  130. }.bind(this));
  131. },
  132. _setEditStyle_custom: function(name){
  133. if (name=="hideSystemTools"){
  134. if (this.json.hideSystemTools){
  135. this.systemTools.each(function(tool){
  136. tool.setStyle("display", "none");
  137. });
  138. }else{
  139. this.systemTools.each(function(tool){
  140. tool.setStyle("display", "block");
  141. });
  142. }
  143. }
  144. if (name=="defaultTools" || name=="tools" || name==="actionStyles"){
  145. this._refreshActionbar();
  146. }
  147. }
  148. });