{I" class:ETI"ProcessedAsset; FI"logical_path; TI" bootstrap-datetimepicker.js; FI" pathname; TI"Ž/home/bigxiang/.rvm/gems/ruby-2.0.0-p0@rails4/gems/bootstrap-datetimepicker-rails-0.0.11/vendor/assets/javascripts/bootstrap-datetimepicker.js; FI"content_type; TI"application/javascript; TI" mtime; Tl+^N1RI"length; TiWªI"digest; TI"%41aa9d0135a68151428bd77fd3d8a577; FI"source; TI"Wª/** * @license * ========================================================= * bootstrap-datetimepicker.js * http://www.eyecon.ro/bootstrap-datepicker * ========================================================= * Copyright 2012 Stefan Petre * * Contributions: * - Andrew Rowls * - Thiago de Arruda * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * 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($) { // Picker object var smartPhone = (window.orientation != undefined); var DateTimePicker = function(element, options) { this.id = dpgId++; this.init(element, options); }; var dateToDate = function(dt) { if (typeof dt === 'string') { return new Date(dt); } return dt; }; DateTimePicker.prototype = { constructor: DateTimePicker, init: function(element, options) { var icon; if (!(options.pickTime || options.pickDate)) throw new Error('Must choose at least one picker'); this.options = options; this.$element = $(element); this.language = options.language in dates ? options.language : 'en' this.pickDate = options.pickDate; this.pickTime = options.pickTime; this.isInput = this.$element.is('input'); this.component = false; if (this.$element.find('.input-append') || this.$element.find('.input-prepend')) this.component = this.$element.find('.add-on'); this.format = options.format; if (!this.format) { if (this.isInput) this.format = this.$element.data('format'); else this.format = this.$element.find('input').data('format'); if (!this.format) this.format = 'MM/dd/yyyy'; } this._compileFormat(); if (this.component) { icon = this.component.find('i'); } if (this.pickTime) { if (icon && icon.length) this.timeIcon = icon.data('time-icon'); if (!this.timeIcon) this.timeIcon = 'icon-time'; icon.addClass(this.timeIcon); } if (this.pickDate) { if (icon && icon.length) this.dateIcon = icon.data('date-icon'); if (!this.dateIcon) this.dateIcon = 'icon-calendar'; icon.removeClass(this.timeIcon); icon.addClass(this.dateIcon); } this.widget = $(getTemplate(this.timeIcon, options.pickDate, options.pickTime, options.pick12HourFormat, options.pickSeconds, options.collapse)).appendTo('body'); this.minViewMode = options.minViewMode||this.$element.data('date-minviewmode')||0; if (typeof this.minViewMode === 'string') { switch (this.minViewMode) { case 'months': this.minViewMode = 1; break; case 'years': this.minViewMode = 2; break; default: this.minViewMode = 0; break; } } this.viewMode = options.viewMode||this.$element.data('date-viewmode')||0; if (typeof this.viewMode === 'string') { switch (this.viewMode) { case 'months': this.viewMode = 1; break; case 'years': this.viewMode = 2; break; default: this.viewMode = 0; break; } } this.startViewMode = this.viewMode; this.weekStart = options.weekStart||this.$element.data('date-weekstart')||0; this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1; this.setStartDate(options.startDate || this.$element.data('date-startdate')); this.setEndDate(options.endDate || this.$element.data('date-enddate')); this.fillDow(); this.fillMonths(); this.fillHours(); this.fillMinutes(); this.fillSeconds(); this.update(); this.showMode(); this._attachDatePickerEvents(); }, show: function(e) { this.widget.show(); this.height = this.component ? this.component.outerHeight() : this.$element.outerHeight(); this.place(); this.$element.trigger({ type: 'show', date: this._date }); this._attachDatePickerGlobalEvents(); if (e) { e.stopPropagation(); e.preventDefault(); } }, disable: function(){ this.$element.find('input').prop('disabled',true); this._detachDatePickerEvents(); }, enable: function(){ this.$element.find('input').prop('disabled',false); this._attachDatePickerEvents(); }, hide: function() { // Ignore event if in the middle of a picker transition var collapse = this.widget.find('.collapse') for (var i = 0; i < collapse.length; i++) { var collapseData = collapse.eq(i).data('collapse'); if (collapseData && collapseData.transitioning) return; } this.widget.hide(); this.viewMode = this.startViewMode; this.showMode(); this.set(); this.$element.trigger({ type: 'hide', date: this._date }); this._detachDatePickerGlobalEvents(); }, set: function() { var formatted = ''; if (!this._unset) formatted = this.formatDate(this._date); if (!this.isInput) { if (this.component){ var input = this.$element.find('input'); input.val(formatted); this._resetMaskPos(input); } this.$element.data('date', formatted); } else { this.$element.val(formatted); this._resetMaskPos(this.$element); } }, setValue: function(newDate) { if (!newDate) { this._unset = true; } else { this._unset = false; } if (typeof newDate === 'string') { this._date = this.parseDate(newDate); } else if(newDate) { this._date = new Date(newDate); } this.set(); this.viewDate = UTCDate(this._date.getUTCFullYear(), this._date.getUTCMonth(), 1, 0, 0, 0, 0); this.fillDate(); this.fillTime(); }, getDate: function() { if (this._unset) return null; return new Date(this._date.valueOf()); }, setDate: function(date) { if (!date) this.setValue(null); else this.setValue(date.valueOf()); }, setStartDate: function(date) { if (date instanceof Date) { this.startDate = date; } else if (typeof date === 'string') { this.startDate = new UTCDate(date); if (! this.startDate.getUTCFullYear()) { this.startDate = -Infinity; } } else { this.startDate = -Infinity; } if (this.viewDate) { this.update(); } }, setEndDate: function(date) { if (date instanceof Date) { this.endDate = date; } else if (typeof date === 'string') { this.endDate = new UTCDate(date); if (! this.endDate.getUTCFullYear()) { this.endDate = Infinity; } } else { this.endDate = Infinity; } if (this.viewDate) { this.update(); } }, getLocalDate: function() { if (this._unset) return null; var d = this._date; return new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()); }, setLocalDate: function(localDate) { if (!localDate) this.setValue(null); else this.setValue(Date.UTC( localDate.getFullYear(), localDate.getMonth(), localDate.getDate(), localDate.getHours(), localDate.getMinutes(), localDate.getSeconds(), localDate.getMilliseconds())); }, place: function(){ var position = 'absolute'; var offset = this.component ? this.component.offset() : this.$element.offset(); this.width = this.component ? this.component.outerWidth() : this.$element.outerWidth(); offset.top = offset.top + this.height; var $window = $(window); if ( this.options.width != undefined ) { this.widget.width( this.options.width ); } if ( this.options.orientation == 'left' ) { this.widget.addClass( 'left-oriented' ); offset.left = offset.left - this.widget.width() + 20; } if (this._isInFixed()) { position = 'fixed'; offset.top -= $window.scrollTop(); offset.left -= $window.scrollLeft(); } if ($window.width() < offset.left + this.widget.outerWidth()) { offset.right = $window.width() - offset.left - this.width; offset.left = 'auto'; this.widget.addClass('pull-right'); } else { offset.right = 'auto'; this.widget.removeClass('pull-right'); } this.widget.css({ position: position, top: offset.top, left: offset.left, right: offset.right }); }, notifyChange: function(){ this.$element.trigger({ type: 'changeDate', date: this.getDate(), localDate: this.getLocalDate() }); }, update: function(newDate){ var dateStr = newDate; if (!dateStr) { if (this.isInput) { dateStr = this.$element.val(); } else { dateStr = this.$element.find('input').val(); } if (dateStr) { this._date = this.parseDate(dateStr); } if (!this._date) { var tmp = new Date() this._date = UTCDate(tmp.getFullYear(), tmp.getMonth(), tmp.getDate(), tmp.getHours(), tmp.getMinutes(), tmp.getSeconds(), tmp.getMilliseconds()) } } this.viewDate = UTCDate(this._date.getUTCFullYear(), this._date.getUTCMonth(), 1, 0, 0, 0, 0); this.fillDate(); this.fillTime(); }, fillDow: function() { var dowCnt = this.weekStart; var html = $('