[Pkg-javascript-commits] [node-pikaday] 01/03: Import Upstream version 1.7.0
Daniel Ring
techwolf-guest at moszumanska.debian.org
Fri Dec 15 10:37:01 UTC 2017
This is an automated email from the git hooks/post-receive script.
techwolf-guest pushed a commit to branch master
in repository node-pikaday.
commit 8f5df1504e8938c09729c5962a32fcb80d9dd364
Author: Daniel Ring <dring at wolfishly.me>
Date: Fri Dec 15 02:34:24 2017 -0800
Import Upstream version 1.7.0
---
.editorconfig | 15 +
.gitattributes | 1 +
.jshintrc | 31 +
CHANGELOG.md | 108 ++++
LICENSE | 36 ++
README.md | 397 +++++++++++++
bower.json | 28 +
component.json | 17 +
css/pikaday.css | 239 ++++++++
css/site.css | 42 ++
css/theme.css | 56 ++
css/triangle.css | 6 +
examples/amd.html | 50 ++
examples/bound-container.html | 52 ++
examples/calendars.html | 57 ++
examples/container.html | 52 ++
examples/date-fns.html | 57 ++
examples/date-range.html | 83 +++
examples/daysInNextMonth.html | 44 ++
examples/diableDayFn.html | 45 ++
examples/jquery-amd.html | 54 ++
examples/jquery.html | 46 ++
examples/moment.html | 53 ++
examples/pick-whole-week.html | 45 ++
examples/positions.html | 106 ++++
examples/theme.html | 57 ++
examples/trigger.html | 46 ++
examples/weeknumbers.html | 41 ++
index.html | 43 ++
package.json | 43 ++
pikaday.js | 1245 +++++++++++++++++++++++++++++++++++++++++
plugins/pikaday.jquery.js | 56 ++
scss/pikaday.scss | 255 +++++++++
tests/methods.js | 130 +++++
tests/module.js | 24 +
35 files changed, 3660 insertions(+)
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..7f30d1b
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,15 @@
+; 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 = false
\ No newline at end of file
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..176a458
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+* text=auto
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..69844c5
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,31 @@
+{
+ "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
+ }
+}
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100755
index 0000000..d648f42
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,108 @@
+# Changelog
+
+## 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…
diff --git a/LICENSE b/LICENSE
new file mode 100755
index 0000000..b2caa06
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,36 @@
+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 PROF [...]
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100755
index 0000000..6034082
--- /dev/null
+++ b/README.md
@@ -0,0 +1,397 @@
+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
+<input type="text" id="datepicker">
+```
+
+Add the JavaScript to the end of your document:
+
+```html
+<script src="pikaday.js"></script>
+<script>
+ var picker = new Pikaday({ field: document.getElementById('datepicker') });
+</script>
+```
+
+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
+<input type="text" id="datepicker" value="9 Oct 2014">
+
+<script src="moment.js"></script>
+<script src="pikaday.js"></script>
+<script>
+ var picker = new Pikaday({
+ field: document.getElementById('datepicker'),
+ format: 'D MMM YYYY',
+ onSelect: function() {
+ console.log(this.getMoment().format('Do MMMM YYYY'));
+ }
+ });
+</script>
+```
+
+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)
+* `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`)
+
+## 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
+<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
+<script src="pikaday.js"></script>
+<script src="plugins/pikaday.jquery.js"></script>
+<script>
+
+// activate datepickers for all elements with a class of `datepicker`
+$('.datepicker').pikaday({ firstDay: 1 });
+
+// chain a few methods for the first datepicker, jQuery style!
+$('.datepicker').eq(0).pikaday('show').pikaday('gotoYear', 2042);
+
+</script>
+```
+
+## 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 [http://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/dbushell/Pikaday/gh-pages/screenshot.png "Screenshot"
+ [issues]: https://github.com/dbushell/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]: http://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/dbushell/Pikaday/issues/1 "Issue 1"
+ [issue18]: https://github.com/dbushell/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]: http://dbushell.github.com/Pikaday/examples/moment.html "Pikaday w/ moment.js"
+ [jQuery example]: http://dbushell.github.com/Pikaday/examples/jquery.html "Pikaday w/ jQuery"
+ [AMD example]: http://dbushell.github.com/Pikaday/examples/amd.html "Pikaday w/ AMD"
+ [jQuery AMD example]: http://dbushell.github.com/Pikaday/examples/jquery-amd.html "Pikaday w/ jQuery + AMD"
+ [trigger example]: http://dbushell.github.com/Pikaday/examples/trigger.html "Pikaday using custom trigger"
+ [positions example]: http://dbushell.github.com/Pikaday/examples/positions.html "Pikaday using different position options"
+ [container example]: http://dbushell.github.com/Pikaday/examples/container.html "Pikaday using custom calendar container"
+ [theme example]: http://dbushell.github.com/Pikaday/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
diff --git a/bower.json b/bower.json
new file mode 100755
index 0000000..6e821cf
--- /dev/null
+++ b/bower.json
@@ -0,0 +1,28 @@
+{
+ "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": "http://dbushell.github.io/Pikaday/",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/dbushell/Pikaday.git"
+ }
+}
diff --git a/component.json b/component.json
new file mode 100755
index 0000000..d0bc4aa
--- /dev/null
+++ b/component.json
@@ -0,0 +1,17 @@
+{
+ "name": "pikaday",
+ "repo": "dbushell/Pikaday",
+ "description": "A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS",
+ "version": "1.7.0",
+ "keywords": [
+ "datepicker",
+ "calendar",
+ "date"
+ ],
+ "main": "pikaday.js",
+ "scripts": ["pikaday.js"],
+ "styles": ["css/pikaday.css"],
+ "dependencies": {},
+ "demo": "http://dbushell.github.io/Pikaday/",
+ "license": "MIT"
+}
diff --git a/css/pikaday.css b/css/pikaday.css
new file mode 100755
index 0000000..1759061
--- /dev/null
+++ b/css/pikaday.css
@@ -0,0 +1,239 @@
+ at charset "UTF-8";
+
+/*!
+ * Pikaday
+ * Copyright © 2014 David Bushell | BSD & MIT license | http://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;
+}
+
diff --git a/css/site.css b/css/site.css
new file mode 100755
index 0000000..a5111a2
--- /dev/null
+++ b/css/site.css
@@ -0,0 +1,42 @@
+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;
+}
\ No newline at end of file
diff --git a/css/theme.css b/css/theme.css
new file mode 100755
index 0000000..3a0c101
--- /dev/null
+++ b/css/theme.css
@@ -0,0 +1,56 @@
+/**
+ * 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;
+}
diff --git a/css/triangle.css b/css/triangle.css
new file mode 100755
index 0000000..894dd19
--- /dev/null
+++ b/css/triangle.css
@@ -0,0 +1,6 @@
+/**
+ * This theme is an example to show how you can add triangles to the dropdowns.
+ */
+.triangle-theme .pika-label:after {
+ content:" \25be";
+}
diff --git a/examples/amd.html b/examples/amd.html
new file mode 100755
index 0000000..74835b5
--- /dev/null
+++ b/examples/amd.html
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
+ <title>Pikaday - AMD example</title>
+ <meta name="author" content="Ramiro Rikkert">
+ <link rel="stylesheet" href="../css/pikaday.css">
+ <link rel="stylesheet" href="../css/site.css">
+</head>
+<body>
+ <a href="https://github.com/dbushell/Pikaday"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"></a>
+
+ <h1>Pikaday - AMD example</h1>
+
+ <p class="large">A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.</p>
+
+ <label for="datepicker">Date:</label>
+ <br>
+ <input type="text" id="datepicker">
+
+ <h2>What is this?</h2>
+
+ <p>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 <a href="https://github.com/dbushell/Pikaday/issues">GitHub issue tracker</a>, thanks!</p>
+
+ <p class="small">Copyright © 2014 <a href="http://dbushell.com/">David Bushell</a> | BSD & MIT license | Example by <a href="https://github.com/rikkert">Ramiro Rikkert</a></p>
+
+ <script src="//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.js"></script>
+ <script>
+
+ require.config({
+ baseUrl: '../',
+ // To get timely, correct error triggers in IE, force a define/shim exports check.
+ enforceDefine: true
+ });
+ require(['pikaday'], function(Pikaday)
+ {
+ var picker = new Pikaday(
+ {
+ field: document.getElementById('datepicker'),
+ firstDay: 1,
+ minDate: new Date(2000, 0, 1),
+ maxDate: new Date(2020, 12, 31),
+ yearRange: [2000,2020]
+ });
+ });
+
+ </script>
+</body>
+</html>
\ No newline at end of file
diff --git a/examples/bound-container.html b/examples/bound-container.html
new file mode 100755
index 0000000..a994028
--- /dev/null
+++ b/examples/bound-container.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
+ <title>Pikaday - Container example</title>
+ <meta name="author" content="Stuart McFarlane">
+ <link rel="stylesheet" href="../css/pikaday.css">
+ <link rel="stylesheet" href="../css/site.css">
+</head>
+<body>
+ <a href="https://github.com/dbushell/Pikaday"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"></a>
+
+ <h1>Pikaday - Container example</h1>
+
+ <p class="large">A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.</p>
+
+ <div>
+ <div class="flow-element">
+ <label for="datepicker">Date:</label>
+ <input type="text" id="datepicker">
+ </div>
+ <div class="flow-element">
+ <div id="container"></div>
+ </div>
+ </div>
+
+ <h2>What is this?</h2>
+
+ <p>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 <a href="https://github.com/dbushell/Pikaday/issues">GitHub issue tracker</a>, thanks!</p>
+
+ <p class="small">Copyright © 2014 <a href="http://dbushell.com/">David Bushell</a> | BSD & MIT license | Example by <a href="https://github.com/rikkert">Ramiro Rikkert</a></p>
+
+
+ <!-- First load pikaday.js and then the jQuery plugin -->
+ <script src="../pikaday.js"></script>
+ <script>
+
+ var picker = new Pikaday(
+ {
+ field: document.getElementById('datepicker'),
+ firstDay: 1,
+ minDate: new Date(2000, 0, 1),
+ maxDate: new Date(2020, 12, 31),
+ yearRange: [2000, 2020],
+ bound: true,
+ container: document.getElementById('container'),
+ });
+
+ </script>
+</body>
+</html>
\ No newline at end of file
diff --git a/examples/calendars.html b/examples/calendars.html
new file mode 100755
index 0000000..b93e665
--- /dev/null
+++ b/examples/calendars.html
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
+ <title>Pikaday - ranges example</title>
+ <meta name="author" content="Maxime Thirouin">
+ <link rel="stylesheet" href="../css/pikaday.css">
+ <link rel="stylesheet" href="../css/site.css">
+</head>
+<body>
+ <a href="https://github.com/dbushell/Pikaday"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"></a>
+
+ <h1>Pikaday</h1>
+
+ <p class="large">A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.</p>
+
+ <label for="datepicker">Date:</label>
+ <br />
+ 2 months <input type="text" id="datepicker-2months">
+ <br />
+ 3 months, main aligned to right <input type="text" id="datepicker-3months-right">
+
+ <h2>What is this?</h2>
+
+ <p>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 <a href="https://github.com/dbushell/Pikaday/issues">GitHub issue tracker</a>, thanks!</p>
+
+ <p class="small">Copyright © 2013 <a href="http://dbushell.com/">David Bushell</a> | BSD & MIT license | Example by <a href="https://github.com/MoOx">MoOx</a></p>
+
+
+ <script src="../pikaday.js"></script>
+ <script>
+
+ var picker2months = new Pikaday(
+ {
+ numberOfMonths: 2,
+ field: document.getElementById('datepicker-2months'),
+ firstDay: 1,
+ minDate: new Date(2000, 0, 1),
+ maxDate: new Date(2020, 12, 31),
+ yearRange: [2000, 2020]
+ });
+
+ var picker3monthsRight = new Pikaday(
+ {
+ numberOfMonths: 3,
+ mainCalendar: 'right',
+ field: document.getElementById('datepicker-3months-right'),
+ firstDay: 1,
+ minDate: new Date(2000, 0, 1),
+ maxDate: new Date(2020, 12, 31),
+ yearRange: [2000, 2020]
+ });
+
+ </script>
+</body>
+</html>
diff --git a/examples/container.html b/examples/container.html
new file mode 100755
index 0000000..d6f11c8
--- /dev/null
+++ b/examples/container.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
+ <title>Pikaday - Container example</title>
+ <meta name="author" content="Stuart McFarlane">
+ <link rel="stylesheet" href="../css/pikaday.css">
+ <link rel="stylesheet" href="../css/site.css">
+</head>
+<body>
+ <a href="https://github.com/dbushell/Pikaday"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"></a>
+
+ <h1>Pikaday - Container example</h1>
+
+ <p class="large">A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.</p>
+
+ <div>
+ <div class="flow-element">
+ <label for="datepicker">Date:</label>
+ <input type="text" id="datepicker">
+ </div>
+ <div class="flow-element">
+ <div id="container"></div>
+ </div>
+ </div>
+
+ <h2>What is this?</h2>
+
+ <p>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 <a href="https://github.com/dbushell/Pikaday/issues">GitHub issue tracker</a>, thanks!</p>
+
+ <p class="small">Copyright © 2014 <a href="http://dbushell.com/">David Bushell</a> | BSD & MIT license | Example by <a href="https://github.com/rikkert">Ramiro Rikkert</a></p>
+
+
+ <!-- First load pikaday.js and then the jQuery plugin -->
+ <script src="../pikaday.js"></script>
+ <script>
+
+ var picker = new Pikaday(
+ {
+ field: document.getElementById('datepicker'),
+ firstDay: 1,
+ minDate: new Date(2000, 0, 1),
+ maxDate: new Date(2020, 12, 31),
+ yearRange: [2000, 2020],
+ bound: false,
+ container: document.getElementById('container'),
+ });
+
+ </script>
+</body>
+</html>
\ No newline at end of file
diff --git a/examples/date-fns.html b/examples/date-fns.html
new file mode 100755
index 0000000..a4d9dfb
--- /dev/null
+++ b/examples/date-fns.html
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
+ <title>Pikaday - date-fns example</title>
+ <meta name="author" content="Ramiro Rikkert">
+ <link rel="stylesheet" href="../css/pikaday.css">
+ <link rel="stylesheet" href="../css/site.css">
+</head>
+<body>
+ <a href="https://github.com/dbushell/Pikaday"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"></a>
+
+ <h1>Pikaday + date-fns</h1>
+
+ <p class="large">A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.</p>
+
+ <label for="datepicker">Date:</label>
+ <br>
+ <input type="text" id="datepicker">
+ <div id="selected"></div>
+ <br>
+
+ <h2>What is this?</h2>
+
+ <p>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 <a href="https://github.com/dbushell/Pikaday/issues">GitHub issue tracker</a>, thanks!</p>
+
+ <p class="small">Copyright © 2014 <a href="http://dbushell.com/">David Bushell</a> | BSD & MIT license | Example by <a href="https://github.com/rikkert">Ramiro Rikkert</a></p>
+
+
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/date-fns/1.28.5/date_fns.min.js"></script>
+ <script src="../pikaday.js"></script>
+ <script>
+
+ // You can get and set dates with custom formatter (and thus also date-fns)
+ new Pikaday(
+ {
+ field: document.getElementById('datepicker'),
+ toString: function(date, format) {
+ return dateFns.format(date, format);
+ },
+ parse: function(dateString, format) {
+ return dateFns.parse(dateString);
+ },
+ onSelect: function(selectedDate) {
+ // not necessary, just showing off
+ if (dateFns.isValid(selectedDate)) {
+ var p = document.createElement('p');
+ p.innerText = dateFns.distanceInWordsToNow(selectedDate, {addSuffix: true});
+ document.getElementById('selected').appendChild(p);
+ }
+ }
+ });
+
+ </script>
+</body>
+</html>
\ No newline at end of file
diff --git a/examples/date-range.html b/examples/date-range.html
new file mode 100755
index 0000000..01e1143
--- /dev/null
+++ b/examples/date-range.html
@@ -0,0 +1,83 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
+ <title>Pikaday - Date Range example</title>
+ <meta name="author" content="David Bushell">
+ <link rel="stylesheet" href="../css/pikaday.css">
+ <link rel="stylesheet" href="../css/site.css">
+</head>
+<body>
+ <h1>Pikaday - Date Range example</h1>
+
+ <p class="large">A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.</p>
+
+ <p><a href="https://github.com/dbushell/Pikaday"><strong>Pikaday source on GitHub</strong></a></p>
+
+ <div style="display: inline-block">
+ <label for="start">Start:</label>
+ <br>
+ <input type="text" id="start">
+ </div>
+
+ <div style="display: inline-block">
+ <label for="end">End:</label>
+ <br>
+ <input type="text" id="end">
+ </div>
+
+ <h2>What is this?</h2>
+
+ <p>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 <a href="https://github.com/dbushell/Pikaday/issues">GitHub issue tracker</a>, thanks!</p>
+
+ <p class="small">Copyright © 2014 <a href="http://dbushell.com/">David Bushell</a> | BSD & MIT license</p>
+
+
+ <script src="../pikaday.js"></script>
+ <script>
+ var startDate,
+ endDate,
+ updateStartDate = function() {
+ startPicker.setStartRange(startDate);
+ endPicker.setStartRange(startDate);
+ endPicker.setMinDate(startDate);
+ },
+ updateEndDate = function() {
+ startPicker.setEndRange(endDate);
+ startPicker.setMaxDate(endDate);
+ endPicker.setEndRange(endDate);
+ },
+ startPicker = new Pikaday({
+ field: document.getElementById('start'),
+ minDate: new Date(),
+ maxDate: new Date(2020, 12, 31),
+ onSelect: function() {
+ startDate = this.getDate();
+ updateStartDate();
+ }
+ }),
+ endPicker = new Pikaday({
+ field: document.getElementById('end'),
+ minDate: new Date(),
+ maxDate: new Date(2020, 12, 31),
+ onSelect: function() {
+ endDate = this.getDate();
+ updateEndDate();
+ }
+ }),
+ _startDate = startPicker.getDate(),
+ _endDate = endPicker.getDate();
+
+ if (_startDate) {
+ startDate = _startDate;
+ updateStartDate();
+ }
+
+ if (_endDate) {
+ endDate = _endDate;
+ updateEndDate();
+ }
+ </script>
+</body>
+</html>
\ No newline at end of file
diff --git a/examples/daysInNextMonth.html b/examples/daysInNextMonth.html
new file mode 100755
index 0000000..e3598f4
--- /dev/null
+++ b/examples/daysInNextMonth.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
+ <title>Pikaday - showDaysInNextAndPreviousMonths example</title>
+ <meta name="author" content="Ramiro Rikkert">
+ <link rel="stylesheet" href="../css/pikaday.css">
+ <link rel="stylesheet" href="../css/site.css">
+</head>
+<body>
+ <a href="https://github.com/dbushell/Pikaday"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"></a>
+
+ <h1>Pikaday - show days in next and previous month example</h1>
+
+ <p class="large">A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.</p>
+
+ <label for="datepicker">Date:</label>
+ <br>
+ <input type="text" id="datepicker">
+
+ <h2>What is this?</h2>
+
+ <p>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 <a href="https://github.com/dbushell/Pikaday/issues">GitHub issue tracker</a>, thanks!</p>
+
+ <p class="small">Copyright © 2014 <a href="http://dbushell.com/">David Bushell</a> | BSD & MIT license | Example by <a href="https://github.com/rikkert">Ramiro Rikkert</a></p>
+
+ <script src="../pikaday.js"></script>
+ <script>
+
+ var disable = false, picker = new Pikaday({
+ field: document.getElementById('datepicker'),
+ firstDay: 1,
+ minDate: new Date(2000, 0, 1),
+ maxDate: new Date(2020, 12, 31),
+ yearRange: [2000,2020],
+
+ showDaysInNextAndPreviousMonths: true,
+ enableSelectionDaysInNextAndPreviousMonths: true
+ });
+
+ </script>
+</body>
+</html>
\ No newline at end of file
diff --git a/examples/diableDayFn.html b/examples/diableDayFn.html
new file mode 100755
index 0000000..81b66c2
--- /dev/null
+++ b/examples/diableDayFn.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
+ <title>Pikaday - disableDayFn example</title>
+ <meta name="author" content="Ramiro Rikkert">
+ <link rel="stylesheet" href="../css/pikaday.css">
+ <link rel="stylesheet" href="../css/site.css">
+</head>
+<body>
+ <a href="https://github.com/dbushell/Pikaday"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"></a>
+
+ <h1>Pikaday - disableDayFn example</h1>
+
+ <p class="large">A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.</p>
+
+ <label for="datepicker">Date:</label>
+ <br>
+ <input type="text" id="datepicker">
+
+ <h2>What is this?</h2>
+
+ <p>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 <a href="https://github.com/dbushell/Pikaday/issues">GitHub issue tracker</a>, thanks!</p>
+
+ <p class="small">Copyright © 2014 <a href="http://dbushell.com/">David Bushell</a> | BSD & MIT license | Example by <a href="https://github.com/rikkert">Ramiro Rikkert</a></p>
+
+ <script src="../pikaday.js"></script>
+ <script>
+
+ var disable = false, picker = new Pikaday({
+ field: document.getElementById('datepicker'),
+ firstDay: 1,
+ minDate: new Date(2000, 0, 1),
+ maxDate: new Date(2020, 12, 31),
+ yearRange: [2000,2020],
+
+ disableDayFn: function(theDate) {
+ return disable = !disable;
+ }
+ });
+
+ </script>
+</body>
+</html>
\ No newline at end of file
diff --git a/examples/jquery-amd.html b/examples/jquery-amd.html
new file mode 100755
index 0000000..136bbf3
--- /dev/null
+++ b/examples/jquery-amd.html
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
+ <title>Pikaday - jQuery + AMD example</title>
+ <meta name="author" content="Ramiro Rikkert">
+ <link rel="stylesheet" href="../css/pikaday.css">
+ <link rel="stylesheet" href="../css/site.css">
+</head>
+<body>
+ <a href="https://github.com/dbushell/Pikaday"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"></a>
+
+ <h1>Pikaday - jQuery + AMD example</h1>
+
+ <p class="large">A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.</p>
+
+ <label for="datepicker">Date:</label>
+ <br>
+ <input type="text" id="datepicker">
+
+ <h2>What is this?</h2>
+
+ <p>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 <a href="https://github.com/dbushell/Pikaday/issues">GitHub issue tracker</a>, thanks!</p>
+
+ <p class="small">Copyright © 2014 <a href="http://dbushell.com/">David Bushell</a> | BSD & MIT license | Example by <a href="https://github.com/rikkert">Ramiro Rikkert</a></p>
+
+
+ <script src="//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.js"></script>
+ <script>
+
+ require.config({
+ baseUrl: '../',
+ // To get timely, correct error triggers in IE, force a define/shim exports check.
+ enforceDefine: true,
+ paths: {
+ jquery: '//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min'
+ }
+ });
+ require(['jquery', 'plugins/pikaday.jquery'], function($)
+ {
+ var $datepicker = $('#datepicker').pikaday({
+ firstDay: 1,
+ minDate: new Date(2000, 0, 1),
+ maxDate: new Date(2020, 12, 31),
+ yearRange: [2000,2020]
+ });
+ // chain a few methods for the first datepicker, jQuery style!
+ $datepicker.pikaday('show').pikaday('nextMonth');
+ });
+
+ </script>
+</body>
+</html>
\ No newline at end of file
diff --git a/examples/jquery.html b/examples/jquery.html
new file mode 100755
index 0000000..33612dd
--- /dev/null
+++ b/examples/jquery.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
+ <title>Pikaday - jQuery example</title>
+ <meta name="author" content="Ramiro Rikkert">
+ <link rel="stylesheet" href="../css/pikaday.css">
+ <link rel="stylesheet" href="../css/site.css">
+</head>
+<body>
+ <a href="https://github.com/dbushell/Pikaday"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"></a>
+
+ <h1>Pikaday - jQuery example</h1>
+
+ <p class="large">A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.</p>
+
+ <label for="datepicker">Date:</label>
+ <br>
+ <input type="text" id="datepicker">
+
+ <h2>What is this?</h2>
+
+ <p>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 <a href="https://github.com/dbushell/Pikaday/issues">GitHub issue tracker</a>, thanks!</p>
+
+ <p class="small">Copyright © 2014 <a href="http://dbushell.com/">David Bushell</a> | BSD & MIT license | Example by <a href="https://github.com/rikkert">Ramiro Rikkert</a></p>
+
+
+ <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
+ <!-- First load pikaday.js and then the jQuery plugin -->
+ <script src="../pikaday.js"></script>
+ <script src="../plugins/pikaday.jquery.js"></script>
+ <script>
+
+ var $datepicker = $('#datepicker').pikaday({
+ firstDay: 1,
+ minDate: new Date(2000, 0, 1),
+ maxDate: new Date(2020, 12, 31),
+ yearRange: [2000,2020]
+ });
+ // chain a few methods for the first datepicker, jQuery style!
+ $datepicker.pikaday('show').pikaday('nextMonth');
+
+ </script>
+</body>
+</html>
\ No newline at end of file
diff --git a/examples/moment.html b/examples/moment.html
new file mode 100755
index 0000000..3977724
--- /dev/null
+++ b/examples/moment.html
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
+ <title>Pikaday - moment.js example</title>
+ <meta name="author" content="Ramiro Rikkert">
+ <link rel="stylesheet" href="../css/pikaday.css">
+ <link rel="stylesheet" href="../css/site.css">
+</head>
+<body>
+ <a href="https://github.com/dbushell/Pikaday"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"></a>
+
+ <h1>Pikaday + moment.js</h1>
+
+ <p class="large">A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.</p>
+
+ <label for="datepicker">Date:</label>
+ <br>
+ <input type="text" id="datepicker">
+ <div id="selected"></div>
+ <br>
+
+ <h2>What is this?</h2>
+
+ <p>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 <a href="https://github.com/dbushell/Pikaday/issues">GitHub issue tracker</a>, thanks!</p>
+
+ <p class="small">Copyright © 2014 <a href="http://dbushell.com/">David Bushell</a> | BSD & MIT license | Example by <a href="https://github.com/rikkert">Ramiro Rikkert</a></p>
+
+
+ <script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.5.1/moment.min.js"></script>
+ <script src="../pikaday.js"></script>
+ <script>
+
+ // You can get and set dates with moment objects
+ var picker = new Pikaday(
+ {
+ field: document.getElementById('datepicker'),
+ firstDay: 1,
+ minDate: new Date(2000, 0, 1),
+ maxDate: new Date(2020, 12, 31),
+ yearRange: [2000,2020],
+ onSelect: function() {
+ var date = document.createTextNode(this.getMoment().format('Do MMMM YYYY') + ' ');
+ document.getElementById('selected').appendChild(date);
+ }
+ });
+
+ picker.setMoment(moment().dayOfYear(366));
+
+ </script>
+</body>
+</html>
\ No newline at end of file
diff --git a/examples/pick-whole-week.html b/examples/pick-whole-week.html
new file mode 100644
index 0000000..901d687
--- /dev/null
+++ b/examples/pick-whole-week.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
+ <title>Pikaday - pickWholeWeek example</title>
+ <meta name="author" content="Lei Zhao">
+ <link rel="stylesheet" href="../css/pikaday.css">
+ <link rel="stylesheet" href="../css/site.css">
+</head>
+<body>
+ <a href="https://github.com/dbushell/Pikaday"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"></a>
+
+ <h1>Pikaday - pickWholeWeek example</h1>
+
+ <p class="large">A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.</p>
+
+ <label for="datepicker">Date:</label>
+ <br>
+ <input type="text" id="datepicker">
+
+ <h2>What is this?</h2>
+
+ <p>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 <a href="https://github.com/dbushell/Pikaday/issues">GitHub issue tracker</a>, thanks!</p>
+
+ <p class="small">Copyright © 2014 <a href="http://dbushell.com/">David Bushell</a> | BSD & MIT license | Example by <a href="https://github.com/leizhao4">Lei Zhao</a></p>
+
+ <script src="../pikaday.js"></script>
+ <script>
+
+ var field = document.getElementById('datepicker');
+ var picker = new Pikaday({
+ field: field,
+ pickWholeWeek: true,
+ onSelect: function (date) {
+ var sundayDate = date.getDate() - date.getDay();
+ var sunday = new Date(date.setDate(sundayDate));
+ var saturday = new Date(date.setDate(sundayDate + 6));
+ field.value = sunday.toLocaleDateString() + ' - ' + saturday.toLocaleDateString();
+ }
+ });
+
+ </script>
+</body>
+</html>
\ No newline at end of file
diff --git a/examples/positions.html b/examples/positions.html
new file mode 100755
index 0000000..ad77322
--- /dev/null
+++ b/examples/positions.html
@@ -0,0 +1,106 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
+ <title>Pikaday alignment example</title>
+ <meta name="author" content="Maxime Thirouin">
+ <link rel="stylesheet" href="../css/pikaday.css">
+ <link rel="stylesheet" href="../css/site.css">
+</head>
+<body>
+ <a href="https://github.com/dbushell/Pikaday"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"></a>
+
+ <h1>Pikaday alignement example</h1>
+
+ <p class="large">A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.</p>
+
+ <label for="datepicker">Dates:</label>
+
+ <br />
+ <input type="text" id="datepicker" value="Default (bottom left)">
+ <br />
+ <input type="text" id="datepicker-topleft" value="Top left (waat?)"> <b>not really (too close from top)</b>
+ <br />
+ <input type="text" id="datepicker-topleft-forreal" value="Top left"> for real this time (same code as above)
+ <br />
+ <input type="text" id="datepicker-topright" value="Top right (waat?)"> <b>not really (too close from right)</b>
+ <br />
+ Here is the top right position with content before (no automatic adjustment used, same code as above) <input type="text" id="datepicker-topright-forreal" value="Top right">
+ <br />
+ <input type="text" id="datepicker-bottomright" value="Bottom right (waat?)">
+ <br />
+ <input type="text" id="datepicker-bottomright-forced" value="forced to position outside viewport">
+ <br />
+ Here is the bottom right position with content before (no automatic adjustment used, , same code as above) <input type="text" id="datepicker-bottomright-forreal" value="Bottom right">
+
+ <p><i>Also, take a look to the bottom right of this page to see an example with position automatically adjusted.</i></p>
+ <input type="text" id="datepicker-auto" style="position: absolute; bottom: 0; right: 0;" value="Automatic position">
+
+ <h2>What is this?</h2>
+
+ <p>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 <a href="https://github.com/dbushell/Pikaday/issues">GitHub issue tracker</a>, thanks!</p>
+
+ <p class="small">Copyright © 2014 <a href="http://dbushell.com/">David Bushell</a> | BSD & MIT license | Example by <a href="https://github.com/MoOx">MoOx</a></p>
+
+
+ <script src="../pikaday.js"></script>
+ <script>
+
+ // default: bottom left
+ new Pikaday(
+ {
+ field: document.getElementById('datepicker')
+ });
+
+ new Pikaday(
+ {
+ field: document.getElementById('datepicker-topleft'),
+ position: 'top left'
+ });
+
+ new Pikaday(
+ {
+ field: document.getElementById('datepicker-topleft-forreal'),
+ position: 'top left'
+ });
+
+ new Pikaday(
+ {
+ field: document.getElementById('datepicker-topright'),
+ position: 'top right'
+ });
+
+ new Pikaday(
+ {
+ field: document.getElementById('datepicker-topright-forreal'),
+ position: 'top right'
+ });
+
+ new Pikaday(
+ {
+ field: document.getElementById('datepicker-bottomright'),
+ position: 'bottom right'
+ });
+
+ new Pikaday(
+ {
+ field: document.getElementById('datepicker-bottomright-forced'),
+ position: 'bottom right',
+ reposition: false
+ });
+
+ new Pikaday(
+ {
+ field: document.getElementById('datepicker-bottomright-forreal'),
+ position: 'bottom right'
+ });
+
+ new Pikaday(
+ {
+ field: document.getElementById('datepicker-auto'),
+ });
+
+ </script>
+</body>
+</html>
diff --git a/examples/theme.html b/examples/theme.html
new file mode 100755
index 0000000..3a2b109
--- /dev/null
+++ b/examples/theme.html
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
+ <title>Pikaday - Theme example</title>
+ <meta name="author" content="Stuart McFarlane">
+ <link rel="stylesheet" href="../css/pikaday.css">
+ <link rel="stylesheet" href="../css/theme.css">
+ <link rel="stylesheet" href="../css/triangle.css">
+ <link rel="stylesheet" href="../css/site.css">
+</head>
+<body>
+ <a href="https://github.com/dbushell/Pikaday"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"></a>
+
+ <h1>Pikaday - Theme example</h1>
+
+ <p class="large">A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.</p>
+
+ <label for="datepicker">Date:</label>
+ <br>
+ No theme <input type="text" id="datepicker">
+ <br>
+ Custom theme <input type="text" id="datepicker-theme">
+ <br>
+ Dropdowns w/ triangles <input type="text" id="datepicker-triangle">
+
+ <h2>What is this?</h2>
+
+ <p>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 <a href="https://github.com/dbushell/Pikaday/issues">GitHub issue tracker</a>, thanks!</p>
+
+ <p class="small">Copyright © 2014 <a href="http://dbushell.com/">David Bushell</a> | BSD & MIT license | Example by <a href="https://github.com/rikkert">Ramiro Rikkert</a></p>
+
+ <script src="../pikaday.js"></script>
+ <script>
+
+ // You can use different themes with the `theme` option
+ var pickerDefault = new Pikaday(
+ {
+ field: document.getElementById('datepicker'),
+ });
+
+ var pickerTheme = new Pikaday(
+ {
+ field: document.getElementById('datepicker-theme'),
+ theme: 'dark-theme'
+ });
+
+ var pickerTriangle = new Pikaday(
+ {
+ field: document.getElementById('datepicker-triangle'),
+ theme: 'triangle-theme'
+ });
+
+ </script>
+</body>
+</html>
diff --git a/examples/trigger.html b/examples/trigger.html
new file mode 100755
index 0000000..b2c6208
--- /dev/null
+++ b/examples/trigger.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
+ <title>Pikaday - custom trigger element example</title>
+ <meta name="author" content="Ramiro Rikkert">
+ <link rel="stylesheet" href="../css/pikaday.css">
+ <link rel="stylesheet" href="../css/site.css">
+</head>
+<body>
+ <a href="https://github.com/dbushell/Pikaday"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"></a>
+
+ <h1>Pikaday - custom trigger example</h1>
+
+ <p class="large">A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.</p>
+
+ <label for="datepicker">Date:</label>
+ <br>
+ <input type="text" disabled id="datepicker">
+ <br>
+ <button id="datepicker-button">Choose Date</button>
+
+
+ <h2>What is this?</h2>
+
+ <p>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 <a href="https://github.com/dbushell/Pikaday/issues">GitHub issue tracker</a>, thanks!</p>
+
+ <p class="small">Copyright © 2014 <a href="http://dbushell.com/">David Bushell</a> | BSD & MIT license | Example by <a href="https://github.com/rikkert">Ramiro Rikkert</a></p>
+
+
+ <script src="../pikaday.js"></script>
+ <script>
+
+ new Pikaday(
+ {
+ field: document.getElementById('datepicker'),
+ trigger: document.getElementById('datepicker-button'),
+ minDate: new Date(2000, 0, 1),
+ maxDate: new Date(2020, 12, 31),
+ yearRange: [2010,2020]
+ });
+
+ </script>
+</body>
+</html>
\ No newline at end of file
diff --git a/examples/weeknumbers.html b/examples/weeknumbers.html
new file mode 100755
index 0000000..595f5ac
--- /dev/null
+++ b/examples/weeknumbers.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
+ <title>Pikaday - weeknumbers example</title>
+ <meta name="author" content="Maxime Thirouin">
+ <link rel="stylesheet" href="../css/pikaday.css">
+ <link rel="stylesheet" href="../css/site.css">
+</head>
+<body>
+ <a href="https://github.com/dbushell/Pikaday"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"></a>
+
+ <h1>Pikaday - showing weeknumbers</h1>
+
+ <p class="large">A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.</p>
+
+ <label for="datepicker">Date:</label>
+ <input type="text" id="datepicker-week-numbers">
+
+ <h2>What is this?</h2>
+
+ <p>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 <a href="https://github.com/dbushell/Pikaday/issues">GitHub issue tracker</a>, thanks!</p>
+
+ <p class="small">Copyright © 2014 <a href="http://dbushell.com/">David Bushell</a> | BSD & MIT license | Example by <a href="https://github.com/rikkert">Ramiro Rikkert</a></p>
+
+ <script src="../pikaday.js"></script>
+ <script>
+
+ var pickerWeekNums = new Pikaday({
+ showWeekNumber: true,
+ field: document.getElementById('datepicker-week-numbers'),
+ firstDay: 1,
+ minDate: new Date(2000, 0, 1),
+ maxDate: new Date(2020, 12, 31),
+ yearRange: [2000, 2020]
+ });
+
+ </script>
+</body>
+</html>
diff --git a/index.html b/index.html
new file mode 100755
index 0000000..2e37c94
--- /dev/null
+++ b/index.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
+ <title>Pikaday</title>
+ <meta name="author" content="David Bushell">
+ <link rel="stylesheet" href="css/pikaday.css">
+ <link rel="stylesheet" href="css/site.css">
+</head>
+<body>
+ <h1>Pikaday</h1>
+
+ <p class="large">A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS.</p>
+
+ <p><a href="https://github.com/dbushell/Pikaday"><strong>Pikaday source on GitHub</strong></a></p>
+
+ <label for="datepicker">Date:</label>
+ <br>
+ <input type="text" id="datepicker">
+
+ <h2>What is this?</h2>
+
+ <p>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 <a href="https://github.com/dbushell/Pikaday/issues">GitHub issue tracker</a>, thanks!</p>
+
+ <p class="small">Copyright © 2014 <a href="http://dbushell.com/">David Bushell</a> | BSD & MIT license</p>
+
+
+ <script src="pikaday.js"></script>
+ <script>
+
+ var picker = new Pikaday(
+ {
+ field: document.getElementById('datepicker'),
+ firstDay: 1,
+ minDate: new Date(),
+ maxDate: new Date(2020, 12, 31),
+ yearRange: [2000,2020]
+ });
+
+ </script>
+</body>
+</html>
diff --git a/package.json b/package.json
new file mode 100755
index 0000000..208f1c5
--- /dev/null
+++ b/package.json
@@ -0,0 +1,43 @@
+{
+ "name": "pikaday",
+ "version": "1.7.0",
+ "description": "A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS",
+ "keywords": [
+ "datepicker",
+ "calendar",
+ "date"
+ ],
+ "homepage": "http://dbushell.github.io/Pikaday/",
+ "bugs": "https://github.com/dbushell/Pikaday/issues",
+ "license": "(0BSD OR MIT)",
+ "main": "pikaday.js",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/dbushell/Pikaday.git"
+ },
+ "optionalDependencies": {
+ "moment": "2.x"
+ },
+ "devDependencies": {
+ "mocha": "~1.18.2",
+ "expect.js": "^0.3.1",
+ "testling": "^1.7",
+ "jshint": "^2.9"
+ },
+ "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"
+ }
+}
diff --git a/pikaday.js b/pikaday.js
new file mode 100755
index 0000000..a13bf97
--- /dev/null
+++ b/pikaday.js
@@ -0,0 +1,1245 @@
+/*!
+ * Pikaday
+ *
+ * Copyright © 2014 David Bushell | BSD & MIT license | https://github.com/dbushell/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,
+
+ // 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 '<td class="is-empty"></td>';
+ }
+ }
+ 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 '<td data-day="' + opts.day + '" class="' + arr.join(' ') + '" aria-selected="' + ariaSelected + '">' +
+ '<button class="pika-button pika-day" type="button" ' +
+ 'data-pika-year="' + opts.year + '" data-pika-month="' + opts.month + '" data-pika-day="' + opts.day + '">' +
+ opts.day +
+ '</button>' +
+ '</td>';
+ },
+
+ 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 '<td class="pika-week">' + weekNum + '</td>';
+ },
+
+ renderRow = function(days, isRTL, pickWholeWeek, isRowSelected)
+ {
+ return '<tr class="pika-row' + (pickWholeWeek ? ' pick-whole-week' : '') + (isRowSelected ? ' is-selected' : '') + '">' + (isRTL ? days.reverse() : days).join('') + '</tr>';
+ },
+
+ renderBody = function(rows)
+ {
+ return '<tbody>' + rows.join('') + '</tbody>';
+ },
+
+ renderHead = function(opts)
+ {
+ var i, arr = [];
+ if (opts.showWeekNumber) {
+ arr.push('<th></th>');
+ }
+ for (i = 0; i < 7; i++) {
+ arr.push('<th scope="col"><abbr title="' + renderDayName(opts, i) + '">' + renderDayName(opts, i, true) + '</abbr></th>');
+ }
+ return '<thead><tr>' + (opts.isRTL ? arr.reverse() : arr).join('') + '</tr></thead>';
+ },
+
+ renderTitle = function(instance, c, year, month, refYear, randId)
+ {
+ var i, j, arr,
+ opts = instance._o,
+ isMinYear = year === opts.minYear,
+ isMaxYear = year === opts.maxYear,
+ html = '<div id="' + randId + '" class="pika-title" role="heading" aria-live="assertive">',
+ monthHtml,
+ yearHtml,
+ prev = true,
+ next = true;
+
+ for (arr = [], i = 0; i < 12; i++) {
+ arr.push('<option value="' + (year === refYear ? i - c : 12 + i - c) + '"' +
+ (i === month ? ' selected="selected"': '') +
+ ((isMinYear && i < opts.minMonth) || (isMaxYear && i > opts.maxMonth) ? 'disabled="disabled"' : '') + '>' +
+ opts.i18n.months[i] + '</option>');
+ }
+
+ monthHtml = '<div class="pika-label">' + opts.i18n.months[month] + '<select class="pika-select pika-select-month" tabindex="-1">' + arr.join('') + '</select></div>';
+
+ 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('<option value="' + i + '"' + (i === year ? ' selected="selected"': '') + '>' + (i) + '</option>');
+ }
+ }
+ yearHtml = '<div class="pika-label">' + year + opts.yearSuffix + '<select class="pika-select pika-select-year" tabindex="-1">' + arr.join('') + '</select></div>';
+
+ 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 += '<button class="pika-prev' + (prev ? '' : ' is-disabled') + '" type="button">' + opts.i18n.previousMonth + '</button>';
+ }
+ if (c === (instance._o.numberOfMonths - 1) ) {
+ html += '<button class="pika-next' + (next ? '' : ' is-disabled') + '" type="button">' + opts.i18n.nextMonth + '</button>';
+ }
+
+ return html += '</div>';
+ },
+
+ renderTable = function(opts, data, randId)
+ {
+ return '<table cellpadding="0" cellspacing="0" class="pika-table" role="grid" aria-labelledby="' + randId + '">' + renderHead(opts) + renderBody(data) + '</table>';
+ },
+
+
+ /**
+ * 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 += '<div class="pika-lendar">' + 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) + '</div>';
+ }
+
+ 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', 'Use the arrow keys to pick a date');
+ }
+ },
+
+ adjustPosition: function()
+ {
+ var field, pEl, width, height, viewportWidth, viewportHeight, scrollTop, left, top, clientRect;
+
+ 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;
+
+ 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;
+ }
+ if ((this._o.reposition && top + height > viewportHeight + scrollTop) ||
+ (
+ this._o.position.indexOf('top') > -1 &&
+ top - height - field.offsetHeight > 0
+ )
+ ) {
+ top = top - height - field.offsetHeight;
+ }
+
+ this.el.style.left = left + 'px';
+ this.el.style.top = top + 'px';
+ },
+
+ /**
+ * 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;
+}));
diff --git a/plugins/pikaday.jquery.js b/plugins/pikaday.jquery.js
new file mode 100755
index 0000000..3ef70ff
--- /dev/null
+++ b/plugins/pikaday.jquery.js
@@ -0,0 +1,56 @@
+/*!
+ * Pikaday jQuery plugin.
+ *
+ * Copyright © 2013 David Bushell | BSD & MIT license | https://github.com/dbushell/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');
+ }
+ }
+ }
+ });
+ };
+
+}));
diff --git a/scss/pikaday.scss b/scss/pikaday.scss
new file mode 100755
index 0000000..f129aad
--- /dev/null
+++ b/scss/pikaday.scss
@@ -0,0 +1,255 @@
+/*!
+ * Pikaday
+ * Copyright © 2014 David Bushell | BSD & MIT license | http://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;
+}
\ No newline at end of file
diff --git a/tests/methods.js b/tests/methods.js
new file mode 100755
index 0000000..731fada
--- /dev/null
+++ b/tests/methods.js
@@ -0,0 +1,130 @@
+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);
+ });
+ });
+});
diff --git a/tests/module.js b/tests/module.js
new file mode 100755
index 0000000..f353dd2
--- /dev/null
+++ b/tests/module.js
@@ -0,0 +1,24 @@
+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();
+ });
+});
\ No newline at end of file
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-pikaday.git
More information about the Pkg-javascript-commits
mailing list