From c9745070f45d584336627069a8c35c20e481eb40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cor=C3=A9=20Ramiro?= Date: Thu, 4 Feb 2016 16:40:26 +0000 Subject: [PATCH 1/2] Ability to show done button together with autoclose --- src/clockpicker.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/clockpicker.js b/src/clockpicker.js index 7f208aa..bb93c65 100644 --- a/src/clockpicker.js +++ b/src/clockpicker.js @@ -159,8 +159,8 @@ } - if (! options.autoclose) { - // If autoclose is not setted, append a button + if (options.showdonebutton) { + // Append a button if donetext was set $('') .click($.proxy(this.done, this)) .appendTo(popover); @@ -368,6 +368,7 @@ placement: 'bottom', // clock popover placement align: 'left', // popover arrow align donetext: '完成', // done button text + showdonebutton: 'true', // show done button autoclose: false, // auto close when minute is selected twelvehour: false, // change to 12 hour AM/PM clock from 24 hour vibrate: true // vibrate the device when dragging clock hand From 883e2aeb0e76221a29bfe9a9b94544361b837244 Mon Sep 17 00:00:00 2001 From: Core Ramiro Date: Thu, 4 Feb 2016 22:03:51 +0000 Subject: [PATCH 2/2] Update comments and README.md --- README.md | 1 + src/clockpicker.js | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 5ff911a..71856f4 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,7 @@ if (something) { | default | '' | default time, 'now' or '13:14' e.g. | | placement | 'bottom' | popover placement | | align | 'left' | popover arrow align | +| showdonebutton | true | show done button | | donetext | '完成' | done button text | | autoclose | false | auto close when minute is selected | | twelvehour | false | enables twelve hour mode with AM & PM buttons | diff --git a/src/clockpicker.js b/src/clockpicker.js index bb93c65..7e301b7 100644 --- a/src/clockpicker.js +++ b/src/clockpicker.js @@ -117,50 +117,50 @@ this.spanMinutes = popover.find('.clockpicker-span-minutes'); this.spanAmPm = popover.find('.clockpicker-span-am-pm'); this.amOrPm = "PM"; - + // Setup for for 12 hour clock if option is selected if (options.twelvehour) { - + var amPmButtonsTemplate = ['
', '', '', '
'].join(''); - + var amPmButtons = $(amPmButtonsTemplate); //amPmButtons.appendTo(plate); - + ////Not working b/c they are not shown when this runs //$('clockpicker-am-button') // .on("click", function() { // self.amOrPm = "AM"; // $('.clockpicker-span-am-pm').empty().append('AM'); // }); - // + // //$('clockpicker-pm-button') // .on("click", function() { // self.amOrPm = "PM"; // $('.clockpicker-span-am-pm').empty().append('PM'); // }); - + $('') .on("click", function() { self.amOrPm = "AM"; $('.clockpicker-span-am-pm').empty().append('AM'); }).appendTo(this.amPmBlock); - - + + $('') .on("click", function() { self.amOrPm = 'PM'; $('.clockpicker-span-am-pm').empty().append('PM'); }).appendTo(this.amPmBlock); - + } - + if (options.showdonebutton) { - // Append a button if donetext was set + // Append a button if showdonebutton options is set to true $('') .click($.proxy(this.done, this)) .appendTo(popover); @@ -577,7 +577,7 @@ inner = isHours && z < (outerRadius + innerRadius) / 2, radius = inner ? innerRadius : outerRadius, value; - + if (options.twelvehour) { radius = outerRadius; } @@ -622,7 +622,7 @@ } } } - + // Once hours or minutes changed, vibrate the device if (this[this.currentView] !== value) { if (vibrate && this.options.vibrate) { @@ -680,7 +680,7 @@ if (this.options.twelvehour) { value = value + this.amOrPm; } - + this.input.prop('value', value); if (value !== last) { this.input.triggerHandler('change');