123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 |
- <!DOCTYPE html>
- <html dir="ltr" lang="en-US">
- <head>
- <meta charset="UTF-8" />
- <title>A date range picker for Bootstrap</title>
- <link href="http://netdna.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet">
- <link href="http://netdna.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet">
- <link rel="stylesheet" type="text/css" media="all" href="daterangepicker-bs3.css" />
- <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
- <script type="text/javascript" src="http://netdna.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
- <script type="text/javascript" src="moment.js"></script>
- <script type="text/javascript" src="daterangepicker.js"></script>
- </head>
- <body>
- <div class="container">
- <div class="span12">
- <h1>Usage Examples</h1>
- <hr />
- <h4>Basic Date Range Picker</h4>
- <div class="well">
- <form class="form-horizontal">
- <fieldset>
- <div class="control-group">
- <div class="controls">
- <div class="input-prepend input-group">
- <span class="add-on input-group-addon"><i class="glyphicon glyphicon-calendar fa fa-calendar"></i></span><input type="text" style="width: 200px" name="reservation" id="reservation" class="form-control" value="03/18/2013 - 03/23/2013" />
- </div>
- </div>
- </div>
- </fieldset>
- </form>
- <script type="text/javascript">
- $(document).ready(function() {
- $('#reservation').daterangepicker(null, function(start, end, label) {
- console.log(start.toISOString(), end.toISOString(), label);
- });
- });
- </script>
- </div>
- <h4>Basic Single Date Picker</h4>
- <div class="well">
- <form class="form-horizontal">
- <fieldset>
- <div class="control-group">
- <div class="controls">
- <div class="input-prepend input-group">
- <span class="add-on input-group-addon"><i class="glyphicon glyphicon-calendar fa fa-calendar"></i></span><input type="text" style="width: 200px" name="birthday" id="birthday" class="form-control" value="03/18/2013" />
- </div>
- </div>
- </div>
- </fieldset>
- </form>
- <script type="text/javascript">
- $(document).ready(function() {
- $('#birthday').daterangepicker({ singleDatePicker: true }, function(start, end, label) {
- console.log(start.toISOString(), end.toISOString(), label);
- });
- });
- </script>
- </div>
- <h4>Date Range & Time Picker with 30 Minute Increments</h4>
- <div class="well">
- <form class="form-horizontal">
- <fieldset>
- <div class="control-group">
- <label class="control-label" for="reservationtime">Choose your check-in and check-out times:</label>
- <div class="controls">
- <div class="input-prepend input-group">
- <span class="add-on input-group-addon"><i class="glyphicon glyphicon-calendar fa fa-calendar"></i></span>
- <input type="text" style="width: 400px" name="reservation" id="reservationtime" class="form-control" value="08/01/2013 1:00 PM - 08/01/2013 1:30 PM" class="span4"/>
- </div>
- </div>
- </div>
- </fieldset>
- </form>
- <script type="text/javascript">
- $(document).ready(function() {
- $('#reservationtime').daterangepicker({
- timePicker: true,
- timePickerIncrement: 30,
- format: 'MM/DD/YYYY h:mm A'
- }, function(start, end, label) {
- console.log(start.toISOString(), end.toISOString(), label);
- });
- });
- </script>
- </div>
- <h4>Options Usage</h4>
- <div class="well" style="overflow: auto">
- <button id="options1" class="btn btn-primary">Apply Option Set 1</button>
- <button id="options2" class="btn btn-primary">Apply Option Set 2</button>
- <button id="destroy" class="btn btn-primary">Remove DateRangePicker</button>
- <div id="reportrange" class="pull-right" style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc">
- <i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
- <span></span> <b class="caret"></b>
- </div>
- <script type="text/javascript">
- $(document).ready(function() {
- var cb = function(start, end, label) {
- console.log(start.toISOString(), end.toISOString(), label);
- $('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
- //alert("Callback has fired: [" + start.format('MMMM D, YYYY') + " to " + end.format('MMMM D, YYYY') + ", label = " + label + "]");
- };
- var optionSet1 = {
- startDate: moment().subtract(29, 'days'),
- endDate: moment(),
- minDate: '01/01/2012',
- maxDate: '12/31/2015',
- dateLimit: { days: 60 },
- showDropdowns: true,
- showWeekNumbers: true,
- timePicker: false,
- timePickerIncrement: 1,
- timePicker12Hour: true,
- ranges: {
- 'Today': [moment(), moment()],
- 'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
- 'Last 7 Days': [moment().subtract(6, 'days'), moment()],
- 'Last 30 Days': [moment().subtract(29, 'days'), moment()],
- 'This Month': [moment().startOf('month'), moment().endOf('month')],
- 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
- },
- opens: 'left',
- buttonClasses: ['btn btn-default'],
- applyClass: 'btn-sm btn-primary',
- cancelClass: 'btn-sm',
- format: 'MM/DD/YYYY',
- separator: ' to ',
- locale: {
- applyLabel: 'Submit',
- cancelLabel: 'Clear',
- fromLabel: 'From',
- toLabel: 'To',
- customRangeLabel: 'Custom',
- daysOfWeek: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr','Sa'],
- monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
- firstDay: 1
- }
- };
- var optionSet2 = {
- startDate: moment().subtract(7, 'days'),
- endDate: moment(),
- opens: 'left',
- ranges: {
- 'Today': [moment(), moment()],
- 'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
- 'Last 7 Days': [moment().subtract(6, 'days'), moment()],
- 'Last 30 Days': [moment().subtract(29, 'days'), moment()],
- 'This Month': [moment().startOf('month'), moment().endOf('month')],
- 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
- }
- };
- $('#reportrange span').html(moment().subtract(29, 'days').format('MMMM D, YYYY') + ' - ' + moment().format('MMMM D, YYYY'));
- $('#reportrange').daterangepicker(optionSet1, cb);
- $('#reportrange').on('show.daterangepicker', function() { console.log("show event fired"); });
- $('#reportrange').on('hide.daterangepicker', function() { console.log("hide event fired"); });
- $('#reportrange').on('apply.daterangepicker', function(ev, picker) {
- console.log("apply event fired, start/end dates are "
- + picker.startDate.format('MMMM D, YYYY')
- + " to "
- + picker.endDate.format('MMMM D, YYYY')
- );
- });
- $('#reportrange').on('cancel.daterangepicker', function(ev, picker) { console.log("cancel event fired"); });
- $('#options1').click(function() {
- $('#reportrange').data('daterangepicker').setOptions(optionSet1, cb);
- });
- $('#options2').click(function() {
- $('#reportrange').data('daterangepicker').setOptions(optionSet2, cb);
- });
- $('#destroy').click(function() {
- $('#reportrange').data('daterangepicker').remove();
- });
- });
- </script>
- </div>
- <h4>Plays nicely with Bootstrap dropdowns</h4>
- <div class="well">
- <div class="dropdown" style="display: inline-block;">
- <a data-toggle="dropdown" class="btn btn-primary" href="#">Regular bootstrap dropdown</a>
- <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
- <li><a href="#">item</a></li>
- </ul>
- </div>
- <div id="reportrange2" class="btn" style="display: inline-block; background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc">
- <i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
- <span></span> <b class="caret"></b>
- </div>
- <script type="text/javascript">
- $(document).ready(function() {
- $('#reportrange2 span').html(moment().subtract(29, 'days').format('MMMM D, YYYY') + ' - ' + moment().format('MMMM D, YYYY'));
- $('#reportrange2').daterangepicker({
- opens: 'center'
- });
- });
- </script>
- </div>
- <h4>And also can drop "up"</h4>
- <div class="well">
- <form class="form-horizontal">
- <fieldset>
- <div class="control-group">
- <div class="controls">
- <div class="input-prepend input-group">
- <span class="add-on input-group-addon"><i class="glyphicon glyphicon-calendar fa fa-calendar"></i></span><input type="text" style="width: 200px" name="dropup" id="dropup" class="form-control" value="03/18/2013 - 03/23/2013" />
- </div>
- </div>
- </div>
- </fieldset>
- </form>
- <script type="text/javascript">
- $(document).ready(function() {
- $('#dropup').daterangepicker({
- drops:'up'
- });
- });
- </script>
- </div>
- </div>
- </div>
- </body>
- </html>
|