Actionbar.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. },
  24. _createNode: function(callback){
  25. this.node = new Element("div", {
  26. "id": this.json.id,
  27. "MWFType": "actionbar",
  28. "styles": this.css.moduleNode,
  29. "events": {
  30. "selectstart": function(e){
  31. e.preventDefault();
  32. }
  33. }
  34. }).inject(this.form.node);
  35. if (this.form.options.mode == "Mobile"){
  36. this.node.set("text", MWF.APPFD.LP.notice.notUseModuleInMobile+"("+this.moduleName+")");
  37. this.node.setStyles({"height": "24px", "line-height": "24px", "background-color": "#999"});
  38. }else{
  39. this.toolbarNode = new Element("div").inject(this.node);
  40. this.toolbarWidget = new MWF.widget.SimpleToolbar(this.toolbarNode, {"style": this.json.style}, this);
  41. MWF.getJSON(this.path+"toolbars.json", function(json){
  42. this.setToolbars(json, this.toolbarNode);
  43. this.toolbarWidget.load();
  44. this._setEditStyle_custom( "hideSetPopularDocumentTool" );
  45. }.bind(this), false);
  46. // if (this.json.sysTools.editTools){
  47. // this.setToolbars(this.json.sysTools.editTools, this.toolbarNode);
  48. //// this.setToolbars(this.json.tools.editTools, this.toolbarNode);
  49. // }else{
  50. // this.setToolbars(this.json.sysTools, this.toolbarNode);
  51. //// this.setToolbars(this.json.tools, this.toolbarNode);
  52. // }
  53. // this.resetIcons();
  54. }
  55. },
  56. _refreshActionbar: function(){
  57. if (this.form.options.mode == "Mobile"){
  58. this.node.set("text", MWF.APPFD.LP.notice.notUseModuleInMobile+"("+this.moduleName+")");
  59. this.node.setStyles({"height": "24px", "line-height": "24px", "background-color": "#999"});
  60. }else{
  61. this.toolbarNode = this.node.getFirst("div");
  62. this.toolbarNode.empty();
  63. this.toolbarWidget = new MWF.widget.SimpleToolbar(this.toolbarNode, {"style": this.json.style}, this);
  64. MWF.getJSON(this.path+"toolbars.json", function(json){
  65. //if( this.json.style == "xform_red_simple" ){
  66. // json.each( function( j ){
  67. // var names = j.img.split(".");
  68. // j.img = names[0] + "_red." + names[1];
  69. // });
  70. //}
  71. this.setToolbars(json, this.toolbarNode);
  72. this.toolbarWidget.load();
  73. this._setEditStyle_custom( "hideSetPopularDocumentTool" );
  74. }.bind(this), false);
  75. // if (this.json.sysTools.editTools){
  76. // this.setToolbars(this.json.sysTools.editTools, this.toolbarNode);
  77. //// this.setToolbars(this.json.tools.editTools, this.toolbarNode);
  78. // }else{
  79. // this.setToolbars(this.json.sysTools, this.toolbarNode);
  80. //// this.setToolbars(this.json.tools, this.toolbarNode);
  81. // }
  82. }
  83. },
  84. setToolbars: function(tools, node){
  85. tools.each(function(tool){
  86. var actionNode = new Element("div", {
  87. "MWFnodetype": tool.type,
  88. "MWFButtonImage": this.path+""+this.options.style +"/tools/"+ (this.json.style || "default") +"/"+tool.img,
  89. "MWFButtonImageOver": this.path+""+this.options.style+"/tools/"+ (this.json.style || "default") +"/"+tool.img_over,
  90. "title": tool.title,
  91. "MWFButtonAction": tool.action,
  92. "MWFButtonText": tool.text
  93. }).inject(node);
  94. this.systemTools.push(actionNode);
  95. if (tool.sub){
  96. var subNode = node.getLast();
  97. this.setToolbars(tool.sub, subNode);
  98. }
  99. }.bind(this));
  100. },
  101. _setEditStyle_custom: function(name){
  102. if (name=="hideSetPopularDocumentTool"){
  103. if (this.json.hideSetPopularDocumentTool){
  104. this.systemTools.each(function(tool){
  105. if( tool.get("MWFButtonAction") == "setPopularDocument" ){
  106. tool.setStyle("display", "none");
  107. }
  108. });
  109. }else{
  110. this.systemTools.each(function(tool){
  111. if( tool.get("MWFButtonAction") == "setPopularDocument" ){
  112. tool.setStyle("display", "block");
  113. }
  114. });
  115. }
  116. }
  117. }
  118. });