Calendar.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. setDescriptionEvent: function(){
  10. if (this.descriptionNode){
  11. this.descriptionNode.addEvents({
  12. "mousedown": function(){
  13. this.descriptionNode.setStyle("display", "none");
  14. this.clickSelect();
  15. }.bind(this)
  16. });
  17. }
  18. },
  19. getValue: function(){
  20. var value = this._getBusinessData();
  21. if (!value) value = this._computeValue();
  22. if (value) value = Date.parse(value).format(this.json.format);
  23. return value || "";
  24. },
  25. clickSelect: function(){
  26. if (!this.calendar){
  27. MWF.require("MWF.widget.Calendar", function(){
  28. this.calendar = new MWF.widget.Calendar(this.node.getFirst(), {
  29. "style": "xform",
  30. "isTime": (this.json.selectType==="datetime" || this.json.selectType==="time"),
  31. "timeOnly": (this.json.selectType === "time"),
  32. //"target": this.form.node,
  33. "target": this.form.app.content,
  34. "format": this.json.format,
  35. "onComplate": function(){
  36. this.validationMode();
  37. if(this.validation())this._setBusinessData(this.getInputData("change"));
  38. this.fireEvent("complete");
  39. }.bind(this),
  40. "onChange": function(){
  41. this.fireEvent("change");
  42. }.bind(this),
  43. "onClear": function(){
  44. this.validationMode();
  45. if(this.validation())this._setBusinessData(this.getInputData("change"));
  46. this.fireEvent("clear");
  47. if (!this.node.getFirst().get("value")) if (this.descriptionNode) this.descriptionNode.setStyle("display", "block");
  48. }.bind(this),
  49. "onShow": function(){
  50. if (this.descriptionNode) this.descriptionNode.setStyle("display", "none");
  51. }.bind(this),
  52. "onHide": function(){
  53. if (!this.node.getFirst().get("value")) if (this.descriptionNode) this.descriptionNode.setStyle("display", "block");
  54. }.bind(this)
  55. });
  56. this.calendar.show();
  57. }.bind(this));
  58. }else{
  59. this.node.getFirst().focus();
  60. }
  61. }
  62. });