Plugin Directory

Changeset 801561


Ignore:
Timestamp:
11/09/2013 01:57:53 PM (12 years ago)
Author:
shockware
Message:

Update timepicker addon to 1.4

Location:
contact-form-7-datepicker/trunk/js/jquery-ui-timepicker
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • contact-form-7-datepicker/trunk/js/jquery-ui-timepicker/i18n/jquery-ui-timepicker-sv.js

    r755191 r801561  
    44    $.timepicker.regional['sv'] = {
    55        timeOnlyTitle: 'Välj en tid',
    6         timeText: 'Timme',
    7         hourText: 'Timmar',
    8         minuteText: 'Minuter',
    9         secondText: 'Sekunder',
    10         millisecText: 'Millisekunder',
    11         microsecText: 'Mikrosekunder',
     6        timeText: 'Tid',
     7        hourText: 'Timme',
     8        minuteText: 'Minut',
     9        secondText: 'Sekund',
     10        millisecText: 'Millisekund',
     11        microsecText: 'Mikrosekund',
    1212        timezoneText: 'Tidszon',
    1313        currentText: 'Nu',
  • contact-form-7-datepicker/trunk/js/jquery-ui-timepicker/jquery-ui-timepicker-addon.css

    r755191 r801561  
    11.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
    22.ui-timepicker-div dl { text-align: left; }
    3 .ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; }
    4 .ui-timepicker-div dl dd { margin: 0 10px 10px 65px; }
     3.ui-timepicker-div dl dt { float: left; clear:left; padding: 0 0 0 5px; }
     4.ui-timepicker-div dl dd { margin: 0 10px 10px 40%; }
    55.ui-timepicker-div td { font-size: 90%; }
    66.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
    77
    88.ui-timepicker-rtl{ direction: rtl; }
    9 .ui-timepicker-rtl dl { text-align: right; }
    10 .ui-timepicker-rtl dl dd { margin: 0 65px 10px 10px; }
     9.ui-timepicker-rtl dl { text-align: right; padding: 0 5px 0 0; }
     10.ui-timepicker-rtl dl dt{ float: right; clear: right; }
     11.ui-timepicker-rtl dl dd { margin: 0 40% 10px 10px; }
  • contact-form-7-datepicker/trunk/js/jquery-ui-timepicker/jquery-ui-timepicker-addon.js

    r755191 r801561  
    1 /*
    2  * jQuery timepicker addon
    3  * By: Trent Richardson [http://trentrichardson.com]
    4  * Version 1.3
    5  * Last Modified: 05/05/2013
    6  *
    7  * Copyright 2013 Trent Richardson
    8  * You may use this project under MIT or GPL licenses.
    9  * http://trentrichardson.com/Impromptu/GPL-LICENSE.txt
    10  * http://trentrichardson.com/Impromptu/MIT-LICENSE.txt
    11  */
    12 
    13 /*jslint evil: true, white: false, undef: false, nomen: false */
    14 
    15 (function($) {
     1/*! jQuery Timepicker Addon - v1.4 - 2013-08-11
     2* http://trentrichardson.com/examples/timepicker
     3* Copyright (c) 2013 Trent Richardson; Licensed MIT */
     4(function ($) {
    165
    176    /*
     
    2817    $.extend($.ui, {
    2918        timepicker: {
    30             version: "1.3"
     19            version: "1.4"
    3120        }
    3221    });
     
    3827    * allowing multiple different settings on the same page.
    3928    */
    40     var Timepicker = function() {
     29    var Timepicker = function () {
    4130        this.regional = []; // Available regional settings, indexed by language code
    4231        this.regional[''] = { // Default regional settings
     
    147136        formattedDateTime: '',
    148137        timezoneList: null,
    149         units: ['hour','minute','second','millisec', 'microsec'],
     138        units: ['hour', 'minute', 'second', 'millisec', 'microsec'],
    150139        support: {},
    151140        control: null,
     
    153142        /*
    154143        * Override the default settings for all instances of the time picker.
    155         * @param  settings  object - the new settings to use as defaults (anonymous object)
    156         * @return the manager object
     144        * @param  {Object} settings  object - the new settings to use as defaults (anonymous object)
     145        * @return {Object} the manager object
    157146        */
    158         setDefaults: function(settings) {
     147        setDefaults: function (settings) {
    159148            extendRemove(this._defaults, settings || {});
    160149            return this;
     
    164153        * Create a new Timepicker instance
    165154        */
    166         _newInst: function($input, o) {
     155        _newInst: function ($input, opts) {
    167156            var tp_inst = new Timepicker(),
    168157                inlineSettings = {},
    169                 fns = {},
    170                 overrides, i;
     158                fns = {},
     159                overrides, i;
    171160
    172161            for (var attrName in this._defaults) {
    173                 if(this._defaults.hasOwnProperty(attrName)){
     162                if (this._defaults.hasOwnProperty(attrName)) {
    174163                    var attrValue = $input.attr('time:' + attrName);
    175164                    if (attrValue) {
     
    183172            }
    184173
    185             overrides = {
    186                 beforeShow: function (input, dp_inst) {
    187                     if ($.isFunction(tp_inst._defaults.evnts.beforeShow)) {
    188                         return tp_inst._defaults.evnts.beforeShow.call($input[0], input, dp_inst, tp_inst);
    189                     }
    190                 },
    191                 onChangeMonthYear: function (year, month, dp_inst) {
    192                     // Update the time as well : this prevents the time from disappearing from the $input field.
    193                     tp_inst._updateDateTime(dp_inst);
    194                     if ($.isFunction(tp_inst._defaults.evnts.onChangeMonthYear)) {
    195                         tp_inst._defaults.evnts.onChangeMonthYear.call($input[0], year, month, dp_inst, tp_inst);
    196                     }
    197                 },
    198                 onClose: function (dateText, dp_inst) {
    199                     if (tp_inst.timeDefined === true && $input.val() !== '') {
    200                         tp_inst._updateDateTime(dp_inst);
    201                     }
    202                     if ($.isFunction(tp_inst._defaults.evnts.onClose)) {
    203                         tp_inst._defaults.evnts.onClose.call($input[0], dateText, dp_inst, tp_inst);
    204                     }
    205                 }
    206             };
    207             for (i in overrides) {
    208                 if (overrides.hasOwnProperty(i)) {
    209                     fns[i] = o[i] || null;
    210                 }
    211             }
    212 
    213             tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, o, overrides, {
    214                 evnts:fns,
    215                 timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker');
    216             });
    217             tp_inst.amNames = $.map(tp_inst._defaults.amNames, function(val) {
     174            overrides = {
     175                beforeShow: function (input, dp_inst) {
     176                    if ($.isFunction(tp_inst._defaults.evnts.beforeShow)) {
     177                        return tp_inst._defaults.evnts.beforeShow.call($input[0], input, dp_inst, tp_inst);
     178                    }
     179                },
     180                onChangeMonthYear: function (year, month, dp_inst) {
     181                    // Update the time as well : this prevents the time from disappearing from the $input field.
     182                    tp_inst._updateDateTime(dp_inst);
     183                    if ($.isFunction(tp_inst._defaults.evnts.onChangeMonthYear)) {
     184                        tp_inst._defaults.evnts.onChangeMonthYear.call($input[0], year, month, dp_inst, tp_inst);
     185                    }
     186                },
     187                onClose: function (dateText, dp_inst) {
     188                    if (tp_inst.timeDefined === true && $input.val() !== '') {
     189                        tp_inst._updateDateTime(dp_inst);
     190                    }
     191                    if ($.isFunction(tp_inst._defaults.evnts.onClose)) {
     192                        tp_inst._defaults.evnts.onClose.call($input[0], dateText, dp_inst, tp_inst);
     193                    }
     194                }
     195            };
     196            for (i in overrides) {
     197                if (overrides.hasOwnProperty(i)) {
     198                    fns[i] = opts[i] || null;
     199                }
     200            }
     201
     202            tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, opts, overrides, {
     203                evnts: fns,
     204                timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker');
     205            });
     206            tp_inst.amNames = $.map(tp_inst._defaults.amNames, function (val) {
    218207                return val.toUpperCase();
    219208            });
    220             tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function(val) {
     209            tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function (val) {
    221210                return val.toUpperCase();
    222211            });
     
    225214            tp_inst.support = detectSupport(
    226215                    tp_inst._defaults.timeFormat +
    227                     (tp_inst._defaults.pickerTimeFormat? tp_inst._defaults.pickerTimeFormat:'') +
    228                     (tp_inst._defaults.altTimeFormat? tp_inst._defaults.altTimeFormat:''));
     216                    (tp_inst._defaults.pickerTimeFormat ? tp_inst._defaults.pickerTimeFormat : '') +
     217                    (tp_inst._defaults.altTimeFormat ? tp_inst._defaults.altTimeFormat : ''));
    229218
    230219            // controlType is string - key to our this._controls
    231             if(typeof(tp_inst._defaults.controlType) === 'string'){
    232                 if(tp_inst._defaults.controlType == 'slider' && typeof(jQuery.ui.slider) === 'undefined'){
     220            if (typeof(tp_inst._defaults.controlType) === 'string') {
     221                if (tp_inst._defaults.controlType === 'slider' && typeof($.ui.slider) === 'undefined') {
    233222                    tp_inst._defaults.controlType = 'select';
    234223                }
     
    236225            }
    237226            // controlType is an object and must implement create, options, value methods
    238             else{
     227            else {
    239228                tp_inst.control = tp_inst._defaults.controlType;
    240229            }
    241230
    242231            // prep the timezone options
    243             var timezoneList = [-720,-660,-600,-570,-540,-480,-420,-360,-300,-270,-240,-210,-180,-120,-60,
    244                     0,60,120,180,210,240,270,300,330,345,360,390,420,480,525,540,570,600,630,660,690,720,765,780,840];
     232            var timezoneList = [-720, -660, -600, -570, -540, -480, -420, -360, -300, -270, -240, -210, -180, -120, -60,
     233                    0, 60, 120, 180, 210, 240, 270, 300, 330, 345, 360, 390, 420, 480, 525, 540, 570, 600, 630, 660, 690, 720, 765, 780, 840];
    245234            if (tp_inst._defaults.timezoneList !== null) {
    246235                timezoneList = tp_inst._defaults.timezoneList;
    247236            }
    248             var tzl=timezoneList.length,tzi=0,tzv=null;
     237            var tzl = timezoneList.length, tzi = 0, tzv = null;
    249238            if (tzl > 0 && typeof timezoneList[0] !== 'object') {
    250                 for(; tzi<tzl; tzi++){
     239                for (; tzi < tzl; tzi++) {
    251240                    tzv = timezoneList[tzi];
    252241                    timezoneList[tzi] = { value: tzv, label: $.timepicker.timezoneOffsetString(tzv, tp_inst.support.iso8601) };
     
    256245
    257246            // set the default units
    258             tp_inst.timezone = tp_inst._defaults.timezone !== null? $.timepicker.timezoneOffsetNumber(tp_inst._defaults.timezone) :
    259                             ((new Date()).getTimezoneOffset()*-1);
    260             tp_inst.hour = tp_inst._defaults.hour < tp_inst._defaults.hourMin? tp_inst._defaults.hourMin :
    261                             tp_inst._defaults.hour > tp_inst._defaults.hourMax? tp_inst._defaults.hourMax : tp_inst._defaults.hour;
    262             tp_inst.minute = tp_inst._defaults.minute < tp_inst._defaults.minuteMin? tp_inst._defaults.minuteMin :
    263                             tp_inst._defaults.minute > tp_inst._defaults.minuteMax? tp_inst._defaults.minuteMax : tp_inst._defaults.minute;
    264             tp_inst.second = tp_inst._defaults.second < tp_inst._defaults.secondMin? tp_inst._defaults.secondMin :
    265                             tp_inst._defaults.second > tp_inst._defaults.secondMax? tp_inst._defaults.secondMax : tp_inst._defaults.second;
    266             tp_inst.millisec = tp_inst._defaults.millisec < tp_inst._defaults.millisecMin? tp_inst._defaults.millisecMin :
    267                             tp_inst._defaults.millisec > tp_inst._defaults.millisecMax? tp_inst._defaults.millisecMax : tp_inst._defaults.millisec;
    268             tp_inst.microsec = tp_inst._defaults.microsec < tp_inst._defaults.microsecMin? tp_inst._defaults.microsecMin :
    269                             tp_inst._defaults.microsec > tp_inst._defaults.microsecMax? tp_inst._defaults.microsecMax : tp_inst._defaults.microsec;
     247            tp_inst.timezone = tp_inst._defaults.timezone !== null ? $.timepicker.timezoneOffsetNumber(tp_inst._defaults.timezone) :
     248                            ((new Date()).getTimezoneOffset() * -1);
     249            tp_inst.hour = tp_inst._defaults.hour < tp_inst._defaults.hourMin ? tp_inst._defaults.hourMin :
     250                            tp_inst._defaults.hour > tp_inst._defaults.hourMax ? tp_inst._defaults.hourMax : tp_inst._defaults.hour;
     251            tp_inst.minute = tp_inst._defaults.minute < tp_inst._defaults.minuteMin ? tp_inst._defaults.minuteMin :
     252                            tp_inst._defaults.minute > tp_inst._defaults.minuteMax ? tp_inst._defaults.minuteMax : tp_inst._defaults.minute;
     253            tp_inst.second = tp_inst._defaults.second < tp_inst._defaults.secondMin ? tp_inst._defaults.secondMin :
     254                            tp_inst._defaults.second > tp_inst._defaults.secondMax ? tp_inst._defaults.secondMax : tp_inst._defaults.second;
     255            tp_inst.millisec = tp_inst._defaults.millisec < tp_inst._defaults.millisecMin ? tp_inst._defaults.millisecMin :
     256                            tp_inst._defaults.millisec > tp_inst._defaults.millisecMax ? tp_inst._defaults.millisecMax : tp_inst._defaults.millisec;
     257            tp_inst.microsec = tp_inst._defaults.microsec < tp_inst._defaults.microsecMin ? tp_inst._defaults.microsecMin :
     258                            tp_inst._defaults.microsec > tp_inst._defaults.microsecMax ? tp_inst._defaults.microsecMax : tp_inst._defaults.microsec;
    270259            tp_inst.ampm = '';
    271260            tp_inst.$input = $input;
    272261
    273             if (o.altField) {
    274                 tp_inst.$altInput = $(o.altField).css({
     262            if (tp_inst._defaults.altField) {
     263                tp_inst.$altInput = $(tp_inst._defaults.altField).css({
    275264                    cursor: 'pointer'
    276                 }).focus(function() {
     265                }).focus(function () {
    277266                    $input.trigger("focus");
    278267                });
     
    299288                tp_inst._defaults.maxDate = new Date(tp_inst._defaults.maxDateTime.getTime());
    300289            }
    301             tp_inst.$input.bind('focus', function() {
     290            tp_inst.$input.bind('focus', function () {
    302291                tp_inst._onFocus();
    303292            });
     
    309298        * add our sliders to the calendar
    310299        */
    311         _addTimePicker: function(dp_inst) {
     300        _addTimePicker: function (dp_inst) {
    312301            var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ? this.$input.val() + ' ' + this.$altInput.val() : this.$input.val();
    313302
     
    320309        * parse the time string from input value or _setTime
    321310        */
    322         _parseTime: function(timeString, withDate) {
     311        _parseTime: function (timeString, withDate) {
    323312            if (!this.inst) {
    324313                this.inst = $.datepicker._getInst(this.$input[0]);
     
    354343        * generate and inject html for timepicker into ui datepicker
    355344        */
    356         _injectTimePicker: function() {
     345        _injectTimePicker: function () {
    357346            var $dp = this.inst.dpDiv,
    358347                o = this.inst.settings,
     
    364353                gridSize = {},
    365354                size = null,
    366                 i=0,
    367                 l=0;
     355                i = 0,
     356                l = 0;
    368357
    369358            // Prevent displaying twice
    370359            if ($dp.find("div.ui-timepicker-div").length === 0 && o.showTimepicker) {
    371360                var noDisplay = ' style="display:none;"',
    372                     html = '<div class="ui-timepicker-div'+ (o.isRTL? ' ui-timepicker-rtl' : '') +'"><dl>' + '<dt class="ui_tpicker_time_label"' + ((o.showTime) ? '' : noDisplay) + '>' + o.timeText + '</dt>' +
     361                    html = '<div class="ui-timepicker-div' + (o.isRTL ? ' ui-timepicker-rtl' : '') + '"><dl>' + '<dt class="ui_tpicker_time_label"' + ((o.showTime) ? '' : noDisplay) + '>' + o.timeText + '</dt>' +
    373362                                '<dd class="ui_tpicker_time"' + ((o.showTime) ? '' : noDisplay) + '></dd>';
    374363
    375364                // Create the markup
    376                 for(i=0,l=this.units.length; i<l; i++){
     365                for (i = 0, l = this.units.length; i < l; i++) {
    377366                    litem = this.units[i];
    378                     uitem = litem.substr(0,1).toUpperCase() + litem.substr(1);
    379                     show = o['show'+uitem] !== null? o['show'+uitem] : this.support[litem];
     367                    uitem = litem.substr(0, 1).toUpperCase() + litem.substr(1);
     368                    show = o['show' + uitem] !== null ? o['show' + uitem] : this.support[litem];
    380369
    381370                    // Added by Peter Medeiros:
    382371                    // - Figure out what the hour/minute/second max should be based on the step values.
    383372                    // - Example: if stepMinute is 15, then minMax is 45.
    384                     max[litem] = parseInt((o[litem+'Max'] - ((o[litem+'Max'] - o[litem+'Min']) % o['step'+uitem])), 10);
     373                    max[litem] = parseInt((o[litem + 'Max'] - ((o[litem + 'Max'] - o[litem + 'Min']) % o['step' + uitem])), 10);
    385374                    gridSize[litem] = 0;
    386375
    387                     html += '<dt class="ui_tpicker_'+ litem +'_label"' + (show ? '' : noDisplay) + '>' + o[litem +'Text'] + '</dt>' +
    388                                 '<dd class="ui_tpicker_'+ litem +'"><div class="ui_tpicker_'+ litem +'_slider"' + (show ? '' : noDisplay) + '></div>';
    389 
    390                     if (show && o[litem+'Grid'] > 0) {
     376                    html += '<dt class="ui_tpicker_' + litem + '_label"' + (show ? '' : noDisplay) + '>' + o[litem + 'Text'] + '</dt>' +
     377                                '<dd class="ui_tpicker_' + litem + '"><div class="ui_tpicker_' + litem + '_slider"' + (show ? '' : noDisplay) + '></div>';
     378
     379                    if (show && o[litem + 'Grid'] > 0) {
    391380                        html += '<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';
    392381
    393                         if(litem == 'hour'){
    394                             for (var h = o[litem+'Min']; h <= max[litem]; h += parseInt(o[litem+'Grid'], 10)) {
     382                        if (litem === 'hour') {
     383                            for (var h = o[litem + 'Min']; h <= max[litem]; h += parseInt(o[litem + 'Grid'], 10)) {
    395384                                gridSize[litem]++;
    396                                 var tmph = $.datepicker.formatTime(this.support.ampm? 'hht':'HH', {hour:h}, o);                                 
    397                                 html += '<td data-for="'+litem+'">' + tmph + '</td>';
     385                                var tmph = $.datepicker.formatTime(this.support.ampm ? 'hht' : 'HH', {hour: h}, o);
     386                                html += '<td data-for="' + litem + '">' + tmph + '</td>';
    398387                            }
    399388                        }
    400                         else{
    401                             for (var m = o[litem+'Min']; m <= max[litem]; m += parseInt(o[litem+'Grid'], 10)) {
     389                        else {
     390                            for (var m = o[litem + 'Min']; m <= max[litem]; m += parseInt(o[litem + 'Grid'], 10)) {
    402391                                gridSize[litem]++;
    403                                 html += '<td data-for="'+litem+'">' + ((m < 10) ? '0' : '') + m + '</td>';
     392                                html += '<td data-for="' + litem + '">' + ((m < 10) ? '0' : '') + m + '</td>';
    404393                            }
    405394                        }
     
    411400               
    412401                // Timezone
    413                 var showTz = o.showTimezone !== null? o.showTimezone : this.support.timezone;
     402                var showTz = o.showTimezone !== null ? o.showTimezone : this.support.timezone;
    414403                html += '<dt class="ui_tpicker_timezone_label"' + (showTz ? '' : noDisplay) + '>' + o.timezoneText + '</dt>';
    415404                html += '<dd class="ui_tpicker_timezone" ' + (showTz ? '' : noDisplay) + '></dd>';
     
    426415               
    427416                // add sliders, adjust grids, add events
    428                 for(i=0,l=tp_inst.units.length; i<l; i++){
     417                for (i = 0, l = tp_inst.units.length; i < l; i++) {
    429418                    litem = tp_inst.units[i];
    430                     uitem = litem.substr(0,1).toUpperCase() + litem.substr(1);
    431                     show = o['show'+uitem] !== null? o['show'+uitem] : this.support[litem];
     419                    uitem = litem.substr(0, 1).toUpperCase() + litem.substr(1);
     420                    show = o['show' + uitem] !== null ? o['show' + uitem] : this.support[litem];
    432421
    433422                    // add the slider
    434                     tp_inst[litem+'_slider'] = tp_inst.control.create(tp_inst, $tp.find('.ui_tpicker_'+litem+'_slider'), litem, tp_inst[litem], o[litem+'Min'], max[litem], o['step'+uitem]);
     423                    tp_inst[litem + '_slider'] = tp_inst.control.create(tp_inst, $tp.find('.ui_tpicker_' + litem + '_slider'), litem, tp_inst[litem], o[litem + 'Min'], max[litem], o['step' + uitem]);
    435424
    436425                    // adjust the grid and add click event
    437                     if (show && o[litem+'Grid'] > 0) {
    438                         size = 100 * gridSize[litem] * o[litem+'Grid'] / (max[litem] - o[litem+'Min']);
    439                         $tp.find('.ui_tpicker_'+litem+' table').css({
     426                    if (show && o[litem + 'Grid'] > 0) {
     427                        size = 100 * gridSize[litem] * o[litem + 'Grid'] / (max[litem] - o[litem + 'Min']);
     428                        $tp.find('.ui_tpicker_' + litem + ' table').css({
    440429                            width: size + "%",
    441                             marginLeft: o.isRTL? '0' : ((size / (-2 * gridSize[litem])) + "%"),
    442                             marginRight: o.isRTL? ((size / (-2 * gridSize[litem])) + "%") : '0',
     430                            marginLeft: o.isRTL ? '0' : ((size / (-2 * gridSize[litem])) + "%"),
     431                            marginRight: o.isRTL ? ((size / (-2 * gridSize[litem])) + "%") : '0',
    443432                            borderCollapse: 'collapse'
    444                         }).find("td").click(function(e){
     433                        }).find("td").click(function (e) {
    445434                                var $t = $(this),
    446435                                    h = $t.html(),
    447                                     n = parseInt(h.replace(/[^0-9]/g),10),
     436                                    n = parseInt(h.replace(/[^0-9]/g), 10),
    448437                                    ap = h.replace(/[^apm]/ig),
    449438                                    f = $t.data('for'); // loses scope, so we use data-for
    450439
    451                                 if(f == 'hour'){
    452                                     if(ap.indexOf('p') !== -1 && n < 12){
     440                                if (f === 'hour') {
     441                                    if (ap.indexOf('p') !== -1 && n < 12) {
    453442                                        n += 12;
    454443                                    }
    455                                     else{
    456                                         if(ap.indexOf('a') !== -1 && n === 12){
     444                                    else {
     445                                        if (ap.indexOf('a') !== -1 && n === 12) {
    457446                                            n = 0;
    458447                                        }
     
    460449                                }
    461450                               
    462                                 tp_inst.control.value(tp_inst, tp_inst[f+'_slider'], litem, n);
     451                                tp_inst.control.value(tp_inst, tp_inst[f + '_slider'], litem, n);
    463452
    464453                                tp_inst._onTimeChange();
     
    476465                this.timezone_select = $tp.find('.ui_tpicker_timezone').append('<select></select>').find("select");
    477466                $.fn.append.apply(this.timezone_select,
    478                 $.map(o.timezoneList, function(val, idx) {
    479                     return $("<option />").val(typeof val == "object" ? val.value : val).text(typeof val == "object" ? val.label : val);
     467                $.map(o.timezoneList, function (val, idx) {
     468                    return $("<option />").val(typeof val === "object" ? val.value : val).text(typeof val === "object" ? val.label : val);
    480469                }));
    481                 if (typeof(this.timezone) != "undefined" && this.timezone !== null && this.timezone !== "") {
    482                     var local_timezone = (new Date(this.inst.selectedYear, this.inst.selectedMonth, this.inst.selectedDay, 12)).getTimezoneOffset()*-1;
    483                     if (local_timezone == this.timezone) {
     470                if (typeof(this.timezone) !== "undefined" && this.timezone !== null && this.timezone !== "") {
     471                    var local_timezone = (new Date(this.inst.selectedYear, this.inst.selectedMonth, this.inst.selectedDay, 12)).getTimezoneOffset() * -1;
     472                    if (local_timezone === this.timezone) {
    484473                        selectLocalTimezone(tp_inst);
    485474                    } else {
     
    487476                    }
    488477                } else {
    489                     if (typeof(this.hour) != "undefined" && this.hour !== null && this.hour !== "") {
     478                    if (typeof(this.hour) !== "undefined" && this.hour !== null && this.hour !== "") {
    490479                        this.timezone_select.val(o.timezone);
    491480                    } else {
     
    493482                    }
    494483                }
    495                 this.timezone_select.change(function() {
     484                this.timezone_select.change(function () {
    496485                    tp_inst._onTimeChange();
    497486                    tp_inst._onSelectHandler();
     
    521510                    sliderAccessArgs.isRTL = rtl;
    522511                       
    523                     setTimeout(function() { // fix for inline mode
     512                    setTimeout(function () { // fix for inline mode
    524513                        if ($tp.find('.ui-slider-access').length === 0) {
    525514                            $tp.find('.ui-slider:visible').sliderAccess(sliderAccessArgs);
     
    528517                            var sliderAccessWidth = $tp.find('.ui-slider-access:eq(0)').outerWidth(true);
    529518                            if (sliderAccessWidth) {
    530                                 $tp.find('table:visible').each(function() {
     519                                $tp.find('table:visible').each(function () {
    531520                                    var $g = $(this),
    532521                                        oldWidth = $g.outerWidth(),
    533                                         oldMarginLeft = $g.css(rtl? 'marginRight':'marginLeft').toString().replace('%', ''),
     522                                        oldMarginLeft = $g.css(rtl ? 'marginRight' : 'marginLeft').toString().replace('%', ''),
    534523                                        newWidth = oldWidth - sliderAccessWidth,
    535524                                        newMarginLeft = ((oldMarginLeft * newWidth) / oldWidth) + '%',
    536525                                        css = { width: newWidth, marginRight: 0, marginLeft: 0 };
    537                                     css[rtl? 'marginRight':'marginLeft'] = newMarginLeft;
     526                                    css[rtl ? 'marginRight' : 'marginLeft'] = newMarginLeft;
    538527                                    $g.css(css);
    539528                                });
     
    544533                // end slideAccess integration
    545534
     535                tp_inst._limitMinMaxDateTime(this.inst, true);
    546536            }
    547537        },
     
    551541        * min/max date range
    552542        */
    553         _limitMinMaxDateTime: function(dp_inst, adjustSliders) {
     543        _limitMinMaxDateTime: function (dp_inst, adjustSliders) {
    554544            var o = this._defaults,
    555545                dp_date = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay);
     
    571561                }
    572562
    573                 if (dp_inst.settings.timeOnly || minDateTimeDate.getTime() == dp_date.getTime()) {
     563                if (dp_inst.settings.timeOnly || minDateTimeDate.getTime() === dp_date.getTime()) {
    574564                    this._defaults.hourMin = minDateTime.getHours();
    575565                    if (this.hour <= this._defaults.hourMin) {
     
    582572                                this.second = this._defaults.secondMin;
    583573                                this._defaults.millisecMin = minDateTime.getMilliseconds();
    584                                 if(this.millisec <= this._defaults.millisecMin) {
     574                                if (this.millisec <= this._defaults.millisecMin) {
    585575                                    this.millisec = this._defaults.millisecMin;
    586576                                    this._defaults.microsecMin = minDateTime.getMicroseconds();
     
    627617                }
    628618
    629                 if (dp_inst.settings.timeOnly || maxDateTimeDate.getTime() == dp_date.getTime()) {
     619                if (dp_inst.settings.timeOnly || maxDateTimeDate.getTime() === dp_date.getTime()) {
    630620                    this._defaults.hourMax = maxDateTime.getHours();
    631621                    if (this.hour >= this._defaults.hourMax) {
     
    675665                    minMax = parseInt((this._defaults.minuteMax - ((this._defaults.minuteMax - this._defaults.minuteMin) % this._defaults.stepMinute)), 10),
    676666                    secMax = parseInt((this._defaults.secondMax - ((this._defaults.secondMax - this._defaults.secondMin) % this._defaults.stepSecond)), 10),
    677                     millisecMax = parseInt((this._defaults.millisecMax - ((this._defaults.millisecMax - this._defaults.millisecMin) % this._defaults.stepMillisec)), 10);
     667                    millisecMax = parseInt((this._defaults.millisecMax - ((this._defaults.millisecMax - this._defaults.millisecMin) % this._defaults.stepMillisec)), 10),
    678668                    microsecMax = parseInt((this._defaults.microsecMax - ((this._defaults.microsecMax - this._defaults.microsecMin) % this._defaults.stepMicrosec)), 10);
    679669
     
    706696        * on time change is also called when the time is updated in the text field
    707697        */
    708         _onTimeChange: function() {
     698        _onTimeChange: function () {
     699            if (!this._defaults.showTimepicker) {
     700                                return;
     701            }
    709702            var hour = (this.hour_slider) ? this.control.value(this, this.hour_slider, 'hour') : false,
    710703                minute = (this.minute_slider) ? this.control.value(this, this.minute_slider, 'minute') : false,
     
    717710                pickerTimeSuffix = o.pickerTimeSuffix || o.timeSuffix;
    718711
    719             if (typeof(hour) == 'object') {
     712            if (typeof(hour) === 'object') {
    720713                hour = false;
    721714            }
    722             if (typeof(minute) == 'object') {
     715            if (typeof(minute) === 'object') {
    723716                minute = false;
    724717            }
    725             if (typeof(second) == 'object') {
     718            if (typeof(second) === 'object') {
    726719                second = false;
    727720            }
    728             if (typeof(millisec) == 'object') {
     721            if (typeof(millisec) === 'object') {
    729722                millisec = false;
    730723            }
    731             if (typeof(microsec) == 'object') {
     724            if (typeof(microsec) === 'object') {
    732725                microsec = false;
    733726            }
    734             if (typeof(timezone) == 'object') {
     727            if (typeof(timezone) === 'object') {
    735728                timezone = false;
    736729            }
     
    756749            // If the update was done in the input field, the input field should not be updated.
    757750            // If the update was done using the sliders, update the input field.
    758             var hasChanged = (hour != this.hour || minute != this.minute || second != this.second || millisec != this.millisec || microsec != this.microsec
    759                                 || (this.ampm.length > 0 && (hour < 12) != ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1))
    760                                 || (this.timezone !== null && timezone != this.timezone));
     751            var hasChanged = (hour !== this.hour || minute !== this.minute || second !== this.second || millisec !== this.millisec || microsec !== this.microsec ||
     752                    (this.ampm.length > 0 && (hour < 12) !== ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1)) || (this.timezone !== null && timezone !== this.timezone));
    761753
    762754            if (hasChanged) {
     
    794786            this.formattedTime = $.datepicker.formatTime(o.timeFormat, this, o);
    795787            if (this.$timeObj) {
    796                 if(pickerTimeFormat === o.timeFormat){
     788                if (pickerTimeFormat === o.timeFormat) {
    797789                    this.$timeObj.text(this.formattedTime + pickerTimeSuffix);
    798790                }
    799                 else{
     791                else {
    800792                    this.$timeObj.text($.datepicker.formatTime(pickerTimeFormat, this, o) + pickerTimeSuffix);
    801793                }
     
    812804        * bind to sliders slidestop, and grid click.
    813805        */
    814         _onSelectHandler: function() {
     806        _onSelectHandler: function () {
    815807            var onSelect = this._defaults.onSelect || this.inst.settings.onSelect;
    816808            var inputEl = this.$input ? this.$input[0] : null;
     
    823815        * update our input with the new date time..
    824816        */
    825         _updateDateTime: function(dp_inst) {
     817        _updateDateTime: function (dp_inst) {
    826818            dp_inst = this.inst || dp_inst;
    827             var dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
     819            var dtTmp = (dp_inst.currentYear > 0?
     820                            new Date(dp_inst.currentYear, dp_inst.currentMonth, dp_inst.currentDay) :
     821                            new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
     822                dt = $.datepicker._daylightSavingAdjust(dtTmp),
     823                //dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
     824                //dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.currentYear, dp_inst.currentMonth, dp_inst.currentDay)),
    828825                dateFmt = $.datepicker._get(dp_inst, 'dateFormat'),
    829826                formatCfg = $.datepicker._getFormatConfig(dp_inst),
     
    833830           
    834831            // if a slider was changed but datepicker doesn't have a value yet, set it
    835             if(dp_inst.lastVal===""){
    836                 dp_inst.currentYear=dp_inst.selectedYear;
    837                 dp_inst.currentMonth=dp_inst.selectedMonth;
    838                 dp_inst.currentDay=dp_inst.selectedDay;
     832            if (dp_inst.lastVa === "") {
     833                dp_inst.currentYear = dp_inst.selectedYear;
     834                dp_inst.currentMonth = dp_inst.selectedMonth;
     835                dp_inst.currentDay = dp_inst.selectedDay;
    839836            }
    840837
     
    867864                    altTimeSuffix = this._defaults.altTimeSuffix ? this._defaults.altTimeSuffix : this._defaults.timeSuffix;
    868865               
    869                 if(!this._defaults.timeOnly){
    870                     if (this._defaults.altFormat){
     866                if (!this._defaults.timeOnly) {
     867                    if (this._defaults.altFormat) {
    871868                        altFormattedDateTime = $.datepicker.formatDate(this._defaults.altFormat, (dt === null ? new Date() : dt), formatCfg);
    872869                    }
    873                     else{
     870                    else {
    874871                        altFormattedDateTime = this.formattedDate;
    875872                    }
    876873
    877                     if (altFormattedDateTime){
     874                    if (altFormattedDateTime) {
    878875                        altFormattedDateTime += altSeparator;
    879876                    }
    880877                }
    881878
    882                 if(this._defaults.altTimeFormat){
     879                if (this._defaults.altTimeFormat) {
    883880                    altFormattedDateTime += $.datepicker.formatTime(this._defaults.altTimeFormat, this, this._defaults) + altTimeSuffix;
    884881                }
    885                 else{
     882                else {
    886883                    altFormattedDateTime += this.formattedTime + altTimeSuffix;
    887884                }
     
    894891        },
    895892
    896         _onFocus: function() {
     893        _onFocus: function () {
    897894            if (!this.$input.val() && this._defaults.defaultValue) {
    898895                this.$input.val(this._defaults.defaultValue);
     
    900897                    tp_inst = $.datepicker._get(inst, 'timepicker');
    901898                if (tp_inst) {
    902                     if (tp_inst._defaults.timeOnly && (inst.input.val() != inst.lastVal)) {
     899                    if (tp_inst._defaults.timeOnly && (inst.input.val() !== inst.lastVal)) {
    903900                        try {
    904901                            $.datepicker._updateDatepicker(inst);
     
    918915            // slider methods
    919916            slider: {
    920                 create: function(tp_inst, obj, unit, val, min, max, step){
     917                create: function (tp_inst, obj, unit, val, min, max, step) {
    921918                    var rtl = tp_inst._defaults.isRTL; // if rtl go -60->0 instead of 0->60
    922919                    return obj.prop('slide', null).slider({
    923920                        orientation: "horizontal",
    924                         value: rtl? val*-1 : val,
    925                         min: rtl? max*-1 : min,
    926                         max: rtl? min*-1 : max,
     921                        value: rtl ? val * -1 : val,
     922                        min: rtl ? max * -1 : min,
     923                        max: rtl ? min * -1 : max,
    927924                        step: step,
    928                         slide: function(event, ui) {
    929                             tp_inst.control.value(tp_inst, $(this), unit, rtl? ui.value*-1:ui.value);
     925                        slide: function (event, ui) {
     926                            tp_inst.control.value(tp_inst, $(this), unit, rtl ? ui.value * -1 : ui.value);
    930927                            tp_inst._onTimeChange();
    931928                        },
    932                         stop: function(event, ui) {
     929                        stop: function (event, ui) {
    933930                            tp_inst._onSelectHandler();
    934931                        }
    935932                    });
    936933                },
    937                 options: function(tp_inst, obj, unit, opts, val){
    938                     if(tp_inst._defaults.isRTL){
    939                         if(typeof(opts) == 'string'){
    940                             if(opts == 'min' || opts == 'max'){
    941                                 if(val !== undefined){
    942                                     return obj.slider(opts, val*-1);
     934                options: function (tp_inst, obj, unit, opts, val) {
     935                    if (tp_inst._defaults.isRTL) {
     936                        if (typeof(opts) === 'string') {
     937                            if (opts === 'min' || opts === 'max') {
     938                                if (val !== undefined) {
     939                                    return obj.slider(opts, val * -1);
    943940                                }
    944941                                return Math.abs(obj.slider(opts));
     
    949946                            max = opts.max;
    950947                        opts.min = opts.max = null;
    951                         if(min !== undefined){
     948                        if (min !== undefined) {
    952949                            opts.max = min * -1;
    953950                        }
    954                         if(max !== undefined){
     951                        if (max !== undefined) {
    955952                            opts.min = max * -1;
    956953                        }
    957954                        return obj.slider(opts);
    958955                    }
    959                     if(typeof(opts) == 'string' && val !== undefined){
    960                             return obj.slider(opts, val);
     956                    if (typeof(opts) === 'string' && val !== undefined) {
     957                        return obj.slider(opts, val);
    961958                    }
    962959                    return obj.slider(opts);
    963960                },
    964                 value: function(tp_inst, obj, unit, val){
    965                     if(tp_inst._defaults.isRTL){
    966                         if(val !== undefined){
    967                             return obj.slider('value', val*-1);
     961                value: function (tp_inst, obj, unit, val) {
     962                    if (tp_inst._defaults.isRTL) {
     963                        if (val !== undefined) {
     964                            return obj.slider('value', val * -1);
    968965                        }
    969966                        return Math.abs(obj.slider('value'));
    970967                    }
    971                     if(val !== undefined){
     968                    if (val !== undefined) {
    972969                        return obj.slider('value', val);
    973970                    }
     
    977974            // select methods
    978975            select: {
    979                 create: function(tp_inst, obj, unit, val, min, max, step){
    980                     var sel = '<select class="ui-timepicker-select" data-unit="'+ unit +'" data-min="'+ min +'" data-max="'+ max +'" data-step="'+ step +'">',
     976                create: function (tp_inst, obj, unit, val, min, max, step) {
     977                    var sel = '<select class="ui-timepicker-select" data-unit="' + unit + '" data-min="' + min + '" data-max="' + max + '" data-step="' + step + '">',
    981978                        format = tp_inst._defaults.pickerTimeFormat || tp_inst._defaults.timeFormat;
    982979
    983                     for(var i=min; i<=max; i+=step){                       
    984                         sel += '<option value="'+ i +'"'+ (i==val? ' selected':'') +'>';
    985                         if(unit == 'hour'){
    986                             sel += $.datepicker.formatTime($.trim(format.replace(/[^ht ]/ig,'')), {hour:i}, tp_inst._defaults);
     980                    for (var i = min; i <= max; i += step) {
     981                        sel += '<option value="' + i + '"' + (i === val ? ' selected' : '') + '>';
     982                        if (unit === 'hour') {
     983                            sel += $.datepicker.formatTime($.trim(format.replace(/[^ht ]/ig, '')), {hour: i}, tp_inst._defaults);
    987984                        }
    988                         else if(unit == 'millisec' || unit == 'microsec' || i >= 10){ sel += i; }
    989                         else {sel += '0'+ i.toString(); }
     985                        else if (unit === 'millisec' || unit === 'microsec' || i >= 10) { sel += i; }
     986                        else {sel += '0' + i.toString(); }
    990987                        sel += '</option>';
    991988                    }
     
    994991                    obj.children('select').remove();
    995992
    996                     $(sel).appendTo(obj).change(function(e){
     993                    $(sel).appendTo(obj).change(function (e) {
    997994                        tp_inst._onTimeChange();
    998995                        tp_inst._onSelectHandler();
     
    1001998                    return obj;
    1002999                },
    1003                 options: function(tp_inst, obj, unit, opts, val){
     1000                options: function (tp_inst, obj, unit, opts, val) {
    10041001                    var o = {},
    10051002                        $t = obj.children('select');
    1006                     if(typeof(opts) == 'string'){
    1007                         if(val === undefined){
     1003                    if (typeof(opts) === 'string') {
     1004                        if (val === undefined) {
    10081005                            return $t.data(opts);
    10091006                        }
    10101007                        o[opts] = val; 
    10111008                    }
    1012                     else{ o = opts; }
     1009                    else { o = opts; }
    10131010                    return tp_inst.control.create(tp_inst, obj, $t.data('unit'), $t.val(), o.min || $t.data('min'), o.max || $t.data('max'), o.step || $t.data('step'));
    10141011                },
    1015                 value: function(tp_inst, obj, unit, val){
     1012                value: function (tp_inst, obj, unit, val) {
    10161013                    var $t = obj.children('select');
    1017                     if(val !== undefined){
     1014                    if (val !== undefined) {
    10181015                        return $t.val(val);
    10191016                    }
     
    10271024    $.fn.extend({
    10281025        /*
    1029         * shorthand just to use timepicker..
     1026        * shorthand just to use timepicker.
    10301027        */
    1031         timepicker: function(o) {
     1028        timepicker: function (o) {
    10321029            o = o || {};
    10331030            var tmp_args = Array.prototype.slice.call(arguments);
    10341031
    1035             if (typeof o == 'object') {
     1032            if (typeof o === 'object') {
    10361033                tmp_args[0] = $.extend(o, {
    10371034                    timeOnly: true
     
    10391036            }
    10401037
    1041             return $(this).each(function() {
     1038            return $(this).each(function () {
    10421039                $.fn.datetimepicker.apply($(this), tmp_args);
    10431040            });
     
    10471044        * extend timepicker to datepicker
    10481045        */
    1049         datetimepicker: function(o) {
     1046        datetimepicker: function (o) {
    10501047            o = o || {};
    10511048            var tmp_args = arguments;
    10521049
    1053             if (typeof(o) == 'string') {
    1054                 if (o == 'getDate') {
     1050            if (typeof(o) === 'string') {
     1051                if (o === 'getDate') {
    10551052                    return $.fn.datepicker.apply($(this[0]), tmp_args);
    10561053                } else {
    1057                     return this.each(function() {
     1054                    return this.each(function () {
    10581055                        var $t = $(this);
    10591056                        $t.datepicker.apply($t, tmp_args);
     
    10611058                }
    10621059            } else {
    1063                 return this.each(function() {
     1060                return this.each(function () {
    10641061                    var $t = $(this);
    10651062                    $t.datepicker($.timepicker._newInst($t, o)._defaults);
     
    10721069    * Public Utility to parse date and time
    10731070    */
    1074     $.datepicker.parseDateTime = function(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings) {
     1071    $.datepicker.parseDateTime = function (dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings) {
    10751072        var parseRes = parseDateTimeInternal(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings);
    10761073        if (parseRes.timeObj) {
    10771074            var t = parseRes.timeObj;
    10781075            parseRes.date.setHours(t.hour, t.minute, t.second, t.millisec);
    1079             parseRex.date.setMicroseconds(t.microsec);
     1076            parseRes.date.setMicroseconds(t.microsec);
    10801077        }
    10811078
     
    10861083    * Public utility to parse time
    10871084    */
    1088     $.datepicker.parseTime = function(timeFormat, timeString, options) {       
     1085    $.datepicker.parseTime = function (timeFormat, timeString, options) {
    10891086        var o = extendRemove(extendRemove({}, $.timepicker._defaults), options || {}),
    1090             iso8601 = (timeFormat.replace(/\'.*?\'/g,'').indexOf('Z') !== -1);
     1087            iso8601 = (timeFormat.replace(/\'.*?\'/g, '').indexOf('Z') !== -1);
    10911088
    10921089        // Strict parse requires the timeString to match the timeFormat exactly
    1093         var strictParse = function(f, s, o){
     1090        var strictParse = function (f, s, o) {
    10941091
    10951092            // pattern for standard and localized AM/PM markers
    1096             var getPatternAmpm = function(amNames, pmNames) {
     1093            var getPatternAmpm = function (amNames, pmNames) {
    10971094                var markers = [];
    10981095                if (amNames) {
     
    11021099                    $.merge(markers, pmNames);
    11031100                }
    1104                 markers = $.map(markers, function(val) {
     1101                markers = $.map(markers, function (val) {
    11051102                    return val.replace(/[.*+?|()\[\]{}\\]/g, '\\$&');
    11061103                });
     
    11091106
    11101107            // figure out position of time elements.. cause js cant do named captures
    1111             var getFormatPositions = function(timeFormat) {
     1108            var getFormatPositions = function (timeFormat) {
    11121109                var finds = timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|l{1}|c{1}|t{1,2}|z|'.*?')/g),
    11131110                    orders = {
     
    11231120                if (finds) {
    11241121                    for (var i = 0; i < finds.length; i++) {
    1125                         if (orders[finds[i].toString().charAt(0)] == -1) {
     1122                        if (orders[finds[i].toString().charAt(0)] === -1) {
    11261123                            orders[finds[i].toString().charAt(0)] = i + 1;
    11271124                        }
     
    11351132                            var ml = match.length;
    11361133                            switch (match.charAt(0).toLowerCase()) {
    1137                                 case 'h': return ml === 1? '(\\d?\\d)':'(\\d{'+ml+'})';
    1138                                 case 'm': return ml === 1? '(\\d?\\d)':'(\\d{'+ml+'})';
    1139                                 case 's': return ml === 1? '(\\d?\\d)':'(\\d{'+ml+'})';
    1140                                 case 'l': return '(\\d?\\d?\\d)';
    1141                                 case 'c': return '(\\d?\\d?\\d)';
    1142                                 case 'z': return '(z|[-+]\\d\\d:?\\d\\d|\\S+)?';
    1143                                 case 't': return getPatternAmpm(o.amNames, o.pmNames);
    1144                                 default:    // literal escaped in quotes
    1145                                     return '(' + match.replace(/\'/g, "").replace(/(\.|\$|\^|\\|\/|\(|\)|\[|\]|\?|\+|\*)/g, function (m) { return "\\" + m; }) + ')?';
     1134                            case 'h':
     1135                                return ml === 1 ? '(\\d?\\d)' : '(\\d{' + ml + '})';
     1136                            case 'm':
     1137                                return ml === 1 ? '(\\d?\\d)' : '(\\d{' + ml + '})';
     1138                            case 's':
     1139                                return ml === 1 ? '(\\d?\\d)' : '(\\d{' + ml + '})';
     1140                            case 'l':
     1141                                return '(\\d?\\d?\\d)';
     1142                            case 'c':
     1143                                return '(\\d?\\d?\\d)';
     1144                            case 'z':
     1145                                return '(z|[-+]\\d\\d:?\\d\\d|\\S+)?';
     1146                            case 't':
     1147                                return getPatternAmpm(o.amNames, o.pmNames);
     1148                            default:    // literal escaped in quotes
     1149                                return '(' + match.replace(/\'/g, "").replace(/(\.|\$|\^|\\|\/|\(|\)|\[|\]|\?|\+|\*)/g, function (m) { return "\\" + m; }) + ')?';
    11461150                            }
    11471151                        })
     
    11691173                    } else {
    11701174                        ampm = $.inArray(treg[order.t].toUpperCase(), o.amNames) !== -1 ? 'AM' : 'PM';
    1171                         resTime.ampm = o[ampm == 'AM' ? 'amNames' : 'pmNames'][0];
     1175                        resTime.ampm = o[ampm === 'AM' ? 'amNames' : 'pmNames'][0];
    11721176                    }
    11731177                }
    11741178
    11751179                if (order.h !== -1) {
    1176                     if (ampm == 'AM' && treg[order.h] == '12') {
     1180                    if (ampm === 'AM' && treg[order.h] === '12') {
    11771181                        resTime.hour = 0; // 12am = 0 hour
    11781182                    } else {
    1179                         if (ampm == 'PM' && treg[order.h] != '12') {
     1183                        if (ampm === 'PM' && treg[order.h] !== '12') {
    11801184                            resTime.hour = parseInt(treg[order.h], 10) + 12; // 12pm = 12 hour, any other pm = hour + 12
    11811185                        } else {
     
    12081212
    12091213        // First try JS Date, if that fails, use strictParse
    1210         var looseParse = function(f,s,o){
    1211             try{
    1212                 var d = new Date('2012-01-01 '+ s);
    1213                 if(isNaN(d.getTime())){
    1214                     d = new Date('2012-01-01T'+ s);
    1215                     if(isNaN(d.getTime())){
    1216                         d = new Date('01/01/2012 '+ s);
    1217                         if(isNaN(d.getTime())){
    1218                             throw "Unable to parse time with native Date: "+ s;
     1214        var looseParse = function (f, s, o) {
     1215            try {
     1216                var d = new Date('2012-01-01 ' + s);
     1217                if (isNaN(d.getTime())) {
     1218                    d = new Date('2012-01-01T' + s);
     1219                    if (isNaN(d.getTime())) {
     1220                        d = new Date('01/01/2012 ' + s);
     1221                        if (isNaN(d.getTime())) {
     1222                            throw "Unable to parse time with native Date: " + s;
    12191223                        }
    12201224                    }
     
    12271231                    millisec: d.getMilliseconds(),
    12281232                    microsec: d.getMicroseconds(),
    1229                     timezone: d.getTimezoneOffset()*-1
     1233                    timezone: d.getTimezoneOffset() * -1
    12301234                };
    12311235            }
    1232             catch(err){
    1233                 try{
    1234                     return strictParse(f,s,o);
    1235                 }
    1236                 catch(err2){
    1237                     $.timepicker.log("Unable to parse \ntimeString: "+ s +"\ntimeFormat: "+ f);
     1236            catch (err) {
     1237                try {
     1238                    return strictParse(f, s, o);
     1239                }
     1240                catch (err2) {
     1241                    $.timepicker.log("Unable to parse \ntimeString: " + s + "\ntimeFormat: " + f);
    12381242                }               
    12391243            }
     
    12411245        }; // end looseParse
    12421246       
    1243         if(typeof o.parse === "function"){
     1247        if (typeof o.parse === "function") {
    12441248            return o.parse(timeFormat, timeString, o);
    12451249        }
    1246         if(o.parse === 'loose'){
     1250        if (o.parse === 'loose') {
    12471251            return looseParse(timeFormat, timeString, o);
    12481252        }
     
    12501254    };
    12511255
    1252     /*
    1253     * Public utility to format the time
    1254     * format = string format of the time
    1255     * time = a {}, not a Date() for timezones
    1256     * options = essentially the regional[].. amNames, pmNames, ampm
    1257     */
    1258     $.datepicker.formatTime = function(format, time, options) {
     1256    /**
     1257     * Public utility to format the time
     1258     * @param {string} format format of the time
     1259     * @param {Object} time Object not a Date for timezones
     1260     * @param {Object} [options] essentially the regional[].. amNames, pmNames, ampm
     1261     * @returns {string} the formatted time
     1262     */
     1263    $.datepicker.formatTime = function (format, time, options) {
    12591264        options = options || {};
    12601265        options = $.extend({}, $.timepicker._defaults, options);
     
    12641269            second: 0,
    12651270            millisec: 0,
    1266             timezone: 0
     1271            microsec: 0,
     1272            timezone: null
    12671273        }, time);
    12681274
     
    12751281        }
    12761282
    1277         tmptime = tmptime.replace(/(?:HH?|hh?|mm?|ss?|[tT]{1,2}|[zZ]|[lc]|('.*?'|".*?"))/g, function(match) {
    1278         switch (match) {
     1283        tmptime = tmptime.replace(/(?:HH?|hh?|mm?|ss?|[tT]{1,2}|[zZ]|[lc]|'.*?')/g, function (match) {
     1284            switch (match) {
    12791285            case 'HH':
    12801286                return ('0' + hour).slice(-2);
     
    12981304                return ('00' + time.microsec).slice(-3);
    12991305            case 'z':
    1300                 return $.timepicker.timezoneOffsetString(time.timezone === null? options.timezone : time.timezone, false);
     1306                return $.timepicker.timezoneOffsetString(time.timezone === null ? options.timezone : time.timezone, false);
    13011307            case 'Z':
    1302                 return $.timepicker.timezoneOffsetString(time.timezone === null? options.timezone : time.timezone, true);
    1303             case 'T': 
     1308                return $.timepicker.timezoneOffsetString(time.timezone === null ? options.timezone : time.timezone, true);
     1309            case 'T':
    13041310                return ampmName.charAt(0).toUpperCase();
    1305             case 'TT': 
     1311            case 'TT':
    13061312                return ampmName.toUpperCase();
    13071313            case 't':
     
    13101316                return ampmName.toLowerCase();
    13111317            default:
    1312                 return match.replace(/\'/g, "") || "'";
     1318                return match.replace(/'/g, "");
    13131319            }
    13141320        });
    13151321
    1316         tmptime = $.trim(tmptime);
    13171322        return tmptime;
    13181323    };
    13191324
    13201325    /*
    1321     * the bad hack :/ override datepicker so it doesnt close on select
     1326    * the bad hack :/ override datepicker so it doesn't close on select
    13221327    // inspired: http://stackoverflow.com/questions/1252512/jquery-datepicker-prevent-closing-picker-when-clicking-a-date/1762378#1762378
    13231328    */
    13241329    $.datepicker._base_selectDate = $.datepicker._selectDate;
    1325     $.datepicker._selectDate = function(id, dateStr) {
     1330    $.datepicker._selectDate = function (id, dateStr) {
    13261331        var inst = this._getInst($(id)[0]),
    13271332            tp_inst = this._get(inst, 'timepicker');
     
    13451350    */
    13461351    $.datepicker._base_updateDatepicker = $.datepicker._updateDatepicker;
    1347     $.datepicker._updateDatepicker = function(inst) {
     1352    $.datepicker._updateDatepicker = function (inst) {
    13481353
    13491354        // don't popup the datepicker if there is another instance already opened
    13501355        var input = inst.input[0];
    1351         if ($.datepicker._curInst && $.datepicker._curInst != inst && $.datepicker._datepickerShowing && $.datepicker._lastInput != input) {
     1356        if ($.datepicker._curInst && $.datepicker._curInst !== inst && $.datepicker._datepickerShowing && $.datepicker._lastInput !== input) {
    13521357            return;
    13531358        }
     
    13691374    */
    13701375    $.datepicker._base_doKeyPress = $.datepicker._doKeyPress;
    1371     $.datepicker._doKeyPress = function(event) {
     1376    $.datepicker._doKeyPress = function (event) {
    13721377        var inst = $.datepicker._getInst(event.target),
    13731378            tp_inst = $.datepicker._get(inst, 'timepicker');
     
    13761381            if ($.datepicker._get(inst, 'constrainInput')) {
    13771382                var ampm = tp_inst.support.ampm,
    1378                     tz = tp_inst._defaults.showTimezone !== null? tp_inst._defaults.showTimezone : tp_inst.support.timezone,                   
     1383                    tz = tp_inst._defaults.showTimezone !== null ? tp_inst._defaults.showTimezone : tp_inst.support.timezone,
    13791384                    dateChars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')),
    13801385                    datetimeChars = tp_inst._defaults.timeFormat.toString()
     
    14011406    /*
    14021407    * Fourth bad hack :/ override _updateAlternate function used in inline mode to init altField
     1408    * Update any alternate field to synchronise with the main field.
    14031409    */
    14041410    $.datepicker._base_updateAlternate = $.datepicker._updateAlternate;
    1405     /* Update any alternate field to synchronise with the main field. */
    1406     $.datepicker._updateAlternate = function(inst) {
     1411    $.datepicker._updateAlternate = function (inst) {
    14071412        var tp_inst = this._get(inst, 'timepicker');
    1408         if(tp_inst){
     1413        if (tp_inst) {
    14091414            var altField = tp_inst._defaults.altField;
    14101415            if (altField) { // update alternate field too
     
    14181423               
    14191424                altFormattedDateTime += $.datepicker.formatTime(altTimeFormat, tp_inst, tp_inst._defaults) + altTimeSuffix;
    1420                 if(!tp_inst._defaults.timeOnly && !tp_inst._defaults.altFieldTimeOnly && date !== null){
    1421                     if(tp_inst._defaults.altFormat){
     1425                if (!tp_inst._defaults.timeOnly && !tp_inst._defaults.altFieldTimeOnly && date !== null) {
     1426                    if (tp_inst._defaults.altFormat) {
    14221427                        altFormattedDateTime = $.datepicker.formatDate(tp_inst._defaults.altFormat, date, formatCfg) + altSeparator + altFormattedDateTime;
    14231428                    }
    1424                     else{
     1429                    else {
    14251430                        altFormattedDateTime = tp_inst.formattedDate + altSeparator + altFormattedDateTime;
    14261431                    }
     
    14291434            }
    14301435        }
    1431         else{
     1436        else {
    14321437            $.datepicker._base_updateAlternate(inst);
    14331438        }
     
    14381443    */
    14391444    $.datepicker._base_doKeyUp = $.datepicker._doKeyUp;
    1440     $.datepicker._doKeyUp = function(event) {
     1445    $.datepicker._doKeyUp = function (event) {
    14411446        var inst = $.datepicker._getInst(event.target),
    14421447            tp_inst = $.datepicker._get(inst, 'timepicker');
    14431448
    14441449        if (tp_inst) {
    1445             if (tp_inst._defaults.timeOnly && (inst.input.val() != inst.lastVal)) {
     1450            if (tp_inst._defaults.timeOnly && (inst.input.val() !== inst.lastVal)) {
    14461451                try {
    14471452                    $.datepicker._updateDatepicker(inst);
     
    14591464    */
    14601465    $.datepicker._base_gotoToday = $.datepicker._gotoToday;
    1461     $.datepicker._gotoToday = function(id) {
     1466    $.datepicker._gotoToday = function (id) {
    14621467        var inst = this._getInst($(id)[0]),
    14631468            $dp = inst.dpDiv;
     
    14731478    * Disable & enable the Time in the datetimepicker
    14741479    */
    1475     $.datepicker._disableTimepickerDatepicker = function(target) {
     1480    $.datepicker._disableTimepickerDatepicker = function (target) {
    14761481        var inst = this._getInst(target);
    14771482        if (!inst) {
     
    14821487        $(target).datepicker('getDate'); // Init selected[Year|Month|Day]
    14831488        if (tp_inst) {
     1489            inst.settings.showTimepicker = false;
    14841490            tp_inst._defaults.showTimepicker = false;
    14851491            tp_inst._updateDateTime(inst);
     
    14871493    };
    14881494
    1489     $.datepicker._enableTimepickerDatepicker = function(target) {
     1495    $.datepicker._enableTimepickerDatepicker = function (target) {
    14901496        var inst = this._getInst(target);
    14911497        if (!inst) {
     
    14961502        $(target).datepicker('getDate'); // Init selected[Year|Month|Day]
    14971503        if (tp_inst) {
     1504            inst.settings.showTimepicker = true;
    14981505            tp_inst._defaults.showTimepicker = true;
    14991506            tp_inst._addTimePicker(inst); // Could be disabled on page load
     
    15051512    * Create our own set time function
    15061513    */
    1507     $.datepicker._setTime = function(inst, date) {
     1514    $.datepicker._setTime = function (inst, date) {
    15081515        var tp_inst = this._get(inst, 'timepicker');
    15091516        if (tp_inst) {
     
    15281535    * Create new public method to set only time, callable as $().datepicker('setTime', date)
    15291536    */
    1530     $.datepicker._setTimeDatepicker = function(target, date, withDate) {
     1537    $.datepicker._setTimeDatepicker = function (target, date, withDate) {
    15311538        var inst = this._getInst(target);
    15321539        if (!inst) {
     
    15401547            var tp_date;
    15411548            if (date) {
    1542                 if (typeof date == "string") {
     1549                if (typeof date === "string") {
    15431550                    tp_inst._parseTime(date, withDate);
    15441551                    tp_date = new Date();
     
    15471554                } else {
    15481555                    tp_date = new Date(date.getTime());
    1549                 }
    1550                 if (tp_date.toString() == 'Invalid Date') {
     1556                    tp_date.setMicroseconds(date.getMicroseconds());
     1557                }
     1558                if (tp_date.toString() === 'Invalid Date') {
    15511559                    tp_date = undefined;
    15521560                }
     
    15611569    */
    15621570    $.datepicker._base_setDateDatepicker = $.datepicker._setDateDatepicker;
    1563     $.datepicker._setDateDatepicker = function(target, date) {
     1571    $.datepicker._setDateDatepicker = function (target, date) {
    15641572        var inst = this._getInst(target);
    15651573        if (!inst) {
     
    15671575        }
    15681576
    1569         var tp_inst = this._get(inst, 'timepicker'),
    1570             tp_date = (date instanceof Date) ? new Date(date.getTime()) : date;
     1577        if (typeof(date) === 'string') {
     1578            date = new Date(date);
     1579            if (!date.getTime()) {
     1580                $.timepicker.log("Error creating Date object from string.");
     1581            }
     1582        }
     1583
     1584        var tp_inst = this._get(inst, 'timepicker');
     1585        var tp_date;
     1586        if (date instanceof Date) {
     1587            tp_date = new Date(date.getTime());
     1588            tp_date.setMicroseconds(date.getMicroseconds());
     1589        } else {
     1590            tp_date = date;
     1591        }
    15711592       
    15721593        // This is important if you are using the timezone option, javascript's Date
     
    15741595        // adjust it accordingly.  If not using timezone option this won't matter..
    15751596        // If a timezone is different in tp, keep the timezone as is
    1576         if(tp_inst && tp_inst.timezone != null){
     1597        if (tp_inst) {
     1598            // look out for DST if tz wasn't specified
     1599            if (!tp_inst.support.timezone && tp_inst._defaults.timezone === null) {
     1600                tp_inst.timezone = tp_date.getTimezoneOffset() * -1;
     1601            }
    15771602            date = $.timepicker.timezoneAdjust(date, tp_inst.timezone);
    15781603            tp_date = $.timepicker.timezoneAdjust(tp_date, tp_inst.timezone);
     
    15881613    */
    15891614    $.datepicker._base_getDateDatepicker = $.datepicker._getDateDatepicker;
    1590     $.datepicker._getDateDatepicker = function(target, noDefault) {
     1615    $.datepicker._getDateDatepicker = function (target, noDefault) {
    15911616        var inst = this._getInst(target);
    15921617        if (!inst) {
     
    15981623        if (tp_inst) {
    15991624            // if it hasn't yet been defined, grab from field
    1600             if(inst.lastVal === undefined){
     1625            if (inst.lastVal === undefined) {
    16011626                this._setDateFromField(inst, noDefault);
    16021627            }
     
    16101635                // object will only return the timezone offset for the current locale, so we
    16111636                // adjust it accordingly.  If not using timezone option this won't matter..
    1612                 if(tp_inst.timezone != null){
     1637                if (tp_inst.timezone != null) {
     1638                    // look out for DST if tz wasn't specified
     1639                    if (!tp_inst.support.timezone && tp_inst._defaults.timezone === null) {
     1640                        tp_inst.timezone = date.getTimezoneOffset() * -1;
     1641                    }
    16131642                    date = $.timepicker.timezoneAdjust(date, tp_inst.timezone);
    16141643                }
     
    16241653    */
    16251654    $.datepicker._base_parseDate = $.datepicker.parseDate;
    1626     $.datepicker.parseDate = function(format, value, settings) {
     1655    $.datepicker.parseDate = function (format, value, settings) {
    16271656        var date;
    16281657        try {
     
    16331662            // attempting to perfectly reproduce the parsing algorithm.
    16341663            if (err.indexOf(":") >= 0) {
    1635                 date = this._base_parseDate(format, value.substring(0,value.length-(err.length-err.indexOf(':')-2)), settings);
     1664                date = this._base_parseDate(format, value.substring(0, value.length - (err.length - err.indexOf(':') - 2)), settings);
    16361665                $.timepicker.log("Error parsing the date string: " + err + "\ndate string = " + value + "\ndate format = " + format);
    16371666            } else {
     
    16461675    */
    16471676    $.datepicker._base_formatDate = $.datepicker._formatDate;
    1648     $.datepicker._formatDate = function(inst, day, month, year) {
     1677    $.datepicker._formatDate = function (inst, day, month, year) {
    16491678        var tp_inst = this._get(inst, 'timepicker');
    16501679        if (tp_inst) {
     
    16591688    */
    16601689    $.datepicker._base_optionDatepicker = $.datepicker._optionDatepicker;
    1661     $.datepicker._optionDatepicker = function(target, name, value) {
     1690    $.datepicker._optionDatepicker = function (target, name, value) {
    16621691        var inst = this._getInst(target),
    1663             name_clone;
     1692            name_clone;
    16641693        if (!inst) {
    16651694            return null;
     
    16741703                fns = {},
    16751704                prop;
    1676             if (typeof name == 'string') { // if min/max was set with the string
    1677                 if (name === 'minDate' || name === 'minDateTime') {
    1678                     min = value;
    1679                 } else if (name === 'maxDate' || name === 'maxDateTime') {
    1680                     max = value;
    1681                 } else if (name === 'onSelect') {
    1682                     onselect = value;
    1683                 } else if (overrides.hasOwnProperty(name)) {
    1684                     if (typeof (value) === 'undefined') {
    1685                         return overrides[name];
    1686                     }
    1687                     fns[name] = value;
    1688                     name_clone = {}; //empty results in exiting function after overrides updated
    1689                 }
    1690             } else if (typeof name == 'object') { //if min/max was set with the JSON
    1691                 if (name.minDate) {
    1692                     min = name.minDate;
    1693                 } else if (name.minDateTime) {
    1694                     min = name.minDateTime;
    1695                 } else if (name.maxDate) {
    1696                     max = name.maxDate;
    1697                 } else if (name.maxDateTime) {
    1698                     max = name.maxDateTime;
    1699                 }
    1700                 for (prop in overrides) {
    1701                     if (overrides.hasOwnProperty(prop) && name[prop]) {
    1702                         fns[prop] = name[prop];
    1703                     }
    1704                 }
    1705             }
    1706             for (prop in fns) {
    1707                 if (fns.hasOwnProperty(prop)) {
    1708                     overrides[prop] = fns[prop];
    1709                     if (!name_clone) { name_clone = $.extend({}, name);}
    1710                     delete name_clone[prop];
    1711                 }
    1712             }
    1713             if (name_clone && isEmptyObject(name_clone)) { return; }
    1714             if (min) { //if min was set
    1715                 if (min === 0) {
    1716                     min = new Date();
    1717                 } else {
    1718                     min = new Date(min);
    1719                 }
    1720                 tp_inst._defaults.minDate = min;
    1721                 tp_inst._defaults.minDateTime = min;
    1722             } else if (max) { //if max was set
    1723                 if (max === 0) {
    1724                     max = new Date();
    1725                 } else {
    1726                     max = new Date(max);
    1727                 }
    1728                 tp_inst._defaults.maxDate = max;
    1729                 tp_inst._defaults.maxDateTime = max;
    1730             } else if (onselect) {
    1731                 tp_inst._defaults.onSelect = onselect;
    1732             }
     1705            if (typeof name === 'string') { // if min/max was set with the string
     1706                if (name === 'minDate' || name === 'minDateTime') {
     1707                    min = value;
     1708                } else if (name === 'maxDate' || name === 'maxDateTime') {
     1709                    max = value;
     1710                } else if (name === 'onSelect') {
     1711                    onselect = value;
     1712                } else if (overrides.hasOwnProperty(name)) {
     1713                    if (typeof (value) === 'undefined') {
     1714                        return overrides[name];
     1715                    }
     1716                    fns[name] = value;
     1717                    name_clone = {}; //empty results in exiting function after overrides updated
     1718                }
     1719            } else if (typeof name === 'object') { //if min/max was set with the JSON
     1720                if (name.minDate) {
     1721                    min = name.minDate;
     1722                } else if (name.minDateTime) {
     1723                    min = name.minDateTime;
     1724                } else if (name.maxDate) {
     1725                    max = name.maxDate;
     1726                } else if (name.maxDateTime) {
     1727                    max = name.maxDateTime;
     1728                }
     1729                for (prop in overrides) {
     1730                    if (overrides.hasOwnProperty(prop) && name[prop]) {
     1731                        fns[prop] = name[prop];
     1732                    }
     1733                }
     1734            }
     1735            for (prop in fns) {
     1736                if (fns.hasOwnProperty(prop)) {
     1737                    overrides[prop] = fns[prop];
     1738                    if (!name_clone) { name_clone = $.extend({}, name); }
     1739                    delete name_clone[prop];
     1740                }
     1741            }
     1742            if (name_clone && isEmptyObject(name_clone)) { return; }
     1743            if (min) { //if min was set
     1744                if (min === 0) {
     1745                    min = new Date();
     1746                } else {
     1747                    min = new Date(min);
     1748                }
     1749                tp_inst._defaults.minDate = min;
     1750                tp_inst._defaults.minDateTime = min;
     1751            } else if (max) { //if max was set
     1752                if (max === 0) {
     1753                    max = new Date();
     1754                } else {
     1755                    max = new Date(max);
     1756                }
     1757                tp_inst._defaults.maxDate = max;
     1758                tp_inst._defaults.maxDateTime = max;
     1759            } else if (onselect) {
     1760                tp_inst._defaults.onSelect = onselect;
     1761            }
    17331762        }
    17341763        if (value === undefined) {
     
    17421771    * it will return false for all objects
    17431772    */
    1744     var isEmptyObject = function(obj) {
     1773    var isEmptyObject = function (obj) {
    17451774        var prop;
    17461775        for (prop in obj) {
    1747             if (obj.hasOwnProperty(obj)) {
     1776            if (obj.hasOwnProperty(prop)) {
    17481777                return false;
    17491778            }
     
    17551784    * jQuery extend now ignores nulls!
    17561785    */
    1757     var extendRemove = function(target, props) {
     1786    var extendRemove = function (target, props) {
    17581787        $.extend(target, props);
    17591788        for (var name in props) {
     
    17691798    * Returns an object of booleans for each unit
    17701799    */
    1771     var detectSupport = function(timeFormat){
    1772         var tf = timeFormat.replace(/\'.*?\'/g,'').toLowerCase(), // removes literals
    1773             isIn = function(f, t){ // does the format contain the token?
    1774                     return f.indexOf(t) !== -1? true:false;
     1800    var detectSupport = function (timeFormat) {
     1801        var tf = timeFormat.replace(/'.*?'/g, '').toLowerCase(), // removes literals
     1802            isIn = function (f, t) { // does the format contain the token?
     1803                    return f.indexOf(t) !== -1 ? true : false;
    17751804                };
    17761805        return {
    1777                 hour: isIn(tf,'h'),
    1778                 minute: isIn(tf,'m'),
    1779                 second: isIn(tf,'s'),
    1780                 millisec: isIn(tf,'l'),
    1781                 microsec: isIn(tf,'c'),
    1782                 timezone: isIn(tf,'z'),
    1783                 ampm: isIn('t') && isIn(timeFormat,'h'),
     1806                hour: isIn(tf, 'h'),
     1807                minute: isIn(tf, 'm'),
     1808                second: isIn(tf, 's'),
     1809                millisec: isIn(tf, 'l'),
     1810                microsec: isIn(tf, 'c'),
     1811                timezone: isIn(tf, 'z'),
     1812                ampm: isIn(tf, 't') && isIn(timeFormat, 'h'),
    17841813                iso8601: isIn(timeFormat, 'Z')
    17851814            };
     
    17901819    * Returns 12 hour without leading 0
    17911820    */
    1792     var convert24to12 = function(hour) {
    1793         if (hour > 12) {
    1794             hour = hour - 12;
    1795         }
     1821    var convert24to12 = function (hour) {
     1822        hour %= 12;
    17961823
    17971824        if (hour === 0) {
     
    18021829    };
    18031830
    1804     /*
    1805     * Splits datetime string into date ans time substrings.
     1831    var computeEffectiveSetting = function (settings, property) {
     1832        return settings && settings[property] ? settings[property] : $.timepicker._defaults[property];
     1833    };
     1834
     1835    /*
     1836    * Splits datetime string into date and time substrings.
    18061837    * Throws exception when date can't be parsed
    1807     * Returns [dateString, timeString]
    1808     */
    1809     var splitDateTime = function(dateFormat, dateTimeString, dateSettings, timeSettings) {
    1810         try {
    1811             // The idea is to get the number separator occurances in datetime and the time format requested (since time has
    1812             // fewer unknowns, mostly numbers and am/pm). We will use the time pattern to split.
    1813             var separator = timeSettings && timeSettings.separator ? timeSettings.separator : $.timepicker._defaults.separator,
    1814                 format = timeSettings && timeSettings.timeFormat ? timeSettings.timeFormat : $.timepicker._defaults.timeFormat,
    1815                 timeParts = format.split(separator), // how many occurances of separator may be in our format?
    1816                 timePartsLen = timeParts.length,
    1817                 allParts = dateTimeString.split(separator),
    1818                 allPartsLen = allParts.length;
    1819 
    1820             if (allPartsLen > 1) {
    1821                 return [
    1822                         allParts.splice(0,allPartsLen-timePartsLen).join(separator),
    1823                         allParts.splice(0,timePartsLen).join(separator)
    1824                     ];
    1825             }
    1826 
    1827         } catch (err) {
    1828             $.timepicker.log('Could not split the date from the time. Please check the following datetimepicker options' +
    1829                     "\nthrown error: " + err +
    1830                     "\ndateTimeString" + dateTimeString +
    1831                     "\ndateFormat = " + dateFormat +
    1832                     "\nseparator = " + timeSettings.separator +
    1833                     "\ntimeFormat = " + timeSettings.timeFormat);
    1834 
    1835             if (err.indexOf(":") >= 0) {
    1836                 // Hack!  The error message ends with a colon, a space, and
    1837                 // the "extra" characters.  We rely on that instead of
    1838                 // attempting to perfectly reproduce the parsing algorithm.
    1839                 var dateStringLength = dateTimeString.length - (err.length - err.indexOf(':') - 2),
    1840                     timeString = dateTimeString.substring(dateStringLength);
    1841 
    1842                 return [$.trim(dateTimeString.substring(0, dateStringLength)), $.trim(dateTimeString.substring(dateStringLength))];
    1843 
    1844             } else {
    1845                 throw err;
    1846             }
    1847         }
    1848         return [dateTimeString, ''];
     1838    * Returns {dateString: dateString, timeString: timeString}
     1839    */
     1840    var splitDateTime = function (dateTimeString, timeSettings) {
     1841        // The idea is to get the number separator occurrences in datetime and the time format requested (since time has
     1842        // fewer unknowns, mostly numbers and am/pm). We will use the time pattern to split.
     1843        var separator = computeEffectiveSetting(timeSettings, 'separator'),
     1844            format = computeEffectiveSetting(timeSettings, 'timeFormat'),
     1845            timeParts = format.split(separator), // how many occurrences of separator may be in our format?
     1846            timePartsLen = timeParts.length,
     1847            allParts = dateTimeString.split(separator),
     1848            allPartsLen = allParts.length;
     1849
     1850        if (allPartsLen > 1) {
     1851            return {
     1852                dateString: allParts.splice(0, allPartsLen - timePartsLen).join(separator),
     1853                timeString: allParts.splice(0, timePartsLen).join(separator)
     1854            };
     1855        }
     1856
     1857        return {
     1858            dateString: dateTimeString,
     1859            timeString: ''
     1860        };
    18491861    };
    18501862
     
    18551867    *   timeObj = {hour: , minute: , second: , millisec: , microsec: } - parsed time. Optional
    18561868    */
    1857     var parseDateTimeInternal = function(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings) {
    1858         var date;
    1859         var splitRes = splitDateTime(dateFormat, dateTimeString, dateSettings, timeSettings);
    1860         date = $.datepicker._base_parseDate(dateFormat, splitRes[0], dateSettings);
    1861         if (splitRes[1] !== '') {
    1862             var timeString = splitRes[1],
    1863                 parsedTime = $.datepicker.parseTime(timeFormat, timeString, timeSettings);
    1864 
    1865             if (parsedTime === null) {
    1866                 throw 'Wrong time format';
    1867             }
    1868             return {
    1869                 date: date,
    1870                 timeObj: parsedTime
    1871             };
    1872         } else {
     1869    var parseDateTimeInternal = function (dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings) {
     1870        var date,
     1871            parts,
     1872            parsedTime;
     1873
     1874        parts = splitDateTime(dateTimeString, timeSettings);
     1875        date = $.datepicker._base_parseDate(dateFormat, parts.dateString, dateSettings);
     1876
     1877        if (parts.timeString === '') {
    18731878            return {
    18741879                date: date
    18751880            };
    18761881        }
     1882
     1883        parsedTime = $.datepicker.parseTime(timeFormat, parts.timeString, timeSettings);
     1884
     1885        if (!parsedTime) {
     1886            throw 'Wrong time format';
     1887        }
     1888
     1889        return {
     1890            date: date,
     1891            timeObj: parsedTime
     1892        };
    18771893    };
    18781894
     
    18801896    * Internal function to set timezone_select to the local timezone
    18811897    */
    1882     var selectLocalTimezone = function(tp_inst, date) {
     1898    var selectLocalTimezone = function (tp_inst, date) {
    18831899        if (tp_inst && tp_inst.timezone_select) {
    1884             var now = typeof date !== 'undefined' ? date : new Date();
    1885             tp_inst.timezone_select.val(now.getTimezoneOffset()*-1);
    1886         }
    1887     };
    1888 
    1889     /*
    1890     * Create a Singleton Insance
     1900            var now = date || new Date();
     1901            tp_inst.timezone_select.val(-now.getTimezoneOffset());
     1902        }
     1903    };
     1904
     1905    /*
     1906    * Create a Singleton Instance
    18911907    */
    18921908    $.timepicker = new Timepicker();
     
    18941910    /**
    18951911     * Get the timezone offset as string from a date object (eg '+0530' for UTC+5.5)
    1896      * @param  number if not a number this value is returned
    1897      * @param boolean if true formats in accordance to iso8601 "+12:45"
    1898      * @return string
     1912     * @param {number} tzMinutes if not a number, less than -720 (-1200), or greater than 840 (+1400) this value is returned
     1913     * @param {boolean} iso8601 if true formats in accordance to iso8601 "+12:45"
     1914     * @return {string}
    18991915     */
    1900     $.timepicker.timezoneOffsetString = function(tzMinutes, iso8601) {
    1901         if(isNaN(tzMinutes) || tzMinutes > 840){
     1916    $.timepicker.timezoneOffsetString = function (tzMinutes, iso8601) {
     1917        if (isNaN(tzMinutes) || tzMinutes > 840 || tzMinutes < -720) {
    19021918            return tzMinutes;
    19031919        }
     
    19061922            minutes = off % 60,
    19071923            hours = (off - minutes) / 60,
    1908             iso = iso8601? ':':'',
    1909             tz = (off >= 0 ? '+' : '-') + ('0' + (hours * 101).toString()).slice(-2) + iso + ('0' + (minutes * 101).toString()).slice(-2);
     1924            iso = iso8601 ? ':' : '',
     1925            tz = (off >= 0 ? '+' : '-') + ('0' + Math.abs(hours)).slice(-2) + iso + ('0' + Math.abs(minutes)).slice(-2);
    19101926       
    1911         if(tz == '+00:00'){
     1927        if (tz === '+00:00') {
    19121928            return 'Z';
    19131929        }
     
    19171933    /**
    19181934     * Get the number in minutes that represents a timezone string
    1919      * @param  string formated like "+0500", "-1245"
    1920      * @return number
     1935     * @param  {string} tzString formatted like "+0500", "-1245", "Z"
     1936     * @return {number} the offset minutes or the original string if it doesn't match expectations
    19211937     */
    1922     $.timepicker.timezoneOffsetNumber = function(tzString) {
    1923         tzString = tzString.toString().replace(':',''); // excuse any iso8601, end up with "+1245"
    1924 
    1925         if(tzString.toUpperCase() === 'Z'){ // if iso8601 with Z, its 0 minute offset
     1938    $.timepicker.timezoneOffsetNumber = function (tzString) {
     1939        var normalized = tzString.toString().replace(':', ''); // excuse any iso8601, end up with "+1245"
     1940
     1941        if (normalized.toUpperCase() === 'Z') { // if iso8601 with Z, its 0 minute offset
    19261942            return 0;
    19271943        }
    19281944
    1929         if(!/^(\-|\+)\d{4}$/.test(tzString)){ // possibly a user defined tz, so just give it back
     1945        if (!/^(\-|\+)\d{4}$/.test(normalized)) { // possibly a user defined tz, so just give it back
    19301946            return tzString;
    19311947        }
    19321948
    1933         return ((tzString.substr(0,1) =='-'? -1 : 1) * // plus or minus
    1934                     ((parseInt(tzString.substr(1,2),10)*60) + // hours (converted to minutes)
    1935                     parseInt(tzString.substr(3,2),10))); // minutes
     1949        return ((normalized.substr(0, 1) === '-' ? -1 : 1) * // plus or minus
     1950                    ((parseInt(normalized.substr(1, 2), 10) * 60) + // hours (converted to minutes)
     1951                    parseInt(normalized.substr(3, 2), 10))); // minutes
    19361952    };
    19371953
    19381954    /**
    19391955     * No way to set timezone in js Date, so we must adjust the minutes to compensate. (think setDate, getDate)
    1940      * @param  date
    1941      * @param  string formated like "+0500", "-1245"
    1942      * @return date
     1956     * @param  {Date} date
     1957     * @param  {string} toTimezone formatted like "+0500", "-1245"
     1958     * @return {Date}
    19431959     */
    1944     $.timepicker.timezoneAdjust = function(date, toTimezone) {
     1960    $.timepicker.timezoneAdjust = function (date, toTimezone) {
    19451961        var toTz = $.timepicker.timezoneOffsetNumber(toTimezone);
    1946         if(!isNaN(toTz)){
    1947             var currTz = date.getTimezoneOffset()*-1,
    1948                 diff = currTz - toTz; // difference in minutes
    1949 
    1950             date.setMinutes(date.getMinutes()+diff);
     1962        if (!isNaN(toTz)) {
     1963            date.setMinutes(date.getMinutes() + -date.getTimezoneOffset() - toTz);
    19511964        }
    19521965        return date;
     
    19571970     * enforce date range limits.
    19581971     * n.b. The input value must be correctly formatted (reformatting is not supported)
    1959      * @param  Element startTime
    1960      * @param  Element endTime
    1961      * @param  obj options Options for the timepicker() call
    1962      * @return jQuery
     1972     * @param  {Element} startTime
     1973     * @param  {Element} endTime
     1974     * @param  {Object} options Options for the timepicker() call
     1975     * @return {jQuery}
    19631976     */
    1964     $.timepicker.timeRange = function(startTime, endTime, options) {
     1977    $.timepicker.timeRange = function (startTime, endTime, options) {
    19651978        return $.timepicker.handleRange('timepicker', startTime, endTime, options);
    19661979    };
     
    19691982     * Calls `datetimepicker` on the `startTime` and `endTime` elements, and configures them to
    19701983     * enforce date range limits.
    1971      * @param  Element startTime
    1972      * @param  Element endTime
    1973      * @param  obj options Options for the `timepicker()` call. Also supports `reformat`,
     1984     * @param  {Element} startTime
     1985     * @param  {Element} endTime
     1986     * @param  {Object} options Options for the `timepicker()` call. Also supports `reformat`,
    19741987     *   a boolean value that can be used to reformat the input values to the `dateFormat`.
    1975      * @param  string method Can be used to specify the type of picker to be added
    1976      * @return jQuery
     1988     * @param  {string} method Can be used to specify the type of picker to be added
     1989     * @return {jQuery}
    19771990     */
    1978     $.timepicker.datetimeRange = function(startTime, endTime, options) {
     1991    $.timepicker.datetimeRange = function (startTime, endTime, options) {
    19791992        $.timepicker.handleRange('datetimepicker', startTime, endTime, options);
     1993    };
     1994
     1995    /**
     1996     * Calls `datepicker` on the `startTime` and `endTime` elements, and configures them to
     1997     * enforce date range limits.
     1998     * @param  {Element} startTime
     1999     * @param  {Element} endTime
     2000     * @param  {Object} options Options for the `timepicker()` call. Also supports `reformat`,
     2001     *   a boolean value that can be used to reformat the input values to the `dateFormat`.
     2002     * @return {jQuery}
     2003     */
     2004    $.timepicker.dateRange = function (startTime, endTime, options) {
     2005        $.timepicker.handleRange('datepicker', startTime, endTime, options);
    19802006    };
    19812007
     
    19832009     * Calls `method` on the `startTime` and `endTime` elements, and configures them to
    19842010     * enforce date range limits.
    1985      * @param  Element startTime
    1986      * @param  Element endTime
    1987      * @param  obj options Options for the `timepicker()` call. Also supports `reformat`,
     2011     * @param  {string} method Can be used to specify the type of picker to be added
     2012     * @param  {Element} startTime
     2013     * @param  {Element} endTime
     2014     * @param  {Object} options Options for the `timepicker()` call. Also supports `reformat`,
    19882015     *   a boolean value that can be used to reformat the input values to the `dateFormat`.
    1989      * @return jQuery
     2016     * @return {jQuery}
    19902017     */
    1991     $.timepicker.dateRange = function(startTime, endTime, options) {
    1992         $.timepicker.handleRange('datepicker', startTime, endTime, options);
    1993     };
    1994 
    1995     /**
    1996      * Calls `method` on the `startTime` and `endTime` elements, and configures them to
    1997      * enforce date range limits.
    1998      * @param  string method Can be used to specify the type of picker to be added
    1999      * @param  Element startTime
    2000      * @param  Element endTime
    2001      * @param  obj options Options for the `timepicker()` call. Also supports `reformat`,
    2002      *   a boolean value that can be used to reformat the input values to the `dateFormat`.
    2003      * @return jQuery
    2004      */
    2005     $.timepicker.handleRange = function(method, startTime, endTime, options) {
     2018    $.timepicker.handleRange = function (method, startTime, endTime, options) {
    20062019        options = $.extend({}, {
    20072020            minInterval: 0, // min allowed interval in milliseconds
     
    20112024        }, options);
    20122025
    2013         $.fn[method].call(startTime, $.extend({
    2014             onClose: function(dateText, inst) {
    2015                 checkDates($(this), endTime);
    2016             },
    2017             onSelect: function(selectedDateTime) {
    2018                 selected($(this), endTime, 'minDate');
    2019             }
    2020         }, options, options.start));
    2021         $.fn[method].call(endTime, $.extend({
    2022             onClose: function(dateText, inst) {
    2023                 checkDates($(this), startTime);
    2024             },
    2025             onSelect: function(selectedDateTime) {
    2026                 selected($(this), startTime, 'maxDate');
    2027             }
    2028         }, options, options.end));
    2029 
    2030         checkDates(startTime, endTime);
    2031         selected(startTime, endTime, 'minDate');
    2032         selected(endTime, startTime, 'maxDate');
    2033 
    20342026        function checkDates(changed, other) {
    20352027            var startdt = startTime[method]('getDate'),
     
    20372029                changeddt = changed[method]('getDate');
    20382030
    2039             if(startdt !== null){
     2031            if (startdt !== null) {
    20402032                var minDate = new Date(startdt.getTime()),
    20412033                    maxDate = new Date(startdt.getTime());
     
    20442036                maxDate.setMilliseconds(maxDate.getMilliseconds() + options.maxInterval);
    20452037
    2046                 if(options.minInterval > 0 && minDate > enddt){ // minInterval check
    2047                     endTime[method]('setDate',minDate);
    2048                 }
    2049                 else if(options.maxInterval > 0 && maxDate < enddt){ // max interval check
    2050                     endTime[method]('setDate',maxDate);
     2038                if (options.minInterval > 0 && minDate > enddt) { // minInterval check
     2039                    endTime[method]('setDate', minDate);
     2040                }
     2041                else if (options.maxInterval > 0 && maxDate < enddt) { // max interval check
     2042                    endTime[method]('setDate', maxDate);
    20512043                }
    20522044                else if (startdt > enddt) {
    2053                     other[method]('setDate',changeddt);
     2045                    other[method]('setDate', changeddt);
    20542046                }
    20552047            }
     
    20612053            }
    20622054            var date = changed[method].call(changed, 'getDate');
    2063             if(date !== null && options.minInterval > 0){
    2064                 if(option == 'minDate'){
    2065                     date.setMilliseconds(date.getMilliseconds() + options.minInterval); 
    2066                 }
    2067                 if(option == 'maxDate'){
     2055            if (date !== null && options.minInterval > 0) {
     2056                if (option === 'minDate') {
     2057                    date.setMilliseconds(date.getMilliseconds() + options.minInterval);
     2058                }
     2059                if (option === 'maxDate') {
    20682060                    date.setMilliseconds(date.getMilliseconds() - options.minInterval);
    20692061                }
     
    20732065            }
    20742066        }
     2067
     2068        $.fn[method].call(startTime, $.extend({
     2069            onClose: function (dateText, inst) {
     2070                checkDates($(this), endTime);
     2071            },
     2072            onSelect: function (selectedDateTime) {
     2073                selected($(this), endTime, 'minDate');
     2074            }
     2075        }, options, options.start));
     2076        $.fn[method].call(endTime, $.extend({
     2077            onClose: function (dateText, inst) {
     2078                checkDates($(this), startTime);
     2079            },
     2080            onSelect: function (selectedDateTime) {
     2081                selected($(this), startTime, 'maxDate');
     2082            }
     2083        }, options, options.end));
     2084
     2085        checkDates(startTime, endTime);
     2086        selected(startTime, endTime, 'minDate');
     2087        selected(endTime, startTime, 'maxDate');
    20752088        return $([startTime.get(0), endTime.get(0)]);
    20762089    };
     
    20782091    /**
    20792092     * Log error or data to the console during error or debugging
    2080      * @param  Object err pass any type object to log to the console during error or debugging
    2081      * @return void
     2093     * @param  {Object} err pass any type object to log to the console during error or debugging
     2094     * @return {void}
    20822095     */
    2083     $.timepicker.log = function(err){
    2084         if(window.console){
    2085             console.log(err);
    2086         }
    2087     };
    2088 
    2089     /*
    2090     * Rough microsecond support
    2091     */
    2092     if(!Date.prototype.getMicroseconds){
    2093         Date.microseconds = 0;
    2094         Date.prototype.getMicroseconds = function(){ return this.microseconds; };
    2095         Date.prototype.setMicroseconds = function(m){ this.microseconds = m; return this; };
     2096    $.timepicker.log = function (err) {
     2097        if (window.console) {
     2098            window.console.log(err);
     2099        }
     2100    };
     2101
     2102    /*
     2103     * Add util object to allow access to private methods for testability.
     2104     */
     2105    $.timepicker._util = {
     2106        _extendRemove: extendRemove,
     2107        _isEmptyObject: isEmptyObject,
     2108        _convert24to12: convert24to12,
     2109        _detectSupport: detectSupport,
     2110        _selectLocalTimezone: selectLocalTimezone,
     2111        _computeEffectiveSetting: computeEffectiveSetting,
     2112        _splitDateTime: splitDateTime,
     2113        _parseDateTimeInternal: parseDateTimeInternal
     2114    };
     2115
     2116    /*
     2117    * Microsecond support
     2118    */
     2119    if (!Date.prototype.getMicroseconds) {
     2120        Date.prototype.microseconds = 0;
     2121        Date.prototype.getMicroseconds = function () { return this.microseconds; };
     2122        Date.prototype.setMicroseconds = function (m) {
     2123            this.setMilliseconds(this.getMilliseconds() + Math.floor(m / 1000));
     2124            this.microseconds = m % 1000;
     2125            return this;
     2126        };
    20962127    }
    20972128
     
    20992130    * Keep up with the version
    21002131    */
    2101     $.timepicker.version = "1.3";
     2132    $.timepicker.version = "1.4";
    21022133
    21032134})(jQuery);
Note: See TracChangeset for help on using the changeset viewer.