app/assets/javascripts/bootstrap/bootstrap-datepicker.js in bootstrap-rails-engine-2.3.2.0 vs app/assets/javascripts/bootstrap/bootstrap-datepicker.js in bootstrap-rails-engine-3.0.0.0

- old
+ new

@@ -16,11 +16,11 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ========================================================= */ -!function( $ ) { +(function( $ ) { function UTCDate(){ return new Date(Date.UTC.apply(Date, arguments)); } function UTCToday(){ @@ -34,11 +34,10 @@ var that = this; this._process_options(options); this.element = $(element); - this.format = DPGlobal.parseFormat(this.o.format); this.isInline = false; this.isInput = this.element.is('input'); this.component = this.element.is('.date') ? this.element.find('.add-on, .btn') : false; this.hasInput = this.component && this.element.find('input').length; if(this.component && this.component.length === 0) @@ -245,14 +244,12 @@ this.element.trigger({ type: event, date: local_date, format: $.proxy(function(altformat){ - var format = this.format; - if (altformat) - format = DPGlobal.parseFormat(altformat); - return DPGlobal.formatDate(date, format, this.language); + var format = altformat || this.o.format; + return DPGlobal.formatDate(date, format, this.o.language); }, this) }); }, show: function(e) { @@ -327,11 +324,11 @@ } }, getFormattedDate: function(format) { if (format === undefined) - format = this.format; + format = this.o.format; return DPGlobal.formatDate(this.date, format, this.o.language); }, setStartDate: function(startDate){ this._process_options({startDate: startDate}); @@ -376,11 +373,11 @@ } else { date = this.isInput ? this.element.val() : this.element.data('date') || this.element.find('input').val(); delete this.element.data().date; } - this.date = DPGlobal.parseDate(date, this.format, this.o.language); + this.date = DPGlobal.parseDate(date, this.o.format, this.o.language); if(fromArgs) this.setValue(); if (this.date < this.o.startDate) { this.viewDate = new Date(this.o.startDate); @@ -634,14 +631,18 @@ this.showMode(-2); var which = this.o.todayBtn == 'linked' ? null : 'view'; this._setDate(date, which); break; case 'clear': + var element; if (this.isInput) - this.element.val(""); - else - this.element.find('input').val(""); + element = this.element; + else if (this.component) + element = this.element.find('input'); + if (element) + element.val("").change(); + this._trigger('changeDate'); this.update(); if (this.o.autoclose) this.hide(); break; } @@ -1067,10 +1068,12 @@ } return {separators: separators, parts: parts}; }, parseDate: function(date, format, language) { if (date instanceof Date) return date; + if (typeof format === 'string') + format = DPGlobal.parseFormat(format); if (/^[\-+]\d+[dmwy]([\s,]+[\-+]\d+[dmwy])*$/.test(date)) { var part_re = /([\-+]\d+)([dmwy])/, parts = date.match(/([\-+]\d+)([dmwy])/g), part, dir; date = new Date(); @@ -1157,10 +1160,12 @@ } } return date; }, formatDate: function(date, format, language){ + if (typeof format === 'string') + format = DPGlobal.parseFormat(format); var val = { d: date.getUTCDate(), D: dates[language].daysShort[date.getUTCDay()], DD: dates[language].days[date.getUTCDay()], m: date.getUTCMonth() + 1, @@ -1242,6 +1247,6 @@ ); $(function(){ $('[data-provide="datepicker-inline"]').datepicker(); }); -}( window.jQuery ); +}( window.jQuery ));