Actionbar.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. if (!this.toolbarNode) this.toolbarNode = this.node;
  12. if (this.toolbarNode) this.toolbarNode.empty();
  13. //this.node.empty();
  14. MWF.require("MWF.widget.SimpleToolbar", function(){
  15. this.toolbarWidget = new MWF.widget.SimpleToolbar(this.toolbarNode, {"style": this.json.style}, this);
  16. //var json = this.readonly ? this.json.sysTools.readTools : this.json.sysTools.editTools;
  17. //if( this.json.style == "xform_red_simple" ){
  18. // json.each( function( j ){
  19. // var names = j.img.split(".");
  20. // j.img = names[0] + "_red." + names[1];
  21. // });
  22. //}
  23. //this.setToolbars(json, this.toolbarNode);
  24. //this.setCustomToolbars(this.json.tools, this.toolbarNode);
  25. //
  26. //this.toolbarWidget.load();
  27. if (this.json.hideSystemTools){
  28. this.setCustomToolbars(this.json.tools, this.toolbarNode);
  29. this.toolbarWidget.load();
  30. }else{
  31. if (this.json.defaultTools){
  32. this.setToolbars(this.json.defaultTools, this.toolbarNode, this.readonly);
  33. this.setCustomToolbars(this.json.tools, this.toolbarNode);
  34. this.toolbarWidget.load();
  35. }else{
  36. MWF.getJSON("/x_component_cms_Xform/$Form/toolbars.json", function(json){
  37. this.setToolbars(json, this.toolbarNode, this.readonly, true);
  38. this.setCustomToolbars(this.json.tools, this.toolbarNode);
  39. this.toolbarWidget.load();
  40. }.bind(this), false);
  41. }
  42. //MWF.getJSON("/x_component_cms_Xform/$Form/toolbars.json", function(json){
  43. // this.setToolbars(json, this.toolbarNode, this.readonly);
  44. // this.setCustomToolbars(this.json.tools, this.toolbarNode);
  45. //
  46. // this.toolbarWidget.load();
  47. //}.bind(this), false);
  48. }
  49. }.bind(this));
  50. //}
  51. },
  52. setCustomToolbars: function(tools, node){
  53. var path = "/x_component_cms_FormDesigner/Module/Actionbar/";
  54. var style = (this.json.style || "default").indexOf("red") > -1 ? "red" : "blue";
  55. tools.each(function(tool){
  56. var flag = true;
  57. if (this.readonly){
  58. flag = tool.readShow;
  59. }else{
  60. flag = tool.editShow;
  61. }
  62. if (flag){
  63. flag = true;
  64. if (tool.control){
  65. flag = this.form.businessData.control[tool.control]
  66. }
  67. if (tool.condition){
  68. var hideFlag = this.form.Macro.exec(tool.condition, this);
  69. flag = !hideFlag;
  70. }
  71. if (flag){
  72. var actionNode = new Element("div", {
  73. "id": tool.id,
  74. "MWFnodetype": tool.type,
  75. "MWFButtonImage": path+""+this.form.options.style+"/custom/"+ style + "/" +tool.img,
  76. "MWFButtonImageOver": path+""+this.form.options.style+"/custom/white/"+tool.img,
  77. //"MWFButtonImage": "/x_component_cms_FormDesigner/Module/Actionbar/"+ (this.options.style||"default") +"/tools/"+ (this.json.style || "default") +"/"+tool.img,
  78. //"MWFButtonImageOver": "/x_component_cms_FormDesigner/Module/Actionbar/"+ (this.options.style||"default")+"/tools/"+ (this.json.style || "default") +"/"+tool.img_over,
  79. "title": tool.title,
  80. "MWFButtonAction": "runCustomAction",
  81. "MWFButtonText": tool.text
  82. }).inject(node);
  83. if (tool.actionScript){
  84. actionNode.store("script", tool.actionScript);
  85. }
  86. if (tool.sub){
  87. var subNode = node.getLast();
  88. this.setCustomToolbars(tool.sub, subNode);
  89. }
  90. }
  91. }
  92. }.bind(this));
  93. },
  94. setToolbars: function(tools, node, readonly, noCondition){
  95. tools.each(function(tool){
  96. var flag = true;
  97. if (tool.control){
  98. flag = this.form.businessData.control[tool.control]
  99. }
  100. if (!noCondition) if (tool.condition){
  101. var hideFlag = this.form.Macro.exec(tool.condition, this);
  102. flag = !hideFlag;
  103. }
  104. //if (tool.id == "action_processWork"){
  105. // if (!this.form.businessData.task){
  106. // flag = false;
  107. // }
  108. //}
  109. if (readonly){
  110. if (!tool.read) flag = false;
  111. }else{
  112. if (!tool.edit) flag = false;
  113. }
  114. if (this.json.hideSetPopularDocumentTool && tool.id == "action_popular"){
  115. flag = false;
  116. }
  117. if (flag){
  118. var actionNode = new Element("div", {
  119. "id": tool.id,
  120. "MWFnodetype": tool.type,
  121. "MWFButtonImage": "/x_component_cms_FormDesigner/Module/Actionbar/"+(this.options.style||"default") +"/tools/"+ (this.json.style || "default") +"/"+tool.img,
  122. "MWFButtonImageOver": "/x_component_cms_FormDesigner/Module/Actionbar/"+(this.options.style||"default")+"/tools/"+ (this.json.style || "default") +"/"+tool.img_over,
  123. "title": tool.title,
  124. "MWFButtonAction": tool.action,
  125. "MWFButtonText": tool.text
  126. }).inject(node);
  127. if (tool.sub){
  128. var subNode = node.getLast();
  129. this.setToolbars(tool.sub, subNode);
  130. }
  131. }
  132. }.bind(this));
  133. },
  134. runCustomAction: function(bt){
  135. var script = bt.node.retrieve("script");
  136. this.form.Macro.exec(script, this);
  137. },
  138. saveDocument: function(){
  139. this.form.saveDocument();
  140. },
  141. closeDocument: function(){
  142. this.form.closeDocument();
  143. },
  144. publishDocument: function(){
  145. this.form.publishDocument();
  146. },
  147. archiveDocument: function(){
  148. this.form.archiveDocument();
  149. },
  150. redraftDocument: function(){
  151. this.form.redraftDocument();
  152. },
  153. deleteDocument: function(){
  154. this.form.deleteDocument();
  155. },
  156. editDocument: function(){
  157. this.form.editDocument();
  158. },
  159. setPopularDocument: function(){
  160. this.form.setPopularDocument();
  161. }
  162. });