Skip to content

Commit

Permalink
Update jquery-timepicker to version 1.11.10
Browse files Browse the repository at this point in the history
  • Loading branch information
cover committed Mar 22, 2017
1 parent b1608f9 commit 121cdc2
Showing 1 changed file with 76 additions and 61 deletions.
137 changes: 76 additions & 61 deletions vendor/assets/javascripts/jquery.timepicker.js
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* jquery-timepicker v1.11.4 - A jQuery timepicker plugin inspired by Google Calendar. It supports both mouse and keyboard navigation.
* jquery-timepicker v1.11.10 - A jQuery timepicker plugin inspired by Google Calendar. It supports both mouse and keyboard navigation.
* Copyright (c) 2015 Jon Thornton - http://jonthornton.github.com/jquery-timepicker/
* License: MIT
*/
Expand Down Expand Up @@ -30,6 +30,58 @@
hrs: 'hrs'
};

var _DEFAULTS = {
appendTo: 'body',
className: null,
closeOnWindowScroll: false,
disableTextInput: false,
disableTimeRanges: [],
disableTouchKeyboard: false,
durationTime: null,
forceRoundTime: false,
maxTime: null,
minTime: null,
noneOption: false,
orientation: 'l',
roundingFunction: function(seconds, settings) {
if (seconds === null) {
return null;
} else if (typeof settings.step !== "number") {
// TODO: nearest fit irregular steps
return seconds;
} else {
var offset = seconds % (settings.step*60); // step is in minutes

var start = settings.minTime || 0;

// adjust offset by start mod step so that the offset is aligned not to 00:00 but to the start
offset -= start % (settings.step * 60);

if (offset >= settings.step*30) {
// if offset is larger than a half step, round up
seconds += (settings.step*60) - offset;
} else {
// round down
seconds -= offset;
}

return _moduloSeconds(seconds, settings);
}
},
scrollDefault: null,
selectOnBlur: false,
show2400: false,
showDuration: false,
showOn: ['click', 'focus'],
showOnFocus: true,
step: 30,
stopScrollPropagation: false,
timeFormat: 'g:ia',
typeaheadHighlight: true,
useSelect: false,
wrapHours: true
};

var methods = {
init: function(options)
{
Expand All @@ -39,13 +91,13 @@

// pick up settings from data attributes
var attributeOptions = [];
for (var key in $.fn.timepicker.defaults) {
for (var key in _DEFAULTS) {
if (self.data(key)) {
attributeOptions[key] = self.data(key);
}
}

var settings = $.extend({}, $.fn.timepicker.defaults, attributeOptions, options);
var settings = $.extend({}, _DEFAULTS, options, attributeOptions);

if (settings.lang) {
_lang = $.extend(_lang, settings.lang);
Expand All @@ -71,7 +123,7 @@
self.on('keydown.timepicker', _disableTextInputHandler);
}

_formatValue.call(self.get(0));
_formatValue.call(self.get(0), null, 'initial');
}
});
},
Expand Down Expand Up @@ -243,6 +295,8 @@

self.data('timepicker-settings', settings);

_formatValue.call(self.get(0), {'type':'change'}, 'initial');

if (list) {
list.remove();
self.data('timepicker-list', false);
Expand Down Expand Up @@ -507,8 +561,8 @@
row.text(timeString);
} else {
var row = $('<li />');
row.addClass(timeInt % 86400 < 43200 ? 'ui-timepicker-am' : 'ui-timepicker-pm');
row.data('time', (timeInt <= 86400 ? timeInt : timeInt % 86400));
row.addClass((timeInt % _ONE_DAY) < (_ONE_DAY / 2) ? 'ui-timepicker-am' : 'ui-timepicker-pm');
row.data('time', _moduloSeconds(timeInt, settings));
row.text(timeString);
}

Expand Down Expand Up @@ -748,17 +802,21 @@
});

if (settings.forceRoundTime) {
seconds = settings.roundingFunction(seconds, settings);
var roundSeconds = settings.roundingFunction(seconds, settings);
if (roundSeconds != seconds) {
seconds = roundSeconds;
origin = null;
}
}

var prettyTime = _int2time(seconds, settings);

if (rangeError) {
if (_setTimeValue(self, prettyTime, 'error')) {
if (_setTimeValue(self, prettyTime, 'error') || e && e.type == 'change') {
self.trigger('timeRangeError');
}
} else {
_setTimeValue(self, prettyTime);
_setTimeValue(self, prettyTime, origin);
}
}

Expand Down Expand Up @@ -787,7 +845,7 @@
self.data('ui-timepicker-value', value);
if (source == 'select') {
self.trigger('selectTime').trigger('changeTime').trigger('change', 'timepicker');
} else if (source != 'error') {
} else if (['error', 'initial'].indexOf(source) == -1) {
self.trigger('changeTime');
}

Expand Down Expand Up @@ -1174,6 +1232,14 @@
return ("0" + n).slice(-2);
}

function _moduloSeconds(seconds, settings) {
if (seconds == _ONE_DAY && settings.show2400) {
return seconds;
}

return seconds%_ONE_DAY;
}

// Plugin entry
$.fn.timepicker = function(method)
{
Expand All @@ -1188,55 +1254,4 @@
else if(typeof method === "object" || !method) { return methods.init.apply(this, arguments); }
else { $.error("Method "+ method + " does not exist on jQuery.timepicker"); }
};
// Global defaults
$.fn.timepicker.defaults = {
appendTo: 'body',
className: null,
closeOnWindowScroll: false,
disableTextInput: false,
disableTimeRanges: [],
disableTouchKeyboard: false,
durationTime: null,
forceRoundTime: false,
maxTime: null,
minTime: null,
noneOption: false,
orientation: 'l',
roundingFunction: function(seconds, settings) {
if (seconds === null) {
return null;
} else if (typeof settings.step !== "number") {
// TODO: nearest fit irregular steps
return seconds;
} else {
var offset = seconds % (settings.step*60); // step is in minutes

if (offset >= settings.step*30) {
// if offset is larger than a half step, round up
seconds += (settings.step*60) - offset;
} else {
// round down
seconds -= offset;
}

if (seconds == _ONE_DAY && settings.show2400) {
return seconds;
}

return seconds%_ONE_DAY;
}
},
scrollDefault: null,
selectOnBlur: false,
show2400: false,
showDuration: false,
showOn: ['click', 'focus'],
showOnFocus: true,
step: 30,
stopScrollPropagation: false,
timeFormat: 'g:ia',
typeaheadHighlight: true,
useSelect: false,
wrapHours: true
};
}));

0 comments on commit 121cdc2

Please sign in to comment.