mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-16 17:33:45 +00:00
Upgrade datepicker.
This commit is contained in:
362
public/v1/css/daterangepicker.css
vendored
362
public/v1/css/daterangepicker.css
vendored
@@ -3,12 +3,18 @@
|
|||||||
color: inherit;
|
color: inherit;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
width: 278px;
|
width: 278px;
|
||||||
padding: 4px;
|
max-width: none;
|
||||||
margin-top: 1px;
|
padding: 0;
|
||||||
|
margin-top: 7px;
|
||||||
top: 100px;
|
top: 100px;
|
||||||
left: 20px;
|
left: 20px;
|
||||||
/* Calendars */
|
z-index: 3001;
|
||||||
|
display: none;
|
||||||
|
font-family: arial;
|
||||||
|
font-size: 15px;
|
||||||
|
line-height: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.daterangepicker:before, .daterangepicker:after {
|
.daterangepicker:before, .daterangepicker:after {
|
||||||
@@ -64,75 +70,108 @@
|
|||||||
left: 10px;
|
left: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.daterangepicker.dropup {
|
.daterangepicker.drop-up {
|
||||||
margin-top: -5px;
|
margin-top: -7px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.daterangepicker.dropup:before {
|
.daterangepicker.drop-up:before {
|
||||||
top: initial;
|
top: initial;
|
||||||
bottom: -7px;
|
bottom: -7px;
|
||||||
border-bottom: initial;
|
border-bottom: initial;
|
||||||
border-top: 7px solid #ccc;
|
border-top: 7px solid #ccc;
|
||||||
}
|
}
|
||||||
|
|
||||||
.daterangepicker.dropup:after {
|
.daterangepicker.drop-up:after {
|
||||||
top: initial;
|
top: initial;
|
||||||
bottom: -6px;
|
bottom: -6px;
|
||||||
border-bottom: initial;
|
border-bottom: initial;
|
||||||
border-top: 6px solid #fff;
|
border-top: 6px solid #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.daterangepicker.dropdown-menu {
|
.daterangepicker.single .daterangepicker .ranges, .daterangepicker.single .drp-calendar {
|
||||||
max-width: none;
|
|
||||||
z-index: 3001;
|
|
||||||
}
|
|
||||||
|
|
||||||
.daterangepicker.single .ranges, .daterangepicker.single .calendar {
|
|
||||||
float: none;
|
float: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.daterangepicker.show-calendar .calendar {
|
.daterangepicker.single .drp-selected {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.daterangepicker.show-calendar .drp-calendar {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.daterangepicker .calendar {
|
.daterangepicker.show-calendar .drp-buttons {
|
||||||
display: none;
|
display: block;
|
||||||
max-width: 270px;
|
|
||||||
margin: 4px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.daterangepicker .calendar.single .calendar-table {
|
.daterangepicker.auto-apply .drp-buttons {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.daterangepicker .drp-calendar {
|
||||||
|
display: none;
|
||||||
|
max-width: 270px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.daterangepicker .drp-calendar.left {
|
||||||
|
padding: 8px 0 8px 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.daterangepicker .drp-calendar.right {
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.daterangepicker .drp-calendar.single .calendar-table {
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.daterangepicker .calendar th, .daterangepicker .calendar td {
|
.daterangepicker .calendar-table .next span, .daterangepicker .calendar-table .prev span {
|
||||||
|
color: #fff;
|
||||||
|
border: solid black;
|
||||||
|
border-width: 0 2px 2px 0;
|
||||||
|
border-radius: 0;
|
||||||
|
display: inline-block;
|
||||||
|
padding: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.daterangepicker .calendar-table .next span {
|
||||||
|
transform: rotate(-45deg);
|
||||||
|
-webkit-transform: rotate(-45deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.daterangepicker .calendar-table .prev span {
|
||||||
|
transform: rotate(135deg);
|
||||||
|
-webkit-transform: rotate(135deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.daterangepicker .calendar-table th, .daterangepicker .calendar-table td {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
vertical-align: middle;
|
||||||
min-width: 32px;
|
min-width: 32px;
|
||||||
}
|
width: 32px;
|
||||||
|
height: 24px;
|
||||||
.daterangepicker .calendar-table {
|
line-height: 24px;
|
||||||
border: 1px solid #fff;
|
font-size: 12px;
|
||||||
padding: 4px;
|
|
||||||
border-radius: 4px;
|
|
||||||
background-color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.daterangepicker table {
|
|
||||||
width: 100%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.daterangepicker td, .daterangepicker th {
|
|
||||||
text-align: center;
|
|
||||||
width: 20px;
|
|
||||||
height: 20px;
|
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.daterangepicker .calendar-table {
|
||||||
|
border: 1px solid #fff;
|
||||||
|
border-radius: 4px;
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.daterangepicker .calendar-table table {
|
||||||
|
width: 100%;
|
||||||
|
margin: 0;
|
||||||
|
border-spacing: 0;
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
|
||||||
.daterangepicker td.available:hover, .daterangepicker th.available:hover {
|
.daterangepicker td.available:hover, .daterangepicker th.available:hover {
|
||||||
background-color: #eee;
|
background-color: #eee;
|
||||||
border-color: transparent;
|
border-color: transparent;
|
||||||
@@ -204,53 +243,19 @@
|
|||||||
|
|
||||||
.daterangepicker select.hourselect, .daterangepicker select.minuteselect, .daterangepicker select.secondselect, .daterangepicker select.ampmselect {
|
.daterangepicker select.hourselect, .daterangepicker select.minuteselect, .daterangepicker select.secondselect, .daterangepicker select.ampmselect {
|
||||||
width: 50px;
|
width: 50px;
|
||||||
margin-bottom: 0;
|
margin: 0 auto;
|
||||||
}
|
background: #eee;
|
||||||
|
border: 1px solid #eee;
|
||||||
.daterangepicker .input-mini {
|
padding: 2px;
|
||||||
border: 1px solid #ccc;
|
outline: 0;
|
||||||
border-radius: 4px;
|
font-size: 12px;
|
||||||
color: #555;
|
|
||||||
height: 30px;
|
|
||||||
line-height: 30px;
|
|
||||||
display: block;
|
|
||||||
vertical-align: middle;
|
|
||||||
margin: 0 0 5px 0;
|
|
||||||
padding: 0 6px 0 28px;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.daterangepicker .input-mini.active {
|
|
||||||
border: 1px solid #08c;
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.daterangepicker .daterangepicker_input {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.daterangepicker .daterangepicker_input i {
|
|
||||||
position: absolute;
|
|
||||||
left: 8px;
|
|
||||||
top: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.daterangepicker.rtl .input-mini {
|
|
||||||
padding-right: 28px;
|
|
||||||
padding-left: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.daterangepicker.rtl .daterangepicker_input i {
|
|
||||||
left: auto;
|
|
||||||
right: 8px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.daterangepicker .calendar-time {
|
.daterangepicker .calendar-time {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin: 5px auto;
|
margin: 4px auto 0 auto;
|
||||||
line-height: 30px;
|
line-height: 30px;
|
||||||
position: relative;
|
position: relative;
|
||||||
padding-left: 28px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.daterangepicker .calendar-time select.disabled {
|
.daterangepicker .calendar-time select.disabled {
|
||||||
@@ -258,161 +263,126 @@
|
|||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ranges {
|
.daterangepicker .drp-buttons {
|
||||||
font-size: 11px;
|
clear: both;
|
||||||
float: none;
|
text-align: right;
|
||||||
margin: 4px;
|
padding: 8px;
|
||||||
text-align: left;
|
border-top: 1px solid #ddd;
|
||||||
|
display: none;
|
||||||
|
line-height: 12px;
|
||||||
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ranges ul {
|
.daterangepicker .drp-selected {
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 12px;
|
||||||
|
padding-right: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.daterangepicker .drp-buttons .btn {
|
||||||
|
margin-left: 8px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: bold;
|
||||||
|
padding: 4px 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.daterangepicker.show-ranges .drp-calendar.left {
|
||||||
|
border-left: 1px solid #ddd;
|
||||||
|
}
|
||||||
|
|
||||||
|
.daterangepicker .ranges {
|
||||||
|
float: none;
|
||||||
|
text-align: left;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.daterangepicker.show-calendar .ranges {
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.daterangepicker .ranges ul {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ranges li {
|
.daterangepicker .ranges li {
|
||||||
font-size: 13px;
|
font-size: 12px;
|
||||||
background-color: #f5f5f5;
|
padding: 8px 12px;
|
||||||
border: 1px solid #f5f5f5;
|
|
||||||
border-radius: 4px;
|
|
||||||
color: #08c;
|
|
||||||
padding: 3px 12px;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ranges li:hover {
|
.daterangepicker .ranges li:hover {
|
||||||
background-color: #08c;
|
background-color: #eee;
|
||||||
border: 1px solid #08c;
|
|
||||||
color: #fff;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ranges li.active {
|
.daterangepicker .ranges li.active {
|
||||||
background-color: #08c;
|
background-color: #08c;
|
||||||
border: 1px solid #08c;
|
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Larger Screen Styling */
|
/* Larger Screen Styling */
|
||||||
@media (min-width: 564px) {
|
@media (min-width: 564px) {
|
||||||
.daterangepicker {
|
.daterangepicker {
|
||||||
width: auto;
|
width: auto; }
|
||||||
}
|
|
||||||
|
|
||||||
.daterangepicker .ranges ul {
|
.daterangepicker .ranges ul {
|
||||||
width: 160px;
|
width: 140px; }
|
||||||
}
|
|
||||||
|
|
||||||
.daterangepicker.single .ranges ul {
|
.daterangepicker.single .ranges ul {
|
||||||
width: 100%;
|
width: 100%; }
|
||||||
}
|
.daterangepicker.single .drp-calendar.left {
|
||||||
|
clear: none; }
|
||||||
.daterangepicker.single .calendar.left {
|
.daterangepicker.single.ltr .ranges, .daterangepicker.single.ltr .drp-calendar {
|
||||||
clear: none;
|
float: left; }
|
||||||
}
|
.daterangepicker.single.rtl .ranges, .daterangepicker.single.rtl .drp-calendar {
|
||||||
|
float: right; }
|
||||||
.daterangepicker.single.ltr .ranges, .daterangepicker.single.ltr .calendar {
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.daterangepicker.single.rtl .ranges, .daterangepicker.single.rtl .calendar {
|
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.daterangepicker.ltr {
|
.daterangepicker.ltr {
|
||||||
direction: ltr;
|
direction: ltr;
|
||||||
text-align: left;
|
text-align: left; }
|
||||||
}
|
.daterangepicker.ltr .drp-calendar.left {
|
||||||
|
|
||||||
.daterangepicker.ltr .calendar.left {
|
|
||||||
clear: left;
|
clear: left;
|
||||||
margin-right: 0;
|
margin-right: 0; }
|
||||||
}
|
.daterangepicker.ltr .drp-calendar.left .calendar-table {
|
||||||
|
|
||||||
.daterangepicker.ltr .calendar.left .calendar-table {
|
|
||||||
border-right: none;
|
border-right: none;
|
||||||
border-top-right-radius: 0;
|
border-top-right-radius: 0;
|
||||||
border-bottom-right-radius: 0;
|
border-bottom-right-radius: 0; }
|
||||||
}
|
.daterangepicker.ltr .drp-calendar.right {
|
||||||
|
margin-left: 0; }
|
||||||
.daterangepicker.ltr .calendar.right {
|
.daterangepicker.ltr .drp-calendar.right .calendar-table {
|
||||||
margin-left: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.daterangepicker.ltr .calendar.right .calendar-table {
|
|
||||||
border-left: none;
|
border-left: none;
|
||||||
border-top-left-radius: 0;
|
border-top-left-radius: 0;
|
||||||
border-bottom-left-radius: 0;
|
border-bottom-left-radius: 0; }
|
||||||
}
|
.daterangepicker.ltr .drp-calendar.left .calendar-table {
|
||||||
|
padding-right: 8px; }
|
||||||
.daterangepicker.ltr .left .daterangepicker_input {
|
.daterangepicker.ltr .ranges, .daterangepicker.ltr .drp-calendar {
|
||||||
padding-right: 12px;
|
float: left; }
|
||||||
}
|
|
||||||
|
|
||||||
.daterangepicker.ltr .calendar.left .calendar-table {
|
|
||||||
padding-right: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.daterangepicker.ltr .ranges, .daterangepicker.ltr .calendar {
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.daterangepicker.rtl {
|
.daterangepicker.rtl {
|
||||||
direction: rtl;
|
direction: rtl;
|
||||||
text-align: right;
|
text-align: right; }
|
||||||
}
|
.daterangepicker.rtl .drp-calendar.left {
|
||||||
|
|
||||||
.daterangepicker.rtl .calendar.left {
|
|
||||||
clear: right;
|
clear: right;
|
||||||
margin-left: 0;
|
margin-left: 0; }
|
||||||
}
|
.daterangepicker.rtl .drp-calendar.left .calendar-table {
|
||||||
|
|
||||||
.daterangepicker.rtl .calendar.left .calendar-table {
|
|
||||||
border-left: none;
|
border-left: none;
|
||||||
border-top-left-radius: 0;
|
border-top-left-radius: 0;
|
||||||
border-bottom-left-radius: 0;
|
border-bottom-left-radius: 0; }
|
||||||
}
|
.daterangepicker.rtl .drp-calendar.right {
|
||||||
|
margin-right: 0; }
|
||||||
.daterangepicker.rtl .calendar.right {
|
.daterangepicker.rtl .drp-calendar.right .calendar-table {
|
||||||
margin-right: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.daterangepicker.rtl .calendar.right .calendar-table {
|
|
||||||
border-right: none;
|
border-right: none;
|
||||||
border-top-right-radius: 0;
|
border-top-right-radius: 0;
|
||||||
border-bottom-right-radius: 0;
|
border-bottom-right-radius: 0; }
|
||||||
}
|
.daterangepicker.rtl .drp-calendar.left .calendar-table {
|
||||||
|
padding-left: 12px; }
|
||||||
.daterangepicker.rtl .left .daterangepicker_input {
|
.daterangepicker.rtl .ranges, .daterangepicker.rtl .drp-calendar {
|
||||||
padding-left: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.daterangepicker.rtl .calendar.left .calendar-table {
|
|
||||||
padding-left: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.daterangepicker.rtl .ranges, .daterangepicker.rtl .calendar {
|
|
||||||
text-align: right;
|
text-align: right;
|
||||||
float: right;
|
float: right; } }
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 730px) {
|
@media (min-width: 730px) {
|
||||||
.daterangepicker .ranges {
|
.daterangepicker .ranges {
|
||||||
width: auto;
|
width: auto; }
|
||||||
}
|
|
||||||
|
|
||||||
.daterangepicker.ltr .ranges {
|
.daterangepicker.ltr .ranges {
|
||||||
float: left;
|
float: left; }
|
||||||
}
|
|
||||||
|
|
||||||
.daterangepicker.rtl .ranges {
|
.daterangepicker.rtl .ranges {
|
||||||
float: right;
|
float: right; }
|
||||||
}
|
.daterangepicker .drp-calendar.left {
|
||||||
|
clear: none !important; } }
|
||||||
.daterangepicker .calendar.left {
|
|
||||||
clear: none !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
343
public/v1/js/lib/daterangepicker.js
vendored
343
public/v1/js/lib/daterangepicker.js
vendored
@@ -1,16 +1,17 @@
|
|||||||
/**
|
/**
|
||||||
* @version: 2.1.30
|
* @version: 3.0.3
|
||||||
* @author: Dan Grossman http://www.dangrossman.info/
|
* @author: Dan Grossman http://www.dangrossman.info/
|
||||||
* @copyright: Copyright (c) 2012-2017 Dan Grossman. All rights reserved.
|
* @copyright: Copyright (c) 2012-2018 Dan Grossman. All rights reserved.
|
||||||
* @license: Licensed under the MIT license. See http://www.opensource.org/licenses/mit-license.php
|
* @license: Licensed under the MIT license. See http://www.opensource.org/licenses/mit-license.php
|
||||||
* @website: http://www.daterangepicker.com/
|
* @website: http://www.daterangepicker.com/
|
||||||
*/
|
*/
|
||||||
// Follow the UMD template https://github.com/umdjs/umd/blob/master/templates/returnExportsGlobal.js
|
// Following the UMD template https://github.com/umdjs/umd/blob/master/templates/returnExportsGlobal.js
|
||||||
(function (root, factory) {
|
(function (root, factory) {
|
||||||
if (typeof define === 'function' && define.amd) {
|
if (typeof define === 'function' && define.amd) {
|
||||||
// AMD. Make globaly available as well
|
// AMD. Make globaly available as well
|
||||||
define(['moment', 'jquery'], function (moment, jquery) {
|
define(['moment', 'jquery'], function (moment, jquery) {
|
||||||
if (!jquery.fn) jquery.fn = {}; // webpack server rendering
|
if (!jquery.fn) jquery.fn = {}; // webpack server rendering
|
||||||
|
if (typeof moment !== 'function' && moment.default) moment = moment.default
|
||||||
return factory(moment, jquery);
|
return factory(moment, jquery);
|
||||||
});
|
});
|
||||||
} else if (typeof module === 'object' && module.exports) {
|
} else if (typeof module === 'object' && module.exports) {
|
||||||
@@ -37,10 +38,12 @@
|
|||||||
this.endDate = moment().endOf('day');
|
this.endDate = moment().endOf('day');
|
||||||
this.minDate = false;
|
this.minDate = false;
|
||||||
this.maxDate = false;
|
this.maxDate = false;
|
||||||
this.dateLimit = false;
|
this.maxSpan = false;
|
||||||
this.autoApply = false;
|
this.autoApply = false;
|
||||||
this.singleDatePicker = false;
|
this.singleDatePicker = false;
|
||||||
this.showDropdowns = false;
|
this.showDropdowns = false;
|
||||||
|
this.minYear = moment().subtract(100, 'year').format('YYYY');
|
||||||
|
this.maxYear = moment().add(100, 'year').format('YYYY');
|
||||||
this.showWeekNumbers = false;
|
this.showWeekNumbers = false;
|
||||||
this.showISOWeekNumbers = false;
|
this.showISOWeekNumbers = false;
|
||||||
this.showCustomRangeLabel = true;
|
this.showCustomRangeLabel = true;
|
||||||
@@ -62,8 +65,8 @@
|
|||||||
this.drops = 'up';
|
this.drops = 'up';
|
||||||
|
|
||||||
this.buttonClasses = 'btn btn-sm';
|
this.buttonClasses = 'btn btn-sm';
|
||||||
this.applyClass = 'btn-success';
|
this.applyButtonClasses = 'btn-primary';
|
||||||
this.cancelClass = 'btn-default';
|
this.cancelButtonClasses = 'btn-default';
|
||||||
|
|
||||||
this.locale = {
|
this.locale = {
|
||||||
direction: 'ltr',
|
direction: 'ltr',
|
||||||
@@ -95,34 +98,21 @@
|
|||||||
|
|
||||||
//html template for the picker UI
|
//html template for the picker UI
|
||||||
if (typeof options.template !== 'string' && !(options.template instanceof $))
|
if (typeof options.template !== 'string' && !(options.template instanceof $))
|
||||||
options.template = '<div class="daterangepicker dropdown-menu">' +
|
options.template =
|
||||||
'<div class="calendar left">' +
|
'<div class="daterangepicker">' +
|
||||||
'<div class="daterangepicker_input">' +
|
'<div class="ranges"></div>' +
|
||||||
'<input class="input-mini form-control" type="text" name="daterangepicker_start" value="" />' +
|
'<div class="drp-calendar left">' +
|
||||||
'<i class="fa fa-calendar glyphicon glyphicon-calendar"></i>' +
|
|
||||||
'<div class="calendar-time">' +
|
|
||||||
'<div></div>' +
|
|
||||||
'<i class="fa fa-clock-o glyphicon glyphicon-time"></i>' +
|
|
||||||
'</div>' +
|
|
||||||
'</div>' +
|
|
||||||
'<div class="calendar-table"></div>' +
|
'<div class="calendar-table"></div>' +
|
||||||
|
'<div class="calendar-time"></div>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'<div class="calendar right">' +
|
'<div class="drp-calendar right">' +
|
||||||
'<div class="daterangepicker_input">' +
|
|
||||||
'<input class="input-mini form-control" type="text" name="daterangepicker_end" value="" />' +
|
|
||||||
'<i class="fa fa-calendar glyphicon glyphicon-calendar"></i>' +
|
|
||||||
'<div class="calendar-time">' +
|
|
||||||
'<div></div>' +
|
|
||||||
'<i class="fa fa-clock-o glyphicon glyphicon-time"></i>' +
|
|
||||||
'</div>' +
|
|
||||||
'</div>' +
|
|
||||||
'<div class="calendar-table"></div>' +
|
'<div class="calendar-table"></div>' +
|
||||||
|
'<div class="calendar-time"></div>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'<div class="ranges">' +
|
'<div class="drp-buttons">' +
|
||||||
'<div class="range_inputs">' +
|
'<span class="drp-selected"></span>' +
|
||||||
'<button class="applyBtn" disabled="disabled" type="button"></button> ' +
|
|
||||||
'<button class="cancelBtn" type="button"></button>' +
|
'<button class="cancelBtn" type="button"></button>' +
|
||||||
'</div>' +
|
'<button class="applyBtn" disabled="disabled" type="button"></button> ' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
|
|
||||||
@@ -204,14 +194,23 @@
|
|||||||
if (this.maxDate && this.endDate.isAfter(this.maxDate))
|
if (this.maxDate && this.endDate.isAfter(this.maxDate))
|
||||||
this.endDate = this.maxDate.clone();
|
this.endDate = this.maxDate.clone();
|
||||||
|
|
||||||
if (typeof options.applyClass === 'string')
|
if (typeof options.applyButtonClasses === 'string')
|
||||||
this.applyClass = options.applyClass;
|
this.applyButtonClasses = options.applyButtonClasses;
|
||||||
|
|
||||||
if (typeof options.cancelClass === 'string')
|
if (typeof options.applyClass === 'string') //backwards compat
|
||||||
this.cancelClass = options.cancelClass;
|
this.applyButtonClasses = options.applyClass;
|
||||||
|
|
||||||
if (typeof options.dateLimit === 'object')
|
if (typeof options.cancelButtonClasses === 'string')
|
||||||
this.dateLimit = options.dateLimit;
|
this.cancelButtonClasses = options.cancelButtonClasses;
|
||||||
|
|
||||||
|
if (typeof options.cancelClass === 'string') //backwards compat
|
||||||
|
this.cancelButtonClasses = options.cancelClass;
|
||||||
|
|
||||||
|
if (typeof options.maxSpan === 'object')
|
||||||
|
this.maxSpan = options.maxSpan;
|
||||||
|
|
||||||
|
if (typeof options.dateLimit === 'object') //backwards compat
|
||||||
|
this.maxSpan = options.dateLimit;
|
||||||
|
|
||||||
if (typeof options.opens === 'string')
|
if (typeof options.opens === 'string')
|
||||||
this.opens = options.opens;
|
this.opens = options.opens;
|
||||||
@@ -234,6 +233,12 @@
|
|||||||
if (typeof options.showDropdowns === 'boolean')
|
if (typeof options.showDropdowns === 'boolean')
|
||||||
this.showDropdowns = options.showDropdowns;
|
this.showDropdowns = options.showDropdowns;
|
||||||
|
|
||||||
|
if (typeof options.minYear === 'number')
|
||||||
|
this.minYear = options.minYear;
|
||||||
|
|
||||||
|
if (typeof options.maxYear === 'number')
|
||||||
|
this.maxYear = options.maxYear;
|
||||||
|
|
||||||
if (typeof options.showCustomRangeLabel === 'boolean')
|
if (typeof options.showCustomRangeLabel === 'boolean')
|
||||||
this.showCustomRangeLabel = options.showCustomRangeLabel;
|
this.showCustomRangeLabel = options.showCustomRangeLabel;
|
||||||
|
|
||||||
@@ -286,7 +291,7 @@
|
|||||||
|
|
||||||
//if no start/end dates set, check if an input element contains initial values
|
//if no start/end dates set, check if an input element contains initial values
|
||||||
if (typeof options.startDate === 'undefined' && typeof options.endDate === 'undefined') {
|
if (typeof options.startDate === 'undefined' && typeof options.endDate === 'undefined') {
|
||||||
if ($(this.element).is('input[type=text]')) {
|
if ($(this.element).is(':text')) {
|
||||||
var val = $(this.element).val(),
|
var val = $(this.element).val(),
|
||||||
split = val.split(this.locale.separator);
|
split = val.split(this.locale.separator);
|
||||||
|
|
||||||
@@ -319,14 +324,14 @@
|
|||||||
else
|
else
|
||||||
end = moment(options.ranges[range][1]);
|
end = moment(options.ranges[range][1]);
|
||||||
|
|
||||||
// If the start or end date exceed those allowed by the minDate or dateLimit
|
// If the start or end date exceed those allowed by the minDate or maxSpan
|
||||||
// options, shorten the range to the allowable period.
|
// options, shorten the range to the allowable period.
|
||||||
if (this.minDate && start.isBefore(this.minDate))
|
if (this.minDate && start.isBefore(this.minDate))
|
||||||
start = this.minDate.clone();
|
start = this.minDate.clone();
|
||||||
|
|
||||||
var maxDate = this.maxDate;
|
var maxDate = this.maxDate;
|
||||||
if (this.dateLimit && maxDate && start.clone().add(this.dateLimit).isAfter(maxDate))
|
if (this.maxSpan && maxDate && start.clone().add(this.maxSpan).isAfter(maxDate))
|
||||||
maxDate = start.clone().add(this.dateLimit);
|
maxDate = start.clone().add(this.maxSpan);
|
||||||
if (maxDate && end.isAfter(maxDate))
|
if (maxDate && end.isAfter(maxDate))
|
||||||
end = maxDate.clone();
|
end = maxDate.clone();
|
||||||
|
|
||||||
@@ -369,22 +374,20 @@
|
|||||||
if (this.timePicker && this.autoApply)
|
if (this.timePicker && this.autoApply)
|
||||||
this.autoApply = false;
|
this.autoApply = false;
|
||||||
|
|
||||||
if (this.autoApply && typeof options.ranges !== 'object') {
|
if (this.autoApply) {
|
||||||
this.container.find('.ranges').hide();
|
this.container.addClass('auto-apply');
|
||||||
} else if (this.autoApply) {
|
|
||||||
this.container.find('.applyBtn, .cancelBtn').addClass('hide');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof options.ranges === 'object')
|
||||||
|
this.container.addClass('show-ranges');
|
||||||
|
|
||||||
if (this.singleDatePicker) {
|
if (this.singleDatePicker) {
|
||||||
this.container.addClass('single');
|
this.container.addClass('single');
|
||||||
this.container.find('.calendar.left').addClass('single');
|
this.container.find('.drp-calendar.left').addClass('single');
|
||||||
this.container.find('.calendar.left').show();
|
this.container.find('.drp-calendar.left').show();
|
||||||
this.container.find('.calendar.right').hide();
|
this.container.find('.drp-calendar.right').hide();
|
||||||
this.container.find('.daterangepicker_input input, .daterangepicker_input > i').hide();
|
if (!this.timePicker) {
|
||||||
if (this.timePicker) {
|
this.container.addClass('auto-apply');
|
||||||
this.container.find('.ranges ul').hide();
|
|
||||||
} else {
|
|
||||||
this.container.find('.ranges').hide();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -394,17 +397,12 @@
|
|||||||
|
|
||||||
this.container.addClass('opens' + this.opens);
|
this.container.addClass('opens' + this.opens);
|
||||||
|
|
||||||
//swap the position of the predefined ranges if opens right
|
|
||||||
if (typeof options.ranges !== 'undefined' && this.opens == 'right') {
|
|
||||||
this.container.find('.ranges').prependTo( this.container.find('.calendar.left').parent() );
|
|
||||||
}
|
|
||||||
|
|
||||||
//apply CSS classes and labels to buttons
|
//apply CSS classes and labels to buttons
|
||||||
this.container.find('.applyBtn, .cancelBtn').addClass(this.buttonClasses);
|
this.container.find('.applyBtn, .cancelBtn').addClass(this.buttonClasses);
|
||||||
if (this.applyClass.length)
|
if (this.applyButtonClasses.length)
|
||||||
this.container.find('.applyBtn').addClass(this.applyClass);
|
this.container.find('.applyBtn').addClass(this.applyButtonClasses);
|
||||||
if (this.cancelClass.length)
|
if (this.cancelButtonClasses.length)
|
||||||
this.container.find('.cancelBtn').addClass(this.cancelClass);
|
this.container.find('.cancelBtn').addClass(this.cancelButtonClasses);
|
||||||
this.container.find('.applyBtn').html(this.locale.applyLabel);
|
this.container.find('.applyBtn').html(this.locale.applyLabel);
|
||||||
this.container.find('.cancelBtn').html(this.locale.cancelLabel);
|
this.container.find('.cancelBtn').html(this.locale.cancelLabel);
|
||||||
|
|
||||||
@@ -412,27 +410,21 @@
|
|||||||
// event listeners
|
// event listeners
|
||||||
//
|
//
|
||||||
|
|
||||||
this.container.find('.calendar')
|
this.container.find('.drp-calendar')
|
||||||
.on('click.daterangepicker', '.prev', $.proxy(this.clickPrev, this))
|
.on('click.daterangepicker', '.prev', $.proxy(this.clickPrev, this))
|
||||||
.on('click.daterangepicker', '.next', $.proxy(this.clickNext, this))
|
.on('click.daterangepicker', '.next', $.proxy(this.clickNext, this))
|
||||||
.on('mousedown.daterangepicker', 'td.available', $.proxy(this.clickDate, this))
|
.on('mousedown.daterangepicker', 'td.available', $.proxy(this.clickDate, this))
|
||||||
.on('mouseenter.daterangepicker', 'td.available', $.proxy(this.hoverDate, this))
|
.on('mouseenter.daterangepicker', 'td.available', $.proxy(this.hoverDate, this))
|
||||||
.on('mouseleave.daterangepicker', 'td.available', $.proxy(this.updateFormInputs, this))
|
|
||||||
.on('change.daterangepicker', 'select.yearselect', $.proxy(this.monthOrYearChanged, this))
|
.on('change.daterangepicker', 'select.yearselect', $.proxy(this.monthOrYearChanged, this))
|
||||||
.on('change.daterangepicker', 'select.monthselect', $.proxy(this.monthOrYearChanged, this))
|
.on('change.daterangepicker', 'select.monthselect', $.proxy(this.monthOrYearChanged, this))
|
||||||
.on('change.daterangepicker', 'select.hourselect,select.minuteselect,select.secondselect,select.ampmselect', $.proxy(this.timeChanged, this))
|
.on('change.daterangepicker', 'select.hourselect,select.minuteselect,select.secondselect,select.ampmselect', $.proxy(this.timeChanged, this))
|
||||||
.on('click.daterangepicker', '.daterangepicker_input input', $.proxy(this.showCalendars, this))
|
|
||||||
.on('focus.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsFocused, this))
|
|
||||||
.on('blur.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsBlurred, this))
|
|
||||||
.on('change.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsChanged, this))
|
|
||||||
.on('keydown.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsKeydown, this));
|
|
||||||
|
|
||||||
this.container.find('.ranges')
|
this.container.find('.ranges')
|
||||||
|
.on('click.daterangepicker', 'li', $.proxy(this.clickRange, this))
|
||||||
|
|
||||||
|
this.container.find('.drp-buttons')
|
||||||
.on('click.daterangepicker', 'button.applyBtn', $.proxy(this.clickApply, this))
|
.on('click.daterangepicker', 'button.applyBtn', $.proxy(this.clickApply, this))
|
||||||
.on('click.daterangepicker', 'button.cancelBtn', $.proxy(this.clickCancel, this))
|
.on('click.daterangepicker', 'button.cancelBtn', $.proxy(this.clickCancel, this))
|
||||||
.on('click.daterangepicker', 'li', $.proxy(this.clickRange, this))
|
|
||||||
.on('mouseenter.daterangepicker', 'li', $.proxy(this.hoverRange, this))
|
|
||||||
.on('mouseleave.daterangepicker', 'li', $.proxy(this.updateFormInputs, this));
|
|
||||||
|
|
||||||
if (this.element.is('input') || this.element.is('button')) {
|
if (this.element.is('input') || this.element.is('button')) {
|
||||||
this.element.on({
|
this.element.on({
|
||||||
@@ -450,13 +442,7 @@
|
|||||||
// if attached to a text input, set the initial value
|
// if attached to a text input, set the initial value
|
||||||
//
|
//
|
||||||
|
|
||||||
if (this.element.is('input') && !this.singleDatePicker && this.autoUpdateInput) {
|
this.updateElement();
|
||||||
this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
|
|
||||||
this.element.trigger('change');
|
|
||||||
} else if (this.element.is('input') && this.autoUpdateInput) {
|
|
||||||
this.element.val(this.startDate.format(this.locale.format));
|
|
||||||
this.element.trigger('change');
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -514,11 +500,13 @@
|
|||||||
if (this.maxDate && this.endDate.isAfter(this.maxDate))
|
if (this.maxDate && this.endDate.isAfter(this.maxDate))
|
||||||
this.endDate = this.maxDate.clone();
|
this.endDate = this.maxDate.clone();
|
||||||
|
|
||||||
if (this.dateLimit && this.startDate.clone().add(this.dateLimit).isBefore(this.endDate))
|
if (this.maxSpan && this.startDate.clone().add(this.maxSpan).isBefore(this.endDate))
|
||||||
this.endDate = this.startDate.clone().add(this.dateLimit);
|
this.endDate = this.startDate.clone().add(this.maxSpan);
|
||||||
|
|
||||||
this.previousRightTime = this.endDate.clone();
|
this.previousRightTime = this.endDate.clone();
|
||||||
|
|
||||||
|
this.container.find('.drp-selected').html(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
|
||||||
|
|
||||||
if (!this.isShowing)
|
if (!this.isShowing)
|
||||||
this.updateElement();
|
this.updateElement();
|
||||||
|
|
||||||
@@ -543,13 +531,8 @@
|
|||||||
this.container.find('.right .calendar-time select').removeAttr('disabled').removeClass('disabled');
|
this.container.find('.right .calendar-time select').removeAttr('disabled').removeClass('disabled');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.endDate) {
|
if (this.endDate)
|
||||||
this.container.find('input[name="daterangepicker_end"]').removeClass('active');
|
this.container.find('.drp-selected').html(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
|
||||||
this.container.find('input[name="daterangepicker_start"]').addClass('active');
|
|
||||||
} else {
|
|
||||||
this.container.find('input[name="daterangepicker_end"]').addClass('active');
|
|
||||||
this.container.find('input[name="daterangepicker_start"]').removeClass('active');
|
|
||||||
}
|
|
||||||
this.updateMonthsInView();
|
this.updateMonthsInView();
|
||||||
this.updateCalendars();
|
this.updateCalendars();
|
||||||
this.updateFormInputs();
|
this.updateFormInputs();
|
||||||
@@ -710,7 +693,7 @@
|
|||||||
html += '<th></th>';
|
html += '<th></th>';
|
||||||
|
|
||||||
if ((!minDate || minDate.isBefore(calendar.firstDay)) && (!this.linkedCalendars || side == 'left')) {
|
if ((!minDate || minDate.isBefore(calendar.firstDay)) && (!this.linkedCalendars || side == 'left')) {
|
||||||
html += '<th class="prev available"><i class="fa fa-' + arrow.left + ' glyphicon glyphicon-' + arrow.left + '"></i></th>';
|
html += '<th class="prev available"><span></span></th>';
|
||||||
} else {
|
} else {
|
||||||
html += '<th></th>';
|
html += '<th></th>';
|
||||||
}
|
}
|
||||||
@@ -720,8 +703,8 @@
|
|||||||
if (this.showDropdowns) {
|
if (this.showDropdowns) {
|
||||||
var currentMonth = calendar[1][1].month();
|
var currentMonth = calendar[1][1].month();
|
||||||
var currentYear = calendar[1][1].year();
|
var currentYear = calendar[1][1].year();
|
||||||
var maxYear = (maxDate && maxDate.year()) || (currentYear + 5);
|
var maxYear = (maxDate && maxDate.year()) || (this.maxYear);
|
||||||
var minYear = (minDate && minDate.year()) || (currentYear - 50);
|
var minYear = (minDate && minDate.year()) || (this.minYear);
|
||||||
var inMinYear = currentYear == minYear;
|
var inMinYear = currentYear == minYear;
|
||||||
var inMaxYear = currentYear == maxYear;
|
var inMaxYear = currentYear == maxYear;
|
||||||
|
|
||||||
@@ -752,7 +735,7 @@
|
|||||||
|
|
||||||
html += '<th colspan="5" class="month">' + dateHtml + '</th>';
|
html += '<th colspan="5" class="month">' + dateHtml + '</th>';
|
||||||
if ((!maxDate || maxDate.isAfter(calendar.lastDay)) && (!this.linkedCalendars || side == 'right' || this.singleDatePicker)) {
|
if ((!maxDate || maxDate.isAfter(calendar.lastDay)) && (!this.linkedCalendars || side == 'right' || this.singleDatePicker)) {
|
||||||
html += '<th class="next available"><i class="fa fa-' + arrow.right + ' glyphicon glyphicon-' + arrow.right + '"></i></th>';
|
html += '<th class="next available"><span></span></th>';
|
||||||
} else {
|
} else {
|
||||||
html += '<th></th>';
|
html += '<th></th>';
|
||||||
}
|
}
|
||||||
@@ -772,10 +755,10 @@
|
|||||||
html += '</thead>';
|
html += '</thead>';
|
||||||
html += '<tbody>';
|
html += '<tbody>';
|
||||||
|
|
||||||
//adjust maxDate to reflect the dateLimit setting in order to
|
//adjust maxDate to reflect the maxSpan setting in order to
|
||||||
//grey out end dates beyond the dateLimit
|
//grey out end dates beyond the maxSpan
|
||||||
if (this.endDate == null && this.dateLimit) {
|
if (this.endDate == null && this.maxSpan) {
|
||||||
var maxLimit = this.startDate.clone().add(this.dateLimit).endOf('day');
|
var maxLimit = this.startDate.clone().add(this.maxSpan).endOf('day');
|
||||||
if (!maxDate || maxLimit.isBefore(maxDate)) {
|
if (!maxDate || maxLimit.isBefore(maxDate)) {
|
||||||
maxDate = maxLimit;
|
maxDate = maxLimit;
|
||||||
}
|
}
|
||||||
@@ -857,7 +840,7 @@
|
|||||||
html += '</tbody>';
|
html += '</tbody>';
|
||||||
html += '</table>';
|
html += '</table>';
|
||||||
|
|
||||||
this.container.find('.calendar.' + side + ' .calendar-table').html(html);
|
this.container.find('.drp-calendar.' + side + ' .calendar-table').html(html);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -869,8 +852,8 @@
|
|||||||
|
|
||||||
var html, selected, minDate, maxDate = this.maxDate;
|
var html, selected, minDate, maxDate = this.maxDate;
|
||||||
|
|
||||||
if (this.dateLimit && (!this.maxDate || this.startDate.clone().add(this.dateLimit).isAfter(this.maxDate)))
|
if (this.maxSpan && (!this.maxDate || this.startDate.clone().add(this.maxSpan).isAfter(this.maxDate)))
|
||||||
maxDate = this.startDate.clone().add(this.dateLimit);
|
maxDate = this.startDate.clone().add(this.maxSpan);
|
||||||
|
|
||||||
if (side == 'left') {
|
if (side == 'left') {
|
||||||
selected = this.startDate.clone();
|
selected = this.startDate.clone();
|
||||||
@@ -880,12 +863,12 @@
|
|||||||
minDate = this.startDate;
|
minDate = this.startDate;
|
||||||
|
|
||||||
//Preserve the time already selected
|
//Preserve the time already selected
|
||||||
var timeSelector = this.container.find('.calendar.right .calendar-time div');
|
var timeSelector = this.container.find('.drp-calendar.right .calendar-time');
|
||||||
if (timeSelector.html() != '') {
|
if (timeSelector.html() != '') {
|
||||||
|
|
||||||
selected.hour(timeSelector.find('.hourselect option:selected').val() || selected.hour());
|
selected.hour(selected.hour() || timeSelector.find('.hourselect option:selected').val());
|
||||||
selected.minute(timeSelector.find('.minuteselect option:selected').val() || selected.minute());
|
selected.minute(selected.minute() || timeSelector.find('.minuteselect option:selected').val());
|
||||||
selected.second(timeSelector.find('.secondselect option:selected').val() || selected.second());
|
selected.second(selected.second() || timeSelector.find('.secondselect option:selected').val());
|
||||||
|
|
||||||
if (!this.timePicker24Hour) {
|
if (!this.timePicker24Hour) {
|
||||||
var ampm = timeSelector.find('.ampmselect option:selected').val();
|
var ampm = timeSelector.find('.ampmselect option:selected').val();
|
||||||
@@ -1018,20 +1001,12 @@
|
|||||||
html += '</select>';
|
html += '</select>';
|
||||||
}
|
}
|
||||||
|
|
||||||
this.container.find('.calendar.' + side + ' .calendar-time div').html(html);
|
this.container.find('.drp-calendar.' + side + ' .calendar-time').html(html);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
updateFormInputs: function() {
|
updateFormInputs: function() {
|
||||||
|
|
||||||
//ignore mouse movements while an above-calendar text input has focus
|
|
||||||
if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
this.container.find('input[name=daterangepicker_start]').val(this.startDate.format(this.locale.format));
|
|
||||||
if (this.endDate)
|
|
||||||
this.container.find('input[name=daterangepicker_end]').val(this.endDate.format(this.locale.format));
|
|
||||||
|
|
||||||
if (this.singleDatePicker || (this.endDate && (this.startDate.isBefore(this.endDate) || this.startDate.isSame(this.endDate)))) {
|
if (this.singleDatePicker || (this.endDate && (this.startDate.isBefore(this.endDate) || this.startDate.isSame(this.endDate)))) {
|
||||||
this.container.find('button.applyBtn').removeAttr('disabled');
|
this.container.find('button.applyBtn').removeAttr('disabled');
|
||||||
} else {
|
} else {
|
||||||
@@ -1056,7 +1031,7 @@
|
|||||||
containerTop = this.element.offset().top - this.container.outerHeight() - parentOffset.top;
|
containerTop = this.element.offset().top - this.container.outerHeight() - parentOffset.top;
|
||||||
else
|
else
|
||||||
containerTop = this.element.offset().top + this.element.outerHeight() - parentOffset.top;
|
containerTop = this.element.offset().top + this.element.outerHeight() - parentOffset.top;
|
||||||
this.container[this.drops == 'up' ? 'addClass' : 'removeClass']('dropup');
|
this.container[this.drops == 'up' ? 'addClass' : 'removeClass']('drop-up');
|
||||||
|
|
||||||
if (this.opens == 'left') {
|
if (this.opens == 'left') {
|
||||||
this.container.css({
|
this.container.css({
|
||||||
@@ -1139,7 +1114,7 @@
|
|||||||
|
|
||||||
//if a new date range was selected, invoke the user callback function
|
//if a new date range was selected, invoke the user callback function
|
||||||
if (!this.startDate.isSame(this.oldStartDate) || !this.endDate.isSame(this.oldEndDate))
|
if (!this.startDate.isSame(this.oldStartDate) || !this.endDate.isSame(this.oldEndDate))
|
||||||
this.callback(this.startDate, this.endDate, this.chosenLabel);
|
this.callback(this.startDate.clone(), this.endDate.clone(), this.chosenLabel);
|
||||||
|
|
||||||
//if picker is attached to a text input, update it
|
//if picker is attached to a text input, update it
|
||||||
this.updateElement();
|
this.updateElement();
|
||||||
@@ -1185,24 +1160,6 @@
|
|||||||
this.element.trigger('hideCalendar.daterangepicker', this);
|
this.element.trigger('hideCalendar.daterangepicker', this);
|
||||||
},
|
},
|
||||||
|
|
||||||
hoverRange: function(e) {
|
|
||||||
|
|
||||||
//ignore mouse movements while an above-calendar text input has focus
|
|
||||||
if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
var label = e.target.getAttribute('data-range-key');
|
|
||||||
|
|
||||||
if (label == this.locale.customRangeLabel) {
|
|
||||||
this.updateView();
|
|
||||||
} else {
|
|
||||||
var dates = this.ranges[label];
|
|
||||||
this.container.find('input[name=daterangepicker_start]').val(dates[0].format(this.locale.format));
|
|
||||||
this.container.find('input[name=daterangepicker_end]').val(dates[1].format(this.locale.format));
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
clickRange: function(e) {
|
clickRange: function(e) {
|
||||||
var label = e.target.getAttribute('data-range-key');
|
var label = e.target.getAttribute('data-range-key');
|
||||||
this.chosenLabel = label;
|
this.chosenLabel = label;
|
||||||
@@ -1225,7 +1182,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
clickPrev: function(e) {
|
clickPrev: function(e) {
|
||||||
var cal = $(e.target).parents('.calendar');
|
var cal = $(e.target).parents('.drp-calendar');
|
||||||
if (cal.hasClass('left')) {
|
if (cal.hasClass('left')) {
|
||||||
this.leftCalendar.month.subtract(1, 'month');
|
this.leftCalendar.month.subtract(1, 'month');
|
||||||
if (this.linkedCalendars)
|
if (this.linkedCalendars)
|
||||||
@@ -1237,7 +1194,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
clickNext: function(e) {
|
clickNext: function(e) {
|
||||||
var cal = $(e.target).parents('.calendar');
|
var cal = $(e.target).parents('.drp-calendar');
|
||||||
if (cal.hasClass('left')) {
|
if (cal.hasClass('left')) {
|
||||||
this.leftCalendar.month.add(1, 'month');
|
this.leftCalendar.month.add(1, 'month');
|
||||||
} else {
|
} else {
|
||||||
@@ -1250,32 +1207,21 @@
|
|||||||
|
|
||||||
hoverDate: function(e) {
|
hoverDate: function(e) {
|
||||||
|
|
||||||
//ignore mouse movements while an above-calendar text input has focus
|
|
||||||
//if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus"))
|
|
||||||
// return;
|
|
||||||
|
|
||||||
//ignore dates that can't be selected
|
//ignore dates that can't be selected
|
||||||
if (!$(e.target).hasClass('available')) return;
|
if (!$(e.target).hasClass('available')) return;
|
||||||
|
|
||||||
//have the text inputs above calendars reflect the date being hovered over
|
|
||||||
var title = $(e.target).attr('data-title');
|
var title = $(e.target).attr('data-title');
|
||||||
var row = title.substr(1, 1);
|
var row = title.substr(1, 1);
|
||||||
var col = title.substr(3, 1);
|
var col = title.substr(3, 1);
|
||||||
var cal = $(e.target).parents('.calendar');
|
var cal = $(e.target).parents('.drp-calendar');
|
||||||
var date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col];
|
var date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col];
|
||||||
|
|
||||||
if (this.endDate && !this.container.find('input[name=daterangepicker_start]').is(":focus")) {
|
|
||||||
this.container.find('input[name=daterangepicker_start]').val(date.format(this.locale.format));
|
|
||||||
} else if (!this.endDate && !this.container.find('input[name=daterangepicker_end]').is(":focus")) {
|
|
||||||
this.container.find('input[name=daterangepicker_end]').val(date.format(this.locale.format));
|
|
||||||
}
|
|
||||||
|
|
||||||
//highlight the dates between the start date and the date being hovered as a potential end date
|
//highlight the dates between the start date and the date being hovered as a potential end date
|
||||||
var leftCalendar = this.leftCalendar;
|
var leftCalendar = this.leftCalendar;
|
||||||
var rightCalendar = this.rightCalendar;
|
var rightCalendar = this.rightCalendar;
|
||||||
var startDate = this.startDate;
|
var startDate = this.startDate;
|
||||||
if (!this.endDate) {
|
if (!this.endDate) {
|
||||||
this.container.find('.calendar tbody td').each(function(index, el) {
|
this.container.find('.drp-calendar tbody td').each(function(index, el) {
|
||||||
|
|
||||||
//skip week numbers, only look at dates
|
//skip week numbers, only look at dates
|
||||||
if ($(el).hasClass('week')) return;
|
if ($(el).hasClass('week')) return;
|
||||||
@@ -1283,7 +1229,7 @@
|
|||||||
var title = $(el).attr('data-title');
|
var title = $(el).attr('data-title');
|
||||||
var row = title.substr(1, 1);
|
var row = title.substr(1, 1);
|
||||||
var col = title.substr(3, 1);
|
var col = title.substr(3, 1);
|
||||||
var cal = $(el).parents('.calendar');
|
var cal = $(el).parents('.drp-calendar');
|
||||||
var dt = cal.hasClass('left') ? leftCalendar.calendar[row][col] : rightCalendar.calendar[row][col];
|
var dt = cal.hasClass('left') ? leftCalendar.calendar[row][col] : rightCalendar.calendar[row][col];
|
||||||
|
|
||||||
if ((dt.isAfter(startDate) && dt.isBefore(date)) || dt.isSame(date, 'day')) {
|
if ((dt.isAfter(startDate) && dt.isBefore(date)) || dt.isSame(date, 'day')) {
|
||||||
@@ -1304,7 +1250,7 @@
|
|||||||
var title = $(e.target).attr('data-title');
|
var title = $(e.target).attr('data-title');
|
||||||
var row = title.substr(1, 1);
|
var row = title.substr(1, 1);
|
||||||
var col = title.substr(3, 1);
|
var col = title.substr(3, 1);
|
||||||
var cal = $(e.target).parents('.calendar');
|
var cal = $(e.target).parents('.drp-calendar');
|
||||||
var date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col];
|
var date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col];
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -1375,18 +1321,18 @@
|
|||||||
var i = 0;
|
var i = 0;
|
||||||
for (var range in this.ranges) {
|
for (var range in this.ranges) {
|
||||||
if (this.timePicker) {
|
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
|
//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)) {
|
if (this.startDate.format(format) == this.ranges[range][0].format(format) && this.endDate.format(format) == this.ranges[range][1].format(format)) {
|
||||||
customRange = false;
|
customRange = false;
|
||||||
this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').html();
|
this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').attr('data-range-key');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//ignore times when comparing dates if time picker is not enabled
|
//ignore times when comparing dates if time picker is not enabled
|
||||||
if (this.startDate.format('YYYY-MM-DD') == this.ranges[range][0].format('YYYY-MM-DD') && this.endDate.format('YYYY-MM-DD') == this.ranges[range][1].format('YYYY-MM-DD')) {
|
if (this.startDate.format('YYYY-MM-DD') == this.ranges[range][0].format('YYYY-MM-DD') && this.endDate.format('YYYY-MM-DD') == this.ranges[range][1].format('YYYY-MM-DD')) {
|
||||||
customRange = false;
|
customRange = false;
|
||||||
this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').html();
|
this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').attr('data-range-key');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1394,7 +1340,7 @@
|
|||||||
}
|
}
|
||||||
if (customRange) {
|
if (customRange) {
|
||||||
if (this.showCustomRangeLabel) {
|
if (this.showCustomRangeLabel) {
|
||||||
this.chosenLabel = this.container.find('.ranges li:last').addClass('active').html();
|
this.chosenLabel = this.container.find('.ranges li:last').addClass('active').attr('data-range-key');
|
||||||
} else {
|
} else {
|
||||||
this.chosenLabel = null;
|
this.chosenLabel = null;
|
||||||
}
|
}
|
||||||
@@ -1415,9 +1361,9 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
monthOrYearChanged: function(e) {
|
monthOrYearChanged: function(e) {
|
||||||
var isLeft = $(e.target).closest('.calendar').hasClass('left'),
|
var isLeft = $(e.target).closest('.drp-calendar').hasClass('left'),
|
||||||
leftOrRight = isLeft ? 'left' : 'right',
|
leftOrRight = isLeft ? 'left' : 'right',
|
||||||
cal = this.container.find('.calendar.'+leftOrRight);
|
cal = this.container.find('.drp-calendar.'+leftOrRight);
|
||||||
|
|
||||||
// Month must be Number for new moment versions
|
// Month must be Number for new moment versions
|
||||||
var month = parseInt(cal.find('.monthselect').val(), 10);
|
var month = parseInt(cal.find('.monthselect').val(), 10);
|
||||||
@@ -1458,7 +1404,7 @@
|
|||||||
|
|
||||||
timeChanged: function(e) {
|
timeChanged: function(e) {
|
||||||
|
|
||||||
var cal = $(e.target).closest('.calendar'),
|
var cal = $(e.target).closest('.drp-calendar'),
|
||||||
isLeft = cal.hasClass('left');
|
isLeft = cal.hasClass('left');
|
||||||
|
|
||||||
var hour = parseInt(cal.find('.hourselect').val(), 10);
|
var hour = parseInt(cal.find('.hourselect').val(), 10);
|
||||||
@@ -1504,81 +1450,6 @@
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
formInputsChanged: function(e) {
|
|
||||||
var isRight = $(e.target).closest('.calendar').hasClass('right');
|
|
||||||
var start = moment(this.container.find('input[name="daterangepicker_start"]').val(), this.locale.format);
|
|
||||||
var end = moment(this.container.find('input[name="daterangepicker_end"]').val(), this.locale.format);
|
|
||||||
|
|
||||||
if (start.isValid() && end.isValid()) {
|
|
||||||
|
|
||||||
if (isRight && end.isBefore(start))
|
|
||||||
start = end.clone();
|
|
||||||
|
|
||||||
this.setStartDate(start);
|
|
||||||
this.setEndDate(end);
|
|
||||||
|
|
||||||
if (isRight) {
|
|
||||||
this.container.find('input[name="daterangepicker_start"]').val(this.startDate.format(this.locale.format));
|
|
||||||
} else {
|
|
||||||
this.container.find('input[name="daterangepicker_end"]').val(this.endDate.format(this.locale.format));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
this.updateView();
|
|
||||||
},
|
|
||||||
|
|
||||||
formInputsFocused: function(e) {
|
|
||||||
|
|
||||||
// Highlight the focused input
|
|
||||||
this.container.find('input[name="daterangepicker_start"], input[name="daterangepicker_end"]').removeClass('active');
|
|
||||||
$(e.target).addClass('active');
|
|
||||||
|
|
||||||
// Set the state such that if the user goes back to using a mouse,
|
|
||||||
// the calendars are aware we're selecting the end of the range, not
|
|
||||||
// the start. This allows someone to edit the end of a date range without
|
|
||||||
// re-selecting the beginning, by clicking on the end date input then
|
|
||||||
// using the calendar.
|
|
||||||
var isRight = $(e.target).closest('.calendar').hasClass('right');
|
|
||||||
if (isRight) {
|
|
||||||
this.endDate = null;
|
|
||||||
this.setStartDate(this.startDate.clone());
|
|
||||||
this.updateView();
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
formInputsBlurred: function(e) {
|
|
||||||
|
|
||||||
// this function has one purpose right now: if you tab from the first
|
|
||||||
// text input to the second in the UI, the endDate is nulled so that
|
|
||||||
// you can click another, but if you tab out without clicking anything
|
|
||||||
// or changing the input value, the old endDate should be retained
|
|
||||||
|
|
||||||
if (!this.endDate) {
|
|
||||||
var val = this.container.find('input[name="daterangepicker_end"]').val();
|
|
||||||
var end = moment(val, this.locale.format);
|
|
||||||
if (end.isValid()) {
|
|
||||||
this.setEndDate(end);
|
|
||||||
this.updateView();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
formInputsKeydown: function(e) {
|
|
||||||
// This function ensures that if the 'enter' key was pressed in the input, then the calendars
|
|
||||||
// are updated with the startDate and endDate.
|
|
||||||
// This behaviour is automatic in Chrome/Firefox/Edge but not in IE 11 hence why this exists.
|
|
||||||
// Other browsers and versions of IE are untested and the behaviour is unknown.
|
|
||||||
if (e.keyCode === 13) {
|
|
||||||
// Prevent the calendar from being updated twice on Chrome/Firefox/Edge
|
|
||||||
e.preventDefault();
|
|
||||||
this.formInputsChanged(e);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
elementChanged: function() {
|
elementChanged: function() {
|
||||||
if (!this.element.is('input')) return;
|
if (!this.element.is('input')) return;
|
||||||
if (!this.element.val().length) return;
|
if (!this.element.val().length) return;
|
||||||
@@ -1620,12 +1491,14 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
updateElement: function() {
|
updateElement: function() {
|
||||||
if (this.element.is('input') && !this.singleDatePicker && this.autoUpdateInput) {
|
if (this.element.is('input') && this.autoUpdateInput) {
|
||||||
this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
|
var newValue = this.startDate.format(this.locale.format);
|
||||||
this.element.trigger('change');
|
if (!this.singleDatePicker) {
|
||||||
} else if (this.element.is('input') && this.autoUpdateInput) {
|
newValue += this.locale.separator + this.endDate.format(this.locale.format);
|
||||||
this.element.val(this.startDate.format(this.locale.format));
|
}
|
||||||
this.element.trigger('change');
|
if (newValue !== this.element.val()) {
|
||||||
|
this.element.val(newValue).trigger('change');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user