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

date-ranges-selector

v1.0.10

Published

A jQuery plugin to create and manage date ranges

Downloads

19

Readme

date-ranges-selector

A jQuery plugin to create and manage date ranges. Written by Albert Gonzalez and released under the Unlicense.

See it in action!

Install

Download the .js and .css files or install them using npm:

npm install date-ranges-selector

Starting

$(element).dateRangesSelector({options});

Available options:

  • new_date_range_text : Default text for the starting button
  • main_class_prefix : Css class for the plugin main container
  • max_date : Max date value. Default: "+1Y"
  • date_format : Something like "D, dd/mm/yy". Used by the datepickers
  • selector : If true (enabled by default), adds an aditional selector that will be attached to every range)
  • selector_name : "appear" by default. The "name" of the selector (if provided
  • selector_options : Array of options to be shown in the selector. Each element is another array "text"-"value". Default: [ ["Display", "1"], ["Don't display", "0"] ]
  • use_timezone_offset : If true (enabled by default) uses timezone offsets when fetching dates
  • initial_ranges : Start with a fixed amount of ranges (0 by default)
  • disable_add_remove : If true (false by default) disables the "add/remove range" buttons

Now you're ready!

Methods

Add a new range:

$(element).datesRangesSelector("addDateRange", {options});

Available options:

  • date_begin : Optional date_begin value in unixtime to set the first date of the new added element.
  • date_end : Optional date_end value in unixtime to set the second date of the new added element.
  • selector : Optional selector value (if selector is enabled)

Remove an existing range:

$(element).datesRangesSelector("removeDateRange", [position (begins with 1)]);

Remove ALL ranges:

Remove ALL ranges: $(element).datesRangesSelector("removeAllDateRanges");

Get all non-empty ranges:

$(element).datesRangesSelector("getDateRanges", {options});

Available options:

  • only_non_empty : If true (enabled by default) will only return full populated ranges. Otherwise will return the empty ones too.

Visually disable the plugin (the GET method won't return anything, but still can add elements via methods):

$(element).datesRangesSelector("disable");

Visually enable the plugin:

$(element).datesRangesSelector("enable");

Events

The events are triggered when adding or removing elements:

$(element).on('datesRangesSelector.rangeAdded', function(event, date_begin, date_end, selector) {
  console.log('Added range with values ' + date_begin + ', ' + date_end + ', ' + selector + '. Those values can be undefined if the range is added without default values');
});

$(element).on('datesRangesSelector.rangeRemoved', function(event, position) {
  console.log('Range removed at position ' + position);
});

$(element).on('datesRangesSelector.allRangesRemoved', function(event, position) {
  console.log('ALL ranges removed');
});

$(element).on('datesRangesSelector.becameFull', function(event, date_begin, date_end, selector) {
  console.log('I was empty, but after that, I have at least one new element');
});

$(element).on('datesRangesSelector.becameEmpty', function(event) {
  console.log('I wasn't empty (with at least one element) but now I amb after that last operation');
});