Commend.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. MWF.xDesktop.requireApp("process.Xform", "$Module", null, false);
  2. MWF.xApplication.cms.Xform.Commend = MWF.CMSCommend = new Class({
  3. Implements: [Events],
  4. Extends: MWF.APP$Module,
  5. iconStyle: "personfieldIcon",
  6. _loadCommend : function (){
  7. var icon ;
  8. if(!this.form.businessData.extend.isCommend){
  9. icon = "commend.png";
  10. this.button.set("title",this.lp.commend.do);
  11. }else {
  12. icon = "commend_do.png";
  13. this.button.set("title",this.lp.commend.undo);
  14. }
  15. this.button.setStyles({
  16. "border" : 0 ,
  17. "width" : "14px",
  18. "height" : "22px",
  19. "background" : "url(../x_component_cms_FormDesigner/Module/Commend/default/icon/"+ icon +") no-repeat",
  20. "background-size" : "cover",
  21. "background-position": "center 0px"
  22. });
  23. this.countNode.setStyles({
  24. "height" : "22px",
  25. "font-size" : "16px",
  26. "line-height" : "22px"
  27. });
  28. this.countNode.set("text",this.form.businessData.document.commendCount);
  29. },
  30. _loadUserInterface: function(){
  31. this.lp = MWF.xApplication.cms.Xform.LP;
  32. var div = new Element("div");
  33. div.set(this.json.properties);
  34. div.inject(this.node, "after");
  35. this.node.destroy();
  36. this.node = div;
  37. this.button = new Element("button",{"text":""}).inject(this.node);
  38. this.countNode = new Element("span").inject(this.node);
  39. this._loadCommend();
  40. this.button.addEvent("click",function (){
  41. if(!this.form.businessData.extend.isCommend){
  42. o2.Actions.load("x_cms_assemble_control").DocumentAction.persist_commend(this.form.businessData.document.id, function( json ){
  43. this.form.businessData.extend.isCommend = true;
  44. this.form.businessData.document.commendCount = this.form.businessData.document.commendCount + 1;
  45. this._loadCommend();
  46. }.bind(this));
  47. }else {
  48. o2.Actions.load("x_cms_assemble_control").DocumentAction.persist_unCommend(this.form.businessData.document.id, function( json ){
  49. this.form.businessData.extend.isCommend = false;
  50. this.form.businessData.document.commendCount = this.form.businessData.document.commendCount - 1;
  51. this._loadCommend();
  52. }.bind(this));
  53. }
  54. }.bind(this));
  55. }
  56. });