• This repository has been archived on 16/Jul/2022
  • Stars
    star
    620
  • Rank 72,387 (Top 2 %)
  • Language
    JavaScript
  • License
    BSD Zero Clause L...
  • Created about 11 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Really simple, powerful, customizable and lightweight standalone datepicker

⚠️ Project is archived

I have created this library library many years ago and didn't update it in last few years due to not working with frontend anymore.

With that I decided to archive the project.

If you'd like to step in maintaining and modernize the project with the original vision in mind, please reach out via email.

PickMeUp - Really simple, powerful, customizable and lightweight standalone datepicker

No dependencies, single/range/multiple selections, ability to put custom content into dates, very flexible styling and customization abilities.

Written and maintained by Nazar Mokrynskyi with the help of awesome contributors

Based on DatePicker by Stefan Petre

Browser support:

  • IE 10+
  • 2 latest stable versions of Firefox, Chromium, Opera and Edge

If you find this project useful, consider supporting its development on patreon.com/nazarpc, this would help me a lot!

Or if you are representing a company, here is Faircode page.

Demo

Getting started

You need only 2 files: dist/pickmeup.min.js and css/pickmeup.css.

The plugin can also be loaded as AMD or CommonJS module.

Then you can apply datepicker to any element:

pickmeup('.date');

Global default options are stored in pickmeup.defaults

They can be redefined during initialization:

pickmeup('.date', {
	format	: 'Y-m-d'
});

or with data-attributes with pmu- prefix:

<div class="date" data-pmu-format="Y-m-d"></div>

Twitter Bootstrap integration

For Twitter Bootstrap integration you do not need to include style file, but you need to include jquery.pickmeup.twitter-bootstrap.js instead, that will read settings of current Bootstrap theme and apply them to PickMeUp, so that it will look similar to native Bootstrap elements.

To apply integrated version use $(...).pickmeup_twitter_bootstrap() plugin for initialization:

$('.date').pickmeup_twitter_bootstrap();

All options and events are the same.

UIkit integration

For UIkit integration you do not need to include style file, but you need to include jquery.pickmeup.uikit.js instead, that will read settings of current UIkit theme and apply them to PickMeUp, so that it will look similar to native UIkit elements.

To apply integrated version use $(...).pickmeup_uikit() plugin for initialization:

$('.date').pickmeup_uikit();

All options and events are the same.

Configuration options

Option Value type Default Description
date array/number/object/string new Date Selected date after initialization. Can be single date string/object or array depending on selection mode
default_date boolean true If false will keep empty value until date selected
current number/object/string date Represents date that will be in the center of rendered calendar, defaults to date option's value
flat boolean false Whatever if the date picker is appended to the element or triggered by an event
first_day 0/1 1 First day of week: 0 - Sunday, 1 - Monday
prev string β—€ Previous button content
next string β–Ά Next button content
mode single/multiple/range single Date selection mode
select_day boolean true Allow or deny days selection
select_month boolean true Allow or deny months selection
select_year boolean true Allow or deny year selection
view days/months/years days View mode after initialization
calendars int 1 Number of calendars, that will be rendered
format string d-m-Y Date format (aAbBCdeHIjklmMpPsSuwyY are supported)
title_format string/function B, Y Date format for calendar title in days view (aAbBCdeHIjklmMpPsSuwyY are supported). If function, must return the full title as a string. The date and locale are provided as parameters.
position top/right/bottom/left/function bottom Date picker's position relative to the triggered element, if function - must return an object with left and top keys and include units
class_name string Class to be added to root datepicker element
hide_on_select boolean false If true - datepicker will be hidden after selection (for range mode allows to select first and last days)
min number/object/string Min date available for selection
max number/object/string Max date available for selection
separator string - Is used for joining separate dates in multiple mode and first/last dates in range mode
locale string en String, that specifies current locale.
locales object see Localization Key-value object, where keys are locales and values contain localized days of week names and months
render function Executed for each day element rendering, takes date argument, allows to select, disable or add class to element
instance_template function (look at source code) Responsible for rendering simple PickMeUp instance with header and days of weeks
instance_content_template function (look at source code) Responsible for rendering instance content container (which contains years, months or days)
Selecting/disabling dates with custom logic

render options might return object with any of following keys:

  • selected: if true - date will be selected
  • disabled: if true - date will be disabled
  • class_name: will be added to class of day element

Example:

var now = new Date;
pickmeup(element, {
    render : function (date) {
        if (date < now) {
            return {disabled : true, class_name : 'date-in-past'};
        }
        return {};
    } 
})

Events callbacks

In PickMeUp events are native DOM events fired on element when pickmeup() was called and always have pickmeup- prefix.

pickmeup-change

Triggered at date change. Example:

pickmeup(element);
element.addEventListener('pickmeup-change', function (e) {
    console.log(e.detail.formatted_date); // New date according to current format
    console.log(e.detail.date);           // New date as Date object
})
pickmeup-show

Triggered at showing. Example:

pickmeup(element);
element.addEventListener('pickmeup-show', function (e) {
    e.preventDefault(); // Showing can be canceled if needed
})
pickmeup-hide

Triggered at hiding. Example:

pickmeup(element);
element.addEventListener('pickmeup-hide', function (e) {
    e.preventDefault(); // Hiding can be canceled if needed
})
pickmeup-fill

Triggered after filling of PickMeUp container with new markup of days, months, years. May be needed for inner datepicker markup editing.

pickmeup(element);
element.addEventListener('pickmeup-fill', function (e) {
    // Do stuff here
})

Methods

Methods allows external control on datepicker

Hide
pickmeup('.date').hide();
Show
pickmeup('.date').show();
Prev
pickmeup('.date').prev();
Next
pickmeup('.date').next();
Get date
pickmeup('.date').get_date(formatted);

formatted - boolean or string (default false)

  • false - Date object
  • true - string formatted in accordance with format option
  • string is used to specify custom format instead if given during initialization
Set date
pickmeup('.date').set_date(new Date);

date - can be single date string/object or array depending on selection mode

Clear multiple selection
pickmeup('.date').clear();
Update datepicker
pickmeup('.date').update();
Destroy datepicker

Destroys PickMeUp instance, removes created markup, restores everything that was changed to original state.

pickmeup('.date').destroy();

Localization

You can add locales to global defaults and then use different locales in particular instance with locale option. Sample object for English language (no need to add, already included in source code):

pickmeup.defaults.locales['en'] = {
	days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
	daysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
	daysMin: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
	months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
	monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
};

Russian:

pickmeup.defaults.locales['ru'] = {
	days: ['Π’ΠΎΡΠΊΡ€Π΅ΡΠ΅Π½ΡŒΠ΅', 'ПонСдСльник', 'Π’Ρ‚ΠΎΡ€Π½ΠΈΠΊ', 'Π‘Ρ€Π΅Π΄Π°', 'Π§Π΅Ρ‚Π²Π΅Ρ€Π³', 'ΠŸΡΡ‚Π½ΠΈΡ†Π°', 'Π‘ΡƒΠ±Π±ΠΎΡ‚Π°'],
	daysShort: ['Вс', 'Пн', 'Π’Ρ‚', 'Π‘Ρ€', 'Π§Ρ‚', 'ΠŸΡ‚', 'Π‘Π±'],
	daysMin: ['Вс', 'Пн', 'Π’Ρ‚', 'Π‘Ρ€', 'Π§Ρ‚', 'ΠŸΡ‚', 'Π‘Π±'],
	months: ['Π―Π½Π²Π°Ρ€ΡŒ', 'Π€Π΅Π²Ρ€Π°Π»ΡŒ', 'ΠœΠ°Ρ€Ρ‚', 'ΠΠΏΡ€Π΅Π»ΡŒ', 'Май', 'Июнь', 'Июль', 'Август', 'Π‘Π΅Π½Ρ‚ΡΠ±Ρ€ΡŒ', 'ΠžΠΊΡ‚ΡΠ±Ρ€ΡŒ', 'ΠΠΎΡΠ±Ρ€ΡŒ', 'Π”Π΅ΠΊΠ°Π±Ρ€ΡŒ'],
	monthsShort: ['Π―Π½Π²', 'Π€Π΅Π²', 'ΠœΠ°Ρ€', 'Апр', 'Май', 'Июн', 'Июл', 'Авг', 'Π‘Π΅Π½', 'ΠžΠΊΡ‚', 'Ноя', 'Π”Π΅ΠΊ']
};

Other

Current options (for whatever reason) can be accessed as element.__pickmeup.options.

Root pickmeup element can be accessed as element.__pickmeup.element.

Styling

If you want other colors - just change several variables in scss file.

To change size - adjust font-size for root datepicker element, everything will scale nicely.

Contribution

Feel free to create issues and send pull requests, they are highly appreciated!

Before reporting an issue, be so kind to prepare reproducible example on jsfiddle.net, please.

You can start with working demo of latest stable version of PickMeUp: jsfiddle.net/0kg5jL3p

License

Zero-Clause BSD

https://opensource.org/licenses/0BSD

https://tldrlegal.com/license/bsd-0-clause-license

More Repositories

1

docker-webserver

WebServer (MariaDB, PHP-FPM, Nginx) composed from several separate containers linked together
Shell
291
star
2

CleverStyle-Framework

CleverStyle Framework is simple, scalable, fast and secure full-stack PHP framework
PHP
150
star
3

noise-c.wasm

rweather/noise-c compiled to WebAssembly using Emscripten and optimized for small size
LiveScript
92
star
4

RTL8814AU

Realtek RTL8814AU USB Wi-Fi driver
C
50
star
5

docker-phpmyadmin

phpMyAdmin as Docker container, based on official image, always latest version
PHP
40
star
6

BananaHTML

BananaHTML - single class that makes HTML generating easier
PHP
39
star
7

solax-local-api-docs

Solax local API docs
38
star
8

webtorrent-dht

This is an example implementation of something that might become WebTorrent DHT
LiveScript
29
star
9

just-backup-btrfs

Script that does just that - creates backups using snapshot of btrfs filesystem. Also it makes rotation of snapshots by removing old ones and keeping as many snapshots as you want.
PHP
27
star
10

blake2.wasm

BLAKE2b and BLAKE2s hash functions compiled to WebAssembly using Emscripten and optimized for small size
LiveScript
27
star
11

spotify-to-vk

Download Spotify music tracks as mp3 through vk.com
PHP
24
star
12

Useful-PHP-Functions

Set of system-independent functions from CleverStyle Framework
PHP
21
star
13

CleverStyle-PhpStorm-theme

Dark theme for PhpStorm
19
star
14

CleverStyle-Music

CleverStyle Music Open Web App. Music player for Firefox OS built using open web technologies.
JavaScript
18
star
15

space-acres

Space Acres is an opinionated unofficial GUI application for farming on Subspace Network
Rust
16
star
16

ronion

Generic anonymous routing protocol framework agnostic to encryption algorithm and transport layer
LiveScript
14
star
17

Flexy-plexy

Ridiculously simple, incredibly powerful grid system
CSS
14
star
18

supercop.wasm

orlp/ed25519 compiled to WebAssembly using Emscripten and optimized for small size
JavaScript
13
star
19

php-markdown-next

PHP Markdown Next parser, based on PHP Markdown Extra and PHP Markdown Extra Extended
PHP
11
star
20

CSTester

IS NOT MAINTAINED ANYMORE, use PHPT tests instead
PHP
9
star
21

vk-photo-saver

Download your photo in vk.com to PC.
Python
9
star
22

stream-slicer

Get slice of any seekable stream
PHP
8
star
23

phpt-tests-runner

Runner for PHPT tests (with few differences comparing to original PHPT format)
PHP
8
star
24

NPW-1.0

Dual SSI EEB motherboards PC case parametrically designed in SolveSpace
HTML
8
star
25

metadata-audio-parser

Library that parse metadata from mp3(ID3v1 and ID3v2 tags)/mp4(aac, m4a, etc.)/ogg audio files
JavaScript
8
star
26

ed25519-to-x25519.wasm

Library for converting Ed25519 signing key pair into X25519/Curve25519 key pair suitable for Diffie-Hellman key exchange
LiveScript
7
star
27

btrfs-sync-subvolumes

This is a pretty naive implementation of replication exact set of subvolumes from one location to another, plays nicely with Just backup btrfs
PHP
7
star
28

docker-php

More feature-complete PHP Docker images based on official images
Shell
7
star
29

es-dht

Generic DHT framework agnostic to command set and transport layer
LiveScript
6
star
30

matx-open-test-bench

Basic test bench for standard Micro ATX motherboard designed for 3D printing without supports
5
star
31

CleverStyle-PhpStorm-codestyle

Codestyle for PhpStorm (PHP, JS, CSS, LESS)
4
star
32

event-listener-primitives

Low-level primitive for building Node.js-like event listeners
Rust
4
star
33

h264-profile-level-id

Rust
3
star
34

side-futures

Send future for execution on the runtime that may be in a different thread
Rust
3
star
35

opir.org

opir.org Source code
PHP
3
star
36

docker-subset-font

Modifies font file to only include characters from specified CSS file
PHP
3
star
37

docker-webserver-apps

Carefully crafted images that are intended to be used with nazarpc/webserver:* family of images
Dockerfile
3
star
38

docker-coturn

Coturn TURN server as Docker image (achived, use official coturn image instead)
Shell
2
star
39

fixed-size-multiplexer

A tiny library for multiplexing data chunks into blocks of fixed size and vice versa
LiveScript
2
star
40

Frontendweekend

CSS
2
star
41

CherryTea.org

This is complete source code of CherryTea.org
PHP
2
star
42

merkle-tree-binary

Set of functions for creating Merkle Tree, proofs and verifying proofs using binary data
TypeScript
2
star
43

css-template-layout

JavaScript (jQuery) implementation of the CSS Template Layout Module
JavaScript
2
star
44

MyBlog

Demo of simple blog module for CleverStyle CMS 0.393 (outdated)
PHP
2
star
45

cherrytea.org-old

PHP
1
star
46

aez.wasm

AEZ cipher compiled to WebAssembly using Emscripten and optimized for small size
LiveScript
1
star
47

unicode-range-splitter

Unicode range splitter for icon fonts
PHP
1
star
48

async-eventer

A tiny library with asynchronous Promise-based implementation of events dispatching and handling
LiveScript
1
star
49

array-map-set

Just like regular Map and Set, but treats different ArrayBufferView's with the same values as equal
LiveScript
1
star
50

registry-demo-chain

Rust
1
star