Views.Date = Views.Base.extend({ classType: "Views.Date", tagName: "div", listenEvents: function() { //See Views.Base listenDefaultEvents() this.on("onrender", this.onRender); this.on("oninitialize", this.onInitialize); }, triggerEventsOn: function() { //See Views.Base launchDefaultActionsOn() }, triggerAddModelToCollectionOn: function() { //nothing declare here. //it's a particular case because it's datepicker that launch onAddModelToCollection, see onRender() }, hide: function(callback) { //this.$el.animate({height:'0px'}, 100, callback); var that = this; var oldMinHeight = this.$el.css("min-height"); this.$el.css("min-height", "0px"); this.$el.slideUp(100, function() { that.$el.css("min-height", oldMinHeight); if (callback) { callback(); } }); this.options.isShowed = false; }, show: function(callback) { var that = this; this.$el.slideDown(100, function() { if (callback) { callback(); } that.trigger("onshow"); }); this.options.isShowed = true; }, onInitialize: function() { if (!this.options.enabledateselect && !this.options.enabletimeselect) { this.options.enabledateselect = true; this.options.enabletimeselect = false; } }, selectTemplate: function() { if (this.options.isreadonly == true || this.options.issmartdate == true) { if (this.options.issmartdate == true) { this.options.isreadonly = true; return this.options.descriptor.templates.smartdate; } if (this.options.isreadonly == true) { return this.options.descriptor.templates.readOnly; } } else { return this.options.descriptor.templates.standard; } }, onRender: function() { var that = this; if (this.options.enabledateselect && this.options.enabletimeselect) { this.$el.datetimepicker({ onClose: function(dateText, theDatePicker) { //$("input", that.$el).datetimepicker("hide"); that.$el.trigger("change"); that.trigger("onaddmodeltocollection"); } }); } else { if (this.options.enabledateselect) { this.$el.datepicker({ onSelect: function(dateText, theDatePicker) { //$("input", that.$el).datepicker("hide"); that.$el.trigger("change"); that.trigger("onaddmodeltocollection"); } }); } if (this.options.enabletimeselect) { this.$el.timepicker({ onClose: function(dateText, theDatePicker) { //$("input", that.$el).timepicker("hide"); that.$el.trigger("change"); that.trigger("onaddmodeltocollection"); } }); } } //$(this.el).datepicker($.datepicker.regional[edContext().locale]); if (this.options.issmartdate == true && this.options.model.get("value") != "") { var diffInMinutes = 9999; diffInMinutes = $.datepicker.DateDiff.inMinutes($.datepicker.parseDateTime(edContext().dateFormat, edContext().timeFormat, this.model.get("value")), new Date()); if (diffInMinutes <= 1) { var that = this; setTimeout(function() { that.render(); }, 1000); } else if (diffInMinutes < 60) { var that = this; setTimeout(function() { that.render(); }, 60 * 1000 - 1); } else { if (diffInMinutes < 1440) { var that = this; setTimeout(function() { that.render(); }, 60 * 60 * 1000); } } } return this; }, resetEl: function() { this.$el.val(""); }, resetAddEl: function() { this.$el.val(""); }, postComputeOnError : function () { if (this.model.get("value") != "") { return (!this.model.dateStrValidate(this.model.get("value"))); } return false; } }); Views.DateList = Views.BaseList.extend({ classType: "Views.DateList" });