PageSourceSearch

https://predaj.zssk.sk/javax.faces.resource/js/bootstrap-datepicke…cbEkANGmbsv9Bu8!1435662721?ln=version&v=4_0

js zssk.sk collected 2026-09-24 09:23:46 UTC 77,873 bytes, 2,070 lines download raw bytes

vendor: 43,602 bytes, lines 1-1142
1/*!
2 * Datepicker for Bootstrap v1.7.1 (https://github.com/uxsolutions/bootstrap-datepicker)
3 *
4 * Licensed under the Apache License v2.0 (http://www.apache.org/licenses/LICENSE-2.0)
5 */
6
7(function(factory){
8    if (typeof define === "function" && define.amd) {
9        define(["jquery"], factory);
10    } else if (typeof exports === 'object') {
11        factory(require('jquery'));
12    } else {
13        factory(jQuery);
14    }
15}(function($, undefined){
16    function UTCDate(){
17        return new Date(Date.UTC.apply(Date, arguments));
18    }
19    function UTCToday(){
20        var today = new Date();
21        return UTCDate(today.getFullYear(), today.getMonth(), today.getDate());
22    }
23    function UTCTomorrow(){
24        var tomorrow = new Date(+new Date() + 86400000)
25        return UTCDate(tomorrow.getFullYear(), tomorrow.getMonth(), tomorrow.getDate());
26    }
27    function isUTCEquals(date1, date2) {
28        return (
29            date1.getUTCFullYear() === date2.getUTCFullYear() &&
30            date1.getUTCMonth() === date2.getUTCMonth() &&
31            date1.getUTCDate() === date2.getUTCDate()
32        );
33    }
34    function alias(method, deprecationMsg){
35        return function(){
36            if (deprecationMsg !== undefined) {
37                $.fn.datepicker.deprecated(deprecationMsg);
38            }
39
40            return this[method].apply(this, arguments);
41        };
42    }
43    function isValidDate(d) {
44        return d && !isNaN(d.getTime());
45    }
46
47    var DateArray = (function(){
48        var extras = {
49            get: function(i){
50                return this.slice(i)[0];
51            },
52            contains: function(d){
53                // Array.indexOf is not cross-browser;
54                // $.inArray doesn't work with Dates
55                var val = d && d.valueOf();
56                for (var i=0, l=this.length; i < l; i++)
57                    // Use date arithmetic to allow dates with different times to match
58                    if (0 <= this[i].valueOf() - val && this[i].valueOf() - val < 1000*60*60*24)
59                        return i;
60                return -1;
61            },
62            remove: function(i){
63                this.splice(i,1);
64            },
65            replace: function(new_array){
66                if (!new_array)
67                    return;
68                if (!$.isArray(new_array))
69                    new_array = [new_array];
70                this.clear();
71                this.push.apply(this, new_array);
72            },
73            clear: function(){
74                this.length = 0;
75            },
76            copy: function(){
77                var a = new DateArray();
78                a.replace(this);
79                return a;
80            }
81        };
82
83        return function(){
84            var a = [];
85            a.push.apply(a, arguments);
86            $.extend(a, extras);
87            return a;
88        };
89    })();
90
91
92    // Picker object
93
94    var Datepicker = function(element, options){
95        $.data(element, 'datepicker', this);
96        this._process_options(options);
97
98        this.dates = new DateArray();
99        this.viewDate = this.o.defaultViewDate;
100        this.focusDate = null;
101
102        this.element = $(element);
103        this.isInput = this.element.is('input');
104        this.inputField = this.isInput ? this.element : this.element.find('input');
105        this.component = this.element.hasClass('date') ? this.element.find('.add-on, .input-group-addon, .btn') : false;
106        if (this.component && this.component.length === 0)
107            this.component = false;
108        this.isInline = !this.component && this.element.is('div');
109
110        this.picker = $(DPGlobal.template);
111
112        // Checking templates and inserting
113        if (this._check_template(this.o.templates.leftArrow)) {
114            this.picker.find('.prev').html(this.o.templates.leftArrow);
115        }
116
117        if (this._check_template(this.o.templates.rightArrow)) {
118            this.picker.find('.next').html(this.o.templates.rightArrow);
119        }
120
121        this._buildEvents();
122        this._attachEvents();
123
124        if (this.isInline){
125            this.picker.addClass('datepicker-inline').appendTo(this.element);
126        }
127        else {
128            this.picker.addClass('datepicker-dropdown dropdown-menu');
129        }
130
131        if (this.o.rtl){
132            this.picker.addClass('datepicker-rtl');
133        }
134
135        if (this.o.calendarWeeks) {
136            this.picker.find('.datepicker-days .datepicker-switch, thead .datepicker-title, thead .today, tfoot .clear')
137                .attr('colspan', function(i, val){
138                    return Number(val) + 1;
139                });
140        }
141
142        this._process_options({
143            startDate: this._o.startDate,
144            endDate: this._o.endDate,
145            daysOfWeekDisabled: this.o.daysOfWeekDisabled,
146            daysOfWeekHighlighted: this.o.daysOfWeekHighlighted,
147            datesDisabled: this.o.datesDisabled
148        });
149
150        this._allow_update = false;
151        this.setViewMode(this.o.startView);
152        this._allow_update = true;
153
154        this.fillDow();
155        this.fillMonths();
156
157        this.update();
158
159        if (this.isInline){
160            this.show();
161        }
162    };
163
164    Datepicker.prototype = {
165        constructor: Datepicker,
166
167        _resolveViewName: function(view){
168            $.each(DPGlobal.viewModes, function(i, viewMode){
169                if (view === i || $.inArray(view, viewMode.names) !== -1){
170                    view = i;
171                    return false;
172                }
173            });
174
175            return view;
176        },
177
178        _resolveDaysOfWeek: function(daysOfWeek){
179            if (!$.isArray(daysOfWeek))
180                daysOfWeek = daysOfWeek.split(/[,\s]*/);
181            return $.map(daysOfWeek, Number);
182        },
183
184        _check_template: function(tmp){
185            try {
186                // If empty
187                if (tmp === undefined || tmp === "") {
188                    return false;
189                }
190                // If no html, everything ok
191                if ((tmp.match(/[<>]/g) || []).length <= 0) {
192                    return true;
193                }
194                // Checking if html is fine
195                var jDom = $(tmp);
196                return jDom.length > 0;
197            }
198            catch (ex) {
199                return false;
200            }
201        },
202
203        _process_options: function(opts){
204            // Store raw options for reference
205            this._o = $.extend({}, this._o, opts);
206            // Processed options
207            var o = this.o = $.extend({}, this._o);
208
209            // Check if "de-DE" style date is available, if not language should
210            // fallback to 2 letter code eg "de"
211            var lang = o.language;
212            if (!dates[lang]){
213                lang = lang.split('-')[0];
214                if (!dates[lang])
215                    lang = defaults.language;
216            }
217            o.language = lang;
218
219            // Retrieve view index from any aliases
220            o.startView = this._resolveViewName(o.startView);
221            o.minViewMode = this._resolveViewName(o.minViewMode);
222            o.maxViewMode = this._resolveViewName(o.maxViewMode);
223
224            // Check view is between min and max
225            o.startView = Math.max(this.o.minViewMode, Math.min(this.o.maxViewMode, o.startView));
226
227            // true, false, or Number > 0
228            if (o.multidate !== true){
229                o.multidate = Number(o.multidate) || false;
230                if (o.multidate !== false)
231                    o.multidate = Math.max(0, o.multidate);
232            }
233            o.multidateSeparator = String(o.multidateSeparator);
234
235            o.weekStart %= 7;
236            o.weekEnd = (o.weekStart + 6) % 7;
237
238            var format = DPGlobal.parseFormat(o.format);
239            if (o.startDate !== -Infinity){
240                if (!!o.startDate){
241                    if (o.startDate instanceof Date)
242                        o.startDate = this._local_to_utc(this._zero_time(o.startDate));
243                    else
244                        o.startDate = DPGlobal.parseDate(o.startDate, format, o.language, o.assumeNearbyYear);
245                }
246                else {
247                    o.startDate = -Infinity;
248                }
249            }
250            if (o.endDate !== Infinity){
251                if (!!o.endDate){
252                    if (o.endDate instanceof Date)
253                        o.endDate = this._local_to_utc(this._zero_time(o.endDate));
254                    else
255                        o.endDate = DPGlobal.parseDate(o.endDate, format, o.language, o.assumeNearbyYear);
256                }
257                else {
258                    o.endDate = Infinity;
259                }
260            }
261
262            o.daysOfWeekDisabled = this._resolveDaysOfWeek(o.daysOfWeekDisabled||[]);
263            o.daysOfWeekHighlighted = this._resolveDaysOfWeek(o.daysOfWeekHighlighted||[]);
264
265            o.datesDisabled = o.datesDisabled||[];
266            if (!$.isArray(o.datesDisabled)) {
267                o.datesDisabled = o.datesDisabled.split(',');
268            }
269            o.datesDisabled = $.map(o.datesDisabled, function(d){
270                return DPGlobal.parseDate(d, format, o.language, o.assumeNearbyYear);
271            });
272
273            var plc = String(o.orientation).toLowerCase().split(/\s+/g),
274                _plc = o.orientation.toLowerCase();
275            plc = $.grep(plc, function(word){
276                return /^auto|left|right|top|bottom$/.test(word);
277            });
278            o.orientation = {x: 'auto', y: 'auto'};
279            if (!_plc || _plc === 'auto')
280                ; // no action
281            else if (plc.length === 1){
282                switch (plc[0]){
283                    case 'top':
284                    case 'bottom':
285                        o.orientation.y = plc[0];
286                        break;
287                    case 'left':
288                    case 'right':
289                        o.orientation.x = plc[0];
290                        break;
291                }
292            }
293            else {
294                _plc = $.grep(plc, function(word){
295                    return /^left|right$/.test(word);
296                });
297                o.orientation.x = _plc[0] || 'auto';
298
299                _plc = $.grep(plc, function(word){
300                    return /^top|bottom$/.test(word);
301                });
302                o.orientation.y = _plc[0] || 'auto';
303            }
304            if (o.defaultViewDate instanceof Date || typeof o.defaultViewDate === 'string') {
305                o.defaultViewDate = DPGlobal.parseDate(o.defaultViewDate, format, o.language, o.assumeNearbyYear);
306            } else if (o.defaultViewDate) {
307                var year = o.defaultViewDate.year || new Date().getFullYear();
308                var month = o.defaultViewDate.month || 0;
309                var day = o.defaultViewDate.day || 1;
310                o.defaultViewDate = UTCDate(year, month, day);
311            } else {
312                o.defaultViewDate = UTCToday();
313            }
314        },
315        _events: [],
316        _secondaryEvents: [],
317        _applyEvents: function(evs){
318            for (var i=0, el, ch, ev; i < evs.length; i++){
319                el = evs[i][0];
320                if (evs[i].length === 2){
321                    ch = undefined;
322                    ev = evs[i][1];
323                } else if (evs[i].length === 3){
324                    ch = evs[i][1];
325                    ev = evs[i][2];
326                }
327                el.on(ev, ch);
328            }
329        },
330        _unapplyEvents: function(evs){
331            for (var i=0, el, ev, ch; i < evs.length; i++){
332                el = evs[i][0];
333                if (evs[i].length === 2){
334                    ch = undefined;
335                    ev = evs[i][1];
336                } else if (evs[i].length === 3){
337                    ch = evs[i][1];
338                    ev = evs[i][2];
339                }
340                el.off(ev, ch);
341            }
342        },
343        _buildEvents: function(){
344            var events = {
345                keyup: $.proxy(function(e){
346                    if ($.inArray(e.keyCode, [27, 37, 39, 38, 40, 32, 13, 9]) === -1)
347                        this.update();
348                }, this),
349                keydown: $.proxy(this.keydown, this),
350                paste: $.proxy(this.paste, this)
351            };
352
353            if (this.o.showOnFocus === true) {
354                events.focus = $.proxy(this.show, this);
355            }
356
357            if (this.isInput) { // single input
358                this._events = [
359                    [this.element, events]
360                ];
361            }
362            // component: input + button
363            else if (this.component && this.inputField.length) {
364                this._events = [
365                    // For components that are not readonly, allow keyboard nav
366                    [this.inputField, events],
367                    [this.component, {
368                        click: $.proxy(this.show, this)
369                    }]
370                ];
371            }
372            else {
373                this._events = [
374                    [this.element, {
375                        click: $.proxy(this.show, this),
376                        keydown: $.proxy(this.keydown, this)
377                    }]
378                ];
379            }
380            this._events.push(
381                // Component: listen for blur on element descendants
382                [this.element, '*', {
383                    blur: $.proxy(function(e){
384                        this._focused_from = e.target;
385                    }, this)
386                }],
387                // Input: listen for blur on element
388                [this.element, {
389                    blur: $.proxy(function(e){
390                        this._focused_from = e.target;
391                    }, this)
392                }]
393            );
394
395            if (this.o.immediateUpdates) {
396                // Trigger input updates immediately on changed year/month
397                this._events.push([this.element, {
398                    'changeYear changeMonth': $.proxy(function(e){
399                        this.update(e.date);
400                    }, this)
401                }]);
402            }
403
404            this._secondaryEvents = [
405                [this.picker, {
406                    click: $.proxy(this.click, this)
407                }],
408                [this.picker, '.prev, .next', {
409                    click: $.proxy(this.navArrowsClick, this)
410                }],
411                [this.picker, '.day:not(.disabled)', {
412                    click: $.proxy(this.dayCellClick, this)
413                }],
414                [$(window), {
415                    resize: $.proxy(this.place, this)
416                }],
417                [$(document), {
418                    'mousedown touchstart': $.proxy(function(e){
419                        // Clicked outside the datepicker, hide it
420                        if (!(
421                                this.element.is(e.target) ||
422                                this.element.find(e.target).length ||
423                                this.picker.is(e.target) ||
424                                this.picker.find(e.target).length ||
425                                this.isInline
426                            )){
427                            this.hide();
428                        }
429                    }, this)
430                }]
431            ];
432        },
433        _attachEvents: function(){
434            this._detachEvents();
435            this._applyEvents(this._events);
436        },
437        _detachEvents: function(){
438            this._unapplyEvents(this._events);
439        },
440        _attachSecondaryEvents: function(){
441            this._detachSecondaryEvents();
442            this._applyEvents(this._secondaryEvents);
443        },
444        _detachSecondaryEvents: function(){
445            this._unapplyEvents(this._secondaryEvents);
446        },
447        _trigger: function(event, altdate){
448            var date = altdate || this.dates.get(-1),
449                local_date = this._utc_to_local(date);
450
451            this.element.trigger({
452                type: event,
453                date: local_date,
454                viewMode: this.viewMode,
455                dates: $.map(this.dates, this._utc_to_local),
456                format: $.proxy(function(ix, format){
457                    if (arguments.length === 0){
458                        ix = this.dates.length - 1;
459                        format = this.o.format;
460                    } else if (typeof ix === 'string'){
461                        format = ix;
462                        ix = this.dates.length - 1;
463                    }
464                    format = format || this.o.format;
465                    var date = this.dates.get(ix);
466                    return DPGlobal.formatDate(date, format, this.o.language);
467                }, this)
468            });
469        },
470
471        show: function(){
472            if (this.inputField.prop('disabled') || (this.inputField.prop('readonly') && this.o.enableOnReadonly === false))
473                return;
474            if (!this.isInline)
475                this.picker.appendTo(this.o.container);
476            this.place();
477            this.picker.show();
478            this._attachSecondaryEvents();
479            this._trigger('show');
480            if ((window.navigator.msMaxTouchPoints || 'ontouchstart' in document) && this.o.disableTouchKeyboard) {
481                $(this.element).blur();
482            }
483            return this;
484        },
485
486        hide: function(){
487            if (this.isInline || !this.picker.is(':visible'))
488                return this;
489            this.focusDate = null;
490            this.picker.hide().detach();
491            this._detachSecondaryEvents();
492            this.setViewMode(this.o.startView);
493
494            if (this.o.forceParse && this.inputField.val())
495                this.setValue();
496            this._trigger('hide');
497            return this;
498        },
499
500        destroy: function(){
501            this.hide();
502            this._detachEvents();
503            this._detachSecondaryEvents();
504            this.picker.remove();
505            delete this.element.data().datepicker;
506            if (!this.isInput){
507                delete this.element.data().date;
508            }
509            return this;
510        },
511
512        paste: function(e){
513            var dateString;
514            if (e.originalEvent.clipboardData && e.originalEvent.clipboardData.types
515                && $.inArray('text/plain', e.originalEvent.clipboardData.types) !== -1) {
516                dateString = e.originalEvent.clipboardData.getData('text/plain');
517            } else if (window.clipboardData) {
518                dateString = window.clipboardData.getData('Text');
519            } else {
520                return;
521            }
522            this.setDate(dateString);
523            this.update();
524            e.preventDefault();
525        },
526
527        _utc_to_local: function(utc){
528            if (!utc) {
529                return utc;
530            }
531
532            var local = new Date(utc.getTime() + (utc.getTimezoneOffset() * 60000));
533
534            if (local.getTimezoneOffset() !== utc.getTimezoneOffset()) {
535                local = new Date(utc.getTime() + (local.getTimezoneOffset() * 60000));
536            }
537
538            return local;
539        },
540        _local_to_utc: function(local){
541            return local && new Date(local.getTime() - (local.getTimezoneOffset()*60000));
542        },
543        _zero_time: function(local){
544            return local && new Date(local.getFullYear(), local.getMonth(), local.getDate());
545        },
546        _zero_utc_time: function(utc){
547            return utc && UTCDate(utc.getUTCFullYear(), utc.getUTCMonth(), utc.getUTCDate());
548        },
549
550        getDates: function(){
551            return $.map(this.dates, this._utc_to_local);
552        },
553
554        getUTCDates: function(){
555            return $.map(this.dates, function(d){
556                return new Date(d);
557            });
558        },
559
560        getDate: function(){
561            return this._utc_to_local(this.getUTCDate());
562        },
563
564        getUTCDate: function(){
565            var selected_date = this.dates.get(-1);
566            if (selected_date !== undefined) {
567                return new Date(selected_date);
568            } else {
569                return null;
570            }
571        },
572
573        clearDates: function(){
574            this.inputField.val('');
575            this.update();
576            this._trigger('changeDate');
577
578            if (this.o.autoclose) {
579                this.hide();
580            }
581        },
582
583        setDates: function(){
584            var args = $.isArray(arguments[0]) ? arguments[0] : arguments;
585            this.update.apply(this, args);
586            this._trigger('changeDate');
587            this.setValue();
588            return this;
589        },
590
591        setUTCDates: function(){
592            var args = $.isArray(arguments[0]) ? arguments[0] : arguments;
593            this.setDates.apply(this, $.map(args, this._utc_to_local));
594            return this;
595        },
596
597        setDate: alias('setDates'),
598        setUTCDate: alias('setUTCDates'),
599        remove: alias('destroy', 'Method `remove` is deprecated and will be removed in version 2.0. Use `destroy` instead'),
600
601        setValue: function(){
602            var formatted = this.getFormattedDate();
603            this.inputField.val(formatted);
604            return this;
605        },
606
607        getFormattedDate: function(format){
608            if (format === undefined)
609                format = this.o.format;
610
611            var lang = this.o.language;
612            return $.map(this.dates, function(d){
613                return DPGlobal.formatDate(d, format, lang);
614            }).join(this.o.multidateSeparator);
615        },
616
617        getStartDate: function(){
618            return this.o.startDate;
619        },
620
621        setStartDate: function(startDate){
622            this._process_options({startDate: startDate});
623            this.update();
624            this.updateNavArrows();
625            return this;
626        },
627
628        getEndDate: function(){
629            return this.o.endDate;
630        },
631
632        setEndDate: function(endDate){
633            this._process_options({endDate: endDate});
634            this.update();
635            this.updateNavArrows();
636            return this;
637        },
638
639        setDaysOfWeekDisabled: function(daysOfWeekDisabled){
640            this._process_options({daysOfWeekDisabled: daysOfWeekDisabled});
641            this.update();
642            return this;
643        },
644
645        setDaysOfWeekHighlighted: function(daysOfWeekHighlighted){
646            this._process_options({daysOfWeekHighlighted: daysOfWeekHighlighted});
647            this.update();
648            return this;
649        },
650
651        setDatesDisabled: function(datesDisabled){
652            this._process_options({datesDisabled: datesDisabled});
653            this.update();
654            return this;
655        },
656
657        place: function(){
658            if (this.isInline)
659                return this;
660            var calendarWidth = this.picker.outerWidth(),
661                calendarHeight = this.picker.outerHeight(),
662                visualPadding = 10,
663                container = $(this.o.container),
664                windowWidth = container.width(),
665                scrollTop = this.o.container === 'body' ? $(document).scrollTop() : container.scrollTop(),
666                appendOffset = container.offset();
667
668            var parentsZindex = [0];
669            this.element.parents().each(function(){
670                var itemZIndex = $(this).css('z-index');
671                if (itemZIndex !== 'auto' && Number(itemZIndex) !== 0) parentsZindex.push(Number(itemZIndex));
672            });
673            var zIndex = Math.max.apply(Math, parentsZindex) + this.o.zIndexOffset;
674            var offset = this.component ? this.component.parent().offset() : this.element.offset();
675            var height = this.component ? this.component.outerHeight(true) : this.element.outerHeight(false);
676            var width = this.component ? this.component.outerWidth(true) : this.element.outerWidth(false);
677            var left = offset.left - appendOffset.left;
678            var top = offset.top - appendOffset.top;
679
680            if (this.o.container !== 'body') {
681                top += scrollTop;
682            }
683
684            this.picker.removeClass(
685                'datepicker-orient-top datepicker-orient-bottom '+
686                'datepicker-orient-right datepicker-orient-left'
687            );
688
689            if (this.o.orientation.x !== 'auto'){
690                this.picker.addClass('datepicker-orient-' + this.o.orientation.x);
691                if (this.o.orientation.x === 'right')
692                    left -= calendarWidth - width;
693            }
694            // auto x orientation is best-placement: if it crosses a window
695            // edge, fudge it sideways
696            else {
697                if (offset.left < 0) {
698                    // component is outside the window on the left side. Move it into visible range
699                    this.picker.addClass('datepicker-orient-left');
700                    left -= offset.left - visualPadding;
701                } else if (left + calendarWidth > windowWidth) {
702                    // the calendar passes the widow right edge. Align it to component right side
703                    this.picker.addClass('datepicker-orient-right');
704                    left += width - calendarWidth;
705                } else {
706                    if (this.o.rtl) {
707                        // Default to right
708                        this.picker.addClass('datepicker-orient-right');
709                    } else {
710                        // Default to left
711                        this.picker.addClass('datepicker-orient-left');
712                    }
713                }
714            }
715
716            // auto y orientation is best-situation: top or bottom, no fudging,
717            // decision based on which shows more of the calendar
718            var yorient = this.o.orientation.y,
719                top_overflow;
720            if (yorient === 'auto'){
721                top_overflow = -scrollTop + top - calendarHeight;
722                yorient = top_overflow < 0 ? 'bottom' : 'top';
723            }
724
725            this.picker.addClass('datepicker-orient-' + yorient);
726            if (yorient === 'top')
727                top -= calendarHeight + parseInt(this.picker.css('padding-top'));
728            else
729                top += height;
730
731            if (this.o.rtl) {
732                var right = windowWidth - (left + width);
733                this.picker.css({
734                    top: top,
735                    right: right,
736                    zIndex: zIndex
737                });
738            } else {
739                this.picker.css({
740                    top: top,
741                    left: left,
742                    zIndex: zIndex
743                });
744            }
745            return this;
746        },
747
748        _allow_update: true,
749        update: function(){
750            if (!this._allow_update)
751                return this;
752
753            var oldDates = this.dates.copy(),
754                dates = [],
755                fromArgs = false;
756            if (arguments.length){
757                $.each(arguments, $.proxy(function(i, date){
758                    if (date instanceof Date)
759                        date = this._local_to_utc(date);
760                    dates.push(date);
761                }, this));
762                fromArgs = true;
763            } else {
764                dates = this.isInput
765                    ? this.element.val()
766                    : this.element.data('date') || this.inputField.val();
767                if (dates && this.o.multidate)
768                    dates = dates.split(this.o.multidateSeparator);
769                else
770                    dates = [dates];
771                delete this.element.data().date;
772            }
773
774            dates = $.map(dates, $.proxy(function(date){
775                return DPGlobal.parseDate(date, this.o.format, this.o.language, this.o.assumeNearbyYear);
776            }, this));
777            dates = $.grep(dates, $.proxy(function(date){
778                return (
779                    !this.dateWithinRange(date) ||
780                    !date
781                );
782            }, this), true);
783            this.dates.replace(dates);
784
785            if (this.o.updateViewDate) {
786                if (this.dates.length)
787                    this.viewDate = new Date(this.dates.get(-1));
788                else if (this.viewDate < this.o.startDate)
789                    this.viewDate = new Date(this.o.startDate);
790                else if (this.viewDate > this.o.endDate)
791                    this.viewDate = new Date(this.o.endDate);
792                else
793                    this.viewDate = this.o.defaultViewDate;
794            }
795
796            if (fromArgs){
797                // setting date by clicking
798                this.setValue();
799                this.element.change();
800            }
801            else if (this.dates.length){
802                // setting date by typing
803                if (String(oldDates) !== String(this.dates) && fromArgs) {
804                    this._trigger('changeDate');
805                    this.element.change();
806                }
807            }
808            if (!this.dates.length && oldDates.length) {
809                this._trigger('clearDate');
810                this.element.change();
811            }
812
813            this.fill();
814            return this;
815        },
816
817        fillDow: function(){
818            if (this.o.showWeekDays) {
819                var dowCnt = this.o.weekStart,
820                    html = '<tr>';
821                if (this.o.calendarWeeks){
822                    html += '<th class="cw">&#160;</th>';
823                }
824                while (dowCnt < this.o.weekStart + 7){
825                    html += '<th class="dow';
826                    if ($.inArray(dowCnt, this.o.daysOfWeekDisabled) !== -1)
827                        html += ' disabled';
828                    html += '">'+dates[this.o.language].daysMin[(dowCnt++)%7]+'</th>';
829                }
830                html += '</tr>';
831                this.picker.find('.datepicker-days thead').append(html);
832            }
833        },
834
835        fillMonths: function(){
836            var localDate = this._utc_to_local(this.viewDate);
837            var html = '';
838            var focused;
839            for (var i = 0; i < 12; i++){
840                focused = localDate && localDate.getMonth() === i ? ' focused' : '';
841                html += '<span class="month' + focused + '">' + dates[this.o.language].monthsShort[i] + '</span>';
842            }
843            this.picker.find('.datepicker-months td').html(html);
844        },
845
846        setRange: function(range){
847            if (!range || !range.length)
848                delete this.range;
849            else
850                this.range = $.map(range, function(d){
851                    return d.valueOf();
852                });
853            this.fill();
854        },
855
856        getClassNames: function(date){
857            var cls = [],
858                year = this.viewDate.getUTCFullYear(),
859                month = this.viewDate.getUTCMonth(),
860                today = UTCToday();
861            if (date.getUTCFullYear() < year || (date.getUTCFullYear() === year && date.getUTCMonth() < month)){
862                cls.push('old');
863            } else if (date.getUTCFullYear() > year || (date.getUTCFullYear() === year && date.getUTCMonth() > month)){
864                cls.push('new');
865            }
866            if (this.focusDate && date.valueOf() === this.focusDate.valueOf())
867                cls.push('focused');
868            // Compare internal UTC date with UTC today, not local today
869            if (this.o.todayHighlight && isUTCEquals(date, today)) {
870                cls.push('today');
871            }
872            if (this.dates.contains(date) !== -1)
873                cls.push('active');
874            if (!this.dateWithinRange(date)){
875                cls.push('disabled');
876            }
877            if (this.dateIsDisabled(date)){
878                cls.push('disabled', 'disabled-date');
879            }
880            if ($.inArray(date.getUTCDay(), this.o.daysOfWeekHighlighted) !== -1){
881                cls.push('highlighted');
882            }
883
884            if (this.range){
885                if (date > this.range[0] && date < this.range[this.range.length-1]){
886                    cls.push('range');
887                }
888                if ($.inArray(date.valueOf(), this.range) !== -1){
889                    cls.push('selected');
890                }
891                if (date.valueOf() === this.range[0]){
892                    cls.push('range-start');
893                }
894                if (date.valueOf() === this.range[this.range.length-1]){
895                    cls.push('range-end');
896                }
897            }
898            return cls;
899        },
900
901        _fill_yearsView: function(selector, cssClass, factor, year, startYear, endYear, beforeFn){
902            var html = '';
903            var step = factor / 10;
904            var view = this.picker.find(selector);
905            var startVal = Math.floor(year / factor) * factor;
906            var endVal = startVal + step * 9;
907            var focusedVal = Math.floor(this.viewDate.getFullYear() / step) * step;
908            var selected = $.map(this.dates, function(d){
909                return Math.floor(d.getUTCFullYear() / step) * step;
910            });
911
912            var classes, tooltip, before;
913            for (var currVal = startVal - step; currVal <= endVal + step; currVal += step) {
914                classes = [cssClass];
915                tooltip = null;
916
917                if (currVal === startVal - step) {
918                    classes.push('old');
919                } else if (currVal === endVal + step) {
920                    classes.push('new');
921                }
922                if ($.inArray(currVal, selected) !== -1) {
923                    classes.push('active');
924                }
925                if (currVal < startYear || currVal > endYear) {
926                    classes.push('disabled');
927                }
928                if (currVal === focusedVal) {
929                    classes.push('focused');
930                }
931
932                if (beforeFn !== $.noop) {
933                    before = beforeFn(new Date(currVal, 0, 1));
934                    if (before === undefined) {
935                        before = {};
936                    } else if (typeof before === 'boolean') {
937                        before = {enabled: before};
938                    } else if (typeof before === 'string') {
939                        before = {classes: before};
940                    }
941                    if (before.enabled === false) {
942                        classes.push('disabled');
943                    }
944                    if (before.classes) {
945                        classes = classes.concat(before.classes.split(/\s+/));
946                    }
947                    if (before.tooltip) {
948                        tooltip = before.tooltip;
949                    }
950                }
951
952                html += '<span class="' + classes.join(' ') + '"' + (tooltip ? ' title="' + tooltip + '"' : '') + '>' + currVal + '</span>';
953            }
954
955            view.find('.datepicker-switch').text(startVal + '-' + endVal);
956            view.find('td').html(html);
957        },
958
959        fill: function(){
960            var d = new Date(this.viewDate),
961                year = d.getUTCFullYear(),
962                month = d.getUTCMonth(),
963                startYear = this.o.startDate !== -Infinity ? this.o.startDate.getUTCFullYear() : -Infinity,
964                startMonth = this.o.startDate !== -Infinity ? this.o.startDate.getUTCMonth() : -Infinity,
965                endYear = this.o.endDate !== Infinity ? this.o.endDate.getUTCFullYear() : Infinity,
966                endMonth = this.o.endDate !== Infinity ? this.o.endDate.getUTCMonth() : Infinity,
967                todaytxt = dates[this.o.language].today || dates['en'].today || '',
968                tomorrowtxt = dates[this.o.language].tomorrow || dates['en'].tomorrow || '',
969                cleartxt = dates[this.o.language].clear || dates['en'].clear || '',
970                titleFormat = dates[this.o.language].titleFormat || dates['en'].titleFormat,
971                tooltip,
972                before;
973            if (isNaN(year) || isNaN(month))
974                return;
975            this.picker.find('.datepicker-days .datepicker-switch')
976                .text(DPGlobal.formatDate(d, titleFormat, this.o.language));
977            this.picker.find('thead .tomorrow')
978                .text(tomorrowtxt)
979                .css('display', this.o.todayBtn === true || this.o.todayBtn === 'linked' ? 'inline-block' : 'none');
980            this.picker.find('thead .today')
981                .text(todaytxt)
982                .css('display', this.o.todayBtn === true || this.o.todayBtn === 'linked' ? 'inline-block' : 'none');
983            this.picker.find('tfoot .clear')
984                .text(cleartxt)
985                .css('display', this.o.clearBtn === true ? 'table-cell' : 'none');
986            this.picker.find('thead .datepicker-title')
987                .text(this.o.title)
988                .css('display', typeof this.o.title === 'string' && this.o.title !== '' ? 'table-cell' : 'none');
989            this.updateNavArrows();
990            this.fillMonths();
991            var prevMonth = UTCDate(year, month, 0),
992                day = prevMonth.getUTCDate();
993            prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.o.weekStart + 7)%7);
994            var nextMonth = new Date(prevMonth);
995            if (prevMonth.getUTCFullYear() < 100){
996                nextMonth.setUTCFullYear(prevMonth.getUTCFullYear());
997            }
998            nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
999            nextMonth = nextMonth.valueOf();
1000            var html = [];
1001            var weekDay, clsName;
1002            while (prevMonth.valueOf() < nextMonth){
1003                weekDay = prevMonth.getUTCDay();
1004                if (weekDay === this.o.weekStart){
1005                    html.push('<tr>');
1006                    if (this.o.calendarWeeks){
1007                        // ISO 8601: First week contains first thursday.
1008                        // ISO also states week starts on Monday, but we can be more abstract here.
1009                        var
1010                            // Start of current week: based on weekstart/current date
1011                            ws = new Date(+prevMonth + (this.o.weekStart - weekDay - 7) % 7 * 864e5),
1012                            // Thursday of this week
1013                            th = new Date(Number(ws) + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
1014                            // First Thursday of year, year from thursday
1015                            yth = new Date(Number(yth = UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay()) % 7 * 864e5),
1016                            // Calendar week: ms between thursdays, div ms per day, div 7 days
1017                            calWeek = (th - yth) / 864e5 / 7 + 1;
1018                        html.push('<td class="cw">'+ calWeek +'</td>');
1019                    }
1020                }
1021                clsName = this.getClassNames(prevMonth);
1022                clsName.push('day');
1023
1024                var content = prevMonth.getUTCDate();
1025
1026                if (this.o.beforeShowDay !== $.noop){
1027                    before = this.o.beforeShowDay(this._utc_to_local(prevMonth));
1028                    if (before === undefined)
1029                        before = {};
1030                    else if (typeof before === 'boolean')
1031                        before = {enabled: before};
1032                    else if (typeof before === 'string')
1033                        before = {classes: before};
1034                    if (before.enabled === false)
1035                        clsName.push('disabled');
1036                    if (before.classes)
1037                        clsName = clsName.concat(before.classes.split(/\s+/));
1038                    if (before.tooltip)
1039                        tooltip = before.tooltip;
1040                    if (before.content)
1041                        content = before.content;
1042                }
1043
1044                //Check if uniqueSort exists (supported by jquery >=1.12 and >=2.2)
1045                //Fallback to unique function for older jquery versions
1046                if ($.isFunction($.uniqueSort)) {
1047                    clsName = $.uniqueSort(clsName);
1048                } else {
1049                    clsName = $.unique(clsName);
1050                }
1051
1052                html.push('<td class="'+clsName.join(' ')+'"' + (tooltip ? ' title="'+tooltip+'"' : '') + ' data-date="' + prevMonth.getTime().toString() + '"><div>' + content + '</div></td>');
1053                tooltip = null;
1054                if (weekDay === this.o.weekEnd){
1055                    html.push('</tr>');
1056                }
1057                prevMonth.setUTCDate(prevMonth.getUTCDate() + 1);
1058            }
1059            this.picker.find('.datepicker-days tbody').html(html.join(''));
1060
1061            var monthsTitle = dates[this.o.language].monthsTitle || dates['en'].monthsTitle || 'Months';
1062            var months = this.picker.find('.datepicker-months')
1063                .find('.datepicker-switch')
1064                .text(year)
1065                .end()
1066                .find('tbody span').removeClass('active');
1067
1068            $.each(this.dates, function(i, d){
1069                if (d.getUTCFullYear() === year)
1070                    months.eq(d.getUTCMonth()).addClass('active');
1071            });
1072
1073            if (year < startYear || year > endYear){
1074                months.addClass('disabled');
1075            }
1076            if (year === startYear){
1077                months.slice(0, startMonth).addClass('disabled');
1078            }
1079            if (year === endYear){
1080                months.slice(endMonth+1).addClass('disabled');
1081            }
1082
1083            if (this.o.beforeShowMonth !== $.noop){
1084                var that = this;
1085                $.each(months, function(i, month){
1086                    var moDate = new Date(year, i, 1);
1087                    var before = that.o.beforeShowMonth(moDate);
1088                    if (before === undefined)
1089                        before = {};
1090                    else if (typeof before === 'boolean')
1091                        before = {enabled: before};
1092                    else if (typeof before === 'string')
1093                        before = {classes: before};
1094                    if (before.enabled === false && !$(month).hasClass('disabled'))
1095                        $(month).addClass('disabled');
1096                    if (before.classes)
1097                        $(month).addClass(before.classes);
1098                    if (before.tooltip)
1099                        $(month).prop('title', before.tooltip);
1100                });
1101            }
1102
1103            // Generating decade/years picker
1104            this._fill_yearsView(
1105                '.datepicker-years',
1106                'year',
1107                10,
1108                year,
1109                startYear,
1110                endYear,
1111                this.o.beforeShowYear
1112            );
1113
1114            // Generating century/decades picker
1115            this._fill_yearsView(
1116                '.datepicker-decades',
1117                'decade',
1118                100,
1119                year,
1120                startYear,
1121                endYear,
1122                this.o.beforeShowDecade
1123            );
1124
1125            // Generating millennium/centuries picker
1126            this._fill_yearsView(
1127                '.datepicker-centuries',
1128                'century',
1129                1000,
1130                year,
1131                startYear,
1132                endYear,
1133                this.o.beforeShowCentury
1134            );
1135        },
1136
1137        updateNavArrows: function(){
1138            if (!this._allow_update)
1139                return;
1140
1141            var d = new Date(this.viewDate),
1142                year = d.getUTCFullYear(),
1143                month = d.getUTCMonth(),
1144                startYear = this.o.startDate !== -Infinity ? this.o.startDate.getUTCFullYear() : -Infinity,
1145                startMonth = this.o.startDate !== -Infinity ? this.o.startDate.getUTCMonth() : -Infinity,
1146                endYear = this.o.endDate !== Infinity ? this.o.endDate.getUTCFullYear() : Infinity,
1147                endMonth = this.o.endDate !== Infinity ? this.o.endDate.getUTCMonth() : Infinity,
1148                prevIsDisabled,
1149                nextIsDisabled,
1150                factor = 1;
1151            switch (this.viewMode){
1152                case 0:
1153                    prevIsDisabled = year <= startYear && month <= startMonth;
1154                    nextIsDisabled = year >= endYear && month >= endMonth;
1155                    break;
1156                case 4:
1157                    factor *= 10;
1158                /* falls through */
1159                case 3:
1160                    factor *= 10;
1161                /* falls through */
1162                case 2:
1163                    factor *= 10;
1164                /* falls through */
1165                case 1:
1166                    prevIsDisabled = Math.floor(year / factor) * factor <= startYear;
1167                    nextIsDisabled = Math.floor(year / factor) * factor + factor >= endYear;
1168                    break;
1169            }
1170
1171            this.picker.find('.prev').toggleClass('disabled', prevIsDisabled);
1172            this.picker.find('.next').toggleClass('disabled', nextIsDisabled);
1173        },
1174
1175        click: function(e){
1176            e.preventDefault();
1177            e.stopPropagation();
1178
1179            var target, dir, day, year, month;
1180            target = $(e.target);
1181
1182            // Clicked on the switch
1183            if (target.hasClass('datepicker-switch') && this.viewMode !== this.o.maxViewMode){
1184                this.setViewMode(this.viewMode + 1);
1185            }
1186
1187            // Clicked on today button
1188            if (target.hasClass('today') && !target.hasClass('day')){
1189                this.setViewMode(0);
1190                target.addClass("active");
1191                $(".tomorrow").removeClass("active");
1192                this._setDate(UTCToday());
1193            }
1194
1195            // Clicked on tomorrow button
1196            if (target.hasClass('tomorrow') && !target.hasClass('day')){
1197                this.setViewMode(0);
1198                target.addClass("active");
1199                $(".today").removeClass("active");
1200                this._setDate(UTCTomorrow());
1201            }
1202
1203            // Clicked on clear button
1204            if (target.hasClass('clear')){
1205                this.clearDates();
1206            }
1207
1208            if (!target.hasClass('disabled')){
1209                // Clicked on a month, year, decade, century
1210                if (target.hasClass('month')
1211                    || target.hasClass('year')
1212                    || target.hasClass('decade')
1213                    || target.hasClass('century')) {
1214                    this.viewDate.setUTCDate(1);
1215
1216                    day = 1;
1217                    if (this.viewMode === 1){
1218                        month = target.parent().find('span').index(target);
1219                        year = this.viewDate.getUTCFullYear();
1220                        this.viewDate.setUTCMonth(month);
1221                    } else {
1222                        month = 0;
1223                        year = Number(target.text());
1224                        this.viewDate.setUTCFullYear(year);
1225                    }
1226
1227                    this._trigger(DPGlobal.viewModes[this.viewMode - 1].e, this.viewDate);
1228
1229                    if (this.viewMode === this.o.minViewMode){
1230                        this._setDate(UTCDate(year, month, day));
1231                    } else {
1232                        this.setViewMode(this.viewMode - 1);
1233                        this.fill();
1234                    }
1235                }
1236            }
1237
1238            if (this.picker.is(':visible') && this._focused_from){
1239                this._focused_from.focus();
1240            }
1241            delete this._focused_from;
1242        },
1243
1244        dayCellClick: function(e){
1245            var $target = $(e.currentTarget);
1246            var timestamp = $target.data('date');
1247            var date = new Date(timestamp);
1248
1249            if(sameDay(UTCToday(),date)) {
1250                $(".today").addClass("active");
1251                $(".tomorrow").removeClass("active");
1252            }
1253            else {
1254                $(".today").removeClass("active");
1255            }
1256
1257            if(sameDay(UTCTomorrow(),date)) {
1258                $(".tomorrow").addClass("active");
1259                $(".today").removeClass("active");
1260            }
1261            else {
1262                $(".tomorrow").removeClass("active");
1263            }
1264
1265            if (this.o.updateViewDate) {
1266                if (date.getUTCFullYear() !== this.viewDate.getUTCFullYear()) {
1267                    this._trigger('changeYear', this.viewDate);
1268                }
1269
1270                if (date.getUTCMonth() !== this.viewDate.getUTCMonth()) {
1271                    this._trigger('changeMonth', this.viewDate);
1272                }
1273            }
1274            this._setDate(date);
1275        },
1276
1277        // Clicked on prev or next
1278        navArrowsClick: function(e){
1279            var $target = $(e.currentTarget);
1280            var dir = $target.hasClass('prev') ? -1 : 1;
1281            if (this.viewMode !== 0){
vendor: 28,295 bytes, lines 1282-2048
1282                dir *= DPGlobal.viewModes[this.viewMode].navStep * 12;
1283            }
1284            this.viewDate = this.moveMonth(this.viewDate, dir);
1285            this._trigger(DPGlobal.viewModes[this.viewMode].e, this.viewDate);
1286            this.fill();
1287        },
1288
1289        _toggle_multidate: function(date){
1290            var ix = this.dates.contains(date);
1291            if (!date){
1292                this.dates.clear();
1293            }
1294
1295            if (ix !== -1){
1296                if (this.o.multidate === true || this.o.multidate > 1 || this.o.toggleActive){
1297                    this.dates.remove(ix);
1298                }
1299            } else if (this.o.multidate === false) {
1300                this.dates.clear();
1301                this.dates.push(date);
1302            }
1303            else {
1304                this.dates.push(date);
1305            }
1306
1307            if (typeof this.o.multidate === 'number')
1308                while (this.dates.length > this.o.multidate)
1309                    this.dates.remove(0);
1310        },
1311
1312        _setDate: function(date, which){
1313            if (!which || which === 'date')
1314                this._toggle_multidate(date && new Date(date));
1315            if ((!which && this.o.updateViewDate) || which === 'view')
1316                this.viewDate = date && new Date(date);
1317
1318            this.fill();
1319            this.setValue();
1320            if (!which || which !== 'view') {
1321                this._trigger('changeDate');
1322            }
1323            this.inputField.trigger('change');
1324            if (this.o.autoclose && (!which || which === 'date')){
1325                this.hide();
1326            }
1327        },
1328
1329        moveDay: function(date, dir){
1330            var newDate = new Date(date);
1331            newDate.setUTCDate(date.getUTCDate() + dir);
1332
1333            return newDate;
1334        },
1335
1336        moveWeek: function(date, dir){
1337            return this.moveDay(date, dir * 7);
1338        },
1339
1340        moveMonth: function(date, dir){
1341            if (!isValidDate(date))
1342                return this.o.defaultViewDate;
1343            if (!dir)
1344                return date;
1345            var new_date = new Date(date.valueOf()),
1346                day = new_date.getUTCDate(),
1347                month = new_date.getUTCMonth(),
1348                mag = Math.abs(dir),
1349                new_month, test;
1350            dir = dir > 0 ? 1 : -1;
1351            if (mag === 1){
1352                test = dir === -1
1353                    // If going back one month, make sure month is not current month
1354                    // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
1355                    ? function(){
1356                        return new_date.getUTCMonth() === month;
1357                    }
1358                    // If going forward one month, make sure month is as expected
1359                    // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
1360                    : function(){
1361                        return new_date.getUTCMonth() !== new_month;
1362                    };
1363                new_month = month + dir;
1364                new_date.setUTCMonth(new_month);
1365                // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
1366                new_month = (new_month + 12) % 12;
1367            }
1368            else {
1369                // For magnitudes >1, move one month at a time...
1370                for (var i=0; i < mag; i++)
1371                    // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
1372                    new_date = this.moveMonth(new_date, dir);
1373                // ...then reset the day, keeping it in the new month
1374                new_month = new_date.getUTCMonth();
1375                new_date.setUTCDate(day);
1376                test = function(){
1377                    return new_month !== new_date.getUTCMonth();
1378                };
1379            }
1380            // Common date-resetting loop -- if date is beyond end of month, make it
1381            // end of month
1382            while (test()){
1383                new_date.setUTCDate(--day);
1384                new_date.setUTCMonth(new_month);
1385            }
1386            return new_date;
1387        },
1388
1389        moveYear: function(date, dir){
1390            return this.moveMonth(date, dir*12);
1391        },
1392
1393        moveAvailableDate: function(date, dir, fn){
1394            do {
1395                date = this[fn](date, dir);
1396
1397                if (!this.dateWithinRange(date))
1398                    return false;
1399
1400                fn = 'moveDay';
1401            }
1402            while (this.dateIsDisabled(date));
1403
1404            return date;
1405        },
1406
1407        weekOfDateIsDisabled: function(date){
1408            return $.inArray(date.getUTCDay(), this.o.daysOfWeekDisabled) !== -1;
1409        },
1410
1411        dateIsDisabled: function(date){
1412            return (
1413                this.weekOfDateIsDisabled(date) ||
1414                $.grep(this.o.datesDisabled, function(d){
1415                    return isUTCEquals(date, d);
1416                }).length > 0
1417            );
1418        },
1419
1420        dateWithinRange: function(date){
1421            return date >= this.o.startDate && date <= this.o.endDate;
1422        },
1423
1424        keydown: function(e){
1425            if (!this.picker.is(':visible')){
1426                if (e.keyCode === 40 || e.keyCode === 27) { // allow down to re-show picker
1427                    this.show();
1428                    e.stopPropagation();
1429                }
1430                return;
1431            }
1432            var dateChanged = false,
1433                dir, newViewDate,
1434                focusDate = this.focusDate || this.viewDate;
1435            switch (e.keyCode){
1436                case 27: // escape
1437                    if (this.focusDate){
1438                        this.focusDate = null;
1439                        this.viewDate = this.dates.get(-1) || this.viewDate;
1440                        this.fill();
1441                    }
1442                    else
1443                        this.hide();
1444                    e.preventDefault();
1445                    e.stopPropagation();
1446                    break;
1447                case 37: // left
1448                case 38: // up
1449                case 39: // right
1450                case 40: // down
1451                    if (!this.o.keyboardNavigation || this.o.daysOfWeekDisabled.length === 7)
1452                        break;
1453                    dir = e.keyCode === 37 || e.keyCode === 38 ? -1 : 1;
1454                    if (this.viewMode === 0) {
1455                        if (e.ctrlKey){
1456                            newViewDate = this.moveAvailableDate(focusDate, dir, 'moveYear');
1457
1458                            if (newViewDate)
1459                                this._trigger('changeYear', this.viewDate);
1460                        } else if (e.shiftKey){
1461                            newViewDate = this.moveAvailableDate(focusDate, dir, 'moveMonth');
1462
1463                            if (newViewDate)
1464                                this._trigger('changeMonth', this.viewDate);
1465                        } else if (e.keyCode === 37 || e.keyCode === 39){
1466                            newViewDate = this.moveAvailableDate(focusDate, dir, 'moveDay');
1467                        } else if (!this.weekOfDateIsDisabled(focusDate)){
1468                            newViewDate = this.moveAvailableDate(focusDate, dir, 'moveWeek');
1469                        }
1470                    } else if (this.viewMode === 1) {
1471                        if (e.keyCode === 38 || e.keyCode === 40) {
1472                            dir = dir * 4;
1473                        }
1474                        newViewDate = this.moveAvailableDate(focusDate, dir, 'moveMonth');
1475                    } else if (this.viewMode === 2) {
1476                        if (e.keyCode === 38 || e.keyCode === 40) {
1477                            dir = dir * 4;
1478                        }
1479                        newViewDate = this.moveAvailableDate(focusDate, dir, 'moveYear');
1480                    }
1481                    if (newViewDate){
1482                        this.focusDate = this.viewDate = newViewDate;
1483                        this.setValue();
1484                        this.fill();
1485                        e.preventDefault();
1486                    }
1487                    break;
1488                case 13: // enter
1489                    if (!this.o.forceParse)
1490                        break;
1491                    focusDate = this.focusDate || this.dates.get(-1) || this.viewDate;
1492                    if (this.o.keyboardNavigation) {
1493                        this._toggle_multidate(focusDate);
1494                        dateChanged = true;
1495                    }
1496                    this.focusDate = null;
1497                    this.viewDate = this.dates.get(-1) || this.viewDate;
1498                    this.setValue();
1499                    this.fill();
1500                    if (this.picker.is(':visible')){
1501                        e.preventDefault();
1502                        e.stopPropagation();
1503                        if (this.o.autoclose)
1504                            this.hide();
1505                    }
1506                    break;
1507                case 9: // tab
1508                    this.focusDate = null;
1509                    this.viewDate = this.dates.get(-1) || this.viewDate;
1510                    this.fill();
1511                    this.hide();
1512                    break;
1513            }
1514            if (dateChanged){
1515                if (this.dates.length)
1516                    this._trigger('changeDate');
1517                else
1518                    this._trigger('clearDate');
1519                this.inputField.trigger('change');
1520            }
1521        },
1522
1523        setViewMode: function(viewMode){
1524            this.viewMode = viewMode;
1525            this.picker
1526                .children('div')
1527                .hide()
1528                .filter('.datepicker-' + DPGlobal.viewModes[this.viewMode].clsName)
1529                .show();
1530            this.updateNavArrows();
1531            this._trigger('changeViewMode', new Date(this.viewDate));
1532        }
1533    };
1534
1535    var DateRangePicker = function(element, options){
1536        $.data(element, 'datepicker', this);
1537        this.element = $(element);
1538        this.inputs = $.map(options.inputs, function(i){
1539            return i.jquery ? i[0] : i;
1540        });
1541        delete options.inputs;
1542
1543        this.keepEmptyValues = options.keepEmptyValues;
1544        delete options.keepEmptyValues;
1545
1546        datepickerPlugin.call($(this.inputs), options)
1547            .on('changeDate', $.proxy(this.dateUpdated, this));
1548
1549        this.pickers = $.map(this.inputs, function(i){
1550            return $.data(i, 'datepicker');
1551        });
1552        this.updateDates();
1553    };
1554    DateRangePicker.prototype = {
1555        updateDates: function(){
1556            this.dates = $.map(this.pickers, function(i){
1557                return i.getUTCDate();
1558            });
1559            this.updateRanges();
1560        },
1561        updateRanges: function(){
1562            var range = $.map(this.dates, function(d){
1563                return d.valueOf();
1564            });
1565            $.each(this.pickers, function(i, p){
1566                p.setRange(range);
1567            });
1568        },
1569        dateUpdated: function(e){
1570            // `this.updating` is a workaround for preventing infinite recursion
1571            // between `changeDate` triggering and `setUTCDate` calling.  Until
1572            // there is a better mechanism.
1573            if (this.updating)
1574                return;
1575            this.updating = true;
1576
1577            var dp = $.data(e.target, 'datepicker');
1578
1579            if (dp === undefined) {
1580                return;
1581            }
1582
1583            var new_date = dp.getUTCDate(),
1584                keep_empty_values = this.keepEmptyValues,
1585                i = $.inArray(e.target, this.inputs),
1586                j = i - 1,
1587                k = i + 1,
1588                l = this.inputs.length;
1589            if (i === -1)
1590                return;
1591
1592            $.each(this.pickers, function(i, p){
1593                if (!p.getUTCDate() && (p === dp || !keep_empty_values))
1594                    p.setUTCDate(new_date);
1595            });
1596
1597            if (new_date < this.dates[j]){
1598                // Date being moved earlier/left
1599                while (j >= 0 && new_date < this.dates[j]){
1600                    this.pickers[j--].setUTCDate(new_date);
1601                }
1602            } else if (new_date > this.dates[k]){
1603                // Date being moved later/right
1604                while (k < l && new_date > this.dates[k]){
1605                    this.pickers[k++].setUTCDate(new_date);
1606                }
1607            }
1608            this.updateDates();
1609
1610            delete this.updating;
1611        },
1612        destroy: function(){
1613            $.map(this.pickers, function(p){ p.destroy(); });
1614            $(this.inputs).off('changeDate', this.dateUpdated);
1615            delete this.element.data().datepicker;
1616        },
1617        remove: alias('destroy', 'Method `remove` is deprecated and will be removed in version 2.0. Use `destroy` instead')
1618    };
1619
1620    function opts_from_el(el, prefix){
1621        // Derive options from element data-attrs
1622        var data = $(el).data(),
1623            out = {}, inkey,
1624            replace = new RegExp('^' + prefix.toLowerCase() + '([A-Z])');
1625        prefix = new RegExp('^' + prefix.toLowerCase());
1626        function re_lower(_,a){
1627            return a.toLowerCase();
1628        }
1629        for (var key in data)
1630            if (prefix.test(key)){
1631                inkey = key.replace(replace, re_lower);
1632                out[inkey] = data[key];
1633            }
1634        return out;
1635    }
1636
1637    function opts_from_locale(lang){
1638        // Derive options from locale plugins
1639        var out = {};
1640        // Check if "de-DE" style date is available, if not language should
1641        // fallback to 2 letter code eg "de"
1642        if (!dates[lang]){
1643            lang = lang.split('-')[0];
1644            if (!dates[lang])
1645                return;
1646        }
1647        var d = dates[lang];
1648        $.each(locale_opts, function(i,k){
1649            if (k in d)
1650                out[k] = d[k];
1651        });
1652        return out;
1653    }
1654
1655    var old = $.fn.datepicker;
1656    var datepickerPlugin = function(option){
1657        var args = Array.apply(null, arguments);
1658        args.shift();
1659        var internal_return;
1660        this.each(function(){
1661            var $this = $(this),
1662                data = $this.data('datepicker'),
1663                options = typeof option === 'object' && option;
1664            if (!data){
1665                var elopts = opts_from_el(this, 'date'),
1666                    // Preliminary otions
1667                    xopts = $.extend({}, defaults, elopts, options),
1668                    locopts = opts_from_locale(xopts.language),
1669                    // Options priority: js args, data-attrs, locales, defaults
1670                    opts = $.extend({}, defaults, locopts, elopts, options);
1671                if ($this.hasClass('input-daterange') || opts.inputs){
1672                    $.extend(opts, {
1673                        inputs: opts.inputs || $this.find('input').toArray()
1674                    });
1675                    data = new DateRangePicker(this, opts);
1676                }
1677                else {
1678                    data = new Datepicker(this, opts);
1679                }
1680                $this.data('datepicker', data);
1681            }
1682            if (typeof option === 'string' && typeof data[option] === 'function'){
1683                internal_return = data[option].apply(data, args);
1684            }
1685        });
1686
1687        if (
1688            internal_return === undefined ||
1689            internal_return instanceof Datepicker ||
1690            internal_return instanceof DateRangePicker
1691        )
1692            return this;
1693
1694        if (this.length > 1)
1695            throw new Error('Using only allowed for the collection of a single element (' + option + ' function)');
1696        else
1697            return internal_return;
1698    };
1699    $.fn.datepicker = datepickerPlugin;
1700
1701    var defaults = $.fn.datepicker.defaults = {
1702        assumeNearbyYear: false,
1703        autoclose: false,
1704        beforeShowDay: $.noop,
1705        beforeShowMonth: $.noop,
1706        beforeShowYear: $.noop,
1707        beforeShowDecade: $.noop,
1708        beforeShowCentury: $.noop,
1709        calendarWeeks: false,
1710        clearBtn: false,
1711        toggleActive: false,
1712        daysOfWeekDisabled: [],
1713        daysOfWeekHighlighted: [],
1714        datesDisabled: [],
1715        endDate: Infinity,
1716        forceParse: true,
1717        format: 'mm/dd/yyyy',
1718        keepEmptyValues: false,
1719        keyboardNavigation: true,
1720        language: 'en',
1721        minViewMode: 0,
1722        maxViewMode: 4,
1723        multidate: false,
1724        multidateSeparator: ',',
1725        orientation: "auto",
1726        rtl: false,
1727        startDate: -Infinity,
1728        startView: 0,
1729        todayBtn: false,
1730        todayHighlight: false,
1731        updateViewDate: true,
1732        weekStart: 0,
1733        disableTouchKeyboard: false,
1734        enableOnReadonly: true,
1735        showOnFocus: true,
1736        zIndexOffset: 10,
1737        container: 'body',
1738        immediateUpdates: false,
1739        title: '',
1740        templates: {
1741            leftArrow: '&#xf104;',
1742            rightArrow: '&#xf105;'
1743        },
1744        showWeekDays: true
1745    };
1746    var locale_opts = $.fn.datepicker.locale_opts = [
1747        'format',
1748        'rtl',
1749        'weekStart'
1750    ];
1751    $.fn.datepicker.Constructor = Datepicker;
1752    var dates = $.fn.datepicker.dates = {
1753        en: {
1754            days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
1755            daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
1756            daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
1757            months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
1758            monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
1759            today: "Today",
1760            tomorrow: "Tomorrow",
1761            clear: "Clear",
1762            titleFormat: "MM yyyy"
1763        }
1764    };
1765
1766    var DPGlobal = {
1767        viewModes: [
1768            {
1769                names: ['days', 'month'],
1770                clsName: 'days',
1771                e: 'changeMonth'
1772            },
1773            {
1774                names: ['months', 'year'],
1775                clsName: 'months',
1776                e: 'changeYear',
1777                navStep: 1
1778            },
1779            {
1780                names: ['years', 'decade'],
1781                clsName: 'years',
1782                e: 'changeDecade',
1783                navStep: 10
1784            },
1785            {
1786                names: ['decades', 'century'],
1787                clsName: 'decades',
1788                e: 'changeCentury',
1789                navStep: 100
1790            },
1791            {
1792                names: ['centuries', 'millennium'],
1793                clsName: 'centuries',
1794                e: 'changeMillennium',
1795                navStep: 1000
1796            }
1797        ],
1798        validParts: /dd?|DD?|mm?|MM?|yy(?:yy)?/g,
1799        nonpunctuation: /[^ -\/:-@\u5e74\u6708\u65e5\[-`{-~\t\n\r]+/g,
1800        parseFormat: function(format){
1801            if (typeof format.toValue === 'function' && typeof format.toDisplay === 'function')
1802                return format;
1803            // IE treats \0 as a string end in inputs (truncating the value),
1804            // so it's a bad format delimiter, anyway
1805            var separators = format.replace(this.validParts, '\0').split('\0'),
1806                parts = format.match(this.validParts);
1807            if (!separators || !separators.length || !parts || parts.length === 0){
1808                throw new Error("Invalid date format.");
1809            }
1810            return {separators: separators, parts: parts};
1811        },
1812        parseDate: function(date, format, language, assumeNearby){
1813            if (!date)
1814                return undefined;
1815            if (date instanceof Date)
1816                return date;
1817            if (typeof format === 'string')
1818                format = DPGlobal.parseFormat(format);
1819            if (format.toValue)
1820                return format.toValue(date, format, language);
1821            var fn_map = {
1822                    d: 'moveDay',
1823                    m: 'moveMonth',
1824                    w: 'moveWeek',
1825                    y: 'moveYear'
1826                },
1827                dateAliases = {
1828                    yesterday: '-1d',
1829                    today: '+0d',
1830                    tomorrow: '+1d'
1831                },
1832                parts, part, dir, i, fn;
1833            if (date in dateAliases){
1834                date = dateAliases[date];
1835            }
1836            if (/^[\-+]\d+[dmwy]([\s,]+[\-+]\d+[dmwy])*$/i.test(date)){
1837                parts = date.match(/([\-+]\d+)([dmwy])/gi);
1838                date = new Date();
1839                for (i=0; i < parts.length; i++){
1840                    part = parts[i].match(/([\-+]\d+)([dmwy])/i);
1841                    dir = Number(part[1]);
1842                    fn = fn_map[part[2].toLowerCase()];
1843                    date = Datepicker.prototype[fn](date, dir);
1844                }
1845                return Datepicker.prototype._zero_utc_time(date);
1846            }
1847
1848            parts = date && date.match(this.nonpunctuation) || [];
1849
1850            function applyNearbyYear(year, threshold){
1851                if (threshold === true)
1852                    threshold = 10;
1853
1854                // if year is 2 digits or less, than the user most likely is trying to get a recent century
1855                if (year < 100){
1856                    year += 2000;
1857                    // if the new year is more than threshold years in advance, use last century
1858                    if (year > ((new Date()).getFullYear()+threshold)){
1859                        year -= 100;
1860                    }
1861                }
1862
1863                return year;
1864            }
1865
1866            var parsed = {},
1867                setters_order = ['yyyy', 'yy', 'M', 'MM', 'm', 'mm', 'd', 'dd'],
1868                setters_map = {
1869                    yyyy: function(d,v){
1870                        return d.setUTCFullYear(assumeNearby ? applyNearbyYear(v, assumeNearby) : v);
1871                    },
1872                    m: function(d,v){
1873                        if (isNaN(d))
1874                            return d;
1875                        v -= 1;
1876                        while (v < 0) v += 12;
1877                        v %= 12;
1878                        d.setUTCMonth(v);
1879                        while (d.getUTCMonth() !== v)
1880                            d.setUTCDate(d.getUTCDate()-1);
1881                        return d;
1882                    },
1883                    d: function(d,v){
1884                        return d.setUTCDate(v);
1885                    }
1886                },
1887                val, filtered;
1888            setters_map['yy'] = setters_map['yyyy'];
1889            setters_map['M'] = setters_map['MM'] = setters_map['mm'] = setters_map['m'];
1890            setters_map['dd'] = setters_map['d'];
1891            date = UTCToday();
1892            var fparts = format.parts.slice();
1893            // Remove noop parts
1894            if (parts.length !== fparts.length){
1895                fparts = $(fparts).filter(function(i,p){
1896                    return $.inArray(p, setters_order) !== -1;
1897                }).toArray();
1898            }
1899            // Process remainder
1900            function match_part(){
1901                var m = this.slice(0, parts[i].length),
1902                    p = parts[i].slice(0, m.length);
1903                return m.toLowerCase() === p.toLowerCase();
1904            }
1905            if (parts.length === fparts.length){
1906                var cnt;
1907                for (i=0, cnt = fparts.length; i < cnt; i++){
1908                    val = parseInt(parts[i], 10);
1909                    part = fparts[i];
1910                    if (isNaN(val)){
1911                        switch (part){
1912                            case 'MM':
1913                                filtered = $(dates[language].months).filter(match_part);
1914                                val = $.inArray(filtered[0], dates[language].months) + 1;
1915                                break;
1916                            case 'M':
1917                                filtered = $(dates[language].monthsShort).filter(match_part);
1918                                val = $.inArray(filtered[0], dates[language].monthsShort) + 1;
1919                                break;
1920                        }
1921                    }
1922                    parsed[part] = val;
1923                }
1924                var _date, s;
1925                for (i=0; i < setters_order.length; i++){
1926                    s = setters_order[i];
1927                    if (s in parsed && !isNaN(parsed[s])){
1928                        _date = new Date(date);
1929                        setters_map[s](_date, parsed[s]);
1930                        if (!isNaN(_date))
1931                            date = _date;
1932                    }
1933                }
1934            }
1935            return date;
1936        },
1937        formatDate: function(date, format, language){
1938            if (!date)
1939                return '';
1940            if (typeof format === 'string')
1941                format = DPGlobal.parseFormat(format);
1942            if (format.toDisplay)
1943                return format.toDisplay(date, format, language);
1944            var val = {
1945                d: date.getUTCDate(),
1946                D: dates[language].daysShort[date.getUTCDay()],
1947                DD: dates[language].days[date.getUTCDay()],
1948                m: date.getUTCMonth() + 1,
1949                M: dates[language].monthsShort[date.getUTCMonth()],
1950                MM: dates[language].months[date.getUTCMonth()],
1951                yy: date.getUTCFullYear().toString().substring(2),
1952                yyyy: date.getUTCFullYear()
1953            };
1954            val.dd = (val.d < 10 ? '0' : '') + val.d;
1955            val.mm = (val.m < 10 ? '0' : '') + val.m;
1956            date = [];
1957            var seps = $.extend([], format.separators);
1958            for (var i=0, cnt = format.parts.length; i <= cnt; i++){
1959                if (seps.length)
1960                    date.push(seps.shift());
1961                date.push(val[format.parts[i]]);
1962            }
1963            return date.join('');
1964        },
1965        headTemplate: '<thead>'+
1966        '<tr>'+
1967        '<th colspan="7" class="datepicker-title"></th>'+
1968        '</tr>'+
1969        '<tr>'+
1970        '<th colspan="4" class="datepicker-date"><span class="prev">'+defaults.templates.leftArrow+'</span><span class="datepicker-switch"></span><span class="next">'+defaults.templates.rightArrow+'</span></th>'+
1971        '<th colspan="3" class="datepicker-buttons">' +
1972        '<span class="today active"></span>' +
1973        '<span class="tomorrow"></span>' +
1974        '</th>'+
1975        '</tr>'+
1976        '</thead>',
1977        contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>',
1978        footTemplate: '<tfoot>'+
1979        '<tr>'+
1980        '<th colspan="7" class="clear"></th>'+
1981        '</tr>'+
1982        '</tfoot>'
1983    };
1984    DPGlobal.template = '<div class="datepicker">'+
1985        '<div class="datepicker-days">'+
1986        '<table class="table-condensed">'+
1987        DPGlobal.headTemplate+
1988        '<tbody></tbody>'+
1989        DPGlobal.footTemplate+
1990        '</table>'+
1991        '</div>'+
1992        '<div class="datepicker-months">'+
1993        '<table class="table-condensed">'+
1994        DPGlobal.headTemplate+
1995        DPGlobal.contTemplate+
1996        DPGlobal.footTemplate+
1997        '</table>'+
1998        '</div>'+
1999        '<div class="datepicker-years">'+
2000        '<table class="table-condensed">'+
2001        DPGlobal.headTemplate+
2002        DPGlobal.contTemplate+
2003        DPGlobal.footTemplate+
2004        '</table>'+
2005        '</div>'+
2006        '<div class="datepicker-decades">'+
2007        '<table class="table-condensed">'+
2008        DPGlobal.headTemplate+
2009        DPGlobal.contTemplate+
2010        DPGlobal.footTemplate+
2011        '</table>'+
2012        '</div>'+
2013        '<div class="datepicker-centuries">'+
2014        '<table class="table-condensed">'+
2015        DPGlobal.headTemplate+
2016        DPGlobal.contTemplate+
2017        DPGlobal.footTemplate+
2018        '</table>'+
2019        '</div>'+
2020        '</div>';
2021
2022    $.fn.datepicker.DPGlobal = DPGlobal;
2023
2024
2025    /* DATEPICKER NO CONFLICT
2026     * =================== */
2027
2028    $.fn.datepicker.noConflict = function(){
2029        $.fn.datepicker = old;
2030        return this;
2031    };
2032
2033    /* DATEPICKER VERSION
2034     * =================== */
2035    $.fn.datepicker.version = '1.7.1';
2036
2037    $.fn.datepicker.deprecated = function(msg){
2038        var console = window.console;
2039        if (console && console.warn) {
2040            console.warn('DEPRECATED: ' + msg);
2041        }
2042    };
2043
2044
2045    /* DATEPICKER DATA-API
2046     * ================== */
2047
2048    $(document).on(
2049        'focus.datepicker.data-api click.datepicker.data-api',
2050        '[data-provide="datepicker"]',
2051        function(e){
2052            var $this = $(this);
2053            if ($this.data('datepicker'))
2054                return;
2055            e.preventDefault();
2056            // component click requires us to explicitly show it
2057            datepickerPlugin.call($this, 'show');
2058        }
2059    );
2060    $(function(){
2061        datepickerPlugin.call($('[data-provide="datepicker-inline"]'));
2062    });
2063
2064}));
2065
2066function sameDay( d1, d2 ){
2067    return d1.getUTCFullYear() == d2.getUTCFullYear() &&
2068        d1.getUTCMonth() == d2.getUTCMonth() &&
2069        d1.getUTCDate() == d2.getUTCDate();
2070}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.