Giter Club home page Giter Club logo

pikaday's Introduction

Pikaday

NPM version License Downloads

A refreshing JavaScript Datepicker

  • Lightweight (less than 5kb minified and gzipped)
  • No dependencies (but plays well with Moment.js)
  • Modular CSS classes for easy styling

Try Pikaday Demo →

Pikaday 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. Also see the changelog

Installation

You can install Pikaday as an NPM package:

npm install pikaday

Or link directly to the CDN:

<script src="https://cdn.jsdelivr.net/npm/pikaday/pikaday.js"></script>

Styles

You will also need to include Pikaday CSS file. This step depends on how Pikaday was installed. Either import from NPM:

@import './node_modules/pikaday/css/pikaday.css';

Or link to the CDN:

<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/pikaday/css/pikaday.css">

Usage

Pikaday can be bound to an input field:

<input type="text" id="datepicker">

Add the JavaScript to the end of your document:

<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:

var picker = new Pikaday({ field: $('#datepicker')[0] });

If the Pikaday instance is not bound to a field you can append the element anywhere:

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 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.

<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:

parse(dateString, format = 'YYYY-MM-DD')

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], 10) - 1;
        const year = parseInt(parts[2], 10);
        return new Date(year, month, day);
    }
});

Configuration

As the examples demonstrate above Pikaday has many useful options:

  • field bind the datepicker to a form field
  • trigger use a different element to trigger opening the datepicker, see trigger example (default to field)
  • bound automatically show/hide the datepicker on field focus (default true if field is set)
  • ariaLabel data-attribute on the input field with an aria assistance text (only applied when bound is set)
  • position preferred position of the datepicker relative to the form field, e.g.: top right, bottom right Note: automatic adjustment may occur to avoid datepicker from being displayed outside the viewport, see positions example (default to 'bottom left')
  • reposition can be set to false to not reposition datepicker within the viewport, forcing it to take the configured position (default: true)
  • container DOM node to render calendar into, see container example (default: undefined)
  • format the default output format for .toString() and field value (requires Moment.js for custom formatting)
  • formatStrict the default flag for moment's strict date parsing (requires Moment.js 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 Boolean (true/false). make the defaultDate the initial selected value
  • firstDay first day of the week (0: Sunday, 1: Monday, etc)
  • minDate the minimum/earliest date that can be selected (this should be a native Date object - e.g. new Date() or moment().toDate())
  • maxDate the maximum/latest date that can be selected (this should be a native Date object - e.g. new Date() or moment().toDate())
  • disableWeekends disallow selection of Saturdays or Sundays
  • disableDayFn callback function that gets passed a Date object for each day in view. Should return true to disable selection of that day.
  • yearRange number of years either side (e.g. 10) or array of upper/lower range (e.g. [1900,2015])
  • showWeekNumber show the ISO week number at the head of the row (default false)
  • pickWholeWeek select a whole week instead of a day (default false)
  • isRTL reverse the calendar for right-to-left languages
  • i18n language defaults for month and weekday names (see internationalization below)
  • yearSuffix additional text to append to the year in the title
  • showMonthAfterYear render the month after year in the title (default false)
  • showDaysInNextAndPreviousMonths render days of the calendar grid that fall in the next or previous months (default: false)
  • enableSelectionDaysInNextAndPreviousMonths allows user to select date that is in the next or previous months (default: false)
  • numberOfMonths number of visible calendars
  • mainCalendar when numberOfMonths is used, this will help you to choose where the main calendar will be (default left, can be set to right). Only used for the first display or when a selected date is not already visible
  • events array of dates that you would like to differentiate from regular days (e.g. ['Sat Jun 28 2017', 'Sun Jun 29 2017', 'Tue Jul 01 2017',])
  • theme define a classname that can be used as a hook for styling different themes, see theme example (default null)
  • blurFieldOnSelect defines if the field is blurred when a date is selected (default true)
  • onSelect callback function for when a date is selected
  • onOpen callback function for when the picker becomes visible
  • onClose callback function for when the picker is hidden
  • onDraw callback function for when the picker draws a new month
  • keyboardInput enable keyboard input support (default true)

Styling

If the reposition configuration-option is enabled (default), Pikaday will apply CSS-classes to the datepicker according to how it is positioned:

  • top-aligned
  • left-aligned
  • right-aligned
  • bottom-aligned

Note that the DOM element at any time will typically have 2 CSS-classes (eg. top-aligned right-aligned etc).

jQuery Plugin

The normal version of Pikaday does not require jQuery, however there is a jQuery plugin if that floats your boat (see plugins/pikaday.jquery.js in the repository). This version requires jQuery, naturally, and can be used like other plugins: See the jQuery example for a full version.

<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, 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.

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.

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.

var pikaday = require('pikaday');

When you bundle all your required modules with Browserify and you don't use Moment.js 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.

Methods

You can control the date picker after creation:

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 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 section.

If neither moment object exists nor toString function is provided, JavaScript's default .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 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 object (see setDate for details).

Clear and reset date

picker.clear()

Will clear and reset the input where picker is bound to.

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).

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:

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 and #18. These reside in their own fork.

You can use the work @owenmead did most recently at owenmead/Pikaday A more simple time selection approach done by @xeeali at xeeali/Pikaday is based on version 1.2.0. Also @stas has a fork stas/Pikaday, but is now quite old

Browser Compatibility

  • IE 7+
  • Chrome 8+
  • Firefox 3.5+
  • Safari 3+
  • Opera 10.6+

browser compatibility


Authors

Thanks to @shoogledesigns for the name.

Copyright © 2014 David Bushell | BSD & MIT license

pikaday's People

Contributors

bquorning avatar dbushell avatar dylanfm avatar eadmundo avatar elwayman02 avatar entonbiba avatar everdimension avatar jackmoore avatar jeroenbourgois avatar leizhao4 avatar mattrobenolt avatar moox avatar nathancahill avatar noyainrain avatar owenmead avatar paulmillr avatar pts-michaelvera avatar qchouleur avatar radiac avatar rikkert avatar robd avatar robdel12 avatar rubenswieringa avatar stah avatar stanton avatar stephanschubert avatar stuart-bennett avatar stuartmcfarlane avatar wojciechczerniak avatar zestrid3r avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pikaday's Issues

date format does not appear to be working

var pickerOptions = {
    field: document.getElementById('#somepicker'),
    format: 'YYYY-MM-DD'
};

var picker = new Pikaday(pickerOptions);

The format you see defined above, never works - and Pikaday doesn't complain, either. I've tried all sorts of various formats with zero success. What am I doing wrong, if anything?

jQuery plugin does not display when using default options

// Does not display
$('.my_field').pikaday();

// Displays successfully
$('.my_field').pikaday({ format: 'YYYY-MM-DD' });

The following lines (within the jQuery wrapper) prevent Pikaday from loading:

if (!args || !args.length) {
    return this;
}

onclick = "datepicker.show()"

Hello,

I have an issue with the following code. The code allows you to select a date via datepicker and the day of month is displayed in a text field.

Furthermore, you can enter a day into the text field, and the datepicker value gets adjusted via onkeyup="ApplyFormToDatePicker();" command.

The problem: I would like to make the date picker visible once a user clicks into the day text field (using "onclick").
That does not work right now. Instead, the following code uses "onmousemove" instead, which is not optimal for my purposes.

Is there a way to make this code work with onclick? It seems that the date picker is hidden instantly after the onclick event.

Thanks.

<link href="pikaday.css" rel="stylesheet" type="text/css" />

// I would like to get this code running with onclick instead of onmousemove
Day: <input type="text" id="day_field" onmousemove="picker.show()" onkeyup="ApplyFormToDatePicker();">

<img src="calendar.gif" width="21" height="24" id="datepicker">


<script src="pikaday.js"></script>

<script>

    var day_field = document.getElementById('day_field');

    var picker = new Pikaday({
      field: document.getElementById('datepicker'),
      onSelect: function() {
        day_field.value = picker.getDate().getDate();
      },
    });

    function ApplyFormToDatePicker() {
      picker.setDate('2012-11-' + day_field.value);
    };

</script>

IE9 showing default date as 0000-01-01 when using moment.js

I am using Pikaday in my Rails app and have attempted to convert the syntax to coffeescript and use Moment.js as well. I just realized that IE9 on Windows 7 appears to default to a) showing 0000-01-01 in my date field before any click event and b) when I then click on the date field, the Date is year 0.
Chrome, Firefox and Safari don't have this issue and will actually wait till I click on the field to show any date, plus they get the year and month right.

My basic coffescript is as follows:

jQuery -> picker = new Pikaday(field: $("#issue_date")[0])

I just did an experiment and tried using various techniques to get the problem to clear up. Adding this line first $('#issue_date').click (e) -> cleared up the date issue, but I apparently need to click twice before the calendar loads on the page for the first time.

Next, I tried turning off loading of moment.js, and the problem cleared up completely without adding the .click event line.

So then, is there a way I can solve this issue in IE9 without either adding the .click event or disabling moment.js? Any help would be appreciated.


Screen Shot 2013-01-21 at 11 46 56 PM 2


Screen Shot 2013-01-22 at 12 46 51 AM 2

ideas for features

Hi David,
these are the ideas that came to my mind:

  • For mobile: buttons a little bigger and swipe functionality to scroll months
  • An option to stop the manual input of date (users tend to write the strangest things into the input fields)

That's all for the moment,
thanks for your work

minDate Problem with writing something inside the input

I have following configuration

$('.datepicker').pikaday({
    minDate: moment().toDate(),
    format: 'DD.MM.YYYY',
    firstDay: 1,
});

I tested it also with minDate: moment().add('d', 1).toDate() and mindDate: new Date().

minDate is set to today, so only tomorrow is selectable. This works as aspected if i use the datepicker.
Unbenannt-1

As soon as i write something inside the inputfield by hand and press Enter...
Unbenannt-2

the minDate Date was selected!
Unbenannt

This should not be possible
Unbenannt-3

Inclusion within Fuel UX?

The Fuel UX team is looking for a solid date picker to help round out our feature set. Please let me know if you have any thoughts for or against the possibility of your control being included within the Fuel UX library. Thanks for your time!

http://exacttarget.github.com/fuelux

Position inside div with scroll

The date picker is not correctly positioned when the field is inside a div with scroll.
I solved it with getBoundingClientRect function (most browsers support it):

var clientRect = opts.field.getBoundingClientRect();
left = clientRect.left;
top = clientRect.bottom;

You can see here the problem http://jsfiddle.net/mQZWz/1/
Inside the div I have a datepicker field, If you comment the lines 674-676 you'll see the issue (the datepicker position is wrong)

getting field value will reset original settings

Hi there,

I just noticed that:
var picker = new Pikaday({ field: document.getElementById('datepicker') });
will at least overwrite minDate from my first instantiation.

I have not checked whether other values will be overwritten as well but format seems to stay as it is.

I feel like there should be an unobtrusive way to get the current date from a field without changing anything...?!

Thanks though. The picker is very nice

EDIT:
this is how I fix this now:
var picker = new Pikaday({ field: document.getElementById("datepicker"), minDate: moment().subtract({days: 1}).toDate() });

Pikaday problems on last few days of month

Hello, I've got a strange issue that only occurs on the last few days of the month. I use pikaday to update users DOB's and this works perfectly until the last few days of the month and I see unusual behaviour which does not allow me to select certain months. For instance if I have a user with a dob stored as 04/08/1960 and need to change to 04/02/1960, the date picker will go to February but when dates selected will skip forward a month. The fault seems to only occur when selecting months with less than 31 days included.

check if date is valid when moment.js is available

Enter invalid data into the text field ('f' for example).

Click on the text field to open the date picker.

Click outside of the date picker to close it.

Observe: A formatted new Date(0) will be entered into the text field

@@

moment('f', 'YYYY-MM-DD')

=>

Object
_a: Array[7]
_d: Sat Jan 01 0000 00:00:00 GMT+0100 (CET)
_f: "YYYY-MM-DD"
_i: "f"
_isUTC: false
_isValid: false
_l: undefined

FIX for _onInputChange:

date = date && date.isValid() ? date.toDate() : null;

@@

The following line should be modified also:

opts.defaultDate = window.moment(opts.field.value, opts.format).toDate();

Browser Support?

Great project, it was about time someone wrote a decent alternative to the jQuery datepicker.

I'm sure I'm not alone in wondering which browsers you support with this lib. I'd be grateful if you could list it in the readme or something. Thanks!

Invalid argument on date select in IE8

With the following code:

$('li.more a').pikaday({
    minDate: new Date(),
    onSelect: function() {
        return console.log('Broken!');
    }
});

I receive an invalid arguement on line 70, i.e. here:

el.fireEvent('on' + eventName, ev);

Working fine in every other browser I've tested.

Allow setDate to take a moment

I'm using moment.js and keep all dates client side as moments. It would be useful if setDate() could take a moment. I took a quick stab at changing it and added this towards the beginning of the setDate() method:

if (window.moment && window.moment.isMoment(date)){
     date = date.toDate();
}

Is this the right way to go? Or is there another way to accomplish this?

Add unit tests

Mocha unit tests should at least be added for:

  • Plain version
  • AMD version
  • jQuery plugin
  • With moment.js
  • Bugs that have been closed to prevent regressions
  • Every exposed / documented method

Would be great to have them run in testling-ci.

Return Format doesn't seem to work with me...

It's been a few hours i've been trying to figure out how to have 'YYYY-MM-DD' as a return format in my input.
Whatever I try; the result is always similar to this:

  • Fri Jan 04 2013
  • Mon Mar 04 2013

Anyone? Thank you.

I have tried with jQuery and without, the results are always the same.

Automatically adjust datepicker position

The datepicker popup gets cut off when rendered towards the bottom of the window. In these scenarios, it might be nice for the popup to appear above the input field.

Datepicker partially hidden

Format of defaultDate

What's the format of the defaultDate configuration Parameter? I don't find it in the documentation.

jquery plugin does not correctly map return values for methods

I recently noticed that, when using the jquery plugin, any getters in Pikaday are not mapped to return values. For example, let's say you have the following code:

var input = $(".input") // input elements with pikaday already initialized

var dates = input.pikaday("getDate");

dates should be an array of dates returned from Pikaday.getDate();

Instead, dates ends up equalling input; that is, it becomes the DOM element array. This prevents people from using the jquery plugin to extra dates or moments (or use any functionality that has a return value).

Calling pikadate from iframe

Hi, first of all thanks for your script, it's very useful.
My problem is that I'm developing a .NET app and I have to use many iframes as modal dialogs. I have a compressed js file on my main page where I put all the javascript plugins and functions, and I call them from the iframes using parent.myFunction()...

Your script html and events are hardcode attached to window.document, so I'm unable to call using parent.Pikaday(options)

I've added a config option "doc" and I made some minor changes to specify the context in order to attach the calendar to the iframe body. (Basically using this._o.doc instead window.document)

This is the code with the modifications that I made http://jsfiddle.net/J5pxZ/
It would be great if you add this option to the repo.
Thanks!

setMinDate and setMaxDate methods

It would be nice to be able to change the minDate and maxDate fields without initializing the entire picker over again. I think a couple of methods such as setMinDate and set MaxDate would be best.

This would be very useful in creating a range selector.

Can't format datepicker result

Hey, thanks for making this simple and light datepicker!

I'm trying to implement it in a form in Joomla 3, and have tried several different ways to format the date it gives, but no matter what I try, I end up with something like this: "Sat Jun 01 2013".

It looks nice, but it's not in the format required to pass to this external site's page which I can't change.

Any idea on why it won't format?

Attach to multiple inputs?

How do I attach Pikaday to multiple inputs?

E.g. a typical jQuery approach would look something like this:

$('.date-picker').pikaday();

Previous Month button with IE8?

Hi,
I don't know it this is something I am doing wrong but I cannot see the previous month button on IE8 whereas it works fine on Firefox and IE10. Has anyone else seen this problem?

Thanks,
Tony

onchange() not working

onchange event of not working.

I have also tried but not helpful
$(membershipStartDt).change ( function () {
calculateEndDate();
});

Can someone please suggest the solution?

Thanks in Advance.......

Multi and Range selections

Hi David, this plugin is really sweet.

I was wondering if there was a simple way to provide multi or range selections for the picker, or if you are planning to include these in future releases.

This is probably the only this the plugin lacks.

One more quick question: do the callback functions (onClose, ect.) pass the current picker as an argument?

Again, kudos for your great job.

Pick weeks of the year

Hi, is there a posibility to select a week of a year/month instead of a single day?
I would like to get something like a range of days within a month if i click on the link for the number of the week (e.g. startDay=01&endDay=07&month=2)

I would apreciate any help ;-)

field with Pikaday is automatically going backwards by one day everytime record is edited.

I have a field called last_issue on a rails model. If a date exists in the the last_issue field, every time you edit the record, the date appears to be dropping back by one day. Edit a record seven times and your date will be off by a week from where it started.

I am using the following setting for this field:
picker = new Pikaday(field: $("#issue_date")[0])

Any suggestions as to why this is happening?

Release 1.1.0 - AMD Support

Would it be possible to release the 1.1.0 (or next) version of the Pikaday plug-in?

It feels like we need to do the following things:

  • Update changelog
  • Add tag
  • Release gem (I'll do this part)

knockout.js integration

hi,
very nice and small code, is there a way to have knockout integration please ?

thanks in advanced

wrong month shown when setting minDate to a later year

When you set minDate for a date after the currently selected date, the calendar, when shown, should display the month where minDate is. This works if both dates are in the same year, but if the new minDate's year is greater than the selected one, the month shown will be a mix of the selected date's month with the minDate's year.

Example:

selected date: 2013-08-21
minDate: 2014-01-21
month shown: 2014-08

Apparently, modifying 2 if statements from the draw method to be like this solved the problem:

if (this._y < minYear) {
    this._y = minYear;
    this._m = minMonth;
} else if (this._y == minYear && !isNaN(minMonth) && this._m < minMonth) {
   this._m = minMonth;
}
if (this._y > maxYear) {
    this._y = maxYear;
    this._m = maxMonth;
} else if (this._y == maxYear && !isNaN(maxMonth) && this._m > maxMonth) {
    this._m = maxMonth;
}

IE8 <select> opacity

How do you feel about supporting opacity in IE8 w/ "filter"?

.pika-title select {
    /* .... */
    filter: alpha(opacity=0);
    opacity: 0;
}

Please create a new release (for Bower)

Hi there,

I'm loading Pikaday via Bower but this only gives me 1.1.0 when I want 1.2.0 (as defined in bower.json) -- I forked the repo and made a 1.2.0 release which worked via Bower but I'd prefer to come directly to the source!

A new release would be awesome.

thanks

Firefox + colorbox issue

I'm using Colorbox for my lightboxes: http://www.jacklmoore.com/colorbox/

Within the lightbox the month and year select drop down doesn't show. Nothing happens and no js errors. It works just fine in Chrome and Safari.

Anyone has any idea as to why the select menus doesn't show in Firefox?

OS X Mountain Lion with latest browser versions.

Moving Through Months Can Cause Calendar To "Bounce Around"

When moving through months, the calendar will resize itself causing the ui controls to move away from the mouse. This prevents a user from rapidly clicking the "next/prev" months to navigate to the appropriate date.

Scenarios:

  1. Calendar is above the field
    When a month with more weeks to display then the last comes up, the calendar grows vertically, and the navigation controls move a full row above the mouse, breaking the interaction. Navigating again usually shrinks the calendar again breaking it.

  2. Calendar below the field and close to bottom of viewport.
    When a month with more weeks comes up, the calendar is adjusted to be above the field. This jumping greatly breaks the workflow of the user.

Solutions:
A couple solutions we could take.

  1. Always display 6 weeks of dates, with prev/next months as a light grey. This would ensure the calendar is never adjusted
  2. Remove the "move to above field" functionality. By always being below the field it doesn't jump around. This is how jQueryUI date picker as well as Chrome's HTML5 date input widgets work.
  3. Only adjust position when first opening. Works well except for when the calendar is above the field, hitting a larger month causes the input field to be partially covered up.

My suggestion would to go with option (3). The "above and expand" is an edge case. Plus if the user is interacting with the calendar, they most likely won't be interacting with the input field.

I'll see about submitting a patch for this functionality

Block specific dates

Hi,

Is it possible to block specific dates on calendar? For example, I want to allow select this friday, but deny the next friday.

New option: don't close onselect

I'm using pikaday for it's intended purpose but I would also like to use it for selecting a date and then update a list of events. It works fine except pikaday closes on every select.

An option to close on select or not and then supply a way of closing the calendar when done would be nice :) (i don't have the skills to code it myself)

(btw. anyone knows what 'Pikaday' means in danish?)

/anders
denmark

Feature Request: Year Picker

I'm not sure if this functionality already exists but it would be great if there was an optional year arrow (maybe denoted by << and >>) so people could go 12 months at a time instead of 1.

The issue here is if an input field has a wide variety of possible dates going through the arrows could be very cumbersome.

Update maxDate() and Clear options?

Hello,

I'm struggling to achieve the following beaviours.

I want to have maxDate() set as default, but I'd like to override this to null in certain situations.

Is it possible to remove the maxDate option without it being something like maxDate: new Date("200 years from now?").

Also, is it possible the clear the date from the picker? Something like picker.clear()?

Viewport Position Adjustments Breaking When Field's OffsetParent Not Body

When the offsetParent of the field isn't the body tag (when in a relatively positioned element, or a table cell for example), the adjustments to try to make it fit in the viewport cause the calendar to appear almost offscreen.

To reproduce:

  1. Place the input field into a table.
  2. Adjust the window such that the bottom or right side of the calendar will be cut off
  3. Activate the calendar
  4. Notice the calendar is now either at the very top of the page or way off to the left

I have a fix for this and will submit a pull request

Handling empty string values

This PR correct "Uncaught TypeError: Cannot call method 'toDate' of null" error in case of empty value in input holder associated to Pikaday.

Stan

Pikaday not working on mobile browsers

I can't seem to get pikaday to work on a mobile browser( tested on chrome and safari for iOS). I did some testing and it seems the onSelect event never gets send out, thus the input field staying empty.

Feature Request: Disable Weekends

Many low experienced user will want a quick and easy way to disable weekends from the picker, so I'm proposing an option for it.

Default set to 'false' and all that shizz. I'm looking into it later, i'll do a pull request when it's ready.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.