Coder Social home page Coder Social logo

nathanbertram / bootstrap-daterangepicker-rails Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jordanbrock/bootstrap-daterangepicker-rails

0.0 2.0 0.0 201 KB

A gem to incorporate the bootstrap-daterangepicker plugin into Rails 4.1+ projects

License: Other

Ruby 100.00%

bootstrap-daterangepicker-rails's Introduction

Date Range Picker for Twitter Bootstrap

Description from DateRangePicker for Twitter Bootstrap

This date range picker component for Twitter Bootstrap creates a dropdown menu from which a user can select a range of dates. It was created for the reporting UI at Improvely.

If invoked with no options, it will present two calendars to choose a start and end date from. Optionally, you can provide a list of date ranges the user can select from instead of choosing dates from the calendars. If attached to a text input, the selected dates will be inserted into the text box. Otherwise, you can provide a custom callback function to receive the selection.

Live demo & option usage examples

Installation and Usage

This component relies on Twitter Bootstrap, momentjs and jQuery.

Basic usage (with Bootstrap 3)

(Suffix daterangepicker with -bs2 or -bs3 for your version of Bootstrap.)


# Gemfile
gem 'jquery-rails'
gem 'momentjs-rails'
gem 'bootstrap-daterangepicker-rails'

# application.js

//= require moment
//= require daterangepicker


# application.css

/*
 *= require bootstrap
 *= require daterangepicker-bs3
 */
 
 
# In your HTML file

<input type="text" class="daterange"/>

<script type="text/javascript">
$(document).ready(function() {
  $('input[class="daterange"]').daterangepicker();
});
</script>

# for a simple_form field just do something like this and include the above javascript

= f.input :field_name, html: { class: "daterange" }

Additional options allow:

  • Custom callback handler called when the date range selection is made
  • Setting initial start and end dates for the calendars
  • Bounding the minimum and maximum selectable dates
  • Overriding all labels in the interface with localized text
  • Starting the calendar week on any day of week
  • Overriding the direction the dropdown expands (left/right of element it's attached to)
  • Setting the date format string for parsing string inputs

Syntax for all the options can be found in the examples.html file.

Thanks

Thanks to https://github.com/allomov for doing all the work on the 4.x branch.

License

This code is made available under the Apache License v2.0, the same as Twitter Bootstrap.

Date.js is included in this repository for convenience. It is available under the MIT license.

bootstrap-daterangepicker-rails's People

Contributors

ablignaut avatar dannyfallon avatar dioms avatar epdejager avatar jordanbrock avatar nathanbertram avatar navyant24 avatar nyjt avatar zshannon avatar

Watchers

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