From e0bb0af4e379f8142109f1feda7a851be60cf3ab Mon Sep 17 00:00:00 2001 From: Ibrahim Abdo Date: Mon, 7 Dec 2015 16:56:59 +0200 Subject: [PATCH 1/4] Add minutes step greater than 60 --- js/bootstrap-timepicker.js | 262 +++++++++++++++---------------------- 1 file changed, 104 insertions(+), 158 deletions(-) diff --git a/js/bootstrap-timepicker.js b/js/bootstrap-timepicker.js index 48e75214..1adc3501 100644 --- a/js/bootstrap-timepicker.js +++ b/js/bootstrap-timepicker.js @@ -8,7 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ -(function($, window, document) { +(function($, window, document, undefined) { 'use strict'; // TIMEPICKER PUBLIC CLASS DEFINITION @@ -23,27 +23,12 @@ this.modalBackdrop = options.modalBackdrop; this.orientation = options.orientation; this.secondStep = options.secondStep; - this.snapToStep = options.snapToStep; this.showInputs = options.showInputs; this.showMeridian = options.showMeridian; this.showSeconds = options.showSeconds; this.template = options.template; this.appendWidgetTo = options.appendWidgetTo; this.showWidgetOnAddonClick = options.showWidgetOnAddonClick; - this.icons = options.icons; - this.maxHours = options.maxHours; - this.explicitMode = options.explicitMode; // If true 123 = 1:23, 12345 = 1:23:45, else invalid. - - this.handleDocumentClick = function (e) { - var self = e.data.scope; - // This condition was inspired by bootstrap-datepicker. - // The element the timepicker is invoked on is the input but it has a sibling for addon/button. - if (!(self.$element.parent().find(e.target).length || - self.$widget.is(e.target) || - self.$widget.find(e.target).length)) { - self.hideWidget(); - } - }; this._init(); }; @@ -54,8 +39,8 @@ _init: function() { var self = this; - if (this.showWidgetOnAddonClick && (this.$element.parent().hasClass('input-group') && this.$element.parent().hasClass('bootstrap-timepicker'))) { - this.$element.parent('.input-group.bootstrap-timepicker').find('.input-group-addon').on({ + if (this.showWidgetOnAddonClick && (this.$element.parent().hasClass('input-append') || this.$element.parent().hasClass('input-prepend'))) { + this.$element.parent('.input-append, .input-prepend').find('.add-on').on({ 'click.timepicker': $.proxy(this.showWidget, this) }); this.$element.on({ @@ -134,7 +119,7 @@ } } else { if (this.hour <= 0) { - this.hour = this.maxHours - 1; + this.hour = 23; } else { this.hour--; } @@ -147,7 +132,20 @@ if (step) { newVal = this.minute - step; } else { - newVal = this.minute - this.minuteStep; + var minuteStep = this.minuteStep; + if (this.minuteStep > 60) { + var hourStep = Math.floor(this.minuteStep / 60); + minuteStep -= (hourStep * 60); + if (minuteStep == 0) { + minuteStep = 60; + } + + for (var i = 0; i'+ - ''+ + ''+ ' '+ - ''+ + ''+ (this.showSeconds ? ' '+ - '' + '' : '') + (this.showMeridian ? ' '+ - '' + '' : '') + ''+ ''+ @@ -313,16 +294,16 @@ : '') + ''+ ''+ - ''+ + ''+ ''+ - ''+ + ''+ (this.showSeconds ? ' '+ - '' + '' : '') + (this.showMeridian ? ' '+ - '' + '' : '') + ''+ ''; @@ -331,7 +312,7 @@ case 'modal': template = '