Actionbar.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. MWF.xDesktop.requireApp("process.Xform", "Actionbar", null, false);
  2. MWF.xApplication.cms.Xform.Actionbar = MWF.CMSActionbar = new Class({
  3. Extends: MWF.APPActionbar,
  4. _loadUserInterface: function(){
  5. if (this.form.json.mode == "Mobile"){
  6. this.node.empty();
  7. }else if (COMMON.Browser.Platform.isMobile){
  8. this.node.empty();
  9. }else{
  10. this.toolbarNode = this.node.getFirst("div");
  11. this.toolbarNode.empty();
  12. MWF.require("MWF.widget.SimpleToolbar", function(){
  13. this.toolbarWidget = new MWF.widget.SimpleToolbar(this.toolbarNode, {"style": this.json.style}, this);
  14. //var json = this.readonly ? this.json.sysTools.readTools : this.json.sysTools.editTools;
  15. //if( this.json.style == "xform_red_simple" ){
  16. // json.each( function( j ){
  17. // var names = j.img.split(".");
  18. // j.img = names[0] + "_red." + names[1];
  19. // });
  20. //}
  21. //this.setToolbars(json, this.toolbarNode);
  22. //this.setCustomToolbars(this.json.tools, this.toolbarNode);
  23. //
  24. //this.toolbarWidget.load();
  25. MWF.getJSON("/x_component_cms_Xform/$Form/toolbars.json", function(json){
  26. this.setToolbars(json, this.toolbarNode, this.readonly);
  27. this.setCustomToolbars(this.json.tools, this.toolbarNode);
  28. this.toolbarWidget.load();
  29. }.bind(this), false);
  30. }.bind(this));
  31. }
  32. },
  33. setCustomToolbars: function(tools, node){
  34. tools.each(function(tool){
  35. var flag = true;
  36. if (this.readonly){
  37. flag = tool.readShow;
  38. }else{
  39. flag = tool.editShow;
  40. }
  41. if (flag){
  42. flag = true;
  43. if (tool.control){
  44. flag = this.form.businessData.control[tool.control]
  45. }
  46. if (tool.condition){
  47. var hideFlag = this.form.Macro.exec(tool.condition, this);
  48. flag = !hideFlag;
  49. }
  50. if (flag){
  51. var actionNode = new Element("div", {
  52. "id": tool.id,
  53. "MWFnodetype": tool.type,
  54. "MWFButtonImage": this.form.path+""+this.form.options.style+"/actionbar/"+tool.img,
  55. "MWFButtonImageOver": this.form.path+""+this.form.options.style+"/actionbar/"+tool.img,
  56. //"MWFButtonImage": "/x_component_cms_FormDesigner/Module/Actionbar/"+ (this.options.style||"default") +"/tools/"+ (this.json.style || "default") +"/"+tool.img,
  57. //"MWFButtonImageOver": "/x_component_cms_FormDesigner/Module/Actionbar/"+ (this.options.style||"default")+"/tools/"+ (this.json.style || "default") +"/"+tool.img_over,
  58. "title": tool.title,
  59. "MWFButtonAction": "runCustomAction",
  60. "MWFButtonText": tool.text
  61. }).inject(node);
  62. if (tool.actionScript){
  63. actionNode.store("script", tool.actionScript);
  64. }
  65. if (tool.sub){
  66. var subNode = node.getLast();
  67. this.setCustomToolbars(tool.sub, subNode);
  68. }
  69. }
  70. }
  71. }.bind(this));
  72. },
  73. setToolbars: function(tools, node, readonly){
  74. tools.each(function(tool){
  75. var flag = true;
  76. if (tool.control){
  77. flag = this.form.businessData.control[tool.control]
  78. }
  79. if (tool.id == "action_processWork"){
  80. if (!this.form.businessData.task){
  81. flag = false;
  82. }
  83. }
  84. if (readonly){
  85. if (!tool.read) flag = false;
  86. }else{
  87. if (!tool.edit) flag = false;
  88. }
  89. if (this.json.hideSetPopularDocumentTool && tool.id == "action_popular"){
  90. flag = false;
  91. }
  92. if (flag){
  93. var actionNode = new Element("div", {
  94. "id": tool.id,
  95. "MWFnodetype": tool.type,
  96. "MWFButtonImage": "/x_component_cms_FormDesigner/Module/Actionbar/"+(this.options.style||"default") +"/tools/"+ (this.json.style || "default") +"/"+tool.img,
  97. "MWFButtonImageOver": "/x_component_cms_FormDesigner/Module/Actionbar/"+(this.options.style||"default")+"/tools/"+ (this.json.style || "default") +"/"+tool.img_over,
  98. "title": tool.title,
  99. "MWFButtonAction": tool.action,
  100. "MWFButtonText": tool.text
  101. }).inject(node);
  102. if (tool.sub){
  103. var subNode = node.getLast();
  104. this.setToolbars(tool.sub, subNode);
  105. }
  106. }
  107. }.bind(this));
  108. },
  109. runCustomAction: function(bt){
  110. var script = bt.node.retrieve("script");
  111. this.form.Macro.exec(script, this);
  112. },
  113. saveDocument: function(){
  114. this.form.saveDocument();
  115. },
  116. closeDocument: function(){
  117. this.form.closeDocument();
  118. },
  119. publishDocument: function(){
  120. this.form.publishDocument();
  121. },
  122. archiveDocument: function(){
  123. this.form.archiveDocument();
  124. },
  125. redraftDocument: function(){
  126. this.form.redraftDocument();
  127. },
  128. deleteDocument: function(){
  129. this.form.deleteDocument();
  130. },
  131. editDocument: function(){
  132. this.form.editDocument();
  133. },
  134. setPopularDocument: function(){
  135. this.form.setPopularDocument();
  136. }
  137. });