Permalink
Browse files

Add option for time increment, defaults to 30

  • Loading branch information...
1 parent 0aca336 commit 0392fa1d522d050ec986643e30f1594f344d3b05 @lodestone lodestone committed Mar 25, 2011
Showing with 6 additions and 4 deletions.
  1. +6 −4 jquery.calendrical.js
View
@@ -235,15 +235,15 @@
{
var selection = options.selection && parseTime(options.selection);
if (selection) {
- selection.minute = Math.floor(selection.minute / 30.0) * 30;
+ selection.minute = Math.floor(selection.minute / parseFloat(options.increment)) * options.increment;
}
var startTime = options.startTime &&
(options.startTime.hour * 60 + options.startTime.minute);
var scrollTo; //Element to scroll the dropdown box to when shown
var ul = $('<ul />');
for (var hour = 0; hour < 24; hour++) {
- for (var minute = 0; minute < 60; minute += 30) {
+ for (var minute = 0; minute < 60; minute += options.increment) {
if (startTime && startTime > (hour * 60 + minute)) continue;
(function() {
@@ -392,6 +392,7 @@
$.fn.calendricalTime = function(options)
{
options = options || {};
+ options.increment = options.increment || 30;
options.padding = options.padding || 4;
return this.each(function() {
@@ -431,6 +432,7 @@
element.after(div);
var opts = {
+ increment: options.increment,
selection: element.val(),
selectTime: function(time) {
within = false;
@@ -441,7 +443,7 @@
isoTime: options.isoTime || false,
defaultHour: (options.defaultHour != null) ?
options.defaultHour : 8
- };
+ }
if (useStartTime) {
opts.startTime = parseTime(options.startTime.val());
@@ -487,4 +489,4 @@
}
return this;
};
-})(jQuery);
+})(jQuery);

0 comments on commit 0392fa1

Please sign in to comment.