UNPKG

datepair.js

Version:

A javascript plugin for intelligently selecting date and time ranges inspired by Google Calendar.

46 lines (35 loc) 760 B
(function($) { if(!$) { return; } //////////// // Plugin // //////////// $.fn.datepair = function(option) { var out; this.each(function() { var $this = $(this); var data = $this.data('datepair'); var options = typeof option === 'object' && option; if (!data) { data = new Datepair(this, options); $this.data('datepair', data); } if (option === 'remove') { out = data['remove'](); $this.removeData('datepair', data); } if (typeof option === 'string') { out = data[option](); } }); return out || this; }; ////////////// // Data API // ////////////// $('[data-datepair]').each(function() { var $this = $(this); $this.datepair($this.data()); }); }(window.Zepto || window.jQuery));