Actionbar.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. MWF.xApplication.cms.FormDesigner.Module = MWF.xApplication.cms.FormDesigner.Module || {};
  2. MWF.xDesktop.requireApp("cms.FormDesigner", "Module.$Element", null, false);
  3. MWF.require("MWF.widget.SimpleToolbar", null, false);
  4. MWF.xApplication.cms.FormDesigner.Module.Actionbar = MWF.CMSFCActionbar = new Class({
  5. Extends: MWF.CMSFC$Element,
  6. Implements: [Options, Events],
  7. options: {
  8. "style": "default",
  9. "propertyPath": "/x_component_cms_FormDesigner/Module/Actionbar/actionbar.html"
  10. //"actions": [
  11. // {
  12. // "name": "move",
  13. // "icon": "move1.png",
  14. // "event": "mousedown",
  15. // "action": "move",
  16. // "title": MWF.CMSFD.LP.formAction.move
  17. // },
  18. // {
  19. // "name": "copy",
  20. // "icon": "copy1.png",
  21. // "event": "mousedown",
  22. // "action": "copy",
  23. // "title": MWF.CMSFD.LP.formAction.copy
  24. // },
  25. // {
  26. // "name": "add",
  27. // "icon": "add.png",
  28. // "event": "click",
  29. // "action": "addAction",
  30. // "title": MWF.CMSFD.LP.formAction.add
  31. // },
  32. // {
  33. // "name": "delete",
  34. // "icon": "delete1.png",
  35. // "event": "click",
  36. // "action": "delete",
  37. // "title": MWF.CMSFD.LP.formAction["delete"]
  38. // }
  39. //]
  40. },
  41. addAction: function(){
  42. },
  43. initialize: function(form, options){
  44. this.setOptions(options);
  45. this.path = "/x_component_cms_FormDesigner/Module/Actionbar/";
  46. this.cssPath = "/x_component_cms_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. _createMoveNode: function(){
  58. this.moveNode = new Element("div", {
  59. "MWFType": "actionbar",
  60. "id": this.json.id,
  61. "styles": this.css.moduleNodeMove,
  62. "events": {
  63. "selectstart": function(e){
  64. e.preventDefault();
  65. }
  66. }
  67. }).inject(this.form.container);
  68. },
  69. _createNode: function(callback){
  70. this.node = new Element("div", {
  71. "id": this.json.id,
  72. "MWFType": "actionbar",
  73. "styles": this.css.moduleNode,
  74. "events": {
  75. "selectstart": function(e){
  76. e.preventDefault();
  77. }
  78. }
  79. }).inject(this.form.node);
  80. if (this.form.options.mode == "Mobile"){
  81. this.node.set("text", MWF.CMSFD.LP.notice.notUseModuleInMobile+"("+this.moduleName+")");
  82. this.node.setStyles({"height": "24px", "line-height": "24px", "background-color": "#999"});
  83. }else{
  84. this.toolbarNode = new Element("div").inject(this.node);
  85. this.toolbarWidget = new MWF.widget.SimpleToolbar(this.toolbarNode, {"style": this.json.style}, this);
  86. if (this.json.sysTools.editTools){
  87. this.setToolbars(this.json.sysTools.editTools, this.toolbarNode);
  88. // this.setToolbars(this.json.tools.editTools, this.toolbarNode);
  89. }else{
  90. this.setToolbars(this.json.sysTools, this.toolbarNode);
  91. // this.setToolbars(this.json.tools, this.toolbarNode);
  92. }
  93. // this.resetIcons();
  94. this.toolbarWidget.load();
  95. }
  96. },
  97. _initModule: function(){
  98. this._setNodeProperty();
  99. this._createIconAction();
  100. this._setNodeEvent();
  101. this._refreshActionbar();
  102. },
  103. _refreshActionbar: function(){
  104. if (this.form.options.mode == "Mobile"){
  105. this.node.set("text", MWF.CMSFD.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. if (this.json.sysTools.editTools){
  112. this.setToolbars(this.json.sysTools.editTools, this.toolbarNode);
  113. // this.setToolbars(this.json.tools.editTools, this.toolbarNode);
  114. }else{
  115. this.setToolbars(this.json.sysTools, this.toolbarNode);
  116. // this.setToolbars(this.json.tools, this.toolbarNode);
  117. }
  118. this.toolbarWidget.load();
  119. }
  120. },
  121. //resetIcons: function(){
  122. // var divs = this.toolbarNode.getElements("div");
  123. // divs.each(function(item, idx){
  124. // var img = item.get("MWFButtonImage");
  125. // if (img){
  126. // item.set("MWFButtonImage", this.path+""+this.options.style+"/tools/"+img);
  127. // }
  128. // }.bind(this));
  129. //
  130. //},
  131. setToolbars: function(tools, node){
  132. tools.each(function(tool){
  133. var actionNode = new Element("div", {
  134. "MWFnodetype": tool.type,
  135. "MWFButtonImage": this.path+""+this.options.style+"/tools/"+tool.img,
  136. "MWFButtonImageOver": this.path+""+this.options.style+"/tools/"+tool.img_over,
  137. "title": tool.title,
  138. "MWFButtonAction": tool.action,
  139. "MWFButtonText": tool.text,
  140. }).inject(node);
  141. if (tool.sub){
  142. var subNode = node.getLast();
  143. this.setToolbars(tool.sub, subNode);
  144. }
  145. }.bind(this));
  146. },
  147. _setEditStyle_custom: function(name){
  148. }
  149. });