Code Monkey home page Code Monkey logo

calendar's Introduction

Baremetrics Date Range Picker

Baremetrics provides one-click analytics & insights for Stripe. Get started today!


1.0.2 Update

  • Added license and repo info to the package.json
  • Removed underscore dependency
  • Added the github page publisher function to the gulpfile
  • Added a switch statement for keycode checking (Thanks again Theodore Brown)
  • Added the 'use strict' label to the Calendar.js file
  • Cleaned out some unused gulp functions
  • Compressed the Sass folder to a single level

1.0.1 Update

  • Removed global CSS reset file
  • Fixed issue with presets not respecting earliest date
  • Registered the package with Bower bower install BaremetricsCalendar (Thanks Agustin Diaz)
  • Shifted code base to support UMD support (Thanks Derrick Reimer)
  • Added up/down keyboard support
    • day = keystroke up/down
    • week = hold shift + keystroke up/down
    • month = hold meta + keystroke up/down
  • Fixed a couple minor typos hither and thither

The Baremetrics date range picker is a simplified solution for selecting both date ranges and single dates all from a single calender view. There aren't a billion options but the code is pretty basic and modular so feel free to edit however to meet your own needs.

Design by Chris Meeks
Code by Tyler van der Hoeven

View a demo
View in a live production app

Installing

Using the date picker is pretty simple, you've just got to make a couple choices and include a couple settings. Create a div with a daterange class and then either the daterange--double or daterange--single classname for targeting the specific calendar you'd like to generate.

<div class="daterange daterange--double"></div>
<div class="daterange daterange--single"></div>

Next you've just gotta create a new Calendar instance.

new Calendar({
  element: $('.daterange--single'),
  current_date: new Date('June 15, 2015')
});

new Calendar({
  element: $('.daterange--double'),
  earliest_date: new Date('January 1, 2000'),
  latest_date: new Date(),
  start_date: new Date('May 1, 2015'),
  end_date: new Date('May 31, 2015'),
  callback: function() {
    var start = moment(this.start_date).format('ll'),
        end = moment(this.end_date).format('ll');
    
    console.log('Start Date: '+ start +'\nEnd Date: '+ end);
  }
});

Single Calendar params

  • element*
    • jQuery DOM object of the calendar div you're working on
  • callback
    • A function for whenever a new date is saved
    • Inside you have access to variables like this.earliest_date, this.latest_date and this.current_date for doing things with the new dates.
  • earliest_date
    • The earliest date to show in the calendar
  • latest_date
    • The latest date to show in the calendar
  • current_date
    • The date to start the calendar on

Double Calendar params

  • element*
    • jQuery DOM object of the calendar div you're working on
  • callback
    • A function for whenever a new date is saved
    • Inside you have access to variables like this.earliest_date, this.latest_date, this.end_date, this.start_date and this.current_date for doing things with the new dates.
  • earliest_date
    • The earliest date to show in the calendar
  • latest_date
    • The latest date to show in the calendar
  • start_date
    • The date to start the selection on for the calendar
  • end_date
    • The date to end the selection on for the calendar

* required

Developing

I've included my signature gulpfile too so be sure and take a look at that as well.

$ cd <project directory>
$ npm install
$ gulp

I also use pow and the powder gem to run my local dev environments but however you plan on wrangling that the gulpfile turns on a livereload server so as long as you have the files serving somehow any changes you make will show up instantly.

Dependencies

calendar's People

Contributors

kalepail avatar hiroagustin avatar xouabita avatar derrickreimer avatar gpopoteur avatar shpigford avatar theodorejb avatar

Watchers

 avatar Samuel Reh avatar Sergey B (Troex Nevelin) avatar James Cloos avatar  avatar Max Sills avatar

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.