├── .gitignore ├── README.md ├── bower.json ├── daterangepicker.css ├── daterangepicker.js ├── demo.html ├── drp.png ├── example ├── amd │ ├── index.html │ ├── main.js │ └── require.js └── browserify │ ├── README.md │ ├── bundle.js │ ├── index.html │ └── main.js ├── moment.min.js ├── package.js ├── package.json └── website ├── index.html ├── website.css └── website.js /.gitignore: -------------------------------------------------------------------------------- 1 | bower_components 2 | node_modules 3 | npm-debug.log 4 | *.sublime-workspace 5 | *.sublime-project 6 | *.sw[onp] 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Date Range Picker 2 | 3 | ![Improvely.com](https://i.imgur.com/UTRlaar.png) 4 | 5 | This date range picker component creates a dropdown menu from which a user can 6 | select a range of dates. I created it while building the UI for [Improvely](http://www.improvely.com), 7 | which needed a way to select date ranges for reports. 8 | 9 | Features include limiting the selectable date range, localizable strings and date formats, 10 | a single date picker mode, a time picker, and predefined date ranges. 11 | 12 | ## [Documentation and Live Usage Examples](http://www.daterangepicker.com) 13 | 14 | ## [See It In a Live Application](https://awio.iljmp.com/5/drpdemogh) 15 | 16 | ## License 17 | 18 | The MIT License (MIT) 19 | 20 | Copyright (c) 2012-2020 Dan Grossman 21 | 22 | Permission is hereby granted, free of charge, to any person obtaining a copy 23 | of this software and associated documentation files (the "Software"), to deal 24 | in the Software without restriction, including without limitation the rights 25 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 26 | copies of the Software, and to permit persons to whom the Software is 27 | furnished to do so, subject to the following conditions: 28 | 29 | The above copyright notice and this permission notice shall be included in 30 | all copies or substantial portions of the Software. 31 | 32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 33 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 34 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 35 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 36 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 37 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 38 | THE SOFTWARE. 39 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "daterangepicker", 3 | "main": [ 4 | "daterangepicker.js", 5 | "daterangepicker.css" 6 | ], 7 | "ignore": [ 8 | "**/.*", 9 | "node_modules", 10 | "bower_components", 11 | "test", 12 | "tests", 13 | "moment.js", 14 | "moment.min.js" 15 | ], 16 | "dependencies": { 17 | "jquery": "1.9.1 - 3", 18 | "moment": ">=2.9.0" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /daterangepicker.css: -------------------------------------------------------------------------------- 1 | .daterangepicker { 2 | position: absolute; 3 | color: inherit; 4 | background-color: #fff; 5 | border-radius: 4px; 6 | border: 1px solid #ddd; 7 | width: 278px; 8 | max-width: none; 9 | padding: 0; 10 | margin-top: 7px; 11 | top: 100px; 12 | left: 20px; 13 | z-index: 3001; 14 | display: none; 15 | font-family: arial; 16 | font-size: 15px; 17 | line-height: 1em; 18 | } 19 | 20 | .daterangepicker:before, .daterangepicker:after { 21 | position: absolute; 22 | display: inline-block; 23 | border-bottom-color: rgba(0, 0, 0, 0.2); 24 | content: ''; 25 | } 26 | 27 | .daterangepicker:before { 28 | top: -7px; 29 | border-right: 7px solid transparent; 30 | border-left: 7px solid transparent; 31 | border-bottom: 7px solid #ccc; 32 | } 33 | 34 | .daterangepicker:after { 35 | top: -6px; 36 | border-right: 6px solid transparent; 37 | border-bottom: 6px solid #fff; 38 | border-left: 6px solid transparent; 39 | } 40 | 41 | .daterangepicker.opensleft:before { 42 | right: 9px; 43 | } 44 | 45 | .daterangepicker.opensleft:after { 46 | right: 10px; 47 | } 48 | 49 | .daterangepicker.openscenter:before { 50 | left: 0; 51 | right: 0; 52 | width: 0; 53 | margin-left: auto; 54 | margin-right: auto; 55 | } 56 | 57 | .daterangepicker.openscenter:after { 58 | left: 0; 59 | right: 0; 60 | width: 0; 61 | margin-left: auto; 62 | margin-right: auto; 63 | } 64 | 65 | .daterangepicker.opensright:before { 66 | left: 9px; 67 | } 68 | 69 | .daterangepicker.opensright:after { 70 | left: 10px; 71 | } 72 | 73 | .daterangepicker.drop-up { 74 | margin-top: -7px; 75 | } 76 | 77 | .daterangepicker.drop-up:before { 78 | top: initial; 79 | bottom: -7px; 80 | border-bottom: initial; 81 | border-top: 7px solid #ccc; 82 | } 83 | 84 | .daterangepicker.drop-up:after { 85 | top: initial; 86 | bottom: -6px; 87 | border-bottom: initial; 88 | border-top: 6px solid #fff; 89 | } 90 | 91 | .daterangepicker.single .daterangepicker .ranges, .daterangepicker.single .drp-calendar { 92 | float: none; 93 | } 94 | 95 | .daterangepicker.single .drp-selected { 96 | display: none; 97 | } 98 | 99 | .daterangepicker.show-calendar .drp-calendar { 100 | display: block; 101 | } 102 | 103 | .daterangepicker.show-calendar .drp-buttons { 104 | display: block; 105 | } 106 | 107 | .daterangepicker.auto-apply .drp-buttons { 108 | display: none; 109 | } 110 | 111 | .daterangepicker .drp-calendar { 112 | display: none; 113 | max-width: 270px; 114 | } 115 | 116 | .daterangepicker .drp-calendar.left { 117 | padding: 8px 0 8px 8px; 118 | } 119 | 120 | .daterangepicker .drp-calendar.right { 121 | padding: 8px; 122 | } 123 | 124 | .daterangepicker .drp-calendar.single .calendar-table { 125 | border: none; 126 | } 127 | 128 | .daterangepicker .calendar-table .next span, .daterangepicker .calendar-table .prev span { 129 | color: #fff; 130 | border: solid black; 131 | border-width: 0 2px 2px 0; 132 | border-radius: 0; 133 | display: inline-block; 134 | padding: 3px; 135 | } 136 | 137 | .daterangepicker .calendar-table .next span { 138 | transform: rotate(-45deg); 139 | -webkit-transform: rotate(-45deg); 140 | } 141 | 142 | .daterangepicker .calendar-table .prev span { 143 | transform: rotate(135deg); 144 | -webkit-transform: rotate(135deg); 145 | } 146 | 147 | .daterangepicker .calendar-table th, .daterangepicker .calendar-table td { 148 | white-space: nowrap; 149 | text-align: center; 150 | vertical-align: middle; 151 | min-width: 32px; 152 | width: 32px; 153 | height: 24px; 154 | line-height: 24px; 155 | font-size: 12px; 156 | border-radius: 4px; 157 | border: 1px solid transparent; 158 | white-space: nowrap; 159 | cursor: pointer; 160 | } 161 | 162 | .daterangepicker .calendar-table { 163 | border: 1px solid #fff; 164 | border-radius: 4px; 165 | background-color: #fff; 166 | } 167 | 168 | .daterangepicker .calendar-table table { 169 | width: 100%; 170 | margin: 0; 171 | border-spacing: 0; 172 | border-collapse: collapse; 173 | } 174 | 175 | .daterangepicker td.available:hover, .daterangepicker th.available:hover { 176 | background-color: #eee; 177 | border-color: transparent; 178 | color: inherit; 179 | } 180 | 181 | .daterangepicker td.week, .daterangepicker th.week { 182 | font-size: 80%; 183 | color: #ccc; 184 | } 185 | 186 | .daterangepicker td.off, .daterangepicker td.off.in-range, .daterangepicker td.off.start-date, .daterangepicker td.off.end-date { 187 | background-color: #fff; 188 | border-color: transparent; 189 | color: #999; 190 | } 191 | 192 | .daterangepicker td.in-range { 193 | background-color: #ebf4f8; 194 | border-color: transparent; 195 | color: #000; 196 | border-radius: 0; 197 | } 198 | 199 | .daterangepicker td.start-date { 200 | border-radius: 4px 0 0 4px; 201 | } 202 | 203 | .daterangepicker td.end-date { 204 | border-radius: 0 4px 4px 0; 205 | } 206 | 207 | .daterangepicker td.start-date.end-date { 208 | border-radius: 4px; 209 | } 210 | 211 | .daterangepicker td.active, .daterangepicker td.active:hover { 212 | background-color: #357ebd; 213 | border-color: transparent; 214 | color: #fff; 215 | } 216 | 217 | .daterangepicker th.month { 218 | width: auto; 219 | } 220 | 221 | .daterangepicker td.disabled, .daterangepicker option.disabled { 222 | color: #999; 223 | cursor: not-allowed; 224 | text-decoration: line-through; 225 | } 226 | 227 | .daterangepicker select.monthselect, .daterangepicker select.yearselect { 228 | font-size: 12px; 229 | padding: 1px; 230 | height: auto; 231 | margin: 0; 232 | cursor: default; 233 | } 234 | 235 | .daterangepicker select.monthselect { 236 | margin-right: 2%; 237 | width: 56%; 238 | } 239 | 240 | .daterangepicker select.yearselect { 241 | width: 40%; 242 | } 243 | 244 | .daterangepicker select.hourselect, .daterangepicker select.minuteselect, .daterangepicker select.secondselect, .daterangepicker select.ampmselect { 245 | width: 50px; 246 | margin: 0 auto; 247 | background: #eee; 248 | border: 1px solid #eee; 249 | padding: 2px; 250 | outline: 0; 251 | font-size: 12px; 252 | } 253 | 254 | .daterangepicker .calendar-time { 255 | text-align: center; 256 | margin: 4px auto 0 auto; 257 | line-height: 30px; 258 | position: relative; 259 | } 260 | 261 | .daterangepicker .calendar-time select.disabled { 262 | color: #ccc; 263 | cursor: not-allowed; 264 | } 265 | 266 | .daterangepicker .drp-buttons { 267 | clear: both; 268 | text-align: right; 269 | padding: 8px; 270 | border-top: 1px solid #ddd; 271 | display: none; 272 | line-height: 12px; 273 | vertical-align: middle; 274 | } 275 | 276 | .daterangepicker .drp-selected { 277 | display: inline-block; 278 | font-size: 12px; 279 | padding-right: 8px; 280 | } 281 | 282 | .daterangepicker .drp-buttons .btn { 283 | margin-left: 8px; 284 | font-size: 12px; 285 | font-weight: bold; 286 | padding: 4px 8px; 287 | } 288 | 289 | .daterangepicker.show-ranges.single.rtl .drp-calendar.left { 290 | border-right: 1px solid #ddd; 291 | } 292 | 293 | .daterangepicker.show-ranges.single.ltr .drp-calendar.left { 294 | border-left: 1px solid #ddd; 295 | } 296 | 297 | .daterangepicker.show-ranges.rtl .drp-calendar.right { 298 | border-right: 1px solid #ddd; 299 | } 300 | 301 | .daterangepicker.show-ranges.ltr .drp-calendar.left { 302 | border-left: 1px solid #ddd; 303 | } 304 | 305 | .daterangepicker .ranges { 306 | float: none; 307 | text-align: left; 308 | margin: 0; 309 | } 310 | 311 | .daterangepicker.show-calendar .ranges { 312 | margin-top: 8px; 313 | } 314 | 315 | .daterangepicker .ranges ul { 316 | list-style: none; 317 | margin: 0 auto; 318 | padding: 0; 319 | width: 100%; 320 | } 321 | 322 | .daterangepicker .ranges li { 323 | font-size: 12px; 324 | padding: 8px 12px; 325 | cursor: pointer; 326 | } 327 | 328 | .daterangepicker .ranges li:hover { 329 | background-color: #eee; 330 | } 331 | 332 | .daterangepicker .ranges li.active { 333 | background-color: #08c; 334 | color: #fff; 335 | } 336 | 337 | /* Larger Screen Styling */ 338 | @media (min-width: 564px) { 339 | .daterangepicker { 340 | width: auto; 341 | } 342 | 343 | .daterangepicker .ranges ul { 344 | width: 140px; 345 | } 346 | 347 | .daterangepicker.single .ranges ul { 348 | width: 100%; 349 | } 350 | 351 | .daterangepicker.single .drp-calendar.left { 352 | clear: none; 353 | } 354 | 355 | .daterangepicker.single .ranges, .daterangepicker.single .drp-calendar { 356 | float: left; 357 | } 358 | 359 | .daterangepicker { 360 | direction: ltr; 361 | text-align: left; 362 | } 363 | 364 | .daterangepicker .drp-calendar.left { 365 | clear: left; 366 | margin-right: 0; 367 | } 368 | 369 | .daterangepicker .drp-calendar.left .calendar-table { 370 | border-right: none; 371 | border-top-right-radius: 0; 372 | border-bottom-right-radius: 0; 373 | } 374 | 375 | .daterangepicker .drp-calendar.right { 376 | margin-left: 0; 377 | } 378 | 379 | .daterangepicker .drp-calendar.right .calendar-table { 380 | border-left: none; 381 | border-top-left-radius: 0; 382 | border-bottom-left-radius: 0; 383 | } 384 | 385 | .daterangepicker .drp-calendar.left .calendar-table { 386 | padding-right: 8px; 387 | } 388 | 389 | .daterangepicker .ranges, .daterangepicker .drp-calendar { 390 | float: left; 391 | } 392 | } 393 | 394 | @media (min-width: 730px) { 395 | .daterangepicker .ranges { 396 | width: auto; 397 | } 398 | 399 | .daterangepicker .ranges { 400 | float: left; 401 | } 402 | 403 | .daterangepicker.rtl .ranges { 404 | float: right; 405 | } 406 | 407 | .daterangepicker .drp-calendar.left { 408 | clear: none !important; 409 | } 410 | } 411 | -------------------------------------------------------------------------------- /demo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | A date range picker for Bootstrap 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 22 | 23 | 24 | 25 |
26 | 27 |

Configuration Builder

28 | 29 |
30 | 31 |
32 |
33 | 34 |
35 | 36 |
37 | 38 | 39 |
40 | 41 |
42 | 43 | 44 |
45 | 46 |
47 | 48 | 49 |
50 | 51 |
52 | 53 | 54 |
55 | 56 |
57 | 58 | 59 |
60 | 61 |
62 |
63 | 64 |
65 | 68 |
69 | 70 |
71 | 74 |
75 | 76 |
77 | 80 |
81 | 82 |
83 | 86 |
87 | 88 |
89 | 92 |
93 | 94 |
95 | 98 |
99 | 100 |
101 | 104 |
105 | 106 |
107 | 108 | 109 |
110 | 111 |
112 | 115 |
116 | 117 |
118 | 121 |
122 | 123 |
124 | 127 |
128 | 129 |
130 | 133 | 136 |
137 | 138 |
139 | 142 |
143 | 144 |
145 |
146 | 147 |
148 | 151 |
152 | 153 |
154 | 157 |
158 | 159 |
160 | 163 |
164 | 165 |
166 | 167 | 172 |
173 | 174 |
175 | 176 | 180 |
181 | 182 |
183 | 184 | 185 |
186 | 187 |
188 | 189 | 190 |
191 | 192 |
193 | 194 | 195 |
196 | 197 |
198 | 199 |
200 |
201 | 202 |
203 | 204 |
205 | 206 |
207 |

Your Date Range Picker

208 |
209 | 210 |
211 |
212 | 213 |
214 |

Configuration

215 | 216 |
217 | 218 |
219 |
220 | 221 |
222 | 223 |
224 | 225 | 231 | 232 | 372 | 373 | 374 | 375 | -------------------------------------------------------------------------------- /drp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dangrossman/daterangepicker/8495717c4007a03fd5dee422f161811fd6140c0e/drp.png -------------------------------------------------------------------------------- /example/amd/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | A date range picker for Bootstrap 6 | 7 | 8 | 14 | 15 | 16 | 17 |
18 | 19 |

Configuration Builder

20 | 21 |
22 | 23 |
24 |
25 | 26 |
27 | 28 |
29 | 30 | 31 |
32 | 33 |
34 | 35 | 36 |
37 | 38 |
39 | 40 | 41 |
42 | 43 |
44 | 45 | 46 |
47 | 48 |
49 | 50 | 51 |
52 | 53 |
54 |
55 | 56 |
57 | 60 |
61 | 62 |
63 | 66 |
67 | 68 |
69 | 72 |
73 | 74 |
75 | 78 |
79 | 80 |
81 | 84 |
85 | 86 |
87 | 90 |
91 | 92 |
93 | 96 |
97 | 98 |
99 | 100 | 101 |
102 | 103 |
104 | 107 |
108 | 109 |
110 | 113 |
114 | 115 |
116 | 119 |
120 | 121 |
122 | 125 |
126 | 127 |
128 | 131 |
132 | 133 |
134 | 137 |
138 | 139 |
140 | 143 |
144 | 145 |
146 |
147 | 148 |
149 | 150 | 155 |
156 | 157 |
158 | 159 | 163 |
164 | 165 |
166 | 167 | 168 |
169 | 170 |
171 | 172 | 173 |
174 | 175 |
176 | 177 | 178 |
179 | 180 |
181 | 182 |
183 |
184 | 185 |
186 | 187 |
188 | 189 |
190 |

Your Date Range Picker

191 | 192 | 193 |
194 | 195 |
196 |

Configuration

197 | 198 |
199 | 200 |
201 |
202 | 203 |
204 | 205 |
206 | 207 | 208 | 209 | 210 | 211 | -------------------------------------------------------------------------------- /example/amd/main.js: -------------------------------------------------------------------------------- 1 | requirejs.config({ 2 | "paths": { 3 | "jquery": "https://code.jquery.com/jquery-1.11.3.min", 4 | "moment": "../../moment", 5 | "daterangepicker": "../../daterangepicker" 6 | } 7 | }); 8 | 9 | requirejs(['jquery', 'moment', 'daterangepicker'] , function ($, moment) { 10 | $(document).ready(function() { 11 | 12 | $('#config-text').keyup(function() { 13 | eval($(this).val()); 14 | }); 15 | 16 | $('.configurator input, .configurator select').change(function() { 17 | updateConfig(); 18 | }); 19 | 20 | $('.demo i').click(function() { 21 | $(this).parent().find('input').click(); 22 | }); 23 | 24 | $('#startDate').daterangepicker({ 25 | singleDatePicker: true, 26 | startDate: moment().subtract(6, 'days') 27 | }); 28 | 29 | $('#endDate').daterangepicker({ 30 | singleDatePicker: true, 31 | startDate: moment() 32 | }); 33 | 34 | updateConfig(); 35 | 36 | function updateConfig() { 37 | var options = {}; 38 | 39 | if ($('#singleDatePicker').is(':checked')) 40 | options.singleDatePicker = true; 41 | 42 | if ($('#showDropdowns').is(':checked')) 43 | options.showDropdowns = true; 44 | 45 | if ($('#showWeekNumbers').is(':checked')) 46 | options.showWeekNumbers = true; 47 | 48 | if ($('#showISOWeekNumbers').is(':checked')) 49 | options.showISOWeekNumbers = true; 50 | 51 | if ($('#timePicker').is(':checked')) 52 | options.timePicker = true; 53 | 54 | if ($('#timePicker24Hour').is(':checked')) 55 | options.timePicker24Hour = true; 56 | 57 | if ($('#timePickerIncrement').val().length && $('#timePickerIncrement').val() != 1) 58 | options.timePickerIncrement = parseInt($('#timePickerIncrement').val(), 10); 59 | 60 | if ($('#timePickerSeconds').is(':checked')) 61 | options.timePickerSeconds = true; 62 | 63 | if ($('#autoApply').is(':checked')) 64 | options.autoApply = true; 65 | 66 | if ($('#dateLimit').is(':checked')) 67 | options.dateLimit = { days: 7 }; 68 | 69 | if ($('#ranges').is(':checked')) { 70 | options.ranges = { 71 | 'Today': [moment(), moment()], 72 | 'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')], 73 | 'Last 7 Days': [moment().subtract(6, 'days'), moment()], 74 | 'Last 30 Days': [moment().subtract(29, 'days'), moment()], 75 | 'This Month': [moment().startOf('month'), moment().endOf('month')], 76 | 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')] 77 | }; 78 | } 79 | 80 | if ($('#locale').is(':checked')) { 81 | options.locale = { 82 | format: 'MM/DD/YYYY HH:mm', 83 | separator: ' - ', 84 | applyLabel: 'Apply', 85 | cancelLabel: 'Cancel', 86 | fromLabel: 'From', 87 | toLabel: 'To', 88 | customRangeLabel: 'Custom', 89 | daysOfWeek: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr','Sa'], 90 | monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], 91 | firstDay: 1 92 | }; 93 | } 94 | 95 | if (!$('#linkedCalendars').is(':checked')) 96 | options.linkedCalendars = false; 97 | 98 | if (!$('#autoUpdateInput').is(':checked')) 99 | options.autoUpdateInput = false; 100 | 101 | if ($('#alwaysShowCalendars').is(':checked')) 102 | options.alwaysShowCalendars = true; 103 | 104 | if ($('#parentEl').val().length) 105 | options.parentEl = $('#parentEl').val(); 106 | 107 | if ($('#startDate').val().length) 108 | options.startDate = $('#startDate').val(); 109 | 110 | if ($('#endDate').val().length) 111 | options.endDate = $('#endDate').val(); 112 | 113 | if ($('#minDate').val().length) 114 | options.minDate = $('#minDate').val(); 115 | 116 | if ($('#maxDate').val().length) 117 | options.maxDate = $('#maxDate').val(); 118 | 119 | if ($('#opens').val().length && $('#opens').val() != 'right') 120 | options.opens = $('#opens').val(); 121 | 122 | if ($('#drops').val().length && $('#drops').val() != 'down') 123 | options.drops = $('#drops').val(); 124 | 125 | if ($('#buttonClasses').val().length && $('#buttonClasses').val() != 'btn btn-sm') 126 | options.buttonClasses = $('#buttonClasses').val(); 127 | 128 | if ($('#applyClass').val().length && $('#applyClass').val() != 'btn-success') 129 | options.applyClass = $('#applyClass').val(); 130 | 131 | if ($('#cancelClass').val().length && $('#cancelClass').val() != 'btn-default') 132 | options.cancelClass = $('#cancelClass').val(); 133 | 134 | $('#config-text').val("$('#demo').daterangepicker(" + JSON.stringify(options, null, ' ') + ", function(start, end, label) {\n console.log(\"New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')\");\n});"); 135 | 136 | $('#config-demo').daterangepicker(options, function(start, end, label) { console.log('New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')'); }); 137 | 138 | } 139 | 140 | }); 141 | }); 142 | -------------------------------------------------------------------------------- /example/amd/require.js: -------------------------------------------------------------------------------- 1 | /* 2 | RequireJS 2.2.0 Copyright jQuery Foundation and other contributors. 3 | Released under MIT license, http://github.com/requirejs/requirejs/LICENSE 4 | */ 5 | var requirejs,require,define; 6 | (function(ga){function ka(b,c,d,g){return g||""}function K(b){return"[object Function]"===Q.call(b)}function L(b){return"[object Array]"===Q.call(b)}function y(b,c){if(b){var d;for(d=0;dthis.depCount&&!this.defined){if(K(k)){if(this.events.error&&this.map.isDefine||g.onError!== 18 | ha)try{h=l.execCb(c,k,b,h)}catch(d){a=d}else h=l.execCb(c,k,b,h);this.map.isDefine&&void 0===h&&((b=this.module)?h=b.exports:this.usingExports&&(h=this.exports));if(a)return a.requireMap=this.map,a.requireModules=this.map.isDefine?[this.map.id]:null,a.requireType=this.map.isDefine?"define":"require",A(this.error=a)}else h=k;this.exports=h;if(this.map.isDefine&&!this.ignore&&(v[c]=h,g.onResourceLoad)){var f=[];y(this.depMaps,function(a){f.push(a.normalizedMap||a)});g.onResourceLoad(l,this.map,f)}C(c); 19 | this.defined=!0}this.defining=!1;this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0)}}},callPlugin:function(){var a=this.map,b=a.id,d=q(a.prefix);this.depMaps.push(d);w(d,"defined",z(this,function(h){var k,f,d=e(fa,this.map.id),M=this.map.name,r=this.map.parentMap?this.map.parentMap.name:null,m=l.makeRequire(a.parentMap,{enableBuildCallback:!0});if(this.map.unnormalized){if(h.normalize&&(M=h.normalize(M,function(a){return c(a,r,!0)})|| 20 | ""),f=q(a.prefix+"!"+M,this.map.parentMap),w(f,"defined",z(this,function(a){this.map.normalizedMap=f;this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),h=e(t,f.id)){this.depMaps.push(f);if(this.events.error)h.on("error",z(this,function(a){this.emit("error",a)}));h.enable()}}else d?(this.map.url=l.nameToUrl(d),this.load()):(k=z(this,function(a){this.init([],function(){return a},null,{enabled:!0})}),k.error=z(this,function(a){this.inited=!0;this.error=a;a.requireModules=[b];D(t,function(a){0=== 21 | a.map.id.indexOf(b+"_unnormalized")&&C(a.map.id)});A(a)}),k.fromText=z(this,function(h,c){var d=a.name,f=q(d),M=S;c&&(h=c);M&&(S=!1);u(f);x(p.config,b)&&(p.config[d]=p.config[b]);try{g.exec(h)}catch(e){return A(F("fromtexteval","fromText eval for "+b+" failed: "+e,e,[b]))}M&&(S=!0);this.depMaps.push(f);l.completeLoad(d);m([d],k)}),h.load(a.name,m,k,p))}));l.enable(d,this);this.pluginMaps[d.id]=d},enable:function(){Z[this.map.id]=this;this.enabling=this.enabled=!0;y(this.depMaps,z(this,function(a, 22 | b){var c,h;if("string"===typeof a){a=q(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap);this.depMaps[b]=a;if(c=e(R,a.id)){this.depExports[b]=c(this);return}this.depCount+=1;w(a,"defined",z(this,function(a){this.undefed||(this.defineDep(b,a),this.check())}));this.errback?w(a,"error",z(this,this.errback)):this.events.error&&w(a,"error",z(this,function(a){this.emit("error",a)}))}c=a.id;h=t[c];x(R,c)||!h||h.enabled||l.enable(a,this)}));D(this.pluginMaps,z(this,function(a){var b=e(t,a.id); 23 | b&&!b.enabled&&l.enable(a,this)}));this.enabling=!1;this.check()},on:function(a,b){var c=this.events[a];c||(c=this.events[a]=[]);c.push(b)},emit:function(a,b){y(this.events[a],function(a){a(b)});"error"===a&&delete this.events[a]}};l={config:p,contextName:b,registry:t,defined:v,urlFetched:W,defQueue:G,defQueueMap:{},Module:da,makeModuleMap:q,nextTick:g.nextTick,onError:A,configure:function(a){a.baseUrl&&"/"!==a.baseUrl.charAt(a.baseUrl.length-1)&&(a.baseUrl+="/");if("string"===typeof a.urlArgs){var b= 24 | a.urlArgs;a.urlArgs=function(a,c){return(-1===c.indexOf("?")?"?":"&")+b}}var c=p.shim,h={paths:!0,bundles:!0,config:!0,map:!0};D(a,function(a,b){h[b]?(p[b]||(p[b]={}),Y(p[b],a,!0,!0)):p[b]=a});a.bundles&&D(a.bundles,function(a,b){y(a,function(a){a!==b&&(fa[a]=b)})});a.shim&&(D(a.shim,function(a,b){L(a)&&(a={deps:a});!a.exports&&!a.init||a.exportsFn||(a.exportsFn=l.makeShimExports(a));c[b]=a}),p.shim=c);a.packages&&y(a.packages,function(a){var b;a="string"===typeof a?{name:a}:a;b=a.name;a.location&& 25 | (p.paths[b]=a.location);p.pkgs[b]=a.name+"/"+(a.main||"main").replace(na,"").replace(U,"")});D(t,function(a,b){a.inited||a.map.unnormalized||(a.map=q(b,null,!0))});(a.deps||a.callback)&&l.require(a.deps||[],a.callback)},makeShimExports:function(a){return function(){var b;a.init&&(b=a.init.apply(ga,arguments));return b||a.exports&&ia(a.exports)}},makeRequire:function(a,n){function m(c,d,f){var e,r;n.enableBuildCallback&&d&&K(d)&&(d.__requireJsBuild=!0);if("string"===typeof c){if(K(d))return A(F("requireargs", 26 | "Invalid require call"),f);if(a&&x(R,c))return R[c](t[a.id]);if(g.get)return g.get(l,c,a,m);e=q(c,a,!1,!0);e=e.id;return x(v,e)?v[e]:A(F("notloaded",'Module name "'+e+'" has not been loaded yet for context: '+b+(a?"":". Use require([])")))}P();l.nextTick(function(){P();r=u(q(null,a));r.skipMap=n.skipMap;r.init(c,d,f,{enabled:!0});H()});return m}n=n||{};Y(m,{isBrowser:E,toUrl:function(b){var d,f=b.lastIndexOf("."),g=b.split("/")[0];-1!==f&&("."!==g&&".."!==g||1e.attachEvent.toString().indexOf("[native code")||ca?(e.addEventListener("load",b.onScriptLoad,!1),e.addEventListener("error",b.onScriptError,!1)):(S=!0,e.attachEvent("onreadystatechange",b.onScriptLoad));e.src=d;if(m.onNodeCreated)m.onNodeCreated(e,m,c,d);P=e;H?C.insertBefore(e,H):C.appendChild(e);P=null;return e}if(ja)try{setTimeout(function(){}, 35 | 0),importScripts(d),b.completeLoad(c)}catch(q){b.onError(F("importscripts","importScripts failed for "+c+" at "+d,q,[c]))}};E&&!w.skipDataMain&&X(document.getElementsByTagName("script"),function(b){C||(C=b.parentNode);if(O=b.getAttribute("data-main"))return u=O,w.baseUrl||-1!==u.indexOf("!")||(I=u.split("/"),u=I.pop(),T=I.length?I.join("/")+"/":"./",w.baseUrl=T),u=u.replace(U,""),g.jsExtRegExp.test(u)&&(u=O),w.deps=w.deps?w.deps.concat(u):[u],!0});define=function(b,c,d){var e,g;"string"!==typeof b&& 36 | (d=c,c=b,b=null);L(c)||(d=c,c=null);!c&&K(d)&&(c=[],d.length&&(d.toString().replace(qa,ka).replace(ra,function(b,d){c.push(d)}),c=(1===d.length?["require"]:["require","exports","module"]).concat(c)));S&&(e=P||pa())&&(b||(b=e.getAttribute("data-requiremodule")),g=J[e.getAttribute("data-requirecontext")]);g?(g.defQueue.push([b,c,d]),g.defQueueMap[b]=!0):V.push([b,c,d])};define.amd={jQuery:!0};g.exec=function(b){return eval(b)};g(w)}})(this); 37 | -------------------------------------------------------------------------------- /example/browserify/README.md: -------------------------------------------------------------------------------- 1 | # Browserify example 2 | 3 | Two steps need to be done for this to work 4 | 5 | In the project root 6 | 7 | npm install 8 | 9 | In this folder 10 | 11 | ../../node_modules/.bin/browserify main.js -o bundle.js 12 | -------------------------------------------------------------------------------- /example/browserify/bundle.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dangrossman/daterangepicker/8495717c4007a03fd5dee422f161811fd6140c0e/example/browserify/bundle.js -------------------------------------------------------------------------------- /example/browserify/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | A date range picker for Bootstrap 6 | 7 | 8 | 14 | 15 | 16 | 17 |
18 | 19 |

Configuration Builder

20 | 21 |
22 | 23 |
24 |
25 | 26 |
27 | 28 |
29 | 30 | 31 |
32 | 33 |
34 | 35 | 36 |
37 | 38 |
39 | 40 | 41 |
42 | 43 |
44 | 45 | 46 |
47 | 48 |
49 | 50 | 51 |
52 | 53 |
54 |
55 | 56 |
57 | 60 |
61 | 62 |
63 | 66 |
67 | 68 |
69 | 72 |
73 | 74 |
75 | 78 |
79 | 80 |
81 | 84 |
85 | 86 |
87 | 90 |
91 | 92 |
93 | 96 |
97 | 98 |
99 | 100 | 101 |
102 | 103 |
104 | 107 |
108 | 109 |
110 | 113 |
114 | 115 |
116 | 119 |
120 | 121 |
122 | 125 |
126 | 127 |
128 | 131 |
132 | 133 |
134 | 137 |
138 | 139 |
140 | 143 |
144 | 145 |
146 |
147 | 148 |
149 | 150 | 155 |
156 | 157 |
158 | 159 | 163 |
164 | 165 |
166 | 167 | 168 |
169 | 170 |
171 | 172 | 173 |
174 | 175 |
176 | 177 | 178 |
179 | 180 |
181 | 182 |
183 |
184 | 185 |
186 | 187 |
188 | 189 |
190 |

Your Date Range Picker

191 | 192 | 193 |
194 | 195 |
196 |

Configuration

197 | 198 |
199 | 200 |
201 |
202 | 203 |
204 | 205 |
206 | 207 | 208 | 209 | 210 | -------------------------------------------------------------------------------- /example/browserify/main.js: -------------------------------------------------------------------------------- 1 | require('../../daterangepicker.js'); 2 | var $ = require('jquery'), 3 | moment = require('moment'); 4 | 5 | $(document).ready(function() { 6 | 7 | $('#config-text').keyup(function() { 8 | eval($(this).val()); 9 | }); 10 | 11 | $('.configurator input, .configurator select').change(function() { 12 | updateConfig(); 13 | }); 14 | 15 | $('.demo i').click(function() { 16 | $(this).parent().find('input').click(); 17 | }); 18 | 19 | $('#startDate').daterangepicker({ 20 | singleDatePicker: true, 21 | startDate: moment().subtract(6, 'days') 22 | }); 23 | 24 | $('#endDate').daterangepicker({ 25 | singleDatePicker: true, 26 | startDate: moment() 27 | }); 28 | 29 | updateConfig(); 30 | 31 | function updateConfig() { 32 | var options = {}; 33 | 34 | if ($('#singleDatePicker').is(':checked')) 35 | options.singleDatePicker = true; 36 | 37 | if ($('#showDropdowns').is(':checked')) 38 | options.showDropdowns = true; 39 | 40 | if ($('#showWeekNumbers').is(':checked')) 41 | options.showWeekNumbers = true; 42 | 43 | if ($('#showISOWeekNumbers').is(':checked')) 44 | options.showISOWeekNumbers = true; 45 | 46 | if ($('#timePicker').is(':checked')) 47 | options.timePicker = true; 48 | 49 | if ($('#timePicker24Hour').is(':checked')) 50 | options.timePicker24Hour = true; 51 | 52 | if ($('#timePickerIncrement').val().length && $('#timePickerIncrement').val() != 1) 53 | options.timePickerIncrement = parseInt($('#timePickerIncrement').val(), 10); 54 | 55 | if ($('#timePickerSeconds').is(':checked')) 56 | options.timePickerSeconds = true; 57 | 58 | if ($('#autoApply').is(':checked')) 59 | options.autoApply = true; 60 | 61 | if ($('#dateLimit').is(':checked')) 62 | options.dateLimit = { days: 7 }; 63 | 64 | if ($('#ranges').is(':checked')) { 65 | options.ranges = { 66 | 'Today': [moment(), moment()], 67 | 'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')], 68 | 'Last 7 Days': [moment().subtract(6, 'days'), moment()], 69 | 'Last 30 Days': [moment().subtract(29, 'days'), moment()], 70 | 'This Month': [moment().startOf('month'), moment().endOf('month')], 71 | 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')] 72 | }; 73 | } 74 | 75 | if ($('#locale').is(':checked')) { 76 | options.locale = { 77 | format: 'MM/DD/YYYY HH:mm', 78 | separator: ' - ', 79 | applyLabel: 'Apply', 80 | cancelLabel: 'Cancel', 81 | fromLabel: 'From', 82 | toLabel: 'To', 83 | customRangeLabel: 'Custom', 84 | daysOfWeek: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr','Sa'], 85 | monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], 86 | firstDay: 1 87 | }; 88 | } 89 | 90 | if (!$('#linkedCalendars').is(':checked')) 91 | options.linkedCalendars = false; 92 | 93 | if (!$('#autoUpdateInput').is(':checked')) 94 | options.autoUpdateInput = false; 95 | 96 | if ($('#alwaysShowCalendars').is(':checked')) 97 | options.alwaysShowCalendars = true; 98 | 99 | if ($('#parentEl').val().length) 100 | options.parentEl = $('#parentEl').val(); 101 | 102 | if ($('#startDate').val().length) 103 | options.startDate = $('#startDate').val(); 104 | 105 | if ($('#endDate').val().length) 106 | options.endDate = $('#endDate').val(); 107 | 108 | if ($('#minDate').val().length) 109 | options.minDate = $('#minDate').val(); 110 | 111 | if ($('#maxDate').val().length) 112 | options.maxDate = $('#maxDate').val(); 113 | 114 | if ($('#opens').val().length && $('#opens').val() != 'right') 115 | options.opens = $('#opens').val(); 116 | 117 | if ($('#drops').val().length && $('#drops').val() != 'down') 118 | options.drops = $('#drops').val(); 119 | 120 | if ($('#buttonClasses').val().length && $('#buttonClasses').val() != 'btn btn-sm') 121 | options.buttonClasses = $('#buttonClasses').val(); 122 | 123 | if ($('#applyClass').val().length && $('#applyClass').val() != 'btn-success') 124 | options.applyClass = $('#applyClass').val(); 125 | 126 | if ($('#cancelClass').val().length && $('#cancelClass').val() != 'btn-default') 127 | options.cancelClass = $('#cancelClass').val(); 128 | 129 | $('#config-text').val("$('#demo').daterangepicker(" + JSON.stringify(options, null, ' ') + ", function(start, end, label) {\n console.log(\"New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')\");\n});"); 130 | 131 | $('#config-demo').daterangepicker(options, function(start, end, label) { console.log('New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')'); }); 132 | 133 | } 134 | 135 | }); 136 | -------------------------------------------------------------------------------- /moment.min.js: -------------------------------------------------------------------------------- 1 | !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.moment=t()}(this,function(){"use strict";var e,i;function c(){return e.apply(null,arguments)}function o(e){return e instanceof Array||"[object Array]"===Object.prototype.toString.call(e)}function u(e){return null!=e&&"[object Object]"===Object.prototype.toString.call(e)}function l(e){return void 0===e}function h(e){return"number"==typeof e||"[object Number]"===Object.prototype.toString.call(e)}function d(e){return e instanceof Date||"[object Date]"===Object.prototype.toString.call(e)}function f(e,t){var n,s=[];for(n=0;n>>0,s=0;sSe(e)?(r=e+1,o-Se(e)):(r=e,o),{year:r,dayOfYear:a}}function Ie(e,t,n){var s,i,r=Ve(e.year(),t,n),a=Math.floor((e.dayOfYear()-r-1)/7)+1;return a<1?s=a+Ae(i=e.year()-1,t,n):a>Ae(e.year(),t,n)?(s=a-Ae(e.year(),t,n),i=e.year()+1):(i=e.year(),s=a),{week:s,year:i}}function Ae(e,t,n){var s=Ve(e,t,n),i=Ve(e+1,t,n);return(Se(e)-s+i)/7}I("w",["ww",2],"wo","week"),I("W",["WW",2],"Wo","isoWeek"),C("week","w"),C("isoWeek","W"),F("week",5),F("isoWeek",5),ue("w",B),ue("ww",B,z),ue("W",B),ue("WW",B,z),fe(["w","ww","W","WW"],function(e,t,n,s){t[s.substr(0,1)]=D(e)});function je(e,t){return e.slice(t,7).concat(e.slice(0,t))}I("d",0,"do","day"),I("dd",0,0,function(e){return this.localeData().weekdaysMin(this,e)}),I("ddd",0,0,function(e){return this.localeData().weekdaysShort(this,e)}),I("dddd",0,0,function(e){return this.localeData().weekdays(this,e)}),I("e",0,0,"weekday"),I("E",0,0,"isoWeekday"),C("day","d"),C("weekday","e"),C("isoWeekday","E"),F("day",11),F("weekday",11),F("isoWeekday",11),ue("d",B),ue("e",B),ue("E",B),ue("dd",function(e,t){return t.weekdaysMinRegex(e)}),ue("ddd",function(e,t){return t.weekdaysShortRegex(e)}),ue("dddd",function(e,t){return t.weekdaysRegex(e)}),fe(["dd","ddd","dddd"],function(e,t,n,s){var i=n._locale.weekdaysParse(e,s,n._strict);null!=i?t.d=i:g(n).invalidWeekday=e}),fe(["d","e","E"],function(e,t,n,s){t[s]=D(e)});var Ze="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_");var ze="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_");var $e="Su_Mo_Tu_We_Th_Fr_Sa".split("_");var qe=ae;var Je=ae;var Be=ae;function Qe(){function e(e,t){return t.length-e.length}var t,n,s,i,r,a=[],o=[],u=[],l=[];for(t=0;t<7;t++)n=y([2e3,1]).day(t),s=this.weekdaysMin(n,""),i=this.weekdaysShort(n,""),r=this.weekdays(n,""),a.push(s),o.push(i),u.push(r),l.push(s),l.push(i),l.push(r);for(a.sort(e),o.sort(e),u.sort(e),l.sort(e),t=0;t<7;t++)o[t]=he(o[t]),u[t]=he(u[t]),l[t]=he(l[t]);this._weekdaysRegex=new RegExp("^("+l.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+u.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+o.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+a.join("|")+")","i")}function Xe(){return this.hours()%12||12}function Ke(e,t){I(e,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),t)})}function et(e,t){return t._meridiemParse}I("H",["HH",2],0,"hour"),I("h",["hh",2],0,Xe),I("k",["kk",2],0,function(){return this.hours()||24}),I("hmm",0,0,function(){return""+Xe.apply(this)+L(this.minutes(),2)}),I("hmmss",0,0,function(){return""+Xe.apply(this)+L(this.minutes(),2)+L(this.seconds(),2)}),I("Hmm",0,0,function(){return""+this.hours()+L(this.minutes(),2)}),I("Hmmss",0,0,function(){return""+this.hours()+L(this.minutes(),2)+L(this.seconds(),2)}),Ke("a",!0),Ke("A",!1),C("hour","h"),F("hour",13),ue("a",et),ue("A",et),ue("H",B),ue("h",B),ue("k",B),ue("HH",B,z),ue("hh",B,z),ue("kk",B,z),ue("hmm",Q),ue("hmmss",X),ue("Hmm",Q),ue("Hmmss",X),ce(["H","HH"],ge),ce(["k","kk"],function(e,t,n){var s=D(e);t[ge]=24===s?0:s}),ce(["a","A"],function(e,t,n){n._isPm=n._locale.isPM(e),n._meridiem=e}),ce(["h","hh"],function(e,t,n){t[ge]=D(e),g(n).bigHour=!0}),ce("hmm",function(e,t,n){var s=e.length-2;t[ge]=D(e.substr(0,s)),t[ve]=D(e.substr(s)),g(n).bigHour=!0}),ce("hmmss",function(e,t,n){var s=e.length-4,i=e.length-2;t[ge]=D(e.substr(0,s)),t[ve]=D(e.substr(s,2)),t[pe]=D(e.substr(i)),g(n).bigHour=!0}),ce("Hmm",function(e,t,n){var s=e.length-2;t[ge]=D(e.substr(0,s)),t[ve]=D(e.substr(s))}),ce("Hmmss",function(e,t,n){var s=e.length-4,i=e.length-2;t[ge]=D(e.substr(0,s)),t[ve]=D(e.substr(s,2)),t[pe]=D(e.substr(i))});var tt,nt=Te("Hours",!0),st={calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},longDateFormat:{LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},invalidDate:"Invalid date",ordinal:"%d",dayOfMonthOrdinalParse:/\d{1,2}/,relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},months:Ce,monthsShort:He,week:{dow:0,doy:6},weekdays:Ze,weekdaysMin:$e,weekdaysShort:ze,meridiemParse:/[ap]\.?m?\.?/i},it={},rt={};function at(e){return e?e.toLowerCase().replace("_","-"):e}function ot(e){var t=null;if(!it[e]&&"undefined"!=typeof module&&module&&module.exports)try{t=tt._abbr,require("./locale/"+e),ut(t)}catch(e){}return it[e]}function ut(e,t){var n;return e&&((n=l(t)?ht(e):lt(e,t))?tt=n:"undefined"!=typeof console&&console.warn&&console.warn("Locale "+e+" not found. Did you forget to load it?")),tt._abbr}function lt(e,t){if(null===t)return delete it[e],null;var n,s=st;if(t.abbr=e,null!=it[e])T("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),s=it[e]._config;else if(null!=t.parentLocale)if(null!=it[t.parentLocale])s=it[t.parentLocale]._config;else{if(null==(n=ot(t.parentLocale)))return rt[t.parentLocale]||(rt[t.parentLocale]=[]),rt[t.parentLocale].push({name:e,config:t}),null;s=n._config}return it[e]=new P(x(s,t)),rt[e]&&rt[e].forEach(function(e){lt(e.name,e.config)}),ut(e),it[e]}function ht(e){var t;if(e&&e._locale&&e._locale._abbr&&(e=e._locale._abbr),!e)return tt;if(!o(e)){if(t=ot(e))return t;e=[e]}return function(e){for(var t,n,s,i,r=0;r=t&&a(i,n,!0)>=t-1)break;t--}r++}return tt}(e)}function dt(e){var t,n=e._a;return n&&-2===g(e).overflow&&(t=n[_e]<0||11Pe(n[me],n[_e])?ye:n[ge]<0||24Ae(n,r,a)?g(e)._overflowWeeks=!0:null!=u?g(e)._overflowWeekday=!0:(o=Ee(n,s,i,r,a),e._a[me]=o.year,e._dayOfYear=o.dayOfYear)}(e),null!=e._dayOfYear&&(r=ct(e._a[me],s[me]),(e._dayOfYear>Se(r)||0===e._dayOfYear)&&(g(e)._overflowDayOfYear=!0),n=Ge(r,0,e._dayOfYear),e._a[_e]=n.getUTCMonth(),e._a[ye]=n.getUTCDate()),t=0;t<3&&null==e._a[t];++t)e._a[t]=a[t]=s[t];for(;t<7;t++)e._a[t]=a[t]=null==e._a[t]?2===t?1:0:e._a[t];24===e._a[ge]&&0===e._a[ve]&&0===e._a[pe]&&0===e._a[we]&&(e._nextDay=!0,e._a[ge]=0),e._d=(e._useUTC?Ge:function(e,t,n,s,i,r,a){var o;return e<100&&0<=e?(o=new Date(e+400,t,n,s,i,r,a),isFinite(o.getFullYear())&&o.setFullYear(e)):o=new Date(e,t,n,s,i,r,a),o}).apply(null,a),i=e._useUTC?e._d.getUTCDay():e._d.getDay(),null!=e._tzm&&e._d.setUTCMinutes(e._d.getUTCMinutes()-e._tzm),e._nextDay&&(e._a[ge]=24),e._w&&void 0!==e._w.d&&e._w.d!==i&&(g(e).weekdayMismatch=!0)}}var mt=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,_t=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,yt=/Z|[+-]\d\d(?::?\d\d)?/,gt=[["YYYYYY-MM-DD",/[+-]\d{6}-\d\d-\d\d/],["YYYY-MM-DD",/\d{4}-\d\d-\d\d/],["GGGG-[W]WW-E",/\d{4}-W\d\d-\d/],["GGGG-[W]WW",/\d{4}-W\d\d/,!1],["YYYY-DDD",/\d{4}-\d{3}/],["YYYY-MM",/\d{4}-\d\d/,!1],["YYYYYYMMDD",/[+-]\d{10}/],["YYYYMMDD",/\d{8}/],["GGGG[W]WWE",/\d{4}W\d{3}/],["GGGG[W]WW",/\d{4}W\d{2}/,!1],["YYYYDDD",/\d{7}/]],vt=[["HH:mm:ss.SSSS",/\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss,SSSS",/\d\d:\d\d:\d\d,\d+/],["HH:mm:ss",/\d\d:\d\d:\d\d/],["HH:mm",/\d\d:\d\d/],["HHmmss.SSSS",/\d\d\d\d\d\d\.\d+/],["HHmmss,SSSS",/\d\d\d\d\d\d,\d+/],["HHmmss",/\d\d\d\d\d\d/],["HHmm",/\d\d\d\d/],["HH",/\d\d/]],pt=/^\/?Date\((\-?\d+)/i;function wt(e){var t,n,s,i,r,a,o=e._i,u=mt.exec(o)||_t.exec(o);if(u){for(g(e).iso=!0,t=0,n=gt.length;tn.valueOf():n.valueOf()this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()},mn.isLocal=function(){return!!this.isValid()&&!this._isUTC},mn.isUtcOffset=function(){return!!this.isValid()&&this._isUTC},mn.isUtc=Et,mn.isUTC=Et,mn.zoneAbbr=function(){return this._isUTC?"UTC":""},mn.zoneName=function(){return this._isUTC?"Coordinated Universal Time":""},mn.dates=n("dates accessor is deprecated. Use date instead.",un),mn.months=n("months accessor is deprecated. Use month instead",Ue),mn.years=n("years accessor is deprecated. Use year instead",Oe),mn.zone=n("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",function(e,t){return null!=e?("string"!=typeof e&&(e=-e),this.utcOffset(e,t),this):-this.utcOffset()}),mn.isDSTShifted=n("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",function(){if(!l(this._isDSTShifted))return this._isDSTShifted;var e={};if(w(e,this),(e=Ot(e))._a){var t=e._isUTC?y(e._a):bt(e._a);this._isDSTShifted=this.isValid()&&0=1.10", 26 | "moment": "^2.9.0" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /website/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Date Range Picker — JavaScript Date & Time Picker Library 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 43 | 44 |
45 |
46 |
47 |
48 | 49 |

Date Range Picker

50 |

51 | A JavaScript component for choosing date ranges, 52 | dates and times. 53 |

54 | 55 |
56 |
57 | 58 |
59 |   View on GitHub 60 | 61 |   62 | 63 |   Download ZIP 64 |
65 | 66 |
67 | 68 | 69 | 70 | 71 | 72 |
73 | 74 |
75 |
76 |
77 |
78 | 79 |
80 |
81 |
82 | 89 | 90 |
91 | 92 | 93 | 98 | 101 |
102 | 103 |
104 |
105 | 106 |

Originally created for reports at Improvely, the Date Range Picker can be attached to any webpage element to pop up two calendars for selecting dates, times, or predefined ranges like "Last 30 Days".

107 | 108 | 109 | 110 |

Getting Started

111 | 112 |

113 | To get started, include jQuery, Moment.js and Date Range Picker's files in your webpage: 114 |

115 | 116 | 117 | 118 |

119 | Then attach a date range picker to whatever you want to trigger it: 120 |

121 | 122 |
123 |
124 | 125 | 126 |
127 |
128 | 129 | 130 | 135 |
136 |
137 | 138 |

139 | You can customize Date Range Picker with options, and get notified when the user chooses new dates by providing a callback function. 140 |

141 | 142 |

Examples

143 | 144 | 145 |

Simple Date Range Picker With a Callback

146 |
147 |
148 |
149 | 150 | 151 |
152 |
153 | 154 | 155 | 156 | 165 |
166 |
167 |
168 | 169 | 170 |

Date Range Picker With Times

171 |
172 |
173 |
174 | 175 | 176 |
177 |
178 | 179 | 180 | 181 | 193 |
194 |
195 |
196 | 197 | 198 |

Single Date Picker

199 |
200 |
201 |
202 | 203 | 204 |
205 |
206 | 207 | 208 | 209 | 222 |
223 |
224 |
225 | 226 | 227 |

Predefined Date Ranges

228 |
229 |
230 |
231 | 232 | 233 |
234 |
235 | 236 | 237 |
238 |   239 | 240 |
241 | 242 | 269 | 270 |
271 |
272 |
273 | 274 | 275 |

Input Initially Empty

276 |
277 |
278 |
279 | 280 | 281 |
282 |
283 | 284 | 285 | 286 | 306 |
307 |
308 |
309 | 310 |

Options

311 | 312 |
    313 |
  • 314 | startDate (Date or string) The beginning date of the initially selected date range. If you provide a string, it must match the date format string set in your locale setting. 315 |
  • 316 |
  • 317 | endDate: (Date or string) The end date of the initially selected date range. 318 |
  • 319 |
  • 320 | minDate: (Date or string) The earliest date a user may select. 321 |
  • 322 |
  • 323 | maxDate: (Date or string) The latest date a user may select. 324 |
  • 325 |
  • 326 | maxSpan: (object) The maximum span between the selected start and end dates. Check off maxSpan in the configuration generator for an example of how to use this. You can provide any object the moment library would let you add to a date. 327 |
  • 328 |
  • 329 | showDropdowns: (true/false) Show year and month select boxes above calendars to jump to a specific month and year. 330 |
  • 331 |
  • 332 | minYear: (number) The minimum year shown in the dropdowns when showDropdowns is set to true. 333 |
  • 334 |
  • 335 | maxYear: (number) The maximum year shown in the dropdowns when showDropdowns is set to true. 336 |
  • 337 |
  • 338 | showWeekNumbers: (true/false) Show localized week numbers at the start of each week on the calendars. 339 |
  • 340 |
  • 341 | showISOWeekNumbers: (true/false) Show ISO week numbers at the start of each week on the calendars. 342 |
  • 343 |
  • 344 | timePicker: (true/false) Adds select boxes to choose times in addition to dates. 345 |
  • 346 |
  • 347 | timePickerIncrement: (number) Increment of the minutes selection list for times (i.e. 30 to allow only selection of times ending in 0 or 30). 348 |
  • 349 |
  • 350 | timePicker24Hour: (true/false) Use 24-hour instead of 12-hour times, removing the AM/PM selection. 351 |
  • 352 |
  • 353 | timePickerSeconds: (true/false) Show seconds in the timePicker. 354 |
  • 355 |
  • 356 | ranges: (object) Set predefined date ranges the user can select from. Each key is the label for the range, and its value an array with two dates representing the bounds of the range. Click ranges in the configuration generator for examples. 357 |
  • 358 |
  • 359 | showCustomRangeLabel: (true/false) Displays "Custom Range" at 360 | the end of the list of predefined ranges, when the ranges option is used. 361 | This option will be highlighted whenever the current date range selection does not match one of the predefined ranges. Clicking it will display the calendars to select a new range. 362 |
  • 363 |
  • 364 | alwaysShowCalendars: (true/false) Normally, if you use the ranges option to specify pre-defined date ranges, calendars for choosing a custom date range are not shown until the user clicks "Custom Range". When this option is set to true, the calendars for choosing a custom date range are always shown instead. 365 |
  • 366 |
  • 367 | opens: ('left'/'right'/'center') Whether the picker appears aligned to the left, to the right, or centered under the HTML element it's attached to. 368 |
  • 369 |
  • 370 | drops: ('down'/'up'/'auto') Whether the picker appears below (default) or above the HTML element it's attached to. 371 |
  • 372 |
  • 373 | buttonClasses: (string) CSS class names that will be added to both the apply and cancel buttons. 374 |
  • 375 |
  • 376 | applyButtonClasses: (string) CSS class names that will be added only to the apply button. 377 |
  • 378 |
  • 379 | cancelButtonClasses: (string) CSS class names that will be added only to the cancel button. 380 |
  • 381 |
  • 382 | locale: (object) Allows you to provide localized strings for buttons and labels, customize the date format, and change the first day of week for the calendars. 383 | Check off locale in the configuration generator to see how 384 | to customize these options. 385 |
  • 386 |
  • 387 | singleDatePicker: (true/false) Show only a single calendar to choose one date, instead of a range picker with two calendars. The start and end dates provided to your callback will be the same single date chosen. 388 |
  • 389 |
  • 390 | autoApply: (true/false) Hide the apply and cancel buttons, and automatically apply a new date range as soon as two dates are clicked. 391 |
  • 392 |
  • 393 | linkedCalendars: (true/false) When enabled, the two calendars displayed will always be for two sequential months (i.e. January and February), and both will be advanced when clicking the left or right arrows above the calendars. When disabled, the two calendars can be individually advanced and display any month/year. 394 |
  • 395 |
  • 396 | isInvalidDate: (function) A function that is passed each date in the two 397 | calendars before they are displayed, and may return true or false to indicate whether 398 | that date should be available for selection or not. 399 |
  • 400 |
  • 401 | isCustomDate: (function) A function that is passed each date in the two 402 | calendars before they are displayed, and may return a string or array of CSS class names 403 | to apply to that date's calendar cell. 404 |
  • 405 |
  • 406 | autoUpdateInput: (true/false) Indicates whether the date range picker should 407 | automatically update the value of the <input> element it's attached to at initialization and when the selected dates change. 408 |
  • 409 |
  • 410 | parentEl: (string) jQuery selector of the parent element that the date range picker will be added to, if not provided this will be 'body' 411 |
  • 412 |
413 | 414 |

Methods

415 | 416 |

417 | You can programmatically update the startDate and endDate 418 | in the picker using the setStartDate and setEndDate methods. 419 | You can access the Date Range Picker object and its functions and properties through 420 | data properties of the element you attached it to. 421 |

422 | 423 | 424 | 425 |
426 | 427 |
    428 |
  • 429 | setStartDate(Date or string): Sets the date range picker's currently selected start date to the provided date 430 |
  • 431 |
  • 432 | setEndDate(Date or string): Sets the date range picker's currently selected end date to the provided date 433 |
  • 434 |
435 | 436 |

Example usage:

437 | 438 | 439 | 440 |

Events

441 | 442 |

443 | Several events are triggered on the element you attach the picker to, which you can listen for. 444 |

445 | 446 |
    447 |
  • 448 | show.daterangepicker: Triggered when the picker is shown 449 |
  • 450 |
  • 451 | hide.daterangepicker: Triggered when the picker is hidden 452 |
  • 453 |
  • 454 | showCalendar.daterangepicker: Triggered when the calendar(s) are shown 455 |
  • 456 |
  • 457 | hideCalendar.daterangepicker: Triggered when the calendar(s) are hidden 458 |
  • 459 |
  • 460 | apply.daterangepicker: Triggered when the apply button is clicked, 461 | or when a predefined range is clicked 462 |
  • 463 |
  • 464 | cancel.daterangepicker: Triggered when the cancel button is clicked 465 |
  • 466 |
467 | 468 |

469 | Some applications need a "clear" instead of a "cancel" functionality, which can be achieved by changing the button label and watching for the cancel event: 470 |

471 | 472 | 473 | 474 |
475 | 476 |

477 | While passing in a callback to the constructor is the easiest way to listen for changes in the selected date range, you can also do something every time the apply button is clicked even if the selection hasn't changed: 478 |

479 | 480 | 481 | 482 |

Configuration Generator

483 | 484 |
485 | 486 |
487 |
488 | 489 |
490 | 491 |
492 | 493 | 494 |
495 | 496 |
497 | 498 | 499 |
500 | 501 |
502 | 503 | 504 |
505 | 506 |
507 | 508 | 509 |
510 | 511 |
512 | 513 | 514 |
515 | 516 |
517 | 518 | 523 |
524 | 525 |
526 | 527 | 532 |
533 | 534 |
535 |
536 | 537 |
538 | 541 |
542 | 543 |
544 | 545 | 546 |
547 | 548 |
549 | 550 | 551 |
552 | 553 |
554 | 557 |
558 | 559 |
560 | 563 |
564 | 565 |
566 | 569 |
570 | 571 |
572 | 575 |
576 | 577 |
578 | 581 |
582 | 583 |
584 | 585 | 586 |
587 | 588 |
589 | 592 |
593 | 594 |
595 | 598 |
599 | 600 |
601 | 604 |
605 | 606 |
607 | 610 |
611 | 612 |
613 |
614 | 615 |
616 | 617 | 618 |
619 | 620 |
621 | 622 | 623 |
624 | 625 |
626 | 627 | 628 |
629 | 630 |
631 | 634 |
635 | 636 |
637 | 640 |
641 | 642 |
643 | 646 |
647 | 648 |
649 | 652 |
653 | 654 |
655 | 658 |
659 | 660 |
661 | 662 |
663 |
664 | 665 |
666 | 667 |
668 | 669 |
670 |
671 |

Your Date Range Picker

672 | 673 |
674 |
675 | 676 |
677 |

Your Configuration to Copy

678 | 679 |
680 | 681 |
682 |
683 | 684 |
685 | 686 | 687 | 688 |

License

689 | 690 |

The MIT License (MIT)

691 | 692 |

Copyright (c) 2012-2019 Dan Grossman

693 | 694 |

695 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 696 |

697 | 698 |

699 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 700 |

701 | 702 |

703 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 704 |

705 | 706 |

Comments

707 | 708 |
709 | 724 | 725 | 726 |
727 |
728 |
729 | 730 | 731 | 732 | 733 | 734 | 739 | 740 | 743 | 744 | 745 | 746 | -------------------------------------------------------------------------------- /website/website.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 15px; 3 | line-height: 1.6em; 4 | position: relative; 5 | margin: 0; 6 | } 7 | 8 | .navbar .nav-item { 9 | padding: 8px 0 8px 20px; 10 | } 11 | 12 | .navbar .nav-link { 13 | font-weight: bold; 14 | font-size: 14px; 15 | padding: 0; 16 | } 17 | 18 | .navbar-expand-sm .navbar-nav .nav-link { 19 | padding: 0; 20 | } 21 | 22 | .well { 23 | background: #f5f5f5; 24 | border-radius: 4px; 25 | padding: 20px; 26 | } 27 | 28 | h1 { 29 | font-size: 20px; 30 | margin-bottom: 1em; 31 | padding-bottom: 5px; 32 | border-bottom: 1px dotted #08c; 33 | } 34 | 35 | h1:before { 36 | content: '#'; 37 | color: #666; 38 | position: relative; 39 | padding-right: 5px; 40 | } 41 | 42 | h2 { 43 | padding: 0; 44 | margin: 20px 0 0 0; 45 | font-size: 18px; 46 | } 47 | 48 | h2 a { 49 | color: #444; 50 | display: block; 51 | background: #eee; 52 | padding: 8px 12px; 53 | margin-bottom: 0; 54 | cursor: default; 55 | text-decoration: none; 56 | } 57 | 58 | input.form-control { 59 | font-size: 14px; 60 | } 61 | 62 | .collapsable { 63 | border: 1px solid #eee; 64 | padding: 12px; 65 | display: block; 66 | } 67 | 68 | label { 69 | font-size: 13px; 70 | font-weight: bold; 71 | } 72 | 73 | .gist { 74 | overflow: auto; 75 | } 76 | 77 | .gist .blob-wrapper.data { 78 | max-height: 350px; 79 | overflow: auto; 80 | } 81 | 82 | .list-group-item { 83 | padding: 4px 0; 84 | border: 0; 85 | font-size: 16px; 86 | } 87 | 88 | .leftcol { 89 | position: absolute; 90 | top: 180px; 91 | } 92 | 93 | .rightcol { 94 | max-width: 950px; 95 | } 96 | 97 | .container { 98 | max-width: 1300px; 99 | } 100 | 101 | @media (min-width: 980px) { 102 | .rightcol { 103 | margin-left: 320px; 104 | } 105 | } 106 | 107 | p, pre { 108 | margin-bottom: 2em; 109 | } 110 | 111 | ul.nobullets { 112 | margin: 0; 113 | padding: 0; 114 | list-style: none; 115 | } 116 | ul.nobullets li { 117 | padding-bottom: 1em; 118 | margin-bottom: 1em; 119 | border-bottom: 1px dotted #ddd; 120 | } 121 | 122 | input[type="text"] { 123 | padding: 6px; 124 | width: 100%; 125 | border-radius: 4px; 126 | } 127 | 128 | #footer { 129 | background: #222; 130 | margin-top: 80px; 131 | padding: 10px; 132 | color: #fff; 133 | text-align: center; 134 | } 135 | #footer a:link, #footer a:visited { 136 | color: #fff; 137 | border-bottom: 1px dotted #fff; 138 | } 139 | #jumbo { 140 | background: #c1deef; 141 | color: #000; 142 | padding: 20px 0; 143 | margin-bottom: 20px; 144 | } 145 | 146 | #jumbo h1 { 147 | font-size: 28px; 148 | } 149 | #jumbo .btn { 150 | border-radius: 0; 151 | font-size: 16px; 152 | } -------------------------------------------------------------------------------- /website/website.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function() { 2 | 3 | $('#config-text').keyup(function() { 4 | eval($(this).val()); 5 | }); 6 | 7 | $('.configurator input, .configurator select').change(function() { 8 | updateConfig(); 9 | }); 10 | 11 | $('.demo i').click(function() { 12 | $(this).parent().find('input').click(); 13 | }); 14 | 15 | $('#startDate').daterangepicker({ 16 | singleDatePicker: true, 17 | startDate: moment().subtract(6, 'days') 18 | }); 19 | 20 | $('#endDate').daterangepicker({ 21 | singleDatePicker: true, 22 | startDate: moment() 23 | }); 24 | 25 | //updateConfig(); 26 | 27 | function updateConfig() { 28 | var options = {}; 29 | 30 | if ($('#singleDatePicker').is(':checked')) 31 | options.singleDatePicker = true; 32 | 33 | if ($('#showDropdowns').is(':checked')) 34 | options.showDropdowns = true; 35 | 36 | if ($('#minYear').val().length && $('#minYear').val() != 1) 37 | options.minYear = parseInt($('#minYear').val(), 10); 38 | 39 | if ($('#maxYear').val().length && $('#maxYear').val() != 1) 40 | options.maxYear = parseInt($('#maxYear').val(), 10); 41 | 42 | if ($('#showWeekNumbers').is(':checked')) 43 | options.showWeekNumbers = true; 44 | 45 | if ($('#showISOWeekNumbers').is(':checked')) 46 | options.showISOWeekNumbers = true; 47 | 48 | if ($('#timePicker').is(':checked')) 49 | options.timePicker = true; 50 | 51 | if ($('#timePicker24Hour').is(':checked')) 52 | options.timePicker24Hour = true; 53 | 54 | if ($('#timePickerIncrement').val().length && $('#timePickerIncrement').val() != 1) 55 | options.timePickerIncrement = parseInt($('#timePickerIncrement').val(), 10); 56 | 57 | if ($('#timePickerSeconds').is(':checked')) 58 | options.timePickerSeconds = true; 59 | 60 | if ($('#autoApply').is(':checked')) 61 | options.autoApply = true; 62 | 63 | if ($('#maxSpan').is(':checked')) 64 | options.maxSpan = { days: 7 }; 65 | 66 | if ($('#ranges').is(':checked')) { 67 | options.ranges = { 68 | 'Today': [moment(), moment()], 69 | 'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')], 70 | 'Last 7 Days': [moment().subtract(6, 'days'), moment()], 71 | 'Last 30 Days': [moment().subtract(29, 'days'), moment()], 72 | 'This Month': [moment().startOf('month'), moment().endOf('month')], 73 | 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')] 74 | }; 75 | } 76 | 77 | if ($('#locale').is(':checked')) { 78 | options.locale = { 79 | format: 'MM/DD/YYYY', 80 | separator: ' - ', 81 | applyLabel: 'Apply', 82 | cancelLabel: 'Cancel', 83 | fromLabel: 'From', 84 | toLabel: 'To', 85 | customRangeLabel: 'Custom', 86 | weekLabel: 'W', 87 | daysOfWeek: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr','Sa'], 88 | monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], 89 | firstDay: 1 90 | }; 91 | } 92 | 93 | if (!$('#linkedCalendars').is(':checked')) 94 | options.linkedCalendars = false; 95 | 96 | if (!$('#autoUpdateInput').is(':checked')) 97 | options.autoUpdateInput = false; 98 | 99 | if (!$('#showCustomRangeLabel').is(':checked')) 100 | options.showCustomRangeLabel = false; 101 | 102 | if ($('#alwaysShowCalendars').is(':checked')) 103 | options.alwaysShowCalendars = true; 104 | 105 | if ($('#parentEl').val().length) 106 | options.parentEl = $('#parentEl').val(); 107 | 108 | if ($('#startDate').val().length) 109 | options.startDate = $('#startDate').val(); 110 | 111 | if ($('#endDate').val().length) 112 | options.endDate = $('#endDate').val(); 113 | 114 | if ($('#minDate').val().length) 115 | options.minDate = $('#minDate').val(); 116 | 117 | if ($('#maxDate').val().length) 118 | options.maxDate = $('#maxDate').val(); 119 | 120 | if ($('#opens').val().length && $('#opens').val() != 'right') 121 | options.opens = $('#opens').val(); 122 | 123 | if ($('#drops').val().length && $('#drops').val() != 'down') 124 | options.drops = $('#drops').val(); 125 | 126 | if ($('#buttonClasses').val().length && $('#buttonClasses').val() != 'btn btn-sm') 127 | options.buttonClasses = $('#buttonClasses').val(); 128 | 129 | if ($('#applyButtonClasses').val().length && $('#applyButtonClasses').val() != 'btn-primary') 130 | options.applyButtonClasses = $('#applyButtonClasses').val(); 131 | 132 | if ($('#cancelButtonClasses').val().length && $('#cancelButtonClasses').val() != 'btn-default') 133 | options.cancelClass = $('#cancelButtonClasses').val(); 134 | 135 | $('#config-demo').daterangepicker(options, function(start, end, label) { console.log('New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')'); }); 136 | 137 | if (typeof options.ranges !== 'undefined') { 138 | options.ranges = {}; 139 | } 140 | 141 | var option_text = JSON.stringify(options, null, ' '); 142 | 143 | var replacement = "ranges: {\n" 144 | + " 'Today': [moment(), moment()],\n" 145 | + " 'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],\n" 146 | + " 'Last 7 Days': [moment().subtract(6, 'days'), moment()],\n" 147 | + " 'Last 30 Days': [moment().subtract(29, 'days'), moment()],\n" 148 | + " 'This Month': [moment().startOf('month'), moment().endOf('month')],\n" 149 | + " 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]\n" 150 | + " }"; 151 | option_text = option_text.replace(new RegExp('"ranges"\: \{\}', 'g'), replacement); 152 | 153 | $('#config-text').val("$('#demo').daterangepicker(" + option_text + ", function(start, end, label) {\n console.log('New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')');\n});"); 154 | 155 | } 156 | 157 | $(window).scroll(function (event) { 158 | var scroll = $(window).scrollTop(); 159 | if (scroll > 180) { 160 | $('.leftcol').css('position', 'fixed'); 161 | $('.leftcol').css('top', '10px'); 162 | } else { 163 | $('.leftcol').css('position', 'absolute'); 164 | $('.leftcol').css('top', '180px'); 165 | } 166 | }); 167 | 168 | var bg = new Trianglify({ 169 | x_colors: ["#e1f3fd", "#eeeeee", "#407dbf"], 170 | y_colors: 'match_x', 171 | width: document.body.clientWidth, 172 | height: 150, 173 | stroke_width: 0, 174 | cell_size: 20 175 | }); 176 | 177 | $('#jumbo').css('background-image', 'url(' + bg.png() + ')'); 178 | 179 | }); 180 | --------------------------------------------------------------------------------