npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sebastiendaniel-datepicker

v1.1.0

Published

dependency free datepicker widget

Downloads

14

Readme

Getting started

Install datepicker

npm install sebastiendaniel-datepicker --save

Require or link

You can require datepicker into your source:

var datepicker = require("sebastiendaniel-datepicker");

Alternatively, a standalone bundle has been provided for you, which uses the datepicker namespace. To obtain the built files (datepicker.min.js and datepicker.min.css), run the grunt task grunt build.

<script type="text/javascript" src="build/datepicker.min.js"></script>

You'll also need to provide some styling to the datepicker markup, otherwise it's just a bland HTML table. We've provided some default styles for you, feel free to adjust them to your needs:

<link rel="stylesheet" type="test/css" href="build/datepicker.min.css" />

How it works

Datepicker generates a month based on a provided date. It uses the provided date to determine the month to render. If no date is provided, it uses the current date. Datepicker has 3 events:

  • previous month: renders the month before current month
  • next: renders the month after current month
  • select date: triggers the callback with selected date as a JavaScript Date object.

Datepicker doesn't "pre-render" a range of months. It dynamically compiles a new month table when previousMonth or nextMonth events occur. There is always only one month rendered at a time.

Example

By default, datepicker assumes the current date as the date around which to build the calendar. The easiest way is to simply call datepicker.get(), and inject into the DOM:

document.getElementById("myContainer").appendChild(datepicker.get());

You can also optionally provide a date around which to build the datepicker month:

datepicker.get(new Date("2016-06-01"));

setting a callback

You can provide a callback function, which will be triggered with a single argument: the selected date as a JavaScript Date object:

var datepicker = require("sebastiendanie-datepicker");

datepicker.config.callback = function(date) {
        // do something
    };

Members

Functions

config : object

Kind: global variable
Properties

| Name | Type | Description | | --- | --- | --- | | dayNames | Array.<string> | array of 7 strings used as day names, from sunday[0] to saturday[6] | | monthNames | Array.<string> | array of 12 strings used as month names, from january[0] to december[11] | | startDate | Date | JavaScript date object. Used to determine around which date to render the calendar | | selectedDate | string | currently selected date (yyyy-mm-dd) | | callback | function | function called when a user selects a date. It is provided a JavaScript Date object as single argument |

get([date]) ⇒ Element

Kind: global function
Summary: Returns the markup of a calendar month, centered on provided date
Returns: Element - fully-functional calendar markup (HTML)

| Param | Type | Default | Description | | --- | --- | --- | --- | | [date] | string | Date | "Date.now()" | ISO date string or JavaScript Date object |