package/package.json000755 0000001556 3560116604 011560 0ustar00000000 000000 { "name": "pikaday", "version": "1.8.0", "description": "A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS", "keywords": [ "datepicker", "calendar", "date" ], "homepage": "https://pikaday.com", "bugs": "https://github.com/Pikaday/Pikaday/issues", "license": "(0BSD OR MIT)", "main": "pikaday.js", "repository": { "type": "git", "url": "https://github.com/Pikaday/Pikaday.git" }, "devDependencies": { "expect.js": "^0.3.1", "jshint": "^2.9.6", "mocha": "^5.2.0" }, "testling": { "harness": "mocha", "files": "tests/*.js", "browsers": [ "ie/7..latest", "chrome/latest", "firefox/3.6", "firefox/latest", "safari/latest", "opera/latest" ] }, "scripts": { "test": "testling", "lint": "jshint *.js plugins/*.js tests/*.js" } } package/.editorconfig000644 0000000343 3560116604 011735 0ustar00000000 000000 ; http://EditorConfig.org root = true [*] end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.{js,css}] indent_style = space indent_size = 4 [*.md] trim_trailing_whitespace = falsepackage/.gitattributes000644 0000000014 3560116604 012146 0ustar00000000 000000 * text=auto package/.jshintrc000644 0000001020 3560116604 011076 0ustar00000000 000000 { "node": true, "browser": true, "esnext": true, "bitwise": true, "camelcase": true, "eqeqeq": true, "immed": true, "indent": 4, "latedef": true, "newcap": true, "noarg": true, "quotmark": "single", "regexp": true, "undef": true, "unused": true, "strict": true, "trailing": true, "smarttabs": true, "expr": true, "globals": { "define": false, /* MOCHA */ "describe" : false, "it" : false, "before" : false, "beforeEach" : false, "after" : false, "afterEach" : false } } package/bower.json000755 0000001005 3560116604 011270 0ustar00000000 000000 { "name": "pikaday", "description": "A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS", "keywords": [ "datepicker", "calendar", "date" ], "main": [ "./pikaday.js", "./css/pikaday.css" ], "dependencies": {}, "ignore": [ "**/.*", "node_modules", "components" ], "license" : [ "0BSD", "MIT" ], "homepage": "https://pikaday.com", "repository": { "type": "git", "url": "https://github.com/Pikaday/Pikaday.git" } } package/CHANGELOG.md000755 0000006437 3560116604 011106 0ustar00000000 000000 # Changelog ## 1.8.0 - 2018-10-17 - Remove testling because service is not running atm - Move to github organisation Pikaday/Pikaday - Add CSS-classes indicating position - Remove the Moment.js optional dependency - Add aria label text configuration ## 1.7.0 - 2017-12-12 - Add keyboard input option, see #610 ## 1.6.1 - 2017-06-06 - Fix memory leak, fixes #630 ## 1.6.0 - 2017-05-31 - Add custom parsers, see #613 - Re-introduce correct null behavor, fixes #654 - Pick a whole week, see #516 - Added `events` option: dates that you would like to differentiate from regular days, see #152 - Fix the (re)position issue, see #643, #642 - Configure if field is blurred when date is selected, see #631 - Prevent error when no field is bound, fixes #611 ## 1.5.1 - 2016-10-28 - Only set attribute if field is bound, see #567 ## 1.5.0 - 2016-10-27 - Make Pikaday accessibile, see #522 - Add possibility to reset the max and min date to the date picker - Make Pikaday XHTML compatible, see #492 - Remove unnecessary setTimeout call, fixes #496 - Make disabled buttons not clickable in IE 10 and below, fixes #288 - Show days in next and previous months ## 1.4.0 - 2015-10-30 - Fix touch device support, see #374 - Add possibility to reset the max and min date to the date picker ## 1.3.3 - 2015-02-17 - Add theme class support, see #260 - Fix on iOS, see #101, #121 - Add date range example, see #337 - Fix dates used in examples, see #329 ## 1.3.2 - 2015-02-17 - Add options to disable days, see #171 - Add SCSS file, see #130 ## 1.3.1 - 2015-02-04 - Fix for bug introduced in #166; fixes #224, #230 ## 1.3.0 - 2015-01-09 - Fix #79 moving through months can cause calendar to "bounce around" - Add configurable number of shown months - #51 Add unit tests with ci: [testling](https://ci.testling.com/rikkert/pikaday) - Fix #94 blur input field after date selection - Add configuable container to render calendar into - Add option to show week numbers, see #147 - Positioning is now optional, see #192 ## 1.2.0 - 2014-01-28 - Fix #8 Automatically adjust datepicker position - Merge #45 Adjusting position - Merge #11 Allow using a different element to open and bind the datepicker to - Use new Bower package filename: bower.json - Merge #90 Configuration options for the title, useful for Asian languages. - Merge #96 Use proper UMD-wrapper - Merge #92 Export as CommonJS module - Merge #119 Use a px text-indent on .pika-prev/next to prevent Firefox bug - Merge #60 Add customizable position option - Add Component package definition ## 1.1.0 - 2013-03-29 - Add Ruby on Rails [gem](https://rubygems.org/gems/pikaday-gem) - Add project configuration files. (jshint and editorconfig) - Add AMD support to pikaday and pikaday.jquery - Fix #52 check if date is valid when moment.js is available - Fix #54 add CSS support for IE8 Notes: - jQuery plugin needs pikaday.js loaded first - See the examples/ dir: - amd.html module loading example - jquery-amd.html module loading the jQuery plugin example - jquery.html jQuery plugin example - moment.html moment.js library example ## 1.0.0 - 2013-03-15 - Fix issue #41 (minDate does not include the specified date) - Add Bower package definition ## 0.0.2 - 2012-10-10 - jQuery plugin version ## 0.0.1 - 2012-10-08 - Basic documentation written - GitHub repository is ready to go… package/CNAME000644 0000000014 3560116604 010021 0ustar00000000 000000 pikaday.com package/component.json000755 0000000625 3560116604 012163 0ustar00000000 000000 { "name": "pikaday", "repo": "dbushell/Pikaday", "description": "A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS", "version": "1.8.0", "keywords": [ "datepicker", "calendar", "date" ], "main": "pikaday.js", "scripts": ["pikaday.js"], "styles": ["css/pikaday.css"], "dependencies": {}, "demo": "https://pikaday.com", "license": "MIT" } package/index.html000755 0000002533 3560116604 011263 0ustar00000000 000000 Pikaday

Pikaday

A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.

Pikaday source on GitHub


What is this?

Since version 1.0 Pikaday is a stable and battle tested date-picker. Feel free to use it however you like but please report any bugs or feature requests to the GitHub issue tracker, thanks!

Copyright © 2014 David Bushell | BSD & MIT license

package/LICENSE000755 0000004610 3560116604 010271 0ustar00000000 000000 Copyright (c) 2014 David Bushell BSD & MIT license The MIT License (MIT) Copyright (c) 2014 David Bushell 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: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 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. The BSD License Copyright (c) 2014 David Bushell All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.package/pikaday.js000755 0000120165 3560116604 011250 0ustar00000000 000000 /*! * Pikaday * * Copyright © 2014 David Bushell | BSD & MIT license | https://github.com/Pikaday/Pikaday */ (function (root, factory) { 'use strict'; var moment; if (typeof exports === 'object') { // CommonJS module // Load moment.js as an optional dependency try { moment = require('moment'); } catch (e) {} module.exports = factory(moment); } else if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. define(function (req) { // Load moment.js as an optional dependency var id = 'moment'; try { moment = req(id); } catch (e) {} return factory(moment); }); } else { root.Pikaday = factory(root.moment); } }(this, function (moment) { 'use strict'; /** * feature detection and helper functions */ var hasMoment = typeof moment === 'function', hasEventListeners = !!window.addEventListener, document = window.document, sto = window.setTimeout, addEvent = function(el, e, callback, capture) { if (hasEventListeners) { el.addEventListener(e, callback, !!capture); } else { el.attachEvent('on' + e, callback); } }, removeEvent = function(el, e, callback, capture) { if (hasEventListeners) { el.removeEventListener(e, callback, !!capture); } else { el.detachEvent('on' + e, callback); } }, trim = function(str) { return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g,''); }, hasClass = function(el, cn) { return (' ' + el.className + ' ').indexOf(' ' + cn + ' ') !== -1; }, addClass = function(el, cn) { if (!hasClass(el, cn)) { el.className = (el.className === '') ? cn : el.className + ' ' + cn; } }, removeClass = function(el, cn) { el.className = trim((' ' + el.className + ' ').replace(' ' + cn + ' ', ' ')); }, isArray = function(obj) { return (/Array/).test(Object.prototype.toString.call(obj)); }, isDate = function(obj) { return (/Date/).test(Object.prototype.toString.call(obj)) && !isNaN(obj.getTime()); }, isWeekend = function(date) { var day = date.getDay(); return day === 0 || day === 6; }, isLeapYear = function(year) { // solution by Matti Virkkunen: http://stackoverflow.com/a/4881951 return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0; }, getDaysInMonth = function(year, month) { return [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }, setToStartOfDay = function(date) { if (isDate(date)) date.setHours(0,0,0,0); }, compareDates = function(a,b) { // weak date comparison (use setToStartOfDay(date) to ensure correct result) return a.getTime() === b.getTime(); }, extend = function(to, from, overwrite) { var prop, hasProp; for (prop in from) { hasProp = to[prop] !== undefined; if (hasProp && typeof from[prop] === 'object' && from[prop] !== null && from[prop].nodeName === undefined) { if (isDate(from[prop])) { if (overwrite) { to[prop] = new Date(from[prop].getTime()); } } else if (isArray(from[prop])) { if (overwrite) { to[prop] = from[prop].slice(0); } } else { to[prop] = extend({}, from[prop], overwrite); } } else if (overwrite || !hasProp) { to[prop] = from[prop]; } } return to; }, fireEvent = function(el, eventName, data) { var ev; if (document.createEvent) { ev = document.createEvent('HTMLEvents'); ev.initEvent(eventName, true, false); ev = extend(ev, data); el.dispatchEvent(ev); } else if (document.createEventObject) { ev = document.createEventObject(); ev = extend(ev, data); el.fireEvent('on' + eventName, ev); } }, adjustCalendar = function(calendar) { if (calendar.month < 0) { calendar.year -= Math.ceil(Math.abs(calendar.month)/12); calendar.month += 12; } if (calendar.month > 11) { calendar.year += Math.floor(Math.abs(calendar.month)/12); calendar.month -= 12; } return calendar; }, /** * defaults and localisation */ defaults = { // bind the picker to a form field field: null, // automatically show/hide the picker on `field` focus (default `true` if `field` is set) bound: undefined, // data-attribute on the input field with an aria assistance tekst (only applied when `bound` is set) ariaLabel: 'Use the arrow keys to pick a date', // position of the datepicker, relative to the field (default to bottom & left) // ('bottom' & 'left' keywords are not used, 'top' & 'right' are modifier on the bottom/left position) position: 'bottom left', // automatically fit in the viewport even if it means repositioning from the position option reposition: true, // the default output format for `.toString()` and `field` value format: 'YYYY-MM-DD', // the toString function which gets passed a current date object and format // and returns a string toString: null, // used to create date object from current input string parse: null, // the initial date to view when first opened defaultDate: null, // make the `defaultDate` the initial selected value setDefaultDate: false, // first day of week (0: Sunday, 1: Monday etc) firstDay: 0, // the default flag for moment's strict date parsing formatStrict: false, // the minimum/earliest date that can be selected minDate: null, // the maximum/latest date that can be selected maxDate: null, // number of years either side, or array of upper/lower range yearRange: 10, // show week numbers at head of row showWeekNumber: false, // Week picker mode pickWholeWeek: false, // used internally (don't config outside) minYear: 0, maxYear: 9999, minMonth: undefined, maxMonth: undefined, startRange: null, endRange: null, isRTL: false, // Additional text to append to the year in the calendar title yearSuffix: '', // Render the month after year in the calendar title showMonthAfterYear: false, // Render days of the calendar grid that fall in the next or previous month showDaysInNextAndPreviousMonths: false, // Allows user to select days that fall in the next or previous month enableSelectionDaysInNextAndPreviousMonths: false, // how many months are visible numberOfMonths: 1, // when numberOfMonths is used, this will help you to choose where the main calendar will be (default `left`, can be set to `right`) // only used for the first display or when a selected date is not visible mainCalendar: 'left', // Specify a DOM element to render the calendar in container: undefined, // Blur field when date is selected blurFieldOnSelect : true, // internationalization i18n: { previousMonth : 'Previous Month', nextMonth : 'Next Month', months : ['January','February','March','April','May','June','July','August','September','October','November','December'], weekdays : ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'], weekdaysShort : ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'] }, // Theme Classname theme: null, // events array events: [], // callback function onSelect: null, onOpen: null, onClose: null, onDraw: null, // Enable keyboard input keyboardInput: true }, /** * templating functions to abstract HTML rendering */ renderDayName = function(opts, day, abbr) { day += opts.firstDay; while (day >= 7) { day -= 7; } return abbr ? opts.i18n.weekdaysShort[day] : opts.i18n.weekdays[day]; }, renderDay = function(opts) { var arr = []; var ariaSelected = 'false'; if (opts.isEmpty) { if (opts.showDaysInNextAndPreviousMonths) { arr.push('is-outside-current-month'); if(!opts.enableSelectionDaysInNextAndPreviousMonths) { arr.push('is-selection-disabled'); } } else { return ''; } } if (opts.isDisabled) { arr.push('is-disabled'); } if (opts.isToday) { arr.push('is-today'); } if (opts.isSelected) { arr.push('is-selected'); ariaSelected = 'true'; } if (opts.hasEvent) { arr.push('has-event'); } if (opts.isInRange) { arr.push('is-inrange'); } if (opts.isStartRange) { arr.push('is-startrange'); } if (opts.isEndRange) { arr.push('is-endrange'); } return '' + '' + ''; }, renderWeek = function (d, m, y) { // Lifted from http://javascript.about.com/library/blweekyear.htm, lightly modified. var onejan = new Date(y, 0, 1), weekNum = Math.ceil((((new Date(y, m, d) - onejan) / 86400000) + onejan.getDay()+1)/7); return '' + weekNum + ''; }, renderRow = function(days, isRTL, pickWholeWeek, isRowSelected) { return '' + (isRTL ? days.reverse() : days).join('') + ''; }, renderBody = function(rows) { return '' + rows.join('') + ''; }, renderHead = function(opts) { var i, arr = []; if (opts.showWeekNumber) { arr.push(''); } for (i = 0; i < 7; i++) { arr.push('' + renderDayName(opts, i, true) + ''); } return '' + (opts.isRTL ? arr.reverse() : arr).join('') + ''; }, renderTitle = function(instance, c, year, month, refYear, randId) { var i, j, arr, opts = instance._o, isMinYear = year === opts.minYear, isMaxYear = year === opts.maxYear, html = '
', monthHtml, yearHtml, prev = true, next = true; for (arr = [], i = 0; i < 12; i++) { arr.push(''); } monthHtml = '
' + opts.i18n.months[month] + '
'; if (isArray(opts.yearRange)) { i = opts.yearRange[0]; j = opts.yearRange[1] + 1; } else { i = year - opts.yearRange; j = 1 + year + opts.yearRange; } for (arr = []; i < j && i <= opts.maxYear; i++) { if (i >= opts.minYear) { arr.push(''); } } yearHtml = '
' + year + opts.yearSuffix + '
'; if (opts.showMonthAfterYear) { html += yearHtml + monthHtml; } else { html += monthHtml + yearHtml; } if (isMinYear && (month === 0 || opts.minMonth >= month)) { prev = false; } if (isMaxYear && (month === 11 || opts.maxMonth <= month)) { next = false; } if (c === 0) { html += ''; } if (c === (instance._o.numberOfMonths - 1) ) { html += ''; } return html += '
'; }, renderTable = function(opts, data, randId) { return '' + renderHead(opts) + renderBody(data) + '
'; }, /** * Pikaday constructor */ Pikaday = function(options) { var self = this, opts = self.config(options); self._onMouseDown = function(e) { if (!self._v) { return; } e = e || window.event; var target = e.target || e.srcElement; if (!target) { return; } if (!hasClass(target, 'is-disabled')) { if (hasClass(target, 'pika-button') && !hasClass(target, 'is-empty') && !hasClass(target.parentNode, 'is-disabled')) { self.setDate(new Date(target.getAttribute('data-pika-year'), target.getAttribute('data-pika-month'), target.getAttribute('data-pika-day'))); if (opts.bound) { sto(function() { self.hide(); if (opts.blurFieldOnSelect && opts.field) { opts.field.blur(); } }, 100); } } else if (hasClass(target, 'pika-prev')) { self.prevMonth(); } else if (hasClass(target, 'pika-next')) { self.nextMonth(); } } if (!hasClass(target, 'pika-select')) { // if this is touch event prevent mouse events emulation if (e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; return false; } } else { self._c = true; } }; self._onChange = function(e) { e = e || window.event; var target = e.target || e.srcElement; if (!target) { return; } if (hasClass(target, 'pika-select-month')) { self.gotoMonth(target.value); } else if (hasClass(target, 'pika-select-year')) { self.gotoYear(target.value); } }; self._onKeyChange = function(e) { e = e || window.event; if (self.isVisible()) { switch(e.keyCode){ case 13: case 27: if (opts.field) { opts.field.blur(); } break; case 37: e.preventDefault(); self.adjustDate('subtract', 1); break; case 38: self.adjustDate('subtract', 7); break; case 39: self.adjustDate('add', 1); break; case 40: self.adjustDate('add', 7); break; } } }; self._onInputChange = function(e) { var date; if (e.firedBy === self) { return; } if (opts.parse) { date = opts.parse(opts.field.value, opts.format); } else if (hasMoment) { date = moment(opts.field.value, opts.format, opts.formatStrict); date = (date && date.isValid()) ? date.toDate() : null; } else { date = new Date(Date.parse(opts.field.value)); } if (isDate(date)) { self.setDate(date); } if (!self._v) { self.show(); } }; self._onInputFocus = function() { self.show(); }; self._onInputClick = function() { self.show(); }; self._onInputBlur = function() { // IE allows pika div to gain focus; catch blur the input field var pEl = document.activeElement; do { if (hasClass(pEl, 'pika-single')) { return; } } while ((pEl = pEl.parentNode)); if (!self._c) { self._b = sto(function() { self.hide(); }, 50); } self._c = false; }; self._onClick = function(e) { e = e || window.event; var target = e.target || e.srcElement, pEl = target; if (!target) { return; } if (!hasEventListeners && hasClass(target, 'pika-select')) { if (!target.onchange) { target.setAttribute('onchange', 'return;'); addEvent(target, 'change', self._onChange); } } do { if (hasClass(pEl, 'pika-single') || pEl === opts.trigger) { return; } } while ((pEl = pEl.parentNode)); if (self._v && target !== opts.trigger && pEl !== opts.trigger) { self.hide(); } }; self.el = document.createElement('div'); self.el.className = 'pika-single' + (opts.isRTL ? ' is-rtl' : '') + (opts.theme ? ' ' + opts.theme : ''); addEvent(self.el, 'mousedown', self._onMouseDown, true); addEvent(self.el, 'touchend', self._onMouseDown, true); addEvent(self.el, 'change', self._onChange); if (opts.keyboardInput) { addEvent(document, 'keydown', self._onKeyChange); } if (opts.field) { if (opts.container) { opts.container.appendChild(self.el); } else if (opts.bound) { document.body.appendChild(self.el); } else { opts.field.parentNode.insertBefore(self.el, opts.field.nextSibling); } addEvent(opts.field, 'change', self._onInputChange); if (!opts.defaultDate) { if (hasMoment && opts.field.value) { opts.defaultDate = moment(opts.field.value, opts.format).toDate(); } else { opts.defaultDate = new Date(Date.parse(opts.field.value)); } opts.setDefaultDate = true; } } var defDate = opts.defaultDate; if (isDate(defDate)) { if (opts.setDefaultDate) { self.setDate(defDate, true); } else { self.gotoDate(defDate); } } else { self.gotoDate(new Date()); } if (opts.bound) { this.hide(); self.el.className += ' is-bound'; addEvent(opts.trigger, 'click', self._onInputClick); addEvent(opts.trigger, 'focus', self._onInputFocus); addEvent(opts.trigger, 'blur', self._onInputBlur); } else { this.show(); } }; /** * public Pikaday API */ Pikaday.prototype = { /** * configure functionality */ config: function(options) { if (!this._o) { this._o = extend({}, defaults, true); } var opts = extend(this._o, options, true); opts.isRTL = !!opts.isRTL; opts.field = (opts.field && opts.field.nodeName) ? opts.field : null; opts.theme = (typeof opts.theme) === 'string' && opts.theme ? opts.theme : null; opts.bound = !!(opts.bound !== undefined ? opts.field && opts.bound : opts.field); opts.trigger = (opts.trigger && opts.trigger.nodeName) ? opts.trigger : opts.field; opts.disableWeekends = !!opts.disableWeekends; opts.disableDayFn = (typeof opts.disableDayFn) === 'function' ? opts.disableDayFn : null; var nom = parseInt(opts.numberOfMonths, 10) || 1; opts.numberOfMonths = nom > 4 ? 4 : nom; if (!isDate(opts.minDate)) { opts.minDate = false; } if (!isDate(opts.maxDate)) { opts.maxDate = false; } if ((opts.minDate && opts.maxDate) && opts.maxDate < opts.minDate) { opts.maxDate = opts.minDate = false; } if (opts.minDate) { this.setMinDate(opts.minDate); } if (opts.maxDate) { this.setMaxDate(opts.maxDate); } if (isArray(opts.yearRange)) { var fallback = new Date().getFullYear() - 10; opts.yearRange[0] = parseInt(opts.yearRange[0], 10) || fallback; opts.yearRange[1] = parseInt(opts.yearRange[1], 10) || fallback; } else { opts.yearRange = Math.abs(parseInt(opts.yearRange, 10)) || defaults.yearRange; if (opts.yearRange > 100) { opts.yearRange = 100; } } return opts; }, /** * return a formatted string of the current selection (using Moment.js if available) */ toString: function(format) { format = format || this._o.format; if (!isDate(this._d)) { return ''; } if (this._o.toString) { return this._o.toString(this._d, format); } if (hasMoment) { return moment(this._d).format(format); } return this._d.toDateString(); }, /** * return a Moment.js object of the current selection (if available) */ getMoment: function() { return hasMoment ? moment(this._d) : null; }, /** * set the current selection from a Moment.js object (if available) */ setMoment: function(date, preventOnSelect) { if (hasMoment && moment.isMoment(date)) { this.setDate(date.toDate(), preventOnSelect); } }, /** * return a Date object of the current selection */ getDate: function() { return isDate(this._d) ? new Date(this._d.getTime()) : null; }, /** * set the current selection */ setDate: function(date, preventOnSelect) { if (!date) { this._d = null; if (this._o.field) { this._o.field.value = ''; fireEvent(this._o.field, 'change', { firedBy: this }); } return this.draw(); } if (typeof date === 'string') { date = new Date(Date.parse(date)); } if (!isDate(date)) { return; } var min = this._o.minDate, max = this._o.maxDate; if (isDate(min) && date < min) { date = min; } else if (isDate(max) && date > max) { date = max; } this._d = new Date(date.getTime()); setToStartOfDay(this._d); this.gotoDate(this._d); if (this._o.field) { this._o.field.value = this.toString(); fireEvent(this._o.field, 'change', { firedBy: this }); } if (!preventOnSelect && typeof this._o.onSelect === 'function') { this._o.onSelect.call(this, this.getDate()); } }, /** * change view to a specific date */ gotoDate: function(date) { var newCalendar = true; if (!isDate(date)) { return; } if (this.calendars) { var firstVisibleDate = new Date(this.calendars[0].year, this.calendars[0].month, 1), lastVisibleDate = new Date(this.calendars[this.calendars.length-1].year, this.calendars[this.calendars.length-1].month, 1), visibleDate = date.getTime(); // get the end of the month lastVisibleDate.setMonth(lastVisibleDate.getMonth()+1); lastVisibleDate.setDate(lastVisibleDate.getDate()-1); newCalendar = (visibleDate < firstVisibleDate.getTime() || lastVisibleDate.getTime() < visibleDate); } if (newCalendar) { this.calendars = [{ month: date.getMonth(), year: date.getFullYear() }]; if (this._o.mainCalendar === 'right') { this.calendars[0].month += 1 - this._o.numberOfMonths; } } this.adjustCalendars(); }, adjustDate: function(sign, days) { var day = this.getDate() || new Date(); var difference = parseInt(days)*24*60*60*1000; var newDay; if (sign === 'add') { newDay = new Date(day.valueOf() + difference); } else if (sign === 'subtract') { newDay = new Date(day.valueOf() - difference); } this.setDate(newDay); }, adjustCalendars: function() { this.calendars[0] = adjustCalendar(this.calendars[0]); for (var c = 1; c < this._o.numberOfMonths; c++) { this.calendars[c] = adjustCalendar({ month: this.calendars[0].month + c, year: this.calendars[0].year }); } this.draw(); }, gotoToday: function() { this.gotoDate(new Date()); }, /** * change view to a specific month (zero-index, e.g. 0: January) */ gotoMonth: function(month) { if (!isNaN(month)) { this.calendars[0].month = parseInt(month, 10); this.adjustCalendars(); } }, nextMonth: function() { this.calendars[0].month++; this.adjustCalendars(); }, prevMonth: function() { this.calendars[0].month--; this.adjustCalendars(); }, /** * change view to a specific full year (e.g. "2012") */ gotoYear: function(year) { if (!isNaN(year)) { this.calendars[0].year = parseInt(year, 10); this.adjustCalendars(); } }, /** * change the minDate */ setMinDate: function(value) { if(value instanceof Date) { setToStartOfDay(value); this._o.minDate = value; this._o.minYear = value.getFullYear(); this._o.minMonth = value.getMonth(); } else { this._o.minDate = defaults.minDate; this._o.minYear = defaults.minYear; this._o.minMonth = defaults.minMonth; this._o.startRange = defaults.startRange; } this.draw(); }, /** * change the maxDate */ setMaxDate: function(value) { if(value instanceof Date) { setToStartOfDay(value); this._o.maxDate = value; this._o.maxYear = value.getFullYear(); this._o.maxMonth = value.getMonth(); } else { this._o.maxDate = defaults.maxDate; this._o.maxYear = defaults.maxYear; this._o.maxMonth = defaults.maxMonth; this._o.endRange = defaults.endRange; } this.draw(); }, setStartRange: function(value) { this._o.startRange = value; }, setEndRange: function(value) { this._o.endRange = value; }, /** * refresh the HTML */ draw: function(force) { if (!this._v && !force) { return; } var opts = this._o, minYear = opts.minYear, maxYear = opts.maxYear, minMonth = opts.minMonth, maxMonth = opts.maxMonth, html = '', randId; if (this._y <= minYear) { this._y = minYear; if (!isNaN(minMonth) && this._m < minMonth) { this._m = minMonth; } } if (this._y >= maxYear) { this._y = maxYear; if (!isNaN(maxMonth) && this._m > maxMonth) { this._m = maxMonth; } } randId = 'pika-title-' + Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 2); for (var c = 0; c < opts.numberOfMonths; c++) { html += '
' + renderTitle(this, c, this.calendars[c].year, this.calendars[c].month, this.calendars[0].year, randId) + this.render(this.calendars[c].year, this.calendars[c].month, randId) + '
'; } this.el.innerHTML = html; if (opts.bound) { if(opts.field.type !== 'hidden') { sto(function() { opts.trigger.focus(); }, 1); } } if (typeof this._o.onDraw === 'function') { this._o.onDraw(this); } if (opts.bound) { // let the screen reader user know to use arrow keys opts.field.setAttribute('aria-label', opts.ariaLabel); } }, adjustPosition: function() { var field, pEl, width, height, viewportWidth, viewportHeight, scrollTop, left, top, clientRect, leftAligned, bottomAligned; if (this._o.container) return; this.el.style.position = 'absolute'; field = this._o.trigger; pEl = field; width = this.el.offsetWidth; height = this.el.offsetHeight; viewportWidth = window.innerWidth || document.documentElement.clientWidth; viewportHeight = window.innerHeight || document.documentElement.clientHeight; scrollTop = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop; leftAligned = true; bottomAligned = true; if (typeof field.getBoundingClientRect === 'function') { clientRect = field.getBoundingClientRect(); left = clientRect.left + window.pageXOffset; top = clientRect.bottom + window.pageYOffset; } else { left = pEl.offsetLeft; top = pEl.offsetTop + pEl.offsetHeight; while((pEl = pEl.offsetParent)) { left += pEl.offsetLeft; top += pEl.offsetTop; } } // default position is bottom & left if ((this._o.reposition && left + width > viewportWidth) || ( this._o.position.indexOf('right') > -1 && left - width + field.offsetWidth > 0 ) ) { left = left - width + field.offsetWidth; leftAligned = false; } if ((this._o.reposition && top + height > viewportHeight + scrollTop) || ( this._o.position.indexOf('top') > -1 && top - height - field.offsetHeight > 0 ) ) { top = top - height - field.offsetHeight; bottomAligned = false; } this.el.style.left = left + 'px'; this.el.style.top = top + 'px'; addClass(this.el, leftAligned ? 'left-aligned' : 'right-aligned'); addClass(this.el, bottomAligned ? 'bottom-aligned' : 'top-aligned'); removeClass(this.el, !leftAligned ? 'left-aligned' : 'right-aligned'); removeClass(this.el, !bottomAligned ? 'bottom-aligned' : 'top-aligned'); }, /** * render HTML for a particular month */ render: function(year, month, randId) { var opts = this._o, now = new Date(), days = getDaysInMonth(year, month), before = new Date(year, month, 1).getDay(), data = [], row = []; setToStartOfDay(now); if (opts.firstDay > 0) { before -= opts.firstDay; if (before < 0) { before += 7; } } var previousMonth = month === 0 ? 11 : month - 1, nextMonth = month === 11 ? 0 : month + 1, yearOfPreviousMonth = month === 0 ? year - 1 : year, yearOfNextMonth = month === 11 ? year + 1 : year, daysInPreviousMonth = getDaysInMonth(yearOfPreviousMonth, previousMonth); var cells = days + before, after = cells; while(after > 7) { after -= 7; } cells += 7 - after; var isWeekSelected = false; for (var i = 0, r = 0; i < cells; i++) { var day = new Date(year, month, 1 + (i - before)), isSelected = isDate(this._d) ? compareDates(day, this._d) : false, isToday = compareDates(day, now), hasEvent = opts.events.indexOf(day.toDateString()) !== -1 ? true : false, isEmpty = i < before || i >= (days + before), dayNumber = 1 + (i - before), monthNumber = month, yearNumber = year, isStartRange = opts.startRange && compareDates(opts.startRange, day), isEndRange = opts.endRange && compareDates(opts.endRange, day), isInRange = opts.startRange && opts.endRange && opts.startRange < day && day < opts.endRange, isDisabled = (opts.minDate && day < opts.minDate) || (opts.maxDate && day > opts.maxDate) || (opts.disableWeekends && isWeekend(day)) || (opts.disableDayFn && opts.disableDayFn(day)); if (isEmpty) { if (i < before) { dayNumber = daysInPreviousMonth + dayNumber; monthNumber = previousMonth; yearNumber = yearOfPreviousMonth; } else { dayNumber = dayNumber - days; monthNumber = nextMonth; yearNumber = yearOfNextMonth; } } var dayConfig = { day: dayNumber, month: monthNumber, year: yearNumber, hasEvent: hasEvent, isSelected: isSelected, isToday: isToday, isDisabled: isDisabled, isEmpty: isEmpty, isStartRange: isStartRange, isEndRange: isEndRange, isInRange: isInRange, showDaysInNextAndPreviousMonths: opts.showDaysInNextAndPreviousMonths, enableSelectionDaysInNextAndPreviousMonths: opts.enableSelectionDaysInNextAndPreviousMonths }; if (opts.pickWholeWeek && isSelected) { isWeekSelected = true; } row.push(renderDay(dayConfig)); if (++r === 7) { if (opts.showWeekNumber) { row.unshift(renderWeek(i - before, month, year)); } data.push(renderRow(row, opts.isRTL, opts.pickWholeWeek, isWeekSelected)); row = []; r = 0; isWeekSelected = false; } } return renderTable(opts, data, randId); }, isVisible: function() { return this._v; }, show: function() { if (!this.isVisible()) { this._v = true; this.draw(); removeClass(this.el, 'is-hidden'); if (this._o.bound) { addEvent(document, 'click', this._onClick); this.adjustPosition(); } if (typeof this._o.onOpen === 'function') { this._o.onOpen.call(this); } } }, hide: function() { var v = this._v; if (v !== false) { if (this._o.bound) { removeEvent(document, 'click', this._onClick); } this.el.style.position = 'static'; // reset this.el.style.left = 'auto'; this.el.style.top = 'auto'; addClass(this.el, 'is-hidden'); this._v = false; if (v !== undefined && typeof this._o.onClose === 'function') { this._o.onClose.call(this); } } }, /** * GAME OVER */ destroy: function() { var opts = this._o; this.hide(); removeEvent(this.el, 'mousedown', this._onMouseDown, true); removeEvent(this.el, 'touchend', this._onMouseDown, true); removeEvent(this.el, 'change', this._onChange); if (opts.keyboardInput) { removeEvent(document, 'keydown', this._onKeyChange); } if (opts.field) { removeEvent(opts.field, 'change', this._onInputChange); if (opts.bound) { removeEvent(opts.trigger, 'click', this._onInputClick); removeEvent(opts.trigger, 'focus', this._onInputFocus); removeEvent(opts.trigger, 'blur', this._onInputBlur); } } if (this.el.parentNode) { this.el.parentNode.removeChild(this.el); } } }; return Pikaday; })); package/README.md000755 0000041407 3560116604 010550 0ustar00000000 000000 Pikaday ======== [![NPM version][npm-image]][npm-url] [![License][license-image]][license-url] [![Downloads][downloads-image]][downloads-url] ### A refreshing JavaScript Datepicker * Lightweight (less than 5kb minified and gzipped) * No dependencies (but plays well with [Moment.js][moment]) * Modular CSS classes for easy styling [**Try Pikaday Demo →**][Pikaday] ![Pikaday Screenshot][screenshot] **Production ready?** Since version 1.0.0 Pikaday is stable and used in production. If you do however find bugs or have feature requests please submit them to the [GitHub issue tracker][issues]. Also see the [changelog](CHANGELOG.md) ## Installation npm install pikaday ## Usage **Pikaday** can be bound to an input field: ```html ``` Add the JavaScript to the end of your document: ```html ``` If you're using **jQuery** make sure to pass only the first element: ```javascript var picker = new Pikaday({ field: $('#datepicker')[0] }); ``` If the Pikaday instance is not bound to a field you can append the element anywhere: ```javascript var field = document.getElementById('datepicker'); var picker = new Pikaday({ onSelect: function(date) { field.value = picker.toString(); } }); field.parentNode.insertBefore(picker.el, field.nextSibling); ``` ### Formatting By default, dates are formatted and parsed using standard JavaScript Date object. If [Moment.js][moment] is available in scope, it will be used to format and parse input values. You can pass an additional `format` option to the configuration which will be passed to the `moment` constructor. See the [moment.js example][] for a full version. ```html ``` For more advanced and flexible formatting you can pass your own `toString` function to the configuration which will be used to format the date object. This function has the following signature: `toString(date, format = 'YYYY-MM-DD')` You should return a string from it. Be careful, though. If the formatted string that you return cannot be correctly parsed by the `Date.parse` method (or by `moment` if it is available), then you must provide your own `parse` function in the config. This function will be passed the formatted string and the format: `toString(dateString, format = 'YYYY-MM-DD')` ```javascript var picker = new Pikaday({ field: document.getElementById('datepicker'), format: 'D/M/YYYY', toString(date, format) { // you should do formatting based on the passed format, // but we will just return 'D/M/YYYY' for simplicity const day = date.getDate(); const month = date.getMonth() + 1; const year = date.getFullYear(); return `${day}/${month}/${year}`; }, parse(dateString, format) { // dateString is the result of `toString` method const parts = dateString.split('/'); const day = parseInt(parts[0], 10); const month = parseInt(parts[1] - 1, 10); const year = parseInt(parts[1], 10); return new Date(year, month, day); } }); ``` ### Configuration As the examples demonstrate above Pikaday has many useful options: * `field` bind the datepicker to a form field * `trigger` use a different element to trigger opening the datepicker, see [trigger example][] (default to `field`) * `bound` automatically show/hide the datepicker on `field` focus (default `true` if `field` is set) * `ariaLabel` data-attribute on the input field with an aria assistance tekst (only applied when `bound` is set) * `position` preferred position of the datepicker relative to the form field, e.g.: `top right`, `bottom right` **Note:** automatic adjustment may occur to avoid datepicker from being displayed outside the viewport, see [positions example][] (default to 'bottom left') * `reposition` can be set to false to not reposition datepicker within the viewport, forcing it to take the configured `position` (default: true) * `container` DOM node to render calendar into, see [container example][] (default: undefined) * `format` the default output format for `.toString()` and `field` value (requires [Moment.js][moment] for custom formatting) * `formatStrict` the default flag for moment's strict date parsing (requires [Moment.js][moment] for custom formatting) * `toString(date, format)` function which will be used for custom formatting. This function will take precedence over `moment`. * `parse(dateString, format)` function which will be used for parsing input string and getting a date object from it. This function will take precedence over `moment`. * `defaultDate` the initial date to view when first opened * `setDefaultDate` make the `defaultDate` the initial selected value * `firstDay` first day of the week (0: Sunday, 1: Monday, etc) * `minDate` the minimum/earliest date that can be selected (this should be a native Date object - e.g. `new Date()` or `moment().toDate()`) * `maxDate` the maximum/latest date that can be selected (this should be a native Date object - e.g. `new Date()` or `moment().toDate()`) * `disableWeekends` disallow selection of Saturdays or Sundays * `disableDayFn` callback function that gets passed a Date object for each day in view. Should return true to disable selection of that day. * `yearRange` number of years either side (e.g. `10`) or array of upper/lower range (e.g. `[1900,2015]`) * `showWeekNumber` show the ISO week number at the head of the row (default `false`) * `pickWholeWeek` select a whole week instead of a day (default `false`) * `isRTL` reverse the calendar for right-to-left languages * `i18n` language defaults for month and weekday names (see internationalization below) * `yearSuffix` additional text to append to the year in the title * `showMonthAfterYear` render the month after year in the title (default `false`) * `showDaysInNextAndPreviousMonths` render days of the calendar grid that fall in the next or previous months (default: false) * `enableSelectionDaysInNextAndPreviousMonths` allows user to select date that is in the next or previous months (default: false) * `numberOfMonths` number of visible calendars * `mainCalendar` when `numberOfMonths` is used, this will help you to choose where the main calendar will be (default `left`, can be set to `right`). Only used for the first display or when a selected date is not already visible * `events` array of dates that you would like to differentiate from regular days (e.g. `['Sat Jun 28 2017', 'Sun Jun 29 2017', 'Tue Jul 01 2017',]`) * `theme` define a classname that can be used as a hook for styling different themes, see [theme example][] (default `null`) * `blurFieldOnSelect` defines if the field is blurred when a date is selected (default `true`) * `onSelect` callback function for when a date is selected * `onOpen` callback function for when the picker becomes visible * `onClose` callback function for when the picker is hidden * `onDraw` callback function for when the picker draws a new month * `keyboardInput` enable keyboard input support (default `true`) ### Styling If the `reposition` configuration-option is enabled (default), Pikaday will apply CSS-classes to the datepicker according to how it is positioned: * `top-aligned` * `left-aligned` * `right-aligned` * `bottom-aligned` Note that the DOM element at any time will typically have 2 CSS-classes (eg. `top-aligned right-aligned` etc). ## jQuery Plugin The normal version of Pikaday does not require jQuery, however there is a jQuery plugin if that floats your boat (see `plugins/pikaday.jquery.js` in the repository). This version requires jQuery, naturally, and can be used like other plugins: See the [jQuery example][] for a full version. ```html ``` ## AMD support If you use a modular script loader than Pikaday is not bound to the global object and will fit nicely in your build process. You can require Pikaday just like any other module. See the [AMD example][] for a full version. ```javascript require(['pikaday'], function(Pikaday) { var picker = new Pikaday({ field: document.getElementById('datepicker') }); }); ``` The same applies for the jQuery plugin mentioned above. See the [jQuery AMD example][] for a full version. ```javascript require(['jquery', 'pikaday.jquery'], function($) { $('#datepicker').pikaday(); }); ``` ## CommonJS module support If you use a CommonJS compatible environment you can use the require function to import Pikaday. ```javascript var pikaday = require('pikaday'); ``` When you bundle all your required modules with [Browserify][browserify] and you don't use [Moment.js][moment] specify the ignore option: `browserify main.js -o bundle.js -i moment` ## Ruby on Rails If you're using **Ruby on Rails**, make sure to check out the [Pikaday gem][gem]. ## Methods You can control the date picker after creation: ```javascript var picker = new Pikaday({ field: document.getElementById('datepicker') }); ``` ### Get and set date `picker.toString('YYYY-MM-DD')` Returns the selected date in a string format. If [Moment.js][moment] exists (recommended) then Pikaday can return any format that Moment understands. You can also provide your own `toString` function and do the formatting yourself. Read more in the [formatting](#formatting) section. If neither `moment` object exists nor `toString` function is provided, JavaScript's default [`.toDateString()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toDateString) method will be used. `picker.getDate()` Returns a basic JavaScript `Date` object of the selected day, or `null` if no selection. `picker.setDate('2015-01-01')` Set the current selection. This will be restricted within the bounds of `minDate` and `maxDate` options if they're specified. You can optionally pass a boolean as the second parameter to prevent triggering of the onSelect callback (true), allowing the date to be set silently. `picker.getMoment()` Returns a [Moment.js][moment] object for the selected date (Moment must be loaded before Pikaday). `picker.setMoment(moment('14th February 2014', 'DDo MMMM YYYY'))` Set the current selection with a [Moment.js][moment] object (see `setDate` for details). ### Change current view `picker.gotoDate(new Date(2014, 1))` Change the current view to see a specific date. This example will jump to February 2014 ([month is a zero-based index][mdn_date]). `picker.gotoToday()` Shortcut for `picker.gotoDate(new Date())` `picker.gotoMonth(2)` Change the current view by month (0: January, 1: Februrary, etc). `picker.nextMonth()` `picker.prevMonth()` Go to the next or previous month (this will change year if necessary). `picker.gotoYear()` Change the year being viewed. `picker.setMinDate()` Update the minimum/earliest date that can be selected. `picker.setMaxDate()` Update the maximum/latest date that can be selected. `picker.setStartRange()` Update the range start date. For using two Pikaday instances to select a date range. `picker.setEndRange()` Update the range end date. For using two Pikaday instances to select a date range. ### Show and hide datepicker `picker.isVisible()` Returns `true` or `false`. `picker.show()` Make the picker visible. `picker.adjustPosition()` Recalculate and change the position of the picker. `picker.hide()` Hide the picker making it invisible. `picker.destroy()` Hide the picker and remove all event listeners — no going back! ### Internationalization The default `i18n` configuration format looks like this: ```javascript i18n: { previousMonth : 'Previous Month', nextMonth : 'Next Month', months : ['January','February','March','April','May','June','July','August','September','October','November','December'], weekdays : ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'], weekdaysShort : ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'] } ``` You must provide 12 months and 7 weekdays (with abbreviations). Always specify weekdays in this order with Sunday first. You can change the `firstDay` option to reorder if necessary (0: Sunday, 1: Monday, etc). You can also set `isRTL` to `true` for languages that are read right-to-left. ## Extensions ### Timepicker Pikaday is a pure datepicker. It will not support picking a time of day. However, there have been efforts to add time support to Pikaday. See [#1][issue1] and [#18][issue18]. These reside in their own fork. You can use the work [@owenmead][owenmead] did most recently at [owenmead/Pikaday][owen Pika] A more simple time selection approach done by [@xeeali][xeeali] at [xeeali/Pikaday][xeeali Pika] is based on version 1.2.0. Also [@stas][stas] has a fork [stas/Pikaday][stas Pika], but is now quite old ## Browser Compatibility * IE 7+ * Chrome 8+ * Firefox 3.5+ * Safari 3+ * Opera 10.6+ [![browser compatibility](https://ci.testling.com/rikkert/pikaday.png) ](https://ci.testling.com/rikkert/pikaday) * * * ## Authors * David Bushell [https://dbushell.com][Bushell] [@dbushell][Bushell Twitter] * Ramiro Rikkert [GitHub][Rikkert] [@RamRik][Rikkert Twitter] Thanks to [@shoogledesigns][shoogledesigns] for the name. Copyright © 2014 David Bushell | BSD & MIT license [Pikaday]: http://dbushell.github.com/Pikaday/ "Pikaday" [moment]: http://momentjs.com/ "moment.js" [browserify]: http://browserify.org/ "browserify" [screenshot]: https://raw.github.com/Pikaday/Pikaday/gh-pages/screenshot.png "Screenshot" [issues]: https://github.com/Pikaday/Pikaday/issues "Issue tracker" [gem]: https://rubygems.org/gems/pikaday-gem "RoR gem" [mdn_date]: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date "Date" [Bushell]: https://dbushell.com/ "dbushell.com" [Bushell Twitter]: https://twitter.com/dbushell "@dbushell" [Rikkert]: https://github.com/rikkert "Rikkert GitHub" [Rikkert Twitter]: https://twitter.com/ramrik "@ramrik" [shoogledesigns]: https://twitter.com/shoogledesigns/status/255209384261586944 "@shoogledesigns" [issue1]: https://github.com/Pikaday/Pikaday/issues/1 "Issue 1" [issue18]: https://github.com/Pikaday/Pikaday/issues/18 "Issue 18" [stas]: https://github.com/stas "@stas" [stas Pika]: https://github.com/stas/Pikaday "Pikaday" [owenmead]: https://github.com/owenmead "@owenmead" [owen Pika]: https://github.com/owenmead/Pikaday "Pikaday" [xeeali]: https://github.com/xeeali "@xeeali" [xeeali Pika]: https://github.com/xeeali/Pikaday "Pikaday" [moment.js example]: https://pikaday.com/examples/moment.html "Pikaday w/ moment.js" [jQuery example]: https://pikaday.com/examples/jquery.html "Pikaday w/ jQuery" [AMD example]: https://pikaday.com/examples/amd.html "Pikaday w/ AMD" [jQuery AMD example]: https://pikaday.com/examples/jquery-amd.html "Pikaday w/ jQuery + AMD" [trigger example]: https://pikaday.com/examples/trigger.html "Pikaday using custom trigger" [positions example]: https://pikaday.com/examples/positions.html "Pikaday using different position options" [container example]: https://pikaday.com/examples/container.html "Pikaday using custom calendar container" [theme example]: https://pikaday.com/examples/theme.html "Pikaday using multiple themes" [npm-image]: https://img.shields.io/npm/v/pikaday.svg?style=flat-square [npm-url]: https://npmjs.org/package/pikaday [license-image]: https://img.shields.io/:license-mit-blue.svg?style=flat-square [license-url]: LICENSE.md [downloads-image]: http://img.shields.io/npm/dm/pikaday.svg?style=flat-square [downloads-url]: https://npmjs.org/package/pikaday package/css/pikaday.css000755 0000010727 3560116604 012216 0ustar00000000 000000 @charset "UTF-8"; /*! * Pikaday * Copyright © 2014 David Bushell | BSD & MIT license | https://dbushell.com/ */ .pika-single { z-index: 9999; display: block; position: relative; color: #333; background: #fff; border: 1px solid #ccc; border-bottom-color: #bbb; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; } /* clear child float (pika-lendar), using the famous micro clearfix hack http://nicolasgallagher.com/micro-clearfix-hack/ */ .pika-single:before, .pika-single:after { content: " "; display: table; } .pika-single:after { clear: both } .pika-single { *zoom: 1 } .pika-single.is-hidden { display: none; } .pika-single.is-bound { position: absolute; box-shadow: 0 5px 15px -5px rgba(0,0,0,.5); } .pika-lendar { float: left; width: 240px; margin: 8px; } .pika-title { position: relative; text-align: center; } .pika-label { display: inline-block; *display: inline; position: relative; z-index: 9999; overflow: hidden; margin: 0; padding: 5px 3px; font-size: 14px; line-height: 20px; font-weight: bold; background-color: #fff; } .pika-title select { cursor: pointer; position: absolute; z-index: 9998; margin: 0; left: 0; top: 5px; filter: alpha(opacity=0); opacity: 0; } .pika-prev, .pika-next { display: block; cursor: pointer; position: relative; outline: none; border: 0; padding: 0; width: 20px; height: 30px; /* hide text using text-indent trick, using width value (it's enough) */ text-indent: 20px; white-space: nowrap; overflow: hidden; background-color: transparent; background-position: center center; background-repeat: no-repeat; background-size: 75% 75%; opacity: .5; *position: absolute; *top: 0; } .pika-prev:hover, .pika-next:hover { opacity: 1; } .pika-prev, .is-rtl .pika-next { float: left; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAeCAYAAAAsEj5rAAAAUklEQVR42u3VMQoAIBADQf8Pgj+OD9hG2CtONJB2ymQkKe0HbwAP0xucDiQWARITIDEBEnMgMQ8S8+AqBIl6kKgHiXqQqAeJepBo/z38J/U0uAHlaBkBl9I4GwAAAABJRU5ErkJggg=='); *left: 0; } .pika-next, .is-rtl .pika-prev { float: right; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAeCAYAAAAsEj5rAAAAU0lEQVR42u3VOwoAMAgE0dwfAnNjU26bYkBCFGwfiL9VVWoO+BJ4Gf3gtsEKKoFBNTCoCAYVwaAiGNQGMUHMkjGbgjk2mIONuXo0nC8XnCf1JXgArVIZAQh5TKYAAAAASUVORK5CYII='); *right: 0; } .pika-prev.is-disabled, .pika-next.is-disabled { cursor: default; opacity: .2; } .pika-select { display: inline-block; *display: inline; } .pika-table { width: 100%; border-collapse: collapse; border-spacing: 0; border: 0; } .pika-table th, .pika-table td { width: 14.285714285714286%; padding: 0; } .pika-table th { color: #999; font-size: 12px; line-height: 25px; font-weight: bold; text-align: center; } .pika-button { cursor: pointer; display: block; box-sizing: border-box; -moz-box-sizing: border-box; outline: none; border: 0; margin: 0; width: 100%; padding: 5px; color: #666; font-size: 12px; line-height: 15px; text-align: right; background: #f5f5f5; } .pika-week { font-size: 11px; color: #999; } .is-today .pika-button { color: #33aaff; font-weight: bold; } .is-selected .pika-button, .has-event .pika-button { color: #fff; font-weight: bold; background: #33aaff; box-shadow: inset 0 1px 3px #178fe5; border-radius: 3px; } .has-event .pika-button { background: #005da9; box-shadow: inset 0 1px 3px #0076c9; } .is-disabled .pika-button, .is-inrange .pika-button { background: #D5E9F7; } .is-startrange .pika-button { color: #fff; background: #6CB31D; box-shadow: none; border-radius: 3px; } .is-endrange .pika-button { color: #fff; background: #33aaff; box-shadow: none; border-radius: 3px; } .is-disabled .pika-button { pointer-events: none; cursor: default; color: #999; opacity: .3; } .is-outside-current-month .pika-button { color: #999; opacity: .3; } .is-selection-disabled { pointer-events: none; cursor: default; } .pika-button:hover, .pika-row.pick-whole-week:hover .pika-button { color: #fff; background: #ff8000; box-shadow: none; border-radius: 3px; } /* styling for abbr */ .pika-table abbr { border-bottom: none; cursor: help; } package/css/site.css000755 0000001406 3560116604 011532 0ustar00000000 000000 html { margin: 0; padding: 0; } body { font-size: 100%; margin: 0; padding: 1.75em; font-family: 'Helvetica Neue', Arial, sans-serif; } h1 { font-size: 1.75em; margin: 0 0 0.6em 0; } h2 { font-size: 1.25em; margin: 0 0 0.6em 0; } a { color: #2996cc; } a:hover { text-decoration: none; } p { line-height: 1.5em; } .small { color: #666; font-size: 0.875em; } .large { font-size: 1.25em; } label { font-weight: bold; } input[type="text"] { margin: 0.5em 0 3em 0; padding: 0.5em; } button#datepicker-button { margin-bottom: 3em; } .flow-element { display: inline-block; margin-right: 3em; vertical-align: top; } .flow-element:last-child { margin-right: 0; } .flow-element input { margin-top: 0; } #container { min-height: 15em; }package/css/theme.css000755 0000002470 3560116604 011672 0ustar00000000 000000 /** * This theme is an example to show how you can create your own. */ .pika-single.dark-theme { color: #fff; background: #333; border: 1px solid #666; border-bottom-color: #999; } .dark-theme .pika-label { background-color: #333; } .dark-theme .pika-prev, .dark-theme .is-rtl .pika-next { background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAeCAQAAACGG/bgAAAAQ0lEQVR4Ae3KIQ4AIBTD0N0/IeHGI3UIRA3ut/Zl+ltXc5++htVAmIAwAWECwgSEKbgthEoIlRAqIVRCqINQB9nDgQd7ktwFo6UpWQAAAABJRU5ErkJggg=='); } .dark-theme .pika-next, .dark-theme .is-rtl .pika-prev { background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAeCAQAAACGG/bgAAAAP0lEQVQ4y+3TMQoAMAgEwfwfAvvjTZ1uGzuvHhBPPGczEG+FRqqRaqQaqUaqkX6QBmmjacvQ6qEVTjsh+xizebvlaWptGXZAAAAAAElFTkSuQmCC'); } .dark-theme .pika-table th { color: #999; } .dark-theme .pika-button { color: #fff; background: #222; } .dark-theme .pika-week { color: #999; } .dark-theme .is-today .pika-button { color: #33aaff; } .dark-theme .is-selected .pika-button { color: #fff; background: #33aaff; box-shadow: inset 0 1px 3px #178fe5; } .dark-theme .is-disabled .pika-button { color: #999; opacity: .3; } .dark-theme .pika-button:hover { color: #fff !important; background: #ff8000 !important; } package/css/triangle.css000755 0000000224 3560116604 012370 0ustar00000000 000000 /** * This theme is an example to show how you can add triangles to the dropdowns. */ .triangle-theme .pika-label:after { content:" \25be"; } package/examples/amd.html000755 0000003565 3560116604 012541 0ustar00000000 000000 Pikaday - AMD example Fork me on GitHub

Pikaday - AMD example

A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.


What is this?

Since version 1.0 Pikaday is a stable and battle tested date-picker. Feel free to use it however you like but please report any bugs or feature requests to the GitHub issue tracker, thanks!

Copyright © 2014 David Bushell | BSD & MIT license | Example by Ramiro Rikkert

package/examples/aria-label.html000755 0000003240 3560116604 013757 0ustar00000000 000000 Pikaday - custom trigger element example Fork me on GitHub

Pikaday - custom trigger example

A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.


What is this?

Since version 1.0 Pikaday is a stable and battle tested date-picker. Feel free to use it however you like but please report any bugs or feature requests to the GitHub issue tracker, thanks!

Copyright © 2014 David Bushell | BSD & MIT license | Example by Ramiro Rikkert

package/examples/bound-container.html000755 0000003604 3560116604 015061 0ustar00000000 000000 Pikaday - Container example Fork me on GitHub

Pikaday - Container example

A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.

What is this?

Since version 1.0 Pikaday is a stable and battle tested date-picker. Feel free to use it however you like but please report any bugs or feature requests to the GitHub issue tracker, thanks!

Copyright © 2014 David Bushell | BSD & MIT license | Example by Ramiro Rikkert

package/examples/calendars.html000755 0000004005 3560116604 013722 0ustar00000000 000000 Pikaday - ranges example Fork me on GitHub

Pikaday

A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.


2 months
3 months, main aligned to right

What is this?

Since version 1.0 Pikaday is a stable and battle tested date-picker. Feel free to use it however you like but please report any bugs or feature requests to the GitHub issue tracker, thanks!

Copyright © 2013 David Bushell | BSD & MIT license | Example by MoOx

package/examples/container.html000755 0000003605 3560116604 013755 0ustar00000000 000000 Pikaday - Container example Fork me on GitHub

Pikaday - Container example

A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.

What is this?

Since version 1.0 Pikaday is a stable and battle tested date-picker. Feel free to use it however you like but please report any bugs or feature requests to the GitHub issue tracker, thanks!

Copyright © 2014 David Bushell | BSD & MIT license | Example by Ramiro Rikkert

package/examples/date-fns.html000755 0000004323 3560116604 013472 0ustar00000000 000000 Pikaday - date-fns example Fork me on GitHub

Pikaday + date-fns

A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.



What is this?

Since version 1.0 Pikaday is a stable and battle tested date-picker. Feel free to use it however you like but please report any bugs or feature requests to the GitHub issue tracker, thanks!

Copyright © 2014 David Bushell | BSD & MIT license | Example by Ramiro Rikkert

package/examples/date-range.html000755 0000005214 3560116604 014000 0ustar00000000 000000 Pikaday - Date Range example

Pikaday - Date Range example

A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.

Pikaday source on GitHub



What is this?

Since version 1.0 Pikaday is a stable and battle tested date-picker. Feel free to use it however you like but please report any bugs or feature requests to the GitHub issue tracker, thanks!

Copyright © 2014 David Bushell | BSD & MIT license

package/examples/daysInNextMonth.html000755 0000003363 3560116604 015070 0ustar00000000 000000 Pikaday - showDaysInNextAndPreviousMonths example Fork me on GitHub

Pikaday - show days in next and previous month example

A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.


What is this?

Since version 1.0 Pikaday is a stable and battle tested date-picker. Feel free to use it however you like but please report any bugs or feature requests to the GitHub issue tracker, thanks!

Copyright © 2014 David Bushell | BSD & MIT license | Example by Ramiro Rikkert

package/examples/diableDayFn.html000755 0000003272 3560116604 014135 0ustar00000000 000000 Pikaday - disableDayFn example Fork me on GitHub

Pikaday - disableDayFn example

A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.


What is this?

Since version 1.0 Pikaday is a stable and battle tested date-picker. Feel free to use it however you like but please report any bugs or feature requests to the GitHub issue tracker, thanks!

Copyright © 2014 David Bushell | BSD & MIT license | Example by Ramiro Rikkert

package/examples/jquery-amd.html000755 0000004126 3560116604 014050 0ustar00000000 000000 Pikaday - jQuery + AMD example Fork me on GitHub

Pikaday - jQuery + AMD example

A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.


What is this?

Since version 1.0 Pikaday is a stable and battle tested date-picker. Feel free to use it however you like but please report any bugs or feature requests to the GitHub issue tracker, thanks!

Copyright © 2014 David Bushell | BSD & MIT license | Example by Ramiro Rikkert

package/examples/jquery.html000755 0000003546 3560116604 013316 0ustar00000000 000000 Pikaday - jQuery example Fork me on GitHub

Pikaday - jQuery example

A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.


What is this?

Since version 1.0 Pikaday is a stable and battle tested date-picker. Feel free to use it however you like but please report any bugs or feature requests to the GitHub issue tracker, thanks!

Copyright © 2014 David Bushell | BSD & MIT license | Example by Ramiro Rikkert

package/examples/moment.html000755 0000003770 3560116604 013275 0ustar00000000 000000 Pikaday - moment.js example Fork me on GitHub

Pikaday + moment.js

A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.



What is this?

Since version 1.0 Pikaday is a stable and battle tested date-picker. Feel free to use it however you like but please report any bugs or feature requests to the GitHub issue tracker, thanks!

Copyright © 2014 David Bushell | BSD & MIT license | Example by Ramiro Rikkert

package/examples/pick-whole-week.html000644 0000003476 3560116604 014771 0ustar00000000 000000 Pikaday - pickWholeWeek example Fork me on GitHub

Pikaday - pickWholeWeek example

A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.


What is this?

Since version 1.0 Pikaday is a stable and battle tested date-picker. Feel free to use it however you like but please report any bugs or feature requests to the GitHub issue tracker, thanks!

Copyright © 2014 David Bushell | BSD & MIT license | Example by Lei Zhao

package/examples/position-css-classes.html000644 0000010645 3560116604 016057 0ustar00000000 000000 Pikaday alignment CSS-classes example Fork me on GitHub

Pikaday alignment CSS-classes example

A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.

What is this?

Since version 1.0 Pikaday is a stable and battle tested date-picker. Feel free to use it however you like but please report any bugs or feature requests to the GitHub issue tracker, thanks!

Copyright © 2014 David Bushell | BSD & MIT license | Example by Ruben Swieringa

package/examples/positions.html000755 0000007265 3560116604 014030 0ustar00000000 000000 Pikaday alignment example Fork me on GitHub

Pikaday alignment example

A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.



not really (too close from top)
for real this time (same code as above)
not really (too close from right)
Here is the top right position with content before (no automatic adjustment used, same code as above)


Here is the bottom right position with content before (no automatic adjustment used, , same code as above)

Also, take a look to the bottom right of this page to see an example with position automatically adjusted.

What is this?

Since version 1.0 Pikaday is a stable and battle tested date-picker. Feel free to use it however you like but please report any bugs or feature requests to the GitHub issue tracker, thanks!

Copyright © 2014 David Bushell | BSD & MIT license | Example by MoOx

package/examples/theme.html000755 0000004054 3560116604 013074 0ustar00000000 000000 Pikaday - Theme example Fork me on GitHub

Pikaday - Theme example

A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.


No theme
Custom theme
Dropdowns w/ triangles

What is this?

Since version 1.0 Pikaday is a stable and battle tested date-picker. Feel free to use it however you like but please report any bugs or feature requests to the GitHub issue tracker, thanks!

Copyright © 2014 David Bushell | BSD & MIT license | Example by Ramiro Rikkert

package/examples/trigger.html000755 0000003307 3560116604 013435 0ustar00000000 000000 Pikaday - custom trigger element example Fork me on GitHub

Pikaday - custom trigger example

A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.



What is this?

Since version 1.0 Pikaday is a stable and battle tested date-picker. Feel free to use it however you like but please report any bugs or feature requests to the GitHub issue tracker, thanks!

Copyright © 2014 David Bushell | BSD & MIT license | Example by Ramiro Rikkert

package/examples/weeknumbers.html000755 0000003204 3560116604 014315 0ustar00000000 000000 Pikaday - weeknumbers example Fork me on GitHub

Pikaday - showing weeknumbers

A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.

What is this?

Since version 1.0 Pikaday is a stable and battle tested date-picker. Feel free to use it however you like but please report any bugs or feature requests to the GitHub issue tracker, thanks!

Copyright © 2014 David Bushell | BSD & MIT license | Example by Ramiro Rikkert

package/plugins/pikaday.jquery.js000755 0000002773 3560116604 014253 0ustar00000000 000000 /*! * Pikaday jQuery plugin. * * Copyright © 2013 David Bushell | BSD & MIT license | https://github.com/Pikaday/Pikaday */ (function (root, factory) { 'use strict'; if (typeof exports === 'object') { // CommonJS module factory(require('jquery'), require('pikaday')); } else if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. define(['jquery', 'pikaday'], factory); } else { // Browser globals factory(root.jQuery, root.Pikaday); } }(this, function ($, Pikaday) { 'use strict'; $.fn.pikaday = function() { var args = arguments; if (!args || !args.length) { args = [{ }]; } return this.each(function() { var self = $(this), plugin = self.data('pikaday'); if (!(plugin instanceof Pikaday)) { if (typeof args[0] === 'object') { var options = $.extend({}, args[0]); options.field = self[0]; self.data('pikaday', new Pikaday(options)); } } else { if (typeof args[0] === 'string' && typeof plugin[args[0]] === 'function') { plugin[args[0]].apply(plugin, Array.prototype.slice.call(args,1)); if (args[0] === 'destroy') { self.removeData('pikaday'); } } } }); }; })); package/scss/pikaday.scss000755 0000012537 3560116604 012565 0ustar00000000 000000 /*! * Pikaday * Copyright © 2014 David Bushell | BSD & MIT license | https://dbushell.com/ */ // Variables // Declare any of these variables before importing this SCSS file to easily override defaults // Variables are namespaced with the pd (pikaday) prefix // Colours $pd-text-color: #333 !default; $pd-title-color: #333 !default; $pd-title-bg: #fff !default; $pd-picker-bg: #fff !default; $pd-picker-border: #ccc !default; $pd-picker-border-bottom: #bbb !default; $pd-picker-shadow: rgba(0,0,0,.5) !default; $pd-th-color: #999 !default; $pd-day-color: #666 !default; $pd-day-bg: #f5f5f5 !default; $pd-day-hover-color: #fff !default; $pd-day-hover-bg: #ff8000 !default; $pd-day-today-color: #33aaff !default; $pd-day-selected-color: #fff !default; $pd-day-selected-bg: #33aaff !default; $pd-day-selected-shadow: #178fe5 !default; $pd-day-disabled-color: #999 !default; $pd-week-color: #999 !default; // Font $pd-font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !default; .pika-single { z-index: 9999; display: block; position: relative; color: $pd-text-color; background: $pd-picker-bg; border: 1px solid $pd-picker-border; border-bottom-color: $pd-picker-border-bottom; font-family: $pd-font-family; &.is-hidden { display: none; } &.is-bound { position: absolute; box-shadow: 0 5px 15px -5px $pd-picker-shadow; } } // clear child float (pika-lendar), using the famous micro clearfix hack // http://nicolasgallagher.com/micro-clearfix-hack/ .pika-single { *zoom: 1; &:before, &:after { content: " "; display: table; } &:after { clear: both } } .pika-lendar { float: left; width: 240px; margin: 8px; } .pika-title { position: relative; text-align: center; select { cursor: pointer; position: absolute; z-index: 9998; margin: 0; left: 0; top: 5px; filter: alpha(opacity=0); opacity: 0; } } .pika-label { display: inline-block; *display: inline; position: relative; z-index: 9999; overflow: hidden; margin: 0; padding: 5px 3px; font-size: 14px; line-height: 20px; font-weight: bold; color: $pd-title-color; background-color: $pd-title-bg; } .pika-prev, .pika-next { display: block; cursor: pointer; position: relative; outline: none; border: 0; padding: 0; width: 20px; height: 30px; text-indent: 20px; // hide text using text-indent trick, using width value (it's enough) white-space: nowrap; overflow: hidden; background-color: transparent; background-position: center center; background-repeat: no-repeat; background-size: 75% 75%; opacity: .5; *position: absolute; *top: 0; &:hover { opacity: 1; } &.is-disabled { cursor: default; opacity: .2; } } .pika-prev, .is-rtl .pika-next { float: left; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAeCAYAAAAsEj5rAAAAUklEQVR42u3VMQoAIBADQf8Pgj+OD9hG2CtONJB2ymQkKe0HbwAP0xucDiQWARITIDEBEnMgMQ8S8+AqBIl6kKgHiXqQqAeJepBo/z38J/U0uAHlaBkBl9I4GwAAAABJRU5ErkJggg=='); *left: 0; } .pika-next, .is-rtl .pika-prev { float: right; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAeCAYAAAAsEj5rAAAAU0lEQVR42u3VOwoAMAgE0dwfAnNjU26bYkBCFGwfiL9VVWoO+BJ4Gf3gtsEKKoFBNTCoCAYVwaAiGNQGMUHMkjGbgjk2mIONuXo0nC8XnCf1JXgArVIZAQh5TKYAAAAASUVORK5CYII='); *right: 0; } .pika-select { display: inline-block; *display: inline; } .pika-table { width: 100%; border-collapse: collapse; border-spacing: 0; border: 0; th, td { width: 14.285714285714286%; padding: 0; } th { color: $pd-th-color; font-size: 12px; line-height: 25px; font-weight: bold; text-align: center; } abbr { border-bottom: none; cursor: help; } } .pika-button { cursor: pointer; display: block; -moz-box-sizing: border-box; box-sizing: border-box; outline: none; border: 0; margin: 0; width: 100%; padding: 5px; color: $pd-day-color; font-size: 12px; line-height: 15px; text-align: right; background: $pd-day-bg; .is-today & { color: $pd-day-today-color; font-weight: bold; } .is-selected & { color: $pd-day-selected-color; font-weight: bold; background: $pd-day-selected-bg; box-shadow: inset 0 1px 3px $pd-day-selected-shadow; border-radius: 3px; } .is-disabled &, .is-outside-current-month & { color: $pd-day-disabled-color; opacity: .3; } .is-disabled & { pointer-events: none; cursor: default; } &:hover { color: $pd-day-hover-color; background: $pd-day-hover-bg; box-shadow: none; border-radius: 3px; } .is-selection-disabled { pointer-events: none; cursor: default; } } .pika-week { font-size: 11px; color: $pd-week-color; } .is-inrange .pika-button { background: #D5E9F7; } .is-startrange .pika-button { color: #fff; background: #6CB31D; box-shadow: none; border-radius: 3px; } .is-endrange .pika-button { color: #fff; background: #33aaff; box-shadow: none; border-radius: 3px; } package/tests/methods.js000755 0000010476 3560116604 012436 0ustar00000000 000000 var Pikaday = require('../'), expect = require('expect.js'); describe('Pikaday public method', function () { 'use strict'; describe('#getDate()', function() { it('should return null if date not set', function() { expect(new Pikaday().getDate()).to.be(null); }); }); describe('#toString()', function () { it('should return empty string when date not set', function () { var pikaday = new Pikaday(); expect(pikaday.toString()).to.be.empty; }); it('should return date string, formatted by moment, when date is set', function() { var date = new Date(2014, 3, 25), pikaday = new Pikaday({ format: 'DD-MM-YY' }); pikaday.setDate(date); expect(pikaday.toString()).to.eql('25-04-14'); }); it('should use toString function if one is provided', function () { var date = new Date(2014, 3, 25), pikaday = new Pikaday({ toString: function(d) { var date = d.getDate(); var month = d.getMonth() + 1; return 'custom: ' + date + '/' + month; } }); pikaday.setDate(date); expect(pikaday.toString()).to.eql('custom: 25/4'); }); it('should pass current format option to the toString function', function () { var date = new Date(2014, 3, 25); var expectedFormat = 'DD/MM/YYYY'; var passedFormat; var pikaday = new Pikaday({ format: expectedFormat, toString: function(d, format) { passedFormat = format; return ''; } }); pikaday.setDate(date); pikaday.toString(); // invoke toString to set the passedFormat variable expect(passedFormat).to.eql(expectedFormat); }); it('should use parse function if one is provided', function () { var expectedDate = new Date(2017, 3, 6); var pikaday = new Pikaday({ parse: function() { return new Date(2017, 3, 6); } }); // mock input field pikaday._o.field = { value: '', setAttribute: function() {}, dispatchEvent: function() {}, }; pikaday._onInputChange({}); expect(pikaday.getDate().getTime()).to.eql(expectedDate.getTime()); }); it('should pass input value and current format to the parse function', function () { var expectedValue = 'test value'; var expectedFormat = 'DD/MM/YYYY'; var passedValue; var passedFormat; var pikaday = new Pikaday({ format: expectedFormat, parse: function(value, format) { passedValue = value; passedFormat = format; return new Date(2017, 3, 6); } }); // mock input field pikaday._o.field = { value: expectedValue, setAttribute: function() {}, dispatchEvent: function() {}, }; pikaday._onInputChange({}); expect(passedValue).to.eql(expectedValue); expect(passedFormat).to.eql(expectedFormat); }); }); describe('When specifying minDate option in Constructor', function () { it('Should remove the time portion (flattening to midnight)', function () { var date = new Date(2015, 1, 17, 22, 10, 5), expected = new Date(2015, 1, 17, 0, 0, 0), pikaday = new Pikaday({ minDate: date }); expect(pikaday._o.minDate).to.eql(expected); }); }); describe('#setMinDate()', function () { it('should flatten date to midnight ignoring time portion (consistent with minDate option in ctor)', function () { var date = new Date(2015, 1, 17, 22, 10, 5), expected = new Date(2015, 1, 17, 0, 0, 0), pikaday = new Pikaday(); pikaday.setMinDate(date); expect(pikaday._o.minDate).to.eql(expected); }); }); }); package/tests/module.js000755 0000001035 3560116604 012247 0ustar00000000 000000 var Pikaday = require('../'), expect = require('expect.js'); describe('Pikaday', function () { 'use strict'; it('should expose as a CommonJS module', function () { expect(Pikaday).to.be.a('function'); }); it('should NOT leak to the global object', function () { expect(window).to.not.have.property('Pikaday'); }); it('should be possible to create a new instance', function () { expect(function () { new Pikaday(); }).to.not.throwException(); }); });