mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
Add bootstrap.datepicker
This commit is contained in:
@@ -11,6 +11,7 @@ Complete
|
||||
* [async](https://github.com/caolan/async) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [Backbone.js](http://backbonejs.org/) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [Bootstrap](http://twitter.github.com/bootstrap/) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [bootstrap.datepicker](https://github.com/eternicode/bootstrap-datepicker) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [Breeze](http://www.breezejs.com/) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [CodeMirror](http://codemirror.net) (by [Fran<EFBFBD>ois de Campredon](https://github.com/fdecampredon))
|
||||
* [Chosen](http://harvesthq.github.com/chosen/) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
|
||||
79
bootstrap.datepicker/bootstrap.datepicker-tests.ts
Normal file
79
bootstrap.datepicker/bootstrap.datepicker-tests.ts
Normal file
@@ -0,0 +1,79 @@
|
||||
/// <reference path="../jquery/jquery-1.8.d.ts"/>
|
||||
/// <reference path="bootstrap.datepicker.d.ts"/>
|
||||
|
||||
function tests_simple() {
|
||||
$('#datepicker').datepicker();
|
||||
$('#datepicker').datepicker({
|
||||
format: 'mm-dd-yyyy'
|
||||
});
|
||||
$('#datepicker').datepicker('setStartDate');
|
||||
$('#datepicker').datepicker('setStartDate', null);
|
||||
$('#datepicker').datepicker('setEndDate', '2012-12-31');
|
||||
$('#date-end')
|
||||
.datepicker()
|
||||
.on('changeDate', function (ev) { });
|
||||
|
||||
var startDate = new Date(2012, 1, 20);
|
||||
var endDate = new Date(2012, 1, 25);
|
||||
$('#date-start')
|
||||
.datepicker()
|
||||
.on('changeDate', function (ev) {
|
||||
if (ev.date.valueOf() > endDate.valueOf()) {
|
||||
$('#alert').show().find('strong').text('The start date must be before the end date.');
|
||||
} else {
|
||||
$('#alert').hide();
|
||||
startDate = new Date(ev.date);
|
||||
$('#date-start-display').text($('#date-start').data('date'));
|
||||
}
|
||||
$('#date-start').datepicker('hide');
|
||||
});
|
||||
$('#date-end')
|
||||
.datepicker()
|
||||
.on('changeDate', function (ev) {
|
||||
if (ev.date.valueOf() < startDate.valueOf()) {
|
||||
$('#alert').show().find('strong').text('The end date must be after the start date.');
|
||||
} else {
|
||||
$('#alert').hide();
|
||||
endDate = new Date(ev.date);
|
||||
$('#date-end-display').text($('#date-end').data('date'));
|
||||
}
|
||||
$('#date-end').datepicker('hide');
|
||||
});
|
||||
}
|
||||
|
||||
$(function () {
|
||||
$('#dp1').datepicker({
|
||||
format: 'mm-dd-yyyy'
|
||||
});
|
||||
$('#dp2').datepicker();
|
||||
$('#dp3').datepicker();
|
||||
$('#dp3').datepicker();
|
||||
$('#dpYears').datepicker();
|
||||
$('#dpMonths').datepicker();
|
||||
|
||||
|
||||
var startDate = new Date(2012, 1, 20);
|
||||
var endDate = new Date(2012, 1, 25);
|
||||
$('#dp4').datepicker()
|
||||
.on('changeDate', function (ev) {
|
||||
if (ev.date.valueOf() > endDate.valueOf()) {
|
||||
$('#alert').show().find('strong').text('The start date can not be greater then the end date');
|
||||
} else {
|
||||
$('#alert').hide();
|
||||
startDate = new Date(ev.date);
|
||||
$('#startDate').text($('#dp4').data('date'));
|
||||
}
|
||||
$('#dp4').datepicker('hide');
|
||||
});
|
||||
$('#dp5').datepicker()
|
||||
.on('changeDate', function (ev) {
|
||||
if (ev.date.valueOf() < startDate.valueOf()) {
|
||||
$('#alert').show().find('strong').text('The end date can not be less then the start date');
|
||||
} else {
|
||||
$('#alert').hide();
|
||||
endDate = new Date(ev.date);
|
||||
$('#endDate').text($('#dp5').data('date'));
|
||||
}
|
||||
$('#dp5').datepicker('hide');
|
||||
});
|
||||
});
|
||||
27
bootstrap.datepicker/bootstrap.datepicker.d.ts
vendored
Normal file
27
bootstrap.datepicker/bootstrap.datepicker.d.ts
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
// Type definitions for bootstrap.datepicker
|
||||
// Project: https://github.com/eternicode/bootstrap-datepicker
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
/// <reference path="../jquery/jquery-1.8.d.ts"/>
|
||||
|
||||
interface DatepickerOptions {
|
||||
format?: string;
|
||||
weekStart?: number;
|
||||
startDate?: Date;
|
||||
endDate?: Date;
|
||||
autoclose?: bool;
|
||||
startView?: number;
|
||||
todayBtn?: bool;
|
||||
todayHighlight?: bool;
|
||||
keyboardNavigation?: bool;
|
||||
language?: string;
|
||||
}
|
||||
|
||||
interface JQuery {
|
||||
datepicker(): JQuery;
|
||||
datepicker(methodName: string): JQuery;
|
||||
datepicker(methodName: string, params: any): JQuery;
|
||||
datepicker(options: DatepickerOptions): JQuery;
|
||||
}
|
||||
Reference in New Issue
Block a user