Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Conflicts:
	pikaday.js
  • Loading branch information
owenmead committed Feb 25, 2015
2 parents 8875e0f + f2c8d56 commit fda071d
Show file tree
Hide file tree
Showing 10 changed files with 360 additions and 10 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 1.4.0 - TBA

- Add theme class support, see #260
- Fix on iOS, see #101
- Fix #249

## 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"
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Pikaday has many useful options:
* `showMonthAfterYear` render the month after year in the title (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
* `theme` define a classname that can be used as a hook for styling different themes, see [theme example][] (default `null`)
* `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
Expand Down Expand Up @@ -319,3 +320,4 @@ Copyright © 2014 David Bushell | BSD & MIT license
[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"
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pikaday",
"version": "1.3.0",
"version": "1.3.2",
"description": "A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS",
"keywords": [
"datepicker",
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pikaday",
"repo": "dbushell/Pikaday",
"description": "A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS",
"version": "1.3.0",
"version": "1.3.2",
"keywords": [
"datepicker",
"calendar",
Expand Down
56 changes: 56 additions & 0 deletions css/theme.css
Original file line number Diff line number Diff line change
@@ -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;
}
50 changes: 50 additions & 0 deletions examples/theme.html
Original file line number Diff line number Diff line change
@@ -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 - 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/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">

<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 &amp; 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 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'
});

</script>
</body>
</html>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pikaday",
"version": "1.3.0",
"version": "1.3.2",
"description": "A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS",
"keywords": [
"datepicker",
Expand Down
19 changes: 13 additions & 6 deletions pikaday.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@
weekdaysShort : ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']
},

// Theme Classname
theme: null,

// callback function
onSelect: null,
onOpen: null,
Expand Down Expand Up @@ -402,7 +405,8 @@
return;
}

if (!(hasClass(target, 'is-disabled') || hasClass(target.parentElement, 'is-disabled'))) {
e.preventDefault();
if (!hasClass(target, 'is-disabled')) {
if (hasClass(target, 'pika-button') && !hasClass(target, 'is-empty')) {
self.setDate(new Date(target.getAttribute('data-pika-year'), target.getAttribute('data-pika-month'), target.getAttribute('data-pika-day')));
if (opts.bound) {
Expand Down Expand Up @@ -524,9 +528,9 @@
};

self.el = document.createElement('div');
self.el.className = 'pika-single' + (opts.isRTL ? ' is-rtl' : '');
self.el.className = 'pika-single' + (opts.isRTL ? ' is-rtl' : '') + (opts.theme ? ' ' + opts.theme : '');

addEvent(self.el, 'mousedown', self._onMouseDown, true);
addEvent(self.el, 'ontouchend' in document ? 'ontouchend' : 'mousedown', self._onMouseDown, true);
addEvent(self.el, 'change', self._onChange);

if (opts.field) {
Expand Down Expand Up @@ -594,6 +598,8 @@

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;
Expand All @@ -615,9 +621,7 @@
opts.maxDate = opts.minDate = false;
}
if (opts.minDate) {
setToStartOfDay(opts.minDate);
opts.minYear = opts.minDate.getFullYear();
opts.minMonth = opts.minDate.getMonth();
this.setMinDate(opts.minDate)
}
if (opts.maxDate) {
setToStartOfDay(opts.maxDate);
Expand Down Expand Up @@ -806,7 +810,10 @@
*/
setMinDate: function(value)
{
setToStartOfDay(value);
this._o.minDate = value;
this._o.minYear = value.getFullYear();
this._o.minMonth = value.getMonth();
},

/**
Expand Down
Loading

0 comments on commit fda071d

Please sign in to comment.