Skip to content

Commit

Permalink
Update to release v1.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-v committed May 17, 2019
1 parent 517f57b commit c8ed362
Show file tree
Hide file tree
Showing 14 changed files with 131 additions and 59 deletions.
19 changes: 19 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 60
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- bug
- enhancement
- pinned
- security
# Label to use when marking an issue as stale
staleLabel: wontfix
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
7 changes: 7 additions & 0 deletions CHANGE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Change Log: `yii2-date-range`
=============================

## Version 1.7.1

**Date:** 17-May-2019

- (enh #139): Update Latvian Translations.
- (enh #134): Merge ranges for preset dropdown.
- Implement stale bot.

## Version 1.7.0

Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2015 - 2018, Kartik Visweswaran
Copyright (c) 2015 - 2019, Kartik Visweswaran
Krajee.com
All rights reserved.

Expand Down
4 changes: 2 additions & 2 deletions src/DateRangeBehavior.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

/**
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2019
* @package yii2-date-range
* @version 1.7.0
* @version 1.7.1
*/

namespace kartik\daterange;
Expand Down
29 changes: 17 additions & 12 deletions src/DateRangePicker.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

/**
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2019
* @package yii2-date-range
* @version 1.7.0
* @version 1.7.1
*/

namespace kartik\daterange;
Expand Down Expand Up @@ -313,7 +313,11 @@ public function registerAssets()
});
JS;
if ($this->presetDropdown && empty($this->value)) {
$js .= "var val={$nowFrom}+'{$this->_separator}'+{$nowTo};{$id}.find('.range-value').val(val);";
$js .= <<< JS
var val = {$nowFrom} + '{$this->_separator}' + {$nowTo};
{$id}.find('.range-value').val(val);
{$input}.val(val);
JS;
}
$view->registerJs($js);
$this->registerPlugin($this->pluginName, $id, null, $this->callback);
Expand Down Expand Up @@ -432,15 +436,16 @@ protected function initRange()
$beg = "{$m}.startOf('day')";
$end = "{$m}.endOf('day')";
$last = "{$m}.subtract(1, 'month')";
$defaultRanges = [
Yii::t('kvdrp', 'Today') => [$beg, $end],
Yii::t('kvdrp', 'Yesterday') => ["{$beg}.subtract(1,'days')", "{$end}.subtract(1,'days')"],
Yii::t('kvdrp', 'Last {n} Days', ['n' => 7]) => ["{$beg}.subtract(6, 'days')", $end],
Yii::t('kvdrp', 'Last {n} Days', ['n' => 30]) => ["{$beg}.subtract(29, 'days')", $end],
Yii::t('kvdrp', 'This Month') => ["{$m}.startOf('month')", "{$m}.endOf('month')"],
Yii::t('kvdrp', 'Last Month') => ["{$last}.startOf('month')", "{$last}.endOf('month')"],
];
$this->pluginOptions['ranges'] = ArrayHelper::getValue($this->pluginOptions, 'ranges', $defaultRanges);
if (!isset($this->pluginOptions['ranges'])) {
$this->pluginOptions['ranges'] = [
Yii::t('kvdrp', 'Today') => [$beg, $end],
Yii::t('kvdrp', 'Yesterday') => ["{$beg}.subtract(1,'days')", "{$end}.subtract(1,'days')"],
Yii::t('kvdrp', 'Last {n} Days', ['n' => 7]) => ["{$beg}.subtract(6, 'days')", $end],
Yii::t('kvdrp', 'Last {n} Days', ['n' => 30]) => ["{$beg}.subtract(29, 'days')", $end],
Yii::t('kvdrp', 'This Month') => ["{$m}.startOf('month')", "{$m}.endOf('month')"],
Yii::t('kvdrp', 'Last Month') => ["{$last}.startOf('month')", "{$last}.endOf('month')"],
];
}
if (empty($this->value)) {
$this->pluginOptions['startDate'] = new JsExpression("{$m}.startOf('day')");
$this->pluginOptions['endDate'] = new JsExpression($m);
Expand Down
4 changes: 2 additions & 2 deletions src/DateRangePickerAsset.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

/**
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2019
* @package yii2-date-range
* @version 1.7.0
* @version 1.7.1
*/

namespace kartik\daterange;
Expand Down
4 changes: 2 additions & 2 deletions src/LanguageAsset.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

/**
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2019
* @package yii2-date-range
* @version 1.7.0
* @version 1.7.1
*/

namespace kartik\daterange;
Expand Down
4 changes: 2 additions & 2 deletions src/MomentAsset.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

/**
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2019
* @package yii2-date-range
* @version 1.7.0
* @version 1.7.1
*/

namespace kartik\daterange;
Expand Down
4 changes: 2 additions & 2 deletions src/assets/css/daterangepicker-kv.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @version 1.7.0
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2019
* @version 1.7.1
*
* Custom styling for DateRangePicker
*
Expand Down
4 changes: 2 additions & 2 deletions src/assets/css/daterangepicker-kv.min.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @version 1.7.0
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2019
* @version 1.7.1
*
* Custom styling for DateRangePicker
*
Expand Down
4 changes: 2 additions & 2 deletions src/assets/css/daterangepicker.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @version 1.7.0
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2019
* @version 1.7.1
*
* Modified Bootstrap 3.x & 4.x styling for DateRangePicker
*
Expand Down
4 changes: 2 additions & 2 deletions src/assets/css/daterangepicker.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

98 changes: 69 additions & 29 deletions src/assets/js/daterangepicker.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @version: 3.0.3
* @version: 3.0.5
* @author: Dan Grossman http://www.dangrossman.info/
* @copyright: Copyright (c) 2012-2018 Dan Grossman. All rights reserved.
* @copyright: Copyright (c) 2012-2019 Dan Grossman. All rights reserved.
* @license: Licensed under the MIT license. See http://www.opensource.org/licenses/mit-license.php
* @website: http://www.daterangepicker.com/
*/
Expand All @@ -11,6 +11,7 @@
// AMD. Make globaly available as well
define(['moment', 'jquery'], function (moment, jquery) {
if (!jquery.fn) jquery.fn = {}; // webpack server rendering
if (typeof moment !== 'function' && moment.default) moment = moment.default
return factory(moment, jquery);
});
} else if (typeof module === 'object' && module.exports) {
Expand Down Expand Up @@ -488,7 +489,7 @@
this.endDate = moment(endDate);

if (!this.timePicker)
this.endDate = this.endDate.add(1,'d').startOf('day').subtract(1,'second');
this.endDate = this.endDate.endOf('day');

if (this.timePicker && this.timePickerIncrement)
this.endDate.minute(Math.round(this.endDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
Expand Down Expand Up @@ -575,6 +576,9 @@
if (this.endDate) {
hour = parseInt(this.container.find('.left .hourselect').val(), 10);
minute = parseInt(this.container.find('.left .minuteselect').val(), 10);
if (isNaN(minute)) {
minute = parseInt(this.container.find('.left .minuteselect option:last').val(), 10);
}
second = this.timePickerSeconds ? parseInt(this.container.find('.left .secondselect').val(), 10) : 0;
if (!this.timePicker24Hour) {
var ampm = this.container.find('.left .ampmselect').val();
Expand All @@ -586,6 +590,9 @@
} else {
hour = parseInt(this.container.find('.right .hourselect').val(), 10);
minute = parseInt(this.container.find('.right .minuteselect').val(), 10);
if (isNaN(minute)) {
minute = parseInt(this.container.find('.right .minuteselect option:last').val(), 10);
}
second = this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10) : 0;
if (!this.timePicker24Hour) {
var ampm = this.container.find('.right .ampmselect').val();
Expand Down Expand Up @@ -709,7 +716,7 @@

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

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

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

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

if (this.maxSpan && (!this.maxDate || this.startDate.clone().add(this.maxSpan).isAfter(this.maxDate)))
if (this.maxSpan && (!this.maxDate || this.startDate.clone().add(this.maxSpan).isBefore(this.maxDate)))
maxDate = this.startDate.clone().add(this.maxSpan);

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

selected.hour(selected.hour() || timeSelector.find('.hourselect option:selected').val());
selected.minute(selected.minute() || timeSelector.find('.minuteselect option:selected').val());
selected.second(selected.second() || timeSelector.find('.secondselect option:selected').val());
selected.hour(!isNaN(selected.hour()) ? selected.hour() : timeSelector.find('.hourselect option:selected').val());
selected.minute(!isNaN(selected.minute()) ? selected.minute() : timeSelector.find('.minuteselect option:selected').val());
selected.second(!isNaN(selected.second()) ? selected.second() : timeSelector.find('.secondselect option:selected').val());

if (!this.timePicker24Hour) {
var ampm = timeSelector.find('.ampmselect option:selected').val();
Expand Down Expand Up @@ -1030,44 +1037,68 @@
containerTop = this.element.offset().top - this.container.outerHeight() - parentOffset.top;
else
containerTop = this.element.offset().top + this.element.outerHeight() - parentOffset.top;

// Force the container to it's actual width
this.container.css({
top: 0,
left: 0,
right: 'auto'
});
var containerWidth = this.container.outerWidth();

this.container[this.drops == 'up' ? 'addClass' : 'removeClass']('drop-up');

if (this.opens == 'left') {
this.container.css({
top: containerTop,
right: parentRightEdge - this.element.offset().left - this.element.outerWidth(),
left: 'auto'
});
if (this.container.offset().left < 0) {
var containerRight = parentRightEdge - this.element.offset().left - this.element.outerWidth();
if (containerWidth + containerRight > $(window).width()) {
this.container.css({
top: containerTop,
right: 'auto',
left: 9
});
} else {
this.container.css({
top: containerTop,
right: containerRight,
left: 'auto'
});
}
} else if (this.opens == 'center') {
this.container.css({
top: containerTop,
left: this.element.offset().left - parentOffset.left + this.element.outerWidth() / 2
- this.container.outerWidth() / 2,
right: 'auto'
});
if (this.container.offset().left < 0) {
var containerLeft = this.element.offset().left - parentOffset.left + this.element.outerWidth() / 2
- containerWidth / 2;
if (containerLeft < 0) {
this.container.css({
top: containerTop,
right: 'auto',
left: 9
});
} else if (containerLeft + containerWidth > $(window).width()) {
this.container.css({
top: containerTop,
left: 'auto',
right: 0
});
} else {
this.container.css({
top: containerTop,
left: containerLeft,
right: 'auto'
});
}
} else {
this.container.css({
top: containerTop,
left: this.element.offset().left - parentOffset.left,
right: 'auto'
});
if (this.container.offset().left + this.container.outerWidth() > $(window).width()) {
var containerLeft = this.element.offset().left - parentOffset.left;
if (containerLeft + containerWidth > $(window).width()) {
this.container.css({
top: containerTop,
left: 'auto',
right: 0
});
} else {
this.container.css({
top: containerTop,
left: containerLeft,
right: 'auto'
});
}
}
},
Expand Down Expand Up @@ -1272,6 +1303,9 @@
hour = 0;
}
var minute = parseInt(this.container.find('.left .minuteselect').val(), 10);
if (isNaN(minute)) {
minute = parseInt(this.container.find('.left .minuteselect option:last').val(), 10);
}
var second = this.timePickerSeconds ? parseInt(this.container.find('.left .secondselect').val(), 10) : 0;
date = date.clone().hour(hour).minute(minute).second(second);
}
Expand All @@ -1292,6 +1326,9 @@
hour = 0;
}
var minute = parseInt(this.container.find('.right .minuteselect').val(), 10);
if (isNaN(minute)) {
minute = parseInt(this.container.find('.right .minuteselect option:last').val(), 10);
}
var second = this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10) : 0;
date = date.clone().hour(hour).minute(minute).second(second);
}
Expand Down Expand Up @@ -1320,7 +1357,7 @@
var i = 0;
for (var range in this.ranges) {
if (this.timePicker) {
var format = this.timePickerSeconds ? "YYYY-MM-DD hh:mm:ss" : "YYYY-MM-DD hh:mm";
var format = this.timePickerSeconds ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD HH:mm";
//ignore times when comparing dates if time picker seconds is not enabled
if (this.startDate.format(format) == this.ranges[range][0].format(format) && this.endDate.format(format) == this.ranges[range][1].format(format)) {
customRange = false;
Expand Down Expand Up @@ -1408,6 +1445,9 @@

var hour = parseInt(cal.find('.hourselect').val(), 10);
var minute = parseInt(cal.find('.minuteselect').val(), 10);
if (isNaN(minute)) {
minute = parseInt(cal.find('.minuteselect option:last').val(), 10);
}
var second = this.timePickerSeconds ? parseInt(cal.find('.secondselect').val(), 10) : 0;

if (!this.timePicker24Hour) {
Expand Down
3 changes: 2 additions & 1 deletion src/assets/js/daterangepicker.min.js

Large diffs are not rendered by default.

0 comments on commit c8ed362

Please sign in to comment.