Actionbar.js 7.7 KB

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