Calendar.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. MWF.xDesktop.requireApp("process.Xform", "$Input", null, false);
  2. MWF.xApplication.process.Xform.Calendar = MWF.APPCalendar = new Class({
  3. Implements: [Events],
  4. Extends: MWF.APP$Input,
  5. iconStyle: "calendarIcon",
  6. options: {
  7. "moduleEvents": ["complete", "clear", "change"]
  8. },
  9. _loadNode: function(){
  10. if (this.readonly || this.json.isReadonly){
  11. this._loadNodeRead();
  12. }else{
  13. this._loadNodeEdit();
  14. }
  15. },
  16. setDescriptionEvent: function(){
  17. if (this.descriptionNode){
  18. this.descriptionNode.addEvents({
  19. "mousedown": function(){
  20. this.descriptionNode.setStyle("display", "none");
  21. this.clickSelect();
  22. }.bind(this)
  23. });
  24. }
  25. },
  26. getValue: function(){
  27. var value = this._getBusinessData();
  28. if (!value) value = this._computeValue();
  29. if (value) value = Date.parse(value).format(this.json.format);
  30. return value || "";
  31. },
  32. clickSelect: function(){
  33. if (!this.calendar){
  34. MWF.require("MWF.widget.Calendar", function(){
  35. this.calendar = new MWF.widget.Calendar(this.node.getFirst(), {
  36. "style": "xform",
  37. "isTime": (this.json.selectType==="datetime" || this.json.selectType==="time"),
  38. "timeOnly": (this.json.selectType === "time"),
  39. //"target": this.form.node,
  40. "target": this.form.app.content,
  41. "format": this.json.format,
  42. "onComplate": function(){
  43. this.validationMode();
  44. if(this.validation())this._setBusinessData(this.getInputData("change"));
  45. this.fireEvent("complete");
  46. }.bind(this),
  47. "onChange": function(){
  48. this.fireEvent("change");
  49. }.bind(this),
  50. "onClear": function(){
  51. this.validationMode();
  52. if(this.validation())this._setBusinessData(this.getInputData("change"));
  53. this.fireEvent("clear");
  54. if (!this.node.getFirst().get("value")) if (this.descriptionNode) this.descriptionNode.setStyle("display", "block");
  55. }.bind(this),
  56. "onShow": function(){
  57. if (this.descriptionNode) this.descriptionNode.setStyle("display", "none");
  58. }.bind(this),
  59. "onHide": function(){
  60. if (!this.node.getFirst().get("value")) if (this.descriptionNode) this.descriptionNode.setStyle("display", "block");
  61. }.bind(this)
  62. });
  63. this.calendar.show();
  64. }.bind(this));
  65. }else{
  66. this.node.getFirst().focus();
  67. }
  68. }
  69. });