├── .prettierrc ├── .husky └── pre-commit ├── .prettierignore ├── .vscode └── settings.json ├── .gitignore ├── favicon.ico ├── mdp-icon.png ├── demos ├── simple.html ├── input.html ├── max-picks.html ├── days-range.html ├── custom-date-format.html ├── min-max-date.html ├── disable-dates.html ├── preselect-dates.html ├── pickable-range.html ├── alt-field.html ├── disable-calendar.html ├── ui-calendar-methods.html ├── full-year.html └── index.html ├── jest.setup.js ├── eslint.config.mjs ├── jquery-ui.multidatespicker.css ├── bower.json ├── .github └── workflows │ └── ci.yml ├── README.md ├── package.json ├── index.js ├── jest.config.js ├── jquery-ui.multidatespicker.js ├── index.html └── __tests__ └── multidatespicker.test.js /.prettierrc: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | npx lint-staged 2 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | # Ignore artifacts: 2 | build 3 | coverage 4 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.tabSize": 2 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .eslintcache 2 | .idea 3 | /node_modules/ 4 | /coverage/ -------------------------------------------------------------------------------- /favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dubrox/Multiple-Dates-Picker-for-jQuery-UI/HEAD/favicon.ico -------------------------------------------------------------------------------- /mdp-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dubrox/Multiple-Dates-Picker-for-jQuery-UI/HEAD/mdp-icon.png -------------------------------------------------------------------------------- /demos/simple.html: -------------------------------------------------------------------------------- 1 |
2 | 5 | -------------------------------------------------------------------------------- /demos/input.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | -------------------------------------------------------------------------------- /demos/max-picks.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | -------------------------------------------------------------------------------- /demos/days-range.html: -------------------------------------------------------------------------------- 1 | 2 | 8 | -------------------------------------------------------------------------------- /demos/custom-date-format.html: -------------------------------------------------------------------------------- 1 | 2 | 8 | -------------------------------------------------------------------------------- /demos/min-max-date.html: -------------------------------------------------------------------------------- 1 | 2 | 8 | -------------------------------------------------------------------------------- /jest.setup.js: -------------------------------------------------------------------------------- 1 | const jQuery = require("jquery"); 2 | global.$ = global.jQuery = window.$ = window.jQuery = jQuery; 3 | jQuery.ui = require("jquery-ui"); 4 | require("jquery-ui/ui/widgets/datepicker"); 5 | require("./jquery-ui.multidatespicker.js"); 6 | -------------------------------------------------------------------------------- /demos/disable-dates.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | -------------------------------------------------------------------------------- /demos/preselect-dates.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | -------------------------------------------------------------------------------- /demos/pickable-range.html: -------------------------------------------------------------------------------- 1 | 2 | 10 | -------------------------------------------------------------------------------- /demos/alt-field.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | -------------------------------------------------------------------------------- /demos/disable-calendar.html: -------------------------------------------------------------------------------- 1 | 2 | 13 | -------------------------------------------------------------------------------- /demos/ui-calendar-methods.html: -------------------------------------------------------------------------------- 1 | 2 | 13 | -------------------------------------------------------------------------------- /eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import globals from "globals"; 2 | import pluginJs from "@eslint/js"; 3 | import eslintConfigPrettier from "eslint-config-prettier"; 4 | 5 | /** @type {import('eslint').Linter.Config[]} */ 6 | export default [ 7 | { languageOptions: { globals: globals.browser } }, 8 | eslintConfigPrettier, 9 | pluginJs.configs.recommended, 10 | { 11 | rules: { 12 | "no-fallthrough": "off", 13 | "no-undef": "warn", 14 | "no-unused-vars": "warn", 15 | }, 16 | }, 17 | ]; 18 | -------------------------------------------------------------------------------- /jquery-ui.multidatespicker.css: -------------------------------------------------------------------------------- 1 | /* jQuery UI Datepicker moving pixels fix */ 2 | table.ui-datepicker-calendar { 3 | border-collapse: separate; 4 | } 5 | .ui-datepicker-calendar td { 6 | border: 1px solid transparent; 7 | } 8 | 9 | /* jQuery UI Datepicker hide datepicker helper */ 10 | #ui-datepicker-div { 11 | display: none; 12 | } 13 | 14 | /* jQuery UI Datepicker emphasis on selected dates */ 15 | .ui-datepicker .ui-datepicker-calendar .ui-state-highlight a { 16 | background: #743620 none; 17 | color: white; 18 | } 19 | -------------------------------------------------------------------------------- /demos/full-year.html: -------------------------------------------------------------------------------- 1 | 11 | 12 | 21 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery-ui-multidatespicker", 3 | "description": "Extension to the jQuery UI Calendar allowing multiple selections", 4 | "license": "(MIT OR GPLv2)", 5 | "authors": ["Luca Lauretta82 | MDP is a little plugin that enables jQuery UI calendar to manage 83 | multiple dates with the following features: 84 |
85 |X days from where it is possible to
91 | select Y dates.
92 |
127 | Use bower, npm, yarn or
128 | download the
129 | zip. Refer to the
133 | README
137 | for the installation details.
138 |
144 | Please use the issue tracker on 145 | GitHub Issues 149 |
150 |156 | Being an extension to jQuery UI DatePicker you need to include both 157 | jQuery and jQuery UI (with datepicker module included!) javascript 158 | files to your HTML page, and right after that, include 159 | MultiDatesPicker. 160 |
161 |
162 | To apply it to an element, do it the same way as you would do with
163 | jQuery UI datepicker, but write multiDatesPicker instead of
164 | datepicker:
165 |
166 | $(selector).multiDatesPicker(options_for_datepicker_and_mdp);
169 |
176 | Adds an array of dates specified in a string, milliseconds or
177 | javascript date object format.
178 |
179 | NOTE: the string format you should pass to multiDatePicker
181 | depends on the localization of datepicker, see this page for
182 | more infos on how to configure it.
184 |
189 | Disables an array of dates specified in a string, milliseconds or
190 | javascript date object format.
191 |
192 | NOTE: the string format you should pass to multiDatePicker
194 | depends on the localization of datepicker, see this page for
195 | more infos on how to configure it.
197 |
202 | Allows to specify a custom separator for the string representation 203 | of the dates selected (defaults ", "). 204 |
205 |209 | Allows to enable a different MDP modes: 'normal' (default) or 210 | 'daysRange'. 211 |
212 |217 | Number of dates allowed to be selected (see demo). 221 |
222 |226 | Limits the range of dates available for selection to a certain 227 | number of days from the first selection (see demo). 231 |
232 |
236 | A boolean that allows to maintain the number of pickable days
237 | even in case there are disabled days within the range
238 | specified in 'pickableRange'.
239 | See the corresponding demo
240 | and try toggling this flag to see the results.
241 |
249 | Array of two integers: the first sets the beginning of the 250 | range relative to the date clicked on; the last sets the end 251 | of the range. Both numbers may be negative (see demo). 255 |
256 |266 | Compares two dates returning 1, 0 or -1 if date2 is greater, equal 267 | or smaller than date1 respectively. 268 |
269 |
273 | Returns the index of the date in the dates array, or false in case
274 | that date is not found.
275 |
276 | The parameter dates can be a string or a date object.
277 |
279 | Example:
280 | $('#simpliest-usage').multiDatesPicker('gotDate', new
282 | Date());
284 |
289 | Adds one or more dates to the calendar.
290 |
291 | The parameter dates can be a string, a date object or an array (of
292 | strings or javascript date objects).
293 |
295 | Example adding today:
296 | $('#simpliest-usage').multiDatesPicker('addDates', new
298 | Date());
300 |
305 | Removes one or more dates from the dates array using their
306 | indexes.
307 |
308 | The parameter indexes can be an integer or an array of integers.
309 |
311 | Example removing first date:
312 | $('#simpliest-usage').multiDatesPicker('removeIndexes',
314 | 0);
316 |
321 | Removes one or more dates from the dates array using their dates.
322 |
323 | The parameter dates can be a single value or an array of
324 | milliseconds, strings or date object.
325 |
327 | Example removing today date:
328 | $('#simpliest-usage').multiDatesPicker('removeDates', new
330 | Date());
332 |
337 | Removes all dates.
338 |
339 | The array of dates to reset can be of type 'picked'
340 | (default) or 'disabled'.
341 |
343 | Example resetting disabled dates:
344 | $('#simpliest-usage').multiDatesPicker('resetDates',
346 | 'disabled');
348 |
353 | Adds/removes a single date from the calendar.
354 |
355 | The date can be passed as string or as javascript date object.
356 |
358 | Example toggling today:
359 | $('#simpliest-usage').multiDatesPicker('toggleDate', new
361 | Date());
363 |
368 | Retrives the array of dates associated with the multiDatesPicker 369 | in the specified format: "string" (default) for localized string 370 | format, or "object" for javascript date object format. 371 |
372 |
373 | Example:
374 | var dates =
376 | $('#simpliest-usage').multiDatesPicker('getDates');
378 |
383 | If no parameter is passed, returns the string value that would be 384 | used in input elements. Otherwise parses the string for dates to 385 | add. 386 |
387 |
388 | Get Example:
389 | var dates =
391 | $('#simpliest-usage').multiDatesPicker('value');
393 |
395 | Set Example:
396 | $('#simpliest-usage').multiDatesPicker('value', '2/19/1985,
398 | 11/14/2009');
400 |
Destroys the MDP and Datepicker instances on the element.
405 |
406 | Example:
407 | $('#simpliest-usage').multiDatesPicker('destroy');
410 |
You can find MDP implemented in the following sites:
418 |428 | If you're using MDP in your site and would like to share it, simply 429 | contact me. You'd get free ad from here and 430 | we get more examples of implementation from you :) 431 |
432 |
437 | Here are some demos for you to understand how it works and what you
438 | can obtain with it.
439 | To see how it is implemented simply check the source code of this
440 | page: I've tried to keep the code simple and clear :)
441 |
447 | Just apply the plugin to an HTML element and you're ready to 448 | select multiple dates :) 449 |
450 |456 | Same as previous example, but using custom date formats and custom 457 | default day. 458 |
459 |
465 | The name says it all: you can preselect some dates specifying them
466 | in an array.
467 | Dates in the array can be a mix of object date and string dates.
468 |
475 | Again, the name says it all: you can specify some dates to
476 | disable.
477 | Dates in the array can be a mix of object date and string dates.
478 |
Disable a calendar picking functionality.
485 |491 | A way to have a calendar always displayed and a field that fills 492 | with selected dates. 493 |
494 |500 | Set the maximum number of dates that can be picked. 501 |
502 |
508 | Define a range of dates to be allowed after the first date have
509 | been picked.
510 | Some dates have been disabled to show up how
511 | adjustRangeToDisabled
512 | works.
513 |
520 | This way you can automatically select a range of days with respect 521 | to the day clicked. 522 |
523 |
524 | In this example the day range is set to [0, 5], which means from
525 | the day clicked to 5 days in advance.
526 | You can also specify other combinations like:
527 |
543 | As with the jQuery Datespicker, you can define a minimum and
544 | maximum date from where to pick dates.
545 | The values are relative to the current date.
546 |
553 | Just an example of how it would work with an input text field. 554 |
555 |
561 | Define beforeShow, beforeShowDay*,
563 | onSelect and onClose to apply custom
564 | behaviours.
565 |
567 | * Being that MDP needs
568 | beforeShowDay to change the way jQuery datepicker
569 | behaves, there may be cases in which your custom definition in MDP
570 | won't produce the same effects as if you were using it with
571 | datepicker alone.
572 |
579 | Just an example of how it would look to show the full year. 580 |
581 |588 | MDP comes with a small CSS file that applies the following styles: 589 |
590 | 591 |
592 | To even further customize the way the calendar looks, just modify the
593 | jQuery UI's theme you're using.
594 | Multiple Dates Picker is about adding functionality not style :)
595 |
601 | Apart from some features and bug fixes, there is need for a better 602 | documentation and a unit-test to guarantee that any improvements won't 603 | break the existent functionalities. 604 |
605 |606 | I'll try to maintain this project in my spare time (it is not my 607 | primary business), and I welcome anyone who wants to help (just 608 | contact me :) 609 |
610 |615 | You're welcome to get in touch with me to collaborate to this project: 616 |
617 |