forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
daterangepicker: typings for v3.0.1 (DefinitelyTyped#25476)
* daterangepicker: typings for v3.0.1 See release notes for v3.0.0: https://github.com/dangrossman/daterangepicker/releases/tag/v3.0.0 * fix react-bootstrap-daterangepicker * fix linting errors * support for .data('daterangepicker')
- Loading branch information
1 parent
c5907dd
commit 2c008db
Showing
4 changed files
with
161 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,116 @@ | ||
import moment = require("moment") | ||
import daterangepicker = require("daterangepicker"); | ||
import moment = require('moment'); | ||
import daterangepicker = require('daterangepicker'); | ||
|
||
function tests_simple() { | ||
$('#daterange').daterangepicker(); | ||
$('input[name="daterange"]').daterangepicker({ | ||
timePicker: true, | ||
timePickerIncrement: 30, | ||
locale: { | ||
format: 'MM/DD/YYYY h:mm A' | ||
} | ||
}); | ||
$('input[name="daterange"]') | ||
.daterangepicker({ | ||
timePicker: true, | ||
timePickerIncrement: 30, | ||
locale: { | ||
format: 'MM/DD/YYYY h:mm A' | ||
}, | ||
maxSpan: { days: 10 }, | ||
applyButtonClasses: 'my-apply-class', | ||
cancelButtonClasses: 'my-cancel-class', | ||
showDropdowns: true, | ||
maxYear: 3000, | ||
minYear: 2000 | ||
}) | ||
.data('daterangepicker') | ||
.remove(); | ||
|
||
$('#reportrange').daterangepicker({ | ||
ranges: { | ||
'Today': [moment(), moment()], | ||
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')], | ||
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')] | ||
'Last Month': [ | ||
moment() | ||
.subtract(1, 'month') | ||
.startOf('month'), | ||
moment() | ||
.subtract(1, 'month') | ||
.endOf('month') | ||
] | ||
} | ||
}); | ||
|
||
$('input[name="datefilter"]').on('apply.daterangepicker', function (ev, picker) { | ||
$(this).val(picker.startDate.format('MM/DD/YYYY') + ' - ' + picker.endDate.format('MM/DD/YYYY')); | ||
$('input[name="datefilter"]').on('apply.daterangepicker', function(ev, picker) { | ||
$(this).val( | ||
`${picker.startDate.format('MM/DD/YYYY')} - ${picker.endDate.format('MM/DD/YYYY')}` | ||
); | ||
}); | ||
|
||
|
||
$('input[name="datefilter"]').on('cancel.daterangepicker', function (ev, picker) { | ||
$('input[name="datefilter"]').on('cancel.daterangepicker', function(ev, picker) { | ||
$(this).val(''); | ||
}); | ||
|
||
$('#demo').daterangepicker({ | ||
"startDate": "05/06/2016", | ||
"endDate": "05/12/2016" | ||
}, function (start: moment.Moment, end: moment.Moment, label: string) { | ||
console.log("New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')"); | ||
}); | ||
|
||
$(function() { | ||
|
||
function cb(start: moment.Moment, end: moment.Moment) { | ||
$('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY')); | ||
} | ||
cb(moment().subtract(29, 'days'), moment()); | ||
$('#demo').daterangepicker( | ||
{ | ||
startDate: '05/06/2016', | ||
endDate: '05/12/2016' | ||
}, | ||
(start: moment.Moment, end: moment.Moment, label: string) => { | ||
console.log( | ||
"New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')" | ||
); | ||
} | ||
); | ||
|
||
$('#reportrange').daterangepicker({ | ||
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')] | ||
$(() => { | ||
function cb(start: moment.Moment, end: moment.Moment) { | ||
$('#reportrange span').html( | ||
`${start.format('MMMM D, YYYY')} - ${end.format('MMMM D, YYYY')}` | ||
); | ||
} | ||
}, cb); | ||
cb(moment().subtract(29, 'days'), moment()); | ||
|
||
$('#reportrange').daterangepicker({ | ||
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()] | ||
}, | ||
showCustomRangeLabel: false | ||
}, cb); | ||
$('#reportrange').daterangepicker( | ||
{ | ||
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') | ||
] | ||
} | ||
}, | ||
cb | ||
); | ||
|
||
$('#reportrange').daterangepicker( | ||
{ | ||
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()] | ||
}, | ||
showCustomRangeLabel: false | ||
}, | ||
cb | ||
); | ||
|
||
$('#endDate').daterangepicker({ | ||
singleDatePicker: true, | ||
startDate: moment() | ||
$('#endDate').daterangepicker({ | ||
singleDatePicker: true, | ||
startDate: moment() | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
declare const host: HTMLElement; | ||
function test_from_amd() { | ||
var picker = new daterangepicker(host); | ||
console.log(picker.startDate.format("YYYY-MM-DD")); | ||
const picker = new daterangepicker(host); | ||
console.log(picker.startDate.format('YYYY-MM-DD')); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.