jquery.datepair.js 987 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*!
  2. * datepair.js v0.4.16 - A javascript plugin for intelligently selecting date and time ranges inspired by Google Calendar.
  3. * Copyright (c) 2018 Jon Thornton - http://jonthornton.github.com/Datepair.js
  4. * License: MIT
  5. */
  6. (function($) {
  7. if(!$) {
  8. return;
  9. }
  10. ////////////
  11. // Plugin //
  12. ////////////
  13. $.fn.datepair = function(option) {
  14. var out;
  15. this.each(function() {
  16. var $this = $(this);
  17. var data = $this.data('datepair');
  18. var options = typeof option === 'object' && option;
  19. if (!data) {
  20. data = new Datepair(this, options);
  21. $this.data('datepair', data);
  22. }
  23. if (option === 'remove') {
  24. out = data['remove']();
  25. $this.removeData('datepair', data);
  26. }
  27. if (typeof option === 'string') {
  28. out = data[option]();
  29. }
  30. });
  31. return out || this;
  32. };
  33. //////////////
  34. // Data API //
  35. //////////////
  36. $('[data-datepair]').each(function() {
  37. var $this = $(this);
  38. $this.datepair($this.data());
  39. });
  40. }(window.Zepto || window.jQuery));