Skip to content

Commit c8ed362

Browse files
committed
Update to release v1.7.1
1 parent 517f57b commit c8ed362

14 files changed

+131
-59
lines changed

.github/stale.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Number of days of inactivity before an issue becomes stale
2+
daysUntilStale: 60
3+
# Number of days of inactivity before a stale issue is closed
4+
daysUntilClose: 7
5+
# Issues with these labels will never be considered stale
6+
exemptLabels:
7+
- bug
8+
- enhancement
9+
- pinned
10+
- security
11+
# Label to use when marking an issue as stale
12+
staleLabel: wontfix
13+
# Comment to post when marking an issue as stale. Set to `false` to disable
14+
markComment: >
15+
This issue has been automatically marked as stale because it has not had
16+
recent activity. It will be closed if no further activity occurs. Thank you
17+
for your contributions.
18+
# Comment to post when closing a stale issue. Set to `false` to disable
19+
closeComment: false

CHANGE.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Change Log: `yii2-date-range`
22
=============================
33

4+
## Version 1.7.1
5+
6+
**Date:** 17-May-2019
7+
8+
- (enh #139): Update Latvian Translations.
9+
- (enh #134): Merge ranges for preset dropdown.
10+
- Implement stale bot.
411

512
## Version 1.7.0
613

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2015 - 2018, Kartik Visweswaran
1+
Copyright (c) 2015 - 2019, Kartik Visweswaran
22
Krajee.com
33
All rights reserved.
44

src/DateRangeBehavior.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22

33
/**
4-
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
4+
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2019
55
* @package yii2-date-range
6-
* @version 1.7.0
6+
* @version 1.7.1
77
*/
88

99
namespace kartik\daterange;

src/DateRangePicker.php

+17-12
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22

33
/**
4-
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
4+
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2019
55
* @package yii2-date-range
6-
* @version 1.7.0
6+
* @version 1.7.1
77
*/
88

99
namespace kartik\daterange;
@@ -313,7 +313,11 @@ public function registerAssets()
313313
});
314314
JS;
315315
if ($this->presetDropdown && empty($this->value)) {
316-
$js .= "var val={$nowFrom}+'{$this->_separator}'+{$nowTo};{$id}.find('.range-value').val(val);";
316+
$js .= <<< JS
317+
var val = {$nowFrom} + '{$this->_separator}' + {$nowTo};
318+
{$id}.find('.range-value').val(val);
319+
{$input}.val(val);
320+
JS;
317321
}
318322
$view->registerJs($js);
319323
$this->registerPlugin($this->pluginName, $id, null, $this->callback);
@@ -432,15 +436,16 @@ protected function initRange()
432436
$beg = "{$m}.startOf('day')";
433437
$end = "{$m}.endOf('day')";
434438
$last = "{$m}.subtract(1, 'month')";
435-
$defaultRanges = [
436-
Yii::t('kvdrp', 'Today') => [$beg, $end],
437-
Yii::t('kvdrp', 'Yesterday') => ["{$beg}.subtract(1,'days')", "{$end}.subtract(1,'days')"],
438-
Yii::t('kvdrp', 'Last {n} Days', ['n' => 7]) => ["{$beg}.subtract(6, 'days')", $end],
439-
Yii::t('kvdrp', 'Last {n} Days', ['n' => 30]) => ["{$beg}.subtract(29, 'days')", $end],
440-
Yii::t('kvdrp', 'This Month') => ["{$m}.startOf('month')", "{$m}.endOf('month')"],
441-
Yii::t('kvdrp', 'Last Month') => ["{$last}.startOf('month')", "{$last}.endOf('month')"],
442-
];
443-
$this->pluginOptions['ranges'] = ArrayHelper::getValue($this->pluginOptions, 'ranges', $defaultRanges);
439+
if (!isset($this->pluginOptions['ranges'])) {
440+
$this->pluginOptions['ranges'] = [
441+
Yii::t('kvdrp', 'Today') => [$beg, $end],
442+
Yii::t('kvdrp', 'Yesterday') => ["{$beg}.subtract(1,'days')", "{$end}.subtract(1,'days')"],
443+
Yii::t('kvdrp', 'Last {n} Days', ['n' => 7]) => ["{$beg}.subtract(6, 'days')", $end],
444+
Yii::t('kvdrp', 'Last {n} Days', ['n' => 30]) => ["{$beg}.subtract(29, 'days')", $end],
445+
Yii::t('kvdrp', 'This Month') => ["{$m}.startOf('month')", "{$m}.endOf('month')"],
446+
Yii::t('kvdrp', 'Last Month') => ["{$last}.startOf('month')", "{$last}.endOf('month')"],
447+
];
448+
}
444449
if (empty($this->value)) {
445450
$this->pluginOptions['startDate'] = new JsExpression("{$m}.startOf('day')");
446451
$this->pluginOptions['endDate'] = new JsExpression($m);

src/DateRangePickerAsset.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22

33
/**
4-
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
4+
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2019
55
* @package yii2-date-range
6-
* @version 1.7.0
6+
* @version 1.7.1
77
*/
88

99
namespace kartik\daterange;

src/LanguageAsset.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22

33
/**
4-
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
4+
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2019
55
* @package yii2-date-range
6-
* @version 1.7.0
6+
* @version 1.7.1
77
*/
88

99
namespace kartik\daterange;

src/MomentAsset.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22

33
/**
4-
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
4+
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2019
55
* @package yii2-date-range
6-
* @version 1.7.0
6+
* @version 1.7.1
77
*/
88

99
namespace kartik\daterange;

src/assets/css/daterangepicker-kv.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
2-
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
3-
* @version 1.7.0
2+
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2019
3+
* @version 1.7.1
44
*
55
* Custom styling for DateRangePicker
66
*

src/assets/css/daterangepicker-kv.min.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
2-
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
3-
* @version 1.7.0
2+
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2019
3+
* @version 1.7.1
44
*
55
* Custom styling for DateRangePicker
66
*

src/assets/css/daterangepicker.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
2-
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
3-
* @version 1.7.0
2+
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2019
3+
* @version 1.7.1
44
*
55
* Modified Bootstrap 3.x & 4.x styling for DateRangePicker
66
*

src/assets/css/daterangepicker.min.css

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/assets/js/daterangepicker.js

+69-29
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* @version: 3.0.3
2+
* @version: 3.0.5
33
* @author: Dan Grossman http://www.dangrossman.info/
4-
* @copyright: Copyright (c) 2012-2018 Dan Grossman. All rights reserved.
4+
* @copyright: Copyright (c) 2012-2019 Dan Grossman. All rights reserved.
55
* @license: Licensed under the MIT license. See http://www.opensource.org/licenses/mit-license.php
66
* @website: http://www.daterangepicker.com/
77
*/
@@ -11,6 +11,7 @@
1111
// AMD. Make globaly available as well
1212
define(['moment', 'jquery'], function (moment, jquery) {
1313
if (!jquery.fn) jquery.fn = {}; // webpack server rendering
14+
if (typeof moment !== 'function' && moment.default) moment = moment.default
1415
return factory(moment, jquery);
1516
});
1617
} else if (typeof module === 'object' && module.exports) {
@@ -488,7 +489,7 @@
488489
this.endDate = moment(endDate);
489490

490491
if (!this.timePicker)
491-
this.endDate = this.endDate.add(1,'d').startOf('day').subtract(1,'second');
492+
this.endDate = this.endDate.endOf('day');
492493

493494
if (this.timePicker && this.timePickerIncrement)
494495
this.endDate.minute(Math.round(this.endDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
@@ -575,6 +576,9 @@
575576
if (this.endDate) {
576577
hour = parseInt(this.container.find('.left .hourselect').val(), 10);
577578
minute = parseInt(this.container.find('.left .minuteselect').val(), 10);
579+
if (isNaN(minute)) {
580+
minute = parseInt(this.container.find('.left .minuteselect option:last').val(), 10);
581+
}
578582
second = this.timePickerSeconds ? parseInt(this.container.find('.left .secondselect').val(), 10) : 0;
579583
if (!this.timePicker24Hour) {
580584
var ampm = this.container.find('.left .ampmselect').val();
@@ -586,6 +590,9 @@
586590
} else {
587591
hour = parseInt(this.container.find('.right .hourselect').val(), 10);
588592
minute = parseInt(this.container.find('.right .minuteselect').val(), 10);
593+
if (isNaN(minute)) {
594+
minute = parseInt(this.container.find('.right .minuteselect option:last').val(), 10);
595+
}
589596
second = this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10) : 0;
590597
if (!this.timePicker24Hour) {
591598
var ampm = this.container.find('.right .ampmselect').val();
@@ -709,7 +716,7 @@
709716

710717
var monthHtml = '<select class="monthselect">';
711718
for (var m = 0; m < 12; m++) {
712-
if ((!inMinYear || m >= minDate.month()) && (!inMaxYear || m <= maxDate.month())) {
719+
if ((!inMinYear || (minDate && m >= minDate.month())) && (!inMaxYear || (maxDate && m <= maxDate.month()))) {
713720
monthHtml += "<option value='" + m + "'" +
714721
(m === currentMonth ? " selected='selected'" : "") +
715722
">" + this.locale.monthNames[m] + "</option>";
@@ -786,7 +793,7 @@
786793

787794
//grey out the dates in other months displayed at beginning and end of this calendar
788795
if (calendar[row][col].month() != calendar[1][1].month())
789-
classes.push('off');
796+
classes.push('off', 'ends');
790797

791798
//don't allow selection of dates before the minimum date
792799
if (this.minDate && calendar[row][col].isBefore(this.minDate, 'day'))
@@ -851,7 +858,7 @@
851858

852859
var html, selected, minDate, maxDate = this.maxDate;
853860

854-
if (this.maxSpan && (!this.maxDate || this.startDate.clone().add(this.maxSpan).isAfter(this.maxDate)))
861+
if (this.maxSpan && (!this.maxDate || this.startDate.clone().add(this.maxSpan).isBefore(this.maxDate)))
855862
maxDate = this.startDate.clone().add(this.maxSpan);
856863

857864
if (side == 'left') {
@@ -865,9 +872,9 @@
865872
var timeSelector = this.container.find('.drp-calendar.right .calendar-time');
866873
if (timeSelector.html() != '') {
867874

868-
selected.hour(selected.hour() || timeSelector.find('.hourselect option:selected').val());
869-
selected.minute(selected.minute() || timeSelector.find('.minuteselect option:selected').val());
870-
selected.second(selected.second() || timeSelector.find('.secondselect option:selected').val());
875+
selected.hour(!isNaN(selected.hour()) ? selected.hour() : timeSelector.find('.hourselect option:selected').val());
876+
selected.minute(!isNaN(selected.minute()) ? selected.minute() : timeSelector.find('.minuteselect option:selected').val());
877+
selected.second(!isNaN(selected.second()) ? selected.second() : timeSelector.find('.secondselect option:selected').val());
871878

872879
if (!this.timePicker24Hour) {
873880
var ampm = timeSelector.find('.ampmselect option:selected').val();
@@ -1030,44 +1037,68 @@
10301037
containerTop = this.element.offset().top - this.container.outerHeight() - parentOffset.top;
10311038
else
10321039
containerTop = this.element.offset().top + this.element.outerHeight() - parentOffset.top;
1040+
1041+
// Force the container to it's actual width
1042+
this.container.css({
1043+
top: 0,
1044+
left: 0,
1045+
right: 'auto'
1046+
});
1047+
var containerWidth = this.container.outerWidth();
1048+
10331049
this.container[this.drops == 'up' ? 'addClass' : 'removeClass']('drop-up');
10341050

10351051
if (this.opens == 'left') {
1036-
this.container.css({
1037-
top: containerTop,
1038-
right: parentRightEdge - this.element.offset().left - this.element.outerWidth(),
1039-
left: 'auto'
1040-
});
1041-
if (this.container.offset().left < 0) {
1052+
var containerRight = parentRightEdge - this.element.offset().left - this.element.outerWidth();
1053+
if (containerWidth + containerRight > $(window).width()) {
10421054
this.container.css({
1055+
top: containerTop,
10431056
right: 'auto',
10441057
left: 9
10451058
});
1059+
} else {
1060+
this.container.css({
1061+
top: containerTop,
1062+
right: containerRight,
1063+
left: 'auto'
1064+
});
10461065
}
10471066
} else if (this.opens == 'center') {
1048-
this.container.css({
1049-
top: containerTop,
1050-
left: this.element.offset().left - parentOffset.left + this.element.outerWidth() / 2
1051-
- this.container.outerWidth() / 2,
1052-
right: 'auto'
1053-
});
1054-
if (this.container.offset().left < 0) {
1067+
var containerLeft = this.element.offset().left - parentOffset.left + this.element.outerWidth() / 2
1068+
- containerWidth / 2;
1069+
if (containerLeft < 0) {
10551070
this.container.css({
1071+
top: containerTop,
10561072
right: 'auto',
10571073
left: 9
10581074
});
1075+
} else if (containerLeft + containerWidth > $(window).width()) {
1076+
this.container.css({
1077+
top: containerTop,
1078+
left: 'auto',
1079+
right: 0
1080+
});
1081+
} else {
1082+
this.container.css({
1083+
top: containerTop,
1084+
left: containerLeft,
1085+
right: 'auto'
1086+
});
10591087
}
10601088
} else {
1061-
this.container.css({
1062-
top: containerTop,
1063-
left: this.element.offset().left - parentOffset.left,
1064-
right: 'auto'
1065-
});
1066-
if (this.container.offset().left + this.container.outerWidth() > $(window).width()) {
1089+
var containerLeft = this.element.offset().left - parentOffset.left;
1090+
if (containerLeft + containerWidth > $(window).width()) {
10671091
this.container.css({
1092+
top: containerTop,
10681093
left: 'auto',
10691094
right: 0
10701095
});
1096+
} else {
1097+
this.container.css({
1098+
top: containerTop,
1099+
left: containerLeft,
1100+
right: 'auto'
1101+
});
10711102
}
10721103
}
10731104
},
@@ -1272,6 +1303,9 @@
12721303
hour = 0;
12731304
}
12741305
var minute = parseInt(this.container.find('.left .minuteselect').val(), 10);
1306+
if (isNaN(minute)) {
1307+
minute = parseInt(this.container.find('.left .minuteselect option:last').val(), 10);
1308+
}
12751309
var second = this.timePickerSeconds ? parseInt(this.container.find('.left .secondselect').val(), 10) : 0;
12761310
date = date.clone().hour(hour).minute(minute).second(second);
12771311
}
@@ -1292,6 +1326,9 @@
12921326
hour = 0;
12931327
}
12941328
var minute = parseInt(this.container.find('.right .minuteselect').val(), 10);
1329+
if (isNaN(minute)) {
1330+
minute = parseInt(this.container.find('.right .minuteselect option:last').val(), 10);
1331+
}
12951332
var second = this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10) : 0;
12961333
date = date.clone().hour(hour).minute(minute).second(second);
12971334
}
@@ -1320,7 +1357,7 @@
13201357
var i = 0;
13211358
for (var range in this.ranges) {
13221359
if (this.timePicker) {
1323-
var format = this.timePickerSeconds ? "YYYY-MM-DD hh:mm:ss" : "YYYY-MM-DD hh:mm";
1360+
var format = this.timePickerSeconds ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD HH:mm";
13241361
//ignore times when comparing dates if time picker seconds is not enabled
13251362
if (this.startDate.format(format) == this.ranges[range][0].format(format) && this.endDate.format(format) == this.ranges[range][1].format(format)) {
13261363
customRange = false;
@@ -1408,6 +1445,9 @@
14081445

14091446
var hour = parseInt(cal.find('.hourselect').val(), 10);
14101447
var minute = parseInt(cal.find('.minuteselect').val(), 10);
1448+
if (isNaN(minute)) {
1449+
minute = parseInt(cal.find('.minuteselect option:last').val(), 10);
1450+
}
14111451
var second = this.timePickerSeconds ? parseInt(cal.find('.secondselect').val(), 10) : 0;
14121452

14131453
if (!this.timePicker24Hour) {

src/assets/js/daterangepicker.min.js

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)