Merge branch 'update_daterangepicker' into 'dev'
Update Date Range Picker and Moments See merge request Shinobi-Systems/Shinobi!130merge-requests/134/head
commit
797b63581b
|
@ -3,267 +3,408 @@
|
|||
color: inherit;
|
||||
background-color: #fff;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #ddd;
|
||||
width: 278px;
|
||||
padding: 4px;
|
||||
margin-top: 1px;
|
||||
max-width: none;
|
||||
padding: 0;
|
||||
margin-top: 7px;
|
||||
top: 100px;
|
||||
left: 20px;
|
||||
/* Calendars */ }
|
||||
.daterangepicker:before, .daterangepicker:after {
|
||||
position: absolute;
|
||||
display: inline-block;
|
||||
border-bottom-color: rgba(0, 0, 0, 0.2);
|
||||
content: ''; }
|
||||
.daterangepicker:before {
|
||||
top: -7px;
|
||||
border-right: 7px solid transparent;
|
||||
border-left: 7px solid transparent;
|
||||
border-bottom: 7px solid #ccc; }
|
||||
.daterangepicker:after {
|
||||
top: -6px;
|
||||
border-right: 6px solid transparent;
|
||||
border-bottom: 6px solid #fff;
|
||||
border-left: 6px solid transparent; }
|
||||
.daterangepicker.opensleft:before {
|
||||
right: 9px; }
|
||||
.daterangepicker.opensleft:after {
|
||||
right: 10px; }
|
||||
.daterangepicker.openscenter:before {
|
||||
left: 0;
|
||||
right: 0;
|
||||
width: 0;
|
||||
margin-left: auto;
|
||||
margin-right: auto; }
|
||||
.daterangepicker.openscenter:after {
|
||||
left: 0;
|
||||
right: 0;
|
||||
width: 0;
|
||||
margin-left: auto;
|
||||
margin-right: auto; }
|
||||
.daterangepicker.opensright:before {
|
||||
left: 9px; }
|
||||
.daterangepicker.opensright:after {
|
||||
left: 10px; }
|
||||
.daterangepicker.dropup {
|
||||
margin-top: -5px; }
|
||||
.daterangepicker.dropup:before {
|
||||
top: initial;
|
||||
bottom: -7px;
|
||||
border-bottom: initial;
|
||||
border-top: 7px solid #ccc; }
|
||||
.daterangepicker.dropup:after {
|
||||
top: initial;
|
||||
bottom: -6px;
|
||||
border-bottom: initial;
|
||||
border-top: 6px solid #fff; }
|
||||
.daterangepicker.dropdown-menu {
|
||||
max-width: none;
|
||||
z-index: 3001; }
|
||||
.daterangepicker.single .ranges, .daterangepicker.single .calendar {
|
||||
float: none; }
|
||||
.daterangepicker.show-calendar .calendar {
|
||||
display: block; }
|
||||
.daterangepicker .calendar {
|
||||
display: none;
|
||||
max-width: 270px;
|
||||
margin: 4px; }
|
||||
.daterangepicker .calendar.single .calendar-table {
|
||||
border: none; }
|
||||
.daterangepicker .calendar th, .daterangepicker .calendar td {
|
||||
white-space: nowrap;
|
||||
text-align: center;
|
||||
min-width: 32px; }
|
||||
.daterangepicker .calendar-table {
|
||||
border: 1px solid #fff;
|
||||
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: 1px solid transparent;
|
||||
white-space: nowrap;
|
||||
cursor: pointer; }
|
||||
.daterangepicker td.available:hover, .daterangepicker th.available:hover {
|
||||
background-color: #eee;
|
||||
border-color: transparent;
|
||||
color: inherit; }
|
||||
.daterangepicker td.week, .daterangepicker th.week {
|
||||
font-size: 80%;
|
||||
color: #ccc; }
|
||||
.daterangepicker td.off, .daterangepicker td.off.in-range, .daterangepicker td.off.start-date, .daterangepicker td.off.end-date {
|
||||
background-color: #fff;
|
||||
border-color: transparent;
|
||||
color: #999; }
|
||||
.daterangepicker td.in-range {
|
||||
background-color: #ebf4f8;
|
||||
border-color: transparent;
|
||||
color: #000;
|
||||
border-radius: 0; }
|
||||
.daterangepicker td.start-date {
|
||||
border-radius: 4px 0 0 4px; }
|
||||
.daterangepicker td.end-date {
|
||||
border-radius: 0 4px 4px 0; }
|
||||
.daterangepicker td.start-date.end-date {
|
||||
border-radius: 4px; }
|
||||
.daterangepicker td.active, .daterangepicker td.active:hover {
|
||||
background-color: #357ebd;
|
||||
border-color: transparent;
|
||||
color: #fff; }
|
||||
.daterangepicker th.month {
|
||||
width: auto; }
|
||||
.daterangepicker td.disabled, .daterangepicker option.disabled {
|
||||
color: #999;
|
||||
cursor: not-allowed;
|
||||
text-decoration: line-through; }
|
||||
.daterangepicker select.monthselect, .daterangepicker select.yearselect {
|
||||
font-size: 12px;
|
||||
padding: 1px;
|
||||
height: auto;
|
||||
margin: 0;
|
||||
cursor: default; }
|
||||
.daterangepicker select.monthselect {
|
||||
margin-right: 2%;
|
||||
width: 56%; }
|
||||
.daterangepicker select.yearselect {
|
||||
width: 40%; }
|
||||
.daterangepicker select.hourselect, .daterangepicker select.minuteselect, .daterangepicker select.secondselect, .daterangepicker select.ampmselect {
|
||||
width: 50px;
|
||||
margin-bottom: 0; }
|
||||
.daterangepicker .input-mini {
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
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 {
|
||||
text-align: center;
|
||||
margin: 5px auto;
|
||||
line-height: 30px;
|
||||
position: relative;
|
||||
padding-left: 28px; }
|
||||
.daterangepicker .calendar-time select.disabled {
|
||||
color: #ccc;
|
||||
cursor: not-allowed; }
|
||||
z-index: 3001;
|
||||
display: none;
|
||||
font-family: arial;
|
||||
font-size: 15px;
|
||||
line-height: 1em;
|
||||
}
|
||||
|
||||
.ranges {
|
||||
font-size: 11px;
|
||||
.daterangepicker:before, .daterangepicker:after {
|
||||
position: absolute;
|
||||
display: inline-block;
|
||||
border-bottom-color: rgba(0, 0, 0, 0.2);
|
||||
content: '';
|
||||
}
|
||||
|
||||
.daterangepicker:before {
|
||||
top: -7px;
|
||||
border-right: 7px solid transparent;
|
||||
border-left: 7px solid transparent;
|
||||
border-bottom: 7px solid #ccc;
|
||||
}
|
||||
|
||||
.daterangepicker:after {
|
||||
top: -6px;
|
||||
border-right: 6px solid transparent;
|
||||
border-bottom: 6px solid #fff;
|
||||
border-left: 6px solid transparent;
|
||||
}
|
||||
|
||||
.daterangepicker.opensleft:before {
|
||||
right: 9px;
|
||||
}
|
||||
|
||||
.daterangepicker.opensleft:after {
|
||||
right: 10px;
|
||||
}
|
||||
|
||||
.daterangepicker.openscenter:before {
|
||||
left: 0;
|
||||
right: 0;
|
||||
width: 0;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.daterangepicker.openscenter:after {
|
||||
left: 0;
|
||||
right: 0;
|
||||
width: 0;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.daterangepicker.opensright:before {
|
||||
left: 9px;
|
||||
}
|
||||
|
||||
.daterangepicker.opensright:after {
|
||||
left: 10px;
|
||||
}
|
||||
|
||||
.daterangepicker.drop-up {
|
||||
margin-top: -7px;
|
||||
}
|
||||
|
||||
.daterangepicker.drop-up:before {
|
||||
top: initial;
|
||||
bottom: -7px;
|
||||
border-bottom: initial;
|
||||
border-top: 7px solid #ccc;
|
||||
}
|
||||
|
||||
.daterangepicker.drop-up:after {
|
||||
top: initial;
|
||||
bottom: -6px;
|
||||
border-bottom: initial;
|
||||
border-top: 6px solid #fff;
|
||||
}
|
||||
|
||||
.daterangepicker.single .daterangepicker .ranges, .daterangepicker.single .drp-calendar {
|
||||
float: none;
|
||||
margin: 4px;
|
||||
text-align: left; }
|
||||
.ranges ul {
|
||||
list-style: none;
|
||||
margin: 0 auto;
|
||||
padding: 0;
|
||||
width: 100%; }
|
||||
.ranges li {
|
||||
font-size: 13px;
|
||||
background-color: #f5f5f5;
|
||||
border: 1px solid #f5f5f5;
|
||||
border-radius: 4px;
|
||||
color: #08c;
|
||||
padding: 3px 12px;
|
||||
margin-bottom: 8px;
|
||||
cursor: pointer; }
|
||||
.ranges li:hover {
|
||||
background-color: #08c;
|
||||
border: 1px solid #08c;
|
||||
color: #fff; }
|
||||
.ranges li.active {
|
||||
background-color: #08c;
|
||||
border: 1px solid #08c;
|
||||
color: #fff; }
|
||||
}
|
||||
|
||||
.daterangepicker.single .drp-selected {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.daterangepicker.show-calendar .drp-calendar {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.daterangepicker.show-calendar .drp-buttons {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
.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;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
min-width: 32px;
|
||||
width: 32px;
|
||||
height: 24px;
|
||||
line-height: 24px;
|
||||
font-size: 12px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid transparent;
|
||||
white-space: nowrap;
|
||||
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 {
|
||||
background-color: #eee;
|
||||
border-color: transparent;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.daterangepicker td.week, .daterangepicker th.week {
|
||||
font-size: 80%;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.daterangepicker td.off, .daterangepicker td.off.in-range, .daterangepicker td.off.start-date, .daterangepicker td.off.end-date {
|
||||
background-color: #fff;
|
||||
border-color: transparent;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.daterangepicker td.in-range {
|
||||
background-color: #ebf4f8;
|
||||
border-color: transparent;
|
||||
color: #000;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.daterangepicker td.start-date {
|
||||
border-radius: 4px 0 0 4px;
|
||||
}
|
||||
|
||||
.daterangepicker td.end-date {
|
||||
border-radius: 0 4px 4px 0;
|
||||
}
|
||||
|
||||
.daterangepicker td.start-date.end-date {
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.daterangepicker td.active, .daterangepicker td.active:hover {
|
||||
background-color: #357ebd;
|
||||
border-color: transparent;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.daterangepicker th.month {
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.daterangepicker td.disabled, .daterangepicker option.disabled {
|
||||
color: #999;
|
||||
cursor: not-allowed;
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.daterangepicker select.monthselect, .daterangepicker select.yearselect {
|
||||
font-size: 12px;
|
||||
padding: 1px;
|
||||
height: auto;
|
||||
margin: 0;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.daterangepicker select.monthselect {
|
||||
margin-right: 2%;
|
||||
width: 56%;
|
||||
}
|
||||
|
||||
.daterangepicker select.yearselect {
|
||||
width: 40%;
|
||||
}
|
||||
|
||||
.daterangepicker select.hourselect, .daterangepicker select.minuteselect, .daterangepicker select.secondselect, .daterangepicker select.ampmselect {
|
||||
width: 50px;
|
||||
margin: 0 auto;
|
||||
background: #eee;
|
||||
border: 1px solid #eee;
|
||||
padding: 2px;
|
||||
outline: 0;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.daterangepicker .calendar-time {
|
||||
text-align: center;
|
||||
margin: 4px auto 0 auto;
|
||||
line-height: 30px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.daterangepicker .calendar-time select.disabled {
|
||||
color: #ccc;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.daterangepicker .drp-buttons {
|
||||
clear: both;
|
||||
text-align: right;
|
||||
padding: 8px;
|
||||
border-top: 1px solid #ddd;
|
||||
display: none;
|
||||
line-height: 12px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.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.single.rtl .drp-calendar.left {
|
||||
border-right: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.daterangepicker.show-ranges.single.ltr .drp-calendar.left {
|
||||
border-left: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.daterangepicker.show-ranges.rtl .drp-calendar.right {
|
||||
border-right: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.daterangepicker.show-ranges.ltr .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;
|
||||
margin: 0 auto;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.daterangepicker .ranges li {
|
||||
font-size: 12px;
|
||||
padding: 8px 12px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.daterangepicker .ranges li:hover {
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
.daterangepicker .ranges li.active {
|
||||
background-color: #08c;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* Larger Screen Styling */
|
||||
@media (min-width: 564px) {
|
||||
.daterangepicker {
|
||||
width: auto; }
|
||||
.daterangepicker .ranges ul {
|
||||
width: 160px; }
|
||||
.daterangepicker.single .ranges ul {
|
||||
width: 100%; }
|
||||
.daterangepicker.single .calendar.left {
|
||||
clear: none; }
|
||||
.daterangepicker.single.ltr .ranges, .daterangepicker.single.ltr .calendar {
|
||||
float: left; }
|
||||
.daterangepicker.single.rtl .ranges, .daterangepicker.single.rtl .calendar {
|
||||
float: right; }
|
||||
.daterangepicker.ltr {
|
||||
direction: ltr;
|
||||
text-align: left; }
|
||||
.daterangepicker.ltr .calendar.left {
|
||||
clear: left;
|
||||
margin-right: 0; }
|
||||
.daterangepicker.ltr .calendar.left .calendar-table {
|
||||
border-right: none;
|
||||
border-top-right-radius: 0;
|
||||
border-bottom-right-radius: 0; }
|
||||
.daterangepicker.ltr .calendar.right {
|
||||
margin-left: 0; }
|
||||
.daterangepicker.ltr .calendar.right .calendar-table {
|
||||
border-left: none;
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 0; }
|
||||
.daterangepicker.ltr .left .daterangepicker_input {
|
||||
padding-right: 12px; }
|
||||
.daterangepicker.ltr .calendar.left .calendar-table {
|
||||
padding-right: 12px; }
|
||||
.daterangepicker.ltr .ranges, .daterangepicker.ltr .calendar {
|
||||
float: left; }
|
||||
.daterangepicker.rtl {
|
||||
direction: rtl;
|
||||
text-align: right; }
|
||||
.daterangepicker.rtl .calendar.left {
|
||||
clear: right;
|
||||
margin-left: 0; }
|
||||
.daterangepicker.rtl .calendar.left .calendar-table {
|
||||
border-left: none;
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 0; }
|
||||
.daterangepicker.rtl .calendar.right {
|
||||
margin-right: 0; }
|
||||
.daterangepicker.rtl .calendar.right .calendar-table {
|
||||
border-right: none;
|
||||
border-top-right-radius: 0;
|
||||
border-bottom-right-radius: 0; }
|
||||
.daterangepicker.rtl .left .daterangepicker_input {
|
||||
padding-left: 12px; }
|
||||
.daterangepicker.rtl .calendar.left .calendar-table {
|
||||
padding-left: 12px; }
|
||||
.daterangepicker.rtl .ranges, .daterangepicker.rtl .calendar {
|
||||
text-align: right;
|
||||
float: right; } }
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.daterangepicker .ranges ul {
|
||||
width: 140px;
|
||||
}
|
||||
|
||||
.daterangepicker.single .ranges ul {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.daterangepicker.single .drp-calendar.left {
|
||||
clear: none;
|
||||
}
|
||||
|
||||
.daterangepicker.single .ranges, .daterangepicker.single .drp-calendar {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.daterangepicker {
|
||||
direction: ltr;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.daterangepicker .drp-calendar.left {
|
||||
clear: left;
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.daterangepicker .drp-calendar.left .calendar-table {
|
||||
border-right: none;
|
||||
border-top-right-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
}
|
||||
|
||||
.daterangepicker .drp-calendar.right {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.daterangepicker .drp-calendar.right .calendar-table {
|
||||
border-left: none;
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
|
||||
.daterangepicker .drp-calendar.left .calendar-table {
|
||||
padding-right: 8px;
|
||||
}
|
||||
|
||||
.daterangepicker .ranges, .daterangepicker .drp-calendar {
|
||||
float: left;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 730px) {
|
||||
.daterangepicker .ranges {
|
||||
width: auto; }
|
||||
.daterangepicker.ltr .ranges {
|
||||
float: left; }
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.daterangepicker .ranges {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.daterangepicker.rtl .ranges {
|
||||
float: right; }
|
||||
.daterangepicker .calendar.left {
|
||||
clear: none !important; } }
|
||||
float: right;
|
||||
}
|
||||
|
||||
.daterangepicker .drp-calendar.left {
|
||||
clear: none !important;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
/**
|
||||
* @version: 2.1.25
|
||||
* @version: 3.0.5
|
||||
* @author: Dan Grossman http://www.dangrossman.info/
|
||||
* @copyright: Copyright (c) 2012-2017 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/
|
||||
*/
|
||||
// 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) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Make globaly available as well
|
||||
define(['moment', 'jquery'], function (moment, jquery) {
|
||||
return (root.daterangepicker = factory(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) {
|
||||
// Node / Browserify
|
||||
|
@ -36,10 +38,12 @@
|
|||
this.endDate = moment().endOf('day');
|
||||
this.minDate = false;
|
||||
this.maxDate = false;
|
||||
this.dateLimit = false;
|
||||
this.maxSpan = false;
|
||||
this.autoApply = false;
|
||||
this.singleDatePicker = false;
|
||||
this.showDropdowns = false;
|
||||
this.minYear = moment().subtract(100, 'year').format('YYYY');
|
||||
this.maxYear = moment().add(100, 'year').format('YYYY');
|
||||
this.showWeekNumbers = false;
|
||||
this.showISOWeekNumbers = false;
|
||||
this.showCustomRangeLabel = true;
|
||||
|
@ -61,8 +65,8 @@
|
|||
this.drops = 'up';
|
||||
|
||||
this.buttonClasses = 'btn btn-sm';
|
||||
this.applyClass = 'btn-success';
|
||||
this.cancelClass = 'btn-default';
|
||||
this.applyButtonClasses = 'btn-primary';
|
||||
this.cancelButtonClasses = 'btn-default';
|
||||
|
||||
this.locale = {
|
||||
direction: 'ltr',
|
||||
|
@ -94,34 +98,21 @@
|
|||
|
||||
//html template for the picker UI
|
||||
if (typeof options.template !== 'string' && !(options.template instanceof $))
|
||||
options.template = '<div class="daterangepicker dropdown-menu">' +
|
||||
'<div class="calendar left">' +
|
||||
'<div class="daterangepicker_input">' +
|
||||
'<input class="input-mini form-control" type="text" name="daterangepicker_start" 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>' +
|
||||
options.template =
|
||||
'<div class="daterangepicker">' +
|
||||
'<div class="ranges"></div>' +
|
||||
'<div class="drp-calendar left">' +
|
||||
'<div class="calendar-table"></div>' +
|
||||
'<div class="calendar-time"></div>' +
|
||||
'</div>' +
|
||||
'<div class="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="drp-calendar right">' +
|
||||
'<div class="calendar-table"></div>' +
|
||||
'<div class="calendar-time"></div>' +
|
||||
'</div>' +
|
||||
'<div class="ranges">' +
|
||||
'<div class="range_inputs">' +
|
||||
'<button class="applyBtn" disabled="disabled" type="button"></button> ' +
|
||||
'<button class="cancelBtn" type="button"></button>' +
|
||||
'</div>' +
|
||||
'<div class="drp-buttons">' +
|
||||
'<span class="drp-selected"></span>' +
|
||||
'<button class="cancelBtn" type="button"></button>' +
|
||||
'<button class="applyBtn" disabled="disabled" type="button"></button> ' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
|
||||
|
@ -203,14 +194,23 @@
|
|||
if (this.maxDate && this.endDate.isAfter(this.maxDate))
|
||||
this.endDate = this.maxDate.clone();
|
||||
|
||||
if (typeof options.applyClass === 'string')
|
||||
this.applyClass = options.applyClass;
|
||||
if (typeof options.applyButtonClasses === 'string')
|
||||
this.applyButtonClasses = options.applyButtonClasses;
|
||||
|
||||
if (typeof options.cancelClass === 'string')
|
||||
this.cancelClass = options.cancelClass;
|
||||
if (typeof options.applyClass === 'string') //backwards compat
|
||||
this.applyButtonClasses = options.applyClass;
|
||||
|
||||
if (typeof options.dateLimit === 'object')
|
||||
this.dateLimit = options.dateLimit;
|
||||
if (typeof options.cancelButtonClasses === 'string')
|
||||
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')
|
||||
this.opens = options.opens;
|
||||
|
@ -233,6 +233,12 @@
|
|||
if (typeof options.showDropdowns === 'boolean')
|
||||
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')
|
||||
this.showCustomRangeLabel = options.showCustomRangeLabel;
|
||||
|
||||
|
@ -285,7 +291,7 @@
|
|||
|
||||
//if no start/end dates set, check if an input element contains initial values
|
||||
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(),
|
||||
split = val.split(this.locale.separator);
|
||||
|
||||
|
@ -318,20 +324,20 @@
|
|||
else
|
||||
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.
|
||||
if (this.minDate && start.isBefore(this.minDate))
|
||||
start = this.minDate.clone();
|
||||
|
||||
var maxDate = this.maxDate;
|
||||
if (this.dateLimit && maxDate && start.clone().add(this.dateLimit).isAfter(maxDate))
|
||||
maxDate = start.clone().add(this.dateLimit);
|
||||
if (this.maxSpan && maxDate && start.clone().add(this.maxSpan).isAfter(maxDate))
|
||||
maxDate = start.clone().add(this.maxSpan);
|
||||
if (maxDate && end.isAfter(maxDate))
|
||||
end = maxDate.clone();
|
||||
|
||||
// If the end of the range is before the minimum or the start of the range is
|
||||
// after the maximum, don't display this range option at all.
|
||||
if ((this.minDate && end.isBefore(this.minDate, this.timepicker ? 'minute' : 'day'))
|
||||
if ((this.minDate && end.isBefore(this.minDate, this.timepicker ? 'minute' : 'day'))
|
||||
|| (maxDate && start.isAfter(maxDate, this.timepicker ? 'minute' : 'day')))
|
||||
continue;
|
||||
|
||||
|
@ -368,22 +374,20 @@
|
|||
if (this.timePicker && this.autoApply)
|
||||
this.autoApply = false;
|
||||
|
||||
if (this.autoApply && typeof options.ranges !== 'object') {
|
||||
this.container.find('.ranges').hide();
|
||||
} else if (this.autoApply) {
|
||||
this.container.find('.applyBtn, .cancelBtn').addClass('hide');
|
||||
if (this.autoApply) {
|
||||
this.container.addClass('auto-apply');
|
||||
}
|
||||
|
||||
if (typeof options.ranges === 'object')
|
||||
this.container.addClass('show-ranges');
|
||||
|
||||
if (this.singleDatePicker) {
|
||||
this.container.addClass('single');
|
||||
this.container.find('.calendar.left').addClass('single');
|
||||
this.container.find('.calendar.left').show();
|
||||
this.container.find('.calendar.right').hide();
|
||||
this.container.find('.daterangepicker_input input, .daterangepicker_input > i').hide();
|
||||
if (this.timePicker) {
|
||||
this.container.find('.ranges ul').hide();
|
||||
} else {
|
||||
this.container.find('.ranges').hide();
|
||||
this.container.find('.drp-calendar.left').addClass('single');
|
||||
this.container.find('.drp-calendar.left').show();
|
||||
this.container.find('.drp-calendar.right').hide();
|
||||
if (!this.timePicker) {
|
||||
this.container.addClass('auto-apply');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -393,17 +397,12 @@
|
|||
|
||||
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
|
||||
this.container.find('.applyBtn, .cancelBtn').addClass(this.buttonClasses);
|
||||
if (this.applyClass.length)
|
||||
this.container.find('.applyBtn').addClass(this.applyClass);
|
||||
if (this.cancelClass.length)
|
||||
this.container.find('.cancelBtn').addClass(this.cancelClass);
|
||||
if (this.applyButtonClasses.length)
|
||||
this.container.find('.applyBtn').addClass(this.applyButtonClasses);
|
||||
if (this.cancelButtonClasses.length)
|
||||
this.container.find('.cancelBtn').addClass(this.cancelButtonClasses);
|
||||
this.container.find('.applyBtn').html(this.locale.applyLabel);
|
||||
this.container.find('.cancelBtn').html(this.locale.cancelLabel);
|
||||
|
||||
|
@ -411,49 +410,39 @@
|
|||
// event listeners
|
||||
//
|
||||
|
||||
this.container.find('.calendar')
|
||||
this.container.find('.drp-calendar')
|
||||
.on('click.daterangepicker', '.prev', $.proxy(this.clickPrev, this))
|
||||
.on('click.daterangepicker', '.next', $.proxy(this.clickNext, this))
|
||||
.on('mousedown.daterangepicker', 'td.available', $.proxy(this.clickDate, 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.monthselect', $.proxy(this.monthOrYearChanged, 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));
|
||||
|
||||
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.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')) {
|
||||
this.element.on({
|
||||
'click.daterangepicker': $.proxy(this.show, this),
|
||||
'focus.daterangepicker': $.proxy(this.show, this),
|
||||
'keyup.daterangepicker': $.proxy(this.elementChanged, this),
|
||||
'keydown.daterangepicker': $.proxy(this.keydown, this)
|
||||
'keydown.daterangepicker': $.proxy(this.keydown, this) //IE 11 compatibility
|
||||
});
|
||||
} else {
|
||||
this.element.on('click.daterangepicker', $.proxy(this.toggle, this));
|
||||
this.element.on('keydown.daterangepicker', $.proxy(this.toggle, this));
|
||||
}
|
||||
|
||||
//
|
||||
// if attached to a text input, set the initial value
|
||||
//
|
||||
|
||||
if (this.element.is('input') && !this.singleDatePicker && this.autoUpdateInput) {
|
||||
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');
|
||||
}
|
||||
this.updateElement();
|
||||
|
||||
};
|
||||
|
||||
|
@ -511,11 +500,13 @@
|
|||
if (this.maxDate && this.endDate.isAfter(this.maxDate))
|
||||
this.endDate = this.maxDate.clone();
|
||||
|
||||
if (this.dateLimit && this.startDate.clone().add(this.dateLimit).isBefore(this.endDate))
|
||||
this.endDate = this.startDate.clone().add(this.dateLimit);
|
||||
if (this.maxSpan && this.startDate.clone().add(this.maxSpan).isBefore(this.endDate))
|
||||
this.endDate = this.startDate.clone().add(this.maxSpan);
|
||||
|
||||
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)
|
||||
this.updateElement();
|
||||
|
||||
|
@ -535,18 +526,13 @@
|
|||
this.renderTimePicker('left');
|
||||
this.renderTimePicker('right');
|
||||
if (!this.endDate) {
|
||||
this.container.find('.right .calendar-time select').attr('disabled', 'disabled').addClass('disabled');
|
||||
this.container.find('.right .calendar-time select').prop('disabled', true).addClass('disabled');
|
||||
} else {
|
||||
this.container.find('.right .calendar-time select').removeAttr('disabled').removeClass('disabled');
|
||||
this.container.find('.right .calendar-time select').prop('disabled', false).removeClass('disabled');
|
||||
}
|
||||
}
|
||||
if (this.endDate) {
|
||||
this.container.find('input[name="daterangepicker_end"]').removeClass('active');
|
||||
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');
|
||||
}
|
||||
if (this.endDate)
|
||||
this.container.find('.drp-selected').html(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
|
||||
this.updateMonthsInView();
|
||||
this.updateCalendars();
|
||||
this.updateFormInputs();
|
||||
|
@ -590,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();
|
||||
|
@ -601,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();
|
||||
|
@ -707,7 +699,7 @@
|
|||
html += '<th></th>';
|
||||
|
||||
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 {
|
||||
html += '<th></th>';
|
||||
}
|
||||
|
@ -717,14 +709,14 @@
|
|||
if (this.showDropdowns) {
|
||||
var currentMonth = calendar[1][1].month();
|
||||
var currentYear = calendar[1][1].year();
|
||||
var maxYear = (maxDate && maxDate.year()) || (currentYear + 5);
|
||||
var minYear = (minDate && minDate.year()) || (currentYear - 50);
|
||||
var maxYear = (maxDate && maxDate.year()) || (this.maxYear);
|
||||
var minYear = (minDate && minDate.year()) || (this.minYear);
|
||||
var inMinYear = currentYear == minYear;
|
||||
var inMaxYear = currentYear == maxYear;
|
||||
|
||||
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>";
|
||||
|
@ -749,7 +741,7 @@
|
|||
|
||||
html += '<th colspan="5" class="month">' + dateHtml + '</th>';
|
||||
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 {
|
||||
html += '<th></th>';
|
||||
}
|
||||
|
@ -769,10 +761,10 @@
|
|||
html += '</thead>';
|
||||
html += '<tbody>';
|
||||
|
||||
//adjust maxDate to reflect the dateLimit setting in order to
|
||||
//grey out end dates beyond the dateLimit
|
||||
if (this.endDate == null && this.dateLimit) {
|
||||
var maxLimit = this.startDate.clone().add(this.dateLimit).endOf('day');
|
||||
//adjust maxDate to reflect the maxSpan setting in order to
|
||||
//grey out end dates beyond the maxSpan
|
||||
if (this.endDate == null && this.maxSpan) {
|
||||
var maxLimit = this.startDate.clone().add(this.maxSpan).endOf('day');
|
||||
if (!maxDate || maxLimit.isBefore(maxDate)) {
|
||||
maxDate = maxLimit;
|
||||
}
|
||||
|
@ -801,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'))
|
||||
|
@ -854,7 +846,7 @@
|
|||
html += '</tbody>';
|
||||
html += '</table>';
|
||||
|
||||
this.container.find('.calendar.' + side + ' .calendar-table').html(html);
|
||||
this.container.find('.drp-calendar.' + side + ' .calendar-table').html(html);
|
||||
|
||||
},
|
||||
|
||||
|
@ -866,8 +858,8 @@
|
|||
|
||||
var html, selected, minDate, maxDate = this.maxDate;
|
||||
|
||||
if (this.dateLimit && (!this.maxDate || this.startDate.clone().add(this.dateLimit).isAfter(this.maxDate)))
|
||||
maxDate = this.startDate.clone().add(this.dateLimit);
|
||||
if (this.maxSpan && (!this.maxDate || this.startDate.clone().add(this.maxSpan).isBefore(this.maxDate)))
|
||||
maxDate = this.startDate.clone().add(this.maxSpan);
|
||||
|
||||
if (side == 'left') {
|
||||
selected = this.startDate.clone();
|
||||
|
@ -877,12 +869,12 @@
|
|||
minDate = this.startDate;
|
||||
|
||||
//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() != '') {
|
||||
|
||||
selected.hour(timeSelector.find('.hourselect option:selected').val() || selected.hour());
|
||||
selected.minute(timeSelector.find('.minuteselect option:selected').val() || selected.minute());
|
||||
selected.second(timeSelector.find('.secondselect option:selected').val() || selected.second());
|
||||
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();
|
||||
|
@ -1015,24 +1007,16 @@
|
|||
html += '</select>';
|
||||
}
|
||||
|
||||
this.container.find('.calendar.' + side + ' .calendar-time div').html(html);
|
||||
this.container.find('.drp-calendar.' + side + ' .calendar-time').html(html);
|
||||
|
||||
},
|
||||
|
||||
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)))) {
|
||||
this.container.find('button.applyBtn').removeAttr('disabled');
|
||||
this.container.find('button.applyBtn').prop('disabled', false);
|
||||
} else {
|
||||
this.container.find('button.applyBtn').attr('disabled', 'disabled');
|
||||
this.container.find('button.applyBtn').prop('disabled', true);
|
||||
}
|
||||
|
||||
},
|
||||
|
@ -1053,44 +1037,68 @@
|
|||
containerTop = this.element.offset().top - this.container.outerHeight() - parentOffset.top;
|
||||
else
|
||||
containerTop = this.element.offset().top + this.element.outerHeight() - parentOffset.top;
|
||||
this.container[this.drops == 'up' ? 'addClass' : 'removeClass']('dropup');
|
||||
|
||||
// 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 {
|
||||
this.container.css({
|
||||
top: containerTop,
|
||||
left: this.element.offset().left - parentOffset.left,
|
||||
right: 'auto'
|
||||
});
|
||||
if (this.container.offset().left + this.container.outerWidth() > $(window).width()) {
|
||||
} 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 {
|
||||
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'
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -1136,7 +1144,7 @@
|
|||
|
||||
//if a new date range was selected, invoke the user callback function
|
||||
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
|
||||
this.updateElement();
|
||||
|
@ -1182,24 +1190,6 @@
|
|||
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) {
|
||||
var label = e.target.getAttribute('data-range-key');
|
||||
this.chosenLabel = label;
|
||||
|
@ -1222,7 +1212,7 @@
|
|||
},
|
||||
|
||||
clickPrev: function(e) {
|
||||
var cal = $(e.target).parents('.calendar');
|
||||
var cal = $(e.target).parents('.drp-calendar');
|
||||
if (cal.hasClass('left')) {
|
||||
this.leftCalendar.month.subtract(1, 'month');
|
||||
if (this.linkedCalendars)
|
||||
|
@ -1234,7 +1224,7 @@
|
|||
},
|
||||
|
||||
clickNext: function(e) {
|
||||
var cal = $(e.target).parents('.calendar');
|
||||
var cal = $(e.target).parents('.drp-calendar');
|
||||
if (cal.hasClass('left')) {
|
||||
this.leftCalendar.month.add(1, 'month');
|
||||
} else {
|
||||
|
@ -1247,32 +1237,21 @@
|
|||
|
||||
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
|
||||
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 row = title.substr(1, 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];
|
||||
|
||||
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
|
||||
var leftCalendar = this.leftCalendar;
|
||||
var rightCalendar = this.rightCalendar;
|
||||
var startDate = this.startDate;
|
||||
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
|
||||
if ($(el).hasClass('week')) return;
|
||||
|
@ -1280,7 +1259,7 @@
|
|||
var title = $(el).attr('data-title');
|
||||
var row = title.substr(1, 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];
|
||||
|
||||
if ((dt.isAfter(startDate) && dt.isBefore(date)) || dt.isSame(date, 'day')) {
|
||||
|
@ -1301,7 +1280,7 @@
|
|||
var title = $(e.target).attr('data-title');
|
||||
var row = title.substr(1, 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];
|
||||
|
||||
//
|
||||
|
@ -1324,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);
|
||||
}
|
||||
|
@ -1344,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);
|
||||
}
|
||||
|
@ -1371,17 +1356,19 @@
|
|||
var customRange = true;
|
||||
var i = 0;
|
||||
for (var range in this.ranges) {
|
||||
if (this.timePicker) {
|
||||
if (this.startDate.isSame(this.ranges[range][0]) && this.endDate.isSame(this.ranges[range][1])) {
|
||||
if (this.timePicker) {
|
||||
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;
|
||||
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;
|
||||
}
|
||||
} else {
|
||||
//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')) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -1389,7 +1376,7 @@
|
|||
}
|
||||
if (customRange) {
|
||||
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 {
|
||||
this.chosenLabel = null;
|
||||
}
|
||||
|
@ -1410,9 +1397,9 @@
|
|||
},
|
||||
|
||||
monthOrYearChanged: function(e) {
|
||||
var isLeft = $(e.target).closest('.calendar').hasClass('left'),
|
||||
var isLeft = $(e.target).closest('.drp-calendar').hasClass('left'),
|
||||
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
|
||||
var month = parseInt(cal.find('.monthselect').val(), 10);
|
||||
|
@ -1453,11 +1440,14 @@
|
|||
|
||||
timeChanged: function(e) {
|
||||
|
||||
var cal = $(e.target).closest('.calendar'),
|
||||
var cal = $(e.target).closest('.drp-calendar'),
|
||||
isLeft = cal.hasClass('left');
|
||||
|
||||
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) {
|
||||
|
@ -1499,72 +1489,9 @@
|
|||
|
||||
},
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
elementChanged: function() {
|
||||
if (!this.element.is('input')) return;
|
||||
if (!this.element.val().length) return;
|
||||
if (this.element.val().length < this.locale.format.length) return;
|
||||
|
||||
var dateString = this.element.val().split(this.locale.separator),
|
||||
start = null,
|
||||
|
@ -1592,15 +1519,25 @@
|
|||
if ((e.keyCode === 9) || (e.keyCode === 13)) {
|
||||
this.hide();
|
||||
}
|
||||
|
||||
//hide on esc and prevent propagation
|
||||
if (e.keyCode === 27) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
this.hide();
|
||||
}
|
||||
},
|
||||
|
||||
updateElement: function() {
|
||||
if (this.element.is('input') && !this.singleDatePicker && this.autoUpdateInput) {
|
||||
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');
|
||||
if (this.element.is('input') && this.autoUpdateInput) {
|
||||
var newValue = this.startDate.format(this.locale.format);
|
||||
if (!this.singleDatePicker) {
|
||||
newValue += this.locale.separator + this.endDate.format(this.locale.format);
|
||||
}
|
||||
if (newValue !== this.element.val()) {
|
||||
this.element.val(newValue).trigger('change');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -1613,11 +1550,12 @@
|
|||
};
|
||||
|
||||
$.fn.daterangepicker = function(options, callback) {
|
||||
var implementOptions = $.extend(true, {}, $.fn.daterangepicker.defaultOptions, options);
|
||||
this.each(function() {
|
||||
var el = $(this);
|
||||
if (el.data('daterangepicker'))
|
||||
el.data('daterangepicker').remove();
|
||||
el.data('daterangepicker', new DateRangePicker(el, options, callback));
|
||||
el.data('daterangepicker', new DateRangePicker(el, implementOptions, callback));
|
||||
});
|
||||
return this;
|
||||
};
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue