From 7b62a6b459c1da70290320592e78be071b83b0b5 Mon Sep 17 00:00:00 2001 From: csn Date: Tue, 12 Aug 2014 16:55:12 +0200 Subject: [PATCH 01/14] [ADD] calendar week option --- src/js/bootstrap-datetimepicker.js | 7 +++++++ src/less/bootstrap-datetimepicker.less | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/js/bootstrap-datetimepicker.js b/src/js/bootstrap-datetimepicker.js index d2817656f..bf24b3ce1 100644 --- a/src/js/bootstrap-datetimepicker.js +++ b/src/js/bootstrap-datetimepicker.js @@ -385,6 +385,9 @@ THE SOFTWARE. fillDow = function () { moment.locale(picker.options.language); var html = $(''), weekdaysMin = moment.weekdaysMin(), i; + if (picker.options.calendarWeeks === true) { + html.append(' '); + } if (moment().localeData()._week.dow === 0) { // starts on Sunday for (i = 0; i < 7; i++) { html.append('' + weekdaysMin[i] + ''); @@ -446,6 +449,9 @@ THE SOFTWARE. if (prevMonth.weekday() === moment().startOf('week').weekday()) { row = $(''); html.push(row); + if (picker.options.calendarWeeks === true) { + row.append('' + prevMonth.week() + ''); + } } clsName = ''; if (prevMonth.year() < year || (prevMonth.year() === year && prevMonth.month() < month)) { @@ -1341,6 +1347,7 @@ THE SOFTWARE. useMinutes: true, useSeconds: false, useCurrent: true, + calendarWeeks: true, minuteStepping: 1, minDate: moment({y: 1900}), maxDate: moment().add(100, 'y'), diff --git a/src/less/bootstrap-datetimepicker.less b/src/less/bootstrap-datetimepicker.less index 3e785e558..9334a723d 100755 --- a/src/less/bootstrap-datetimepicker.less +++ b/src/less/bootstrap-datetimepicker.less @@ -132,6 +132,13 @@ line-height: 54px; width: 54px; + &.cw + { + font-size: 10px; + height: 20px; + line-height: 20px; + } + &.day { height: 20px; From 45f5f1e02c4731abdc0d27c49ce30483772cd2d5 Mon Sep 17 00:00:00 2001 From: Nikos Kalogridis Date: Wed, 13 Aug 2014 03:05:02 +0300 Subject: [PATCH 02/14] fix for #389 --- src/js/bootstrap-datetimepicker.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/js/bootstrap-datetimepicker.js b/src/js/bootstrap-datetimepicker.js index d2817656f..8d314885d 100644 --- a/src/js/bootstrap-datetimepicker.js +++ b/src/js/bootstrap-datetimepicker.js @@ -304,7 +304,7 @@ THE SOFTWARE. } } if (placePosition === 'top') { - offset.top -= picker.widget.height() + picker.element.outerHeight() + 15; + offset.bottom = $window.height() - offset.top + picker.element.outerHeight() + 3; picker.widget.addClass('top').removeClass('bottom'); } else { offset.top += 1; @@ -335,12 +335,22 @@ THE SOFTWARE. picker.widget.removeClass('pull-right'); } - picker.widget.css({ - position: position, - top: offset.top, - left: offset.left, - right: offset.right - }); + if (placePosition === 'top') { + picker.widget.css({ + position: position, + bottom: offset.bottom, + top: 'auto', + left: offset.left, + right: offset.right + }); + } else { + picker.widget.css({ + position: position, + top: offset.top, + left: offset.left, + right: offset.right + }); + } }, notifyChange = function (oldDate, eventType) { From 5f83ccac9795ca254f42139898a0dd13c3a1d416 Mon Sep 17 00:00:00 2001 From: Nikos Kalogridis Date: Wed, 13 Aug 2014 15:10:40 +0300 Subject: [PATCH 03/14] fix for #476 --- src/js/bootstrap-datetimepicker.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/js/bootstrap-datetimepicker.js b/src/js/bootstrap-datetimepicker.js index 8d314885d..ec3ea8e58 100644 --- a/src/js/bootstrap-datetimepicker.js +++ b/src/js/bootstrap-datetimepicker.js @@ -60,7 +60,7 @@ THE SOFTWARE. }, picker = this, - + errored = false, dDate, init = function () { @@ -354,9 +354,10 @@ THE SOFTWARE. }, notifyChange = function (oldDate, eventType) { - if (moment(picker.date).isSame(moment(oldDate))) { + if (moment(picker.date).isSame(moment(oldDate)) && !errored) { return; } + errored = false; picker.element.trigger({ type: 'dp.change', date: moment(picker.date), @@ -369,6 +370,7 @@ THE SOFTWARE. }, notifyError = function (date) { + errored = true; picker.element.trigger({ type: 'dp.error', date: moment(date, picker.format, picker.options.useStrict) From dab114028fbd333746fd2913a0827029f47672d8 Mon Sep 17 00:00:00 2001 From: csn Date: Wed, 13 Aug 2014 09:52:37 +0200 Subject: [PATCH 04/14] [FIX] display improvement on calendar week option --- src/js/bootstrap-datetimepicker.js | 11 +++++++---- src/less/bootstrap-datetimepicker.less | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/js/bootstrap-datetimepicker.js b/src/js/bootstrap-datetimepicker.js index bf24b3ce1..8619c44a7 100644 --- a/src/js/bootstrap-datetimepicker.js +++ b/src/js/bootstrap-datetimepicker.js @@ -233,6 +233,9 @@ THE SOFTWARE. if (eData.dateUsecurrent !== undefined) { picker.options.useCurrent = eData.dateUsecurrent; } + if (eData.calendarWeeks !== undefined) { + picker.options.calendarWeeks = eData.calendarWeeks; + } if (eData.dateMinutestepping !== undefined) { picker.options.minuteStepping = eData.dateMinutestepping; } @@ -386,7 +389,7 @@ THE SOFTWARE. moment.locale(picker.options.language); var html = $(''), weekdaysMin = moment.weekdaysMin(), i; if (picker.options.calendarWeeks === true) { - html.append(' '); + html.append('#'); } if (moment().localeData()._week.dow === 0) { // starts on Sunday for (i = 0; i < 7; i++) { @@ -1091,11 +1094,11 @@ THE SOFTWARE. headTemplate: '' + '' + - '‹›' + + '‹›' + '' + '', contTemplate: - '' + '' }, tpGlobal = { @@ -1347,7 +1350,7 @@ THE SOFTWARE. useMinutes: true, useSeconds: false, useCurrent: true, - calendarWeeks: true, + calendarWeeks: false, minuteStepping: 1, minDate: moment({y: 1900}), maxDate: moment().add(100, 'y'), diff --git a/src/less/bootstrap-datetimepicker.less b/src/less/bootstrap-datetimepicker.less index 9334a723d..49fbc15d3 100755 --- a/src/less/bootstrap-datetimepicker.less +++ b/src/less/bootstrap-datetimepicker.less @@ -137,6 +137,7 @@ font-size: 10px; height: 20px; line-height: 20px; + color: @gray-light; } &.day From 9cbc8f56e1a48c2e112773514df52b17a1055c34 Mon Sep 17 00:00:00 2001 From: Christian Morgan Date: Wed, 13 Aug 2014 21:47:53 +0100 Subject: [PATCH 05/14] Updated 24hour detection Updated 24hour detection to look for lower case 'h' (12-hour clock hours) as well as case-insensitive 'a' (AM/PM marker) --- src/js/bootstrap-datetimepicker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/bootstrap-datetimepicker.js b/src/js/bootstrap-datetimepicker.js index d2817656f..5da3aafde 100644 --- a/src/js/bootstrap-datetimepicker.js +++ b/src/js/bootstrap-datetimepicker.js @@ -110,7 +110,7 @@ THE SOFTWARE. } } } - picker.use24hours = picker.format.toLowerCase().indexOf('a') < 1; + picker.use24hours = (picker.format.toLowerCase().indexOf('a') < 1 && picker.format.indexOf('h') < 1); if (picker.component) { icon = picker.component.find('span'); From 41e83a61d244132e85d00a1efcda29ea5837a710 Mon Sep 17 00:00:00 2001 From: Christian Morgan Date: Wed, 13 Aug 2014 21:57:51 +0100 Subject: [PATCH 06/14] Fixed repeated word (typo) --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c93d9b55d..90ddb1466 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,7 +20,7 @@ grunt # this runs tests and jshint Very important notes ==================== - * **Pull pull requests to the `master` branch will be closed.** Please submit all pull requests to the `development` branch. + * **Pull requests to the `master` branch will be closed.** Please submit all pull requests to the `development` branch. * **Do not include the minified files in your pull request.** Don't worry, we'll build them when we cut a release. Grunt tasks From 223d2175d5f58eb80838bc428fb93a6e2a0ea60d Mon Sep 17 00:00:00 2001 From: Christian Morgan Date: Wed, 13 Aug 2014 22:14:12 +0100 Subject: [PATCH 07/14] Fixed comparison We're looking for cases where 'a', 'A' and 'h' are not in the format string. They can be in first position so need to check for 'not found', i.e. `<0` or `-1`. --- src/js/bootstrap-datetimepicker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/bootstrap-datetimepicker.js b/src/js/bootstrap-datetimepicker.js index 5da3aafde..cb5c99fc6 100644 --- a/src/js/bootstrap-datetimepicker.js +++ b/src/js/bootstrap-datetimepicker.js @@ -110,7 +110,7 @@ THE SOFTWARE. } } } - picker.use24hours = (picker.format.toLowerCase().indexOf('a') < 1 && picker.format.indexOf('h') < 1); + picker.use24hours = (picker.format.toLowerCase().indexOf('a') < 0 && picker.format.indexOf('h') < 0); if (picker.component) { icon = picker.component.find('span'); From 25ed7f51505eb88f1085cbd25a7e432b3333467f Mon Sep 17 00:00:00 2001 From: Nikos Kalogridis Date: Thu, 14 Aug 2014 04:38:31 +0300 Subject: [PATCH 08/14] fix for calendarweeks --- src/js/bootstrap-datetimepicker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/bootstrap-datetimepicker.js b/src/js/bootstrap-datetimepicker.js index 2632cc611..975d8733b 100644 --- a/src/js/bootstrap-datetimepicker.js +++ b/src/js/bootstrap-datetimepicker.js @@ -1106,11 +1106,11 @@ THE SOFTWARE. headTemplate: '' + '' + - '‹›' + + '‹›' + '' + '', contTemplate: - '' + '' }, tpGlobal = { From 3fbe808a6a0a3621162e6e15ee5f0af998c3ca95 Mon Sep 17 00:00:00 2001 From: Nikos Kalogridis Date: Thu, 14 Aug 2014 04:57:52 +0300 Subject: [PATCH 09/14] fix mess with calendarWeeks --- src/js/bootstrap-datetimepicker.js | 45 +++++++++++++++--------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/src/js/bootstrap-datetimepicker.js b/src/js/bootstrap-datetimepicker.js index 975d8733b..d6d654d0f 100644 --- a/src/js/bootstrap-datetimepicker.js +++ b/src/js/bootstrap-datetimepicker.js @@ -1049,18 +1049,36 @@ THE SOFTWARE. }, getTemplate = function () { + var + headTemplate = + '' + + '' + + '‹›' + + '' + + '', + contTemplate = + '', + template = '
' + + '' + headTemplate + '
' + + '
' + + '
' + + '' + headTemplate + contTemplate + '
' + + '
' + + '
' + + '' + headTemplate + contTemplate + '
' + + '
', + ret = ''; if (picker.options.pickDate && picker.options.pickTime) { - var ret = ''; ret = '