This repository has been archived by the owner on Aug 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Fengyuan Chen
committed
Oct 18, 2015
1 parent
daa926e
commit fea995c
Showing
34 changed files
with
443 additions
and
119 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.container { | ||
max-width: 640px; | ||
margin: 20px auto; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Test Datepicker's events</title> | ||
<link rel="stylesheet" href="../assets/css/qunit.css"> | ||
<link rel="stylesheet" href="../dist/datepicker.css"> | ||
<link rel="stylesheet" href="css/main.css"> | ||
</head> | ||
<body> | ||
<div id="qunit"></div> | ||
<div id="qunit-fixture"></div> | ||
<script src="../assets/js/qunit.js"></script> | ||
<script src="../assets/js/jquery.min.js"></script> | ||
<script src="../dist/datepicker.js"></script> | ||
<script src="js/main.js"></script> | ||
<script src="events/show.js"></script> | ||
<script src="events/hide.js"></script> | ||
<script src="events/pick.js"></script> | ||
</body> | ||
</html> |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
$(function () { | ||
var $input = window.createInput(); | ||
|
||
$input.on('hide.datepicker', function (e) { | ||
QUnit.test('events.hide', function (assert) { | ||
assert.equal(e.type, 'hide'); | ||
assert.equal(e.namespace, 'datepicker'); | ||
}); | ||
}).datepicker({ | ||
hide: function (e) { | ||
QUnit.test('options.hide', function (assert) { | ||
assert.equal(e.type, 'hide'); | ||
assert.equal(e.namespace, 'datepicker'); | ||
}); | ||
} | ||
}).datepicker('show').datepicker('hide'); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
$(function () { | ||
var $input = window.createInput(); | ||
var initialDate = new Date(2014, 1, 14); | ||
|
||
$input.on('pick.datepicker', function (e) { | ||
QUnit.test('events.pick', function (assert) { | ||
assert.equal(e.type, 'pick'); | ||
assert.equal(e.namespace, 'datepicker'); | ||
assert.equal(e.date.getTime(), initialDate.getTime()); | ||
assert.equal(e.view, ''); | ||
}); | ||
}).datepicker({ | ||
date: initialDate, | ||
|
||
pick: function (e) { | ||
QUnit.test('options.pick', function (assert) { | ||
assert.equal(e.type, 'pick'); | ||
assert.equal(e.namespace, 'datepicker'); | ||
assert.equal(e.date.getTime(), initialDate.getTime()); | ||
assert.equal(e.view, ''); | ||
}); | ||
} | ||
}).datepicker('pick'); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
$(function () { | ||
var $input = window.createInput(); | ||
|
||
$input.on('show.datepicker', function (e) { | ||
QUnit.test('events.show', function (assert) { | ||
assert.equal(e.type, 'show'); | ||
assert.equal(e.namespace, 'datepicker'); | ||
}); | ||
}).datepicker({ | ||
show: function (e) { | ||
QUnit.test('options.show', function (assert) { | ||
assert.equal(e.type, 'show'); | ||
assert.equal(e.namespace, 'datepicker'); | ||
}); | ||
} | ||
}).datepicker('show').datepicker('hide'); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
window.createContainer = function () { | ||
var $container = $('<div class="container">'); | ||
|
||
$container.appendTo(document.body); | ||
|
||
return $container; | ||
}; | ||
|
||
window.createInput = function (attrs) { | ||
var $input = $('<input type="text">'); | ||
|
||
if (typeof attrs === 'object') { | ||
$input.attr(attrs); | ||
} | ||
|
||
window.createContainer().append($input); | ||
|
||
return $input; | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Test Datepicker's methods</title> | ||
<link rel="stylesheet" href="../assets/css/qunit.css"> | ||
<link rel="stylesheet" href="../dist/datepicker.css"> | ||
<link rel="stylesheet" href="css/main.css"> | ||
</head> | ||
<body> | ||
<div id="qunit"></div> | ||
<div id="qunit-fixture"></div> | ||
<script src="../assets/js/qunit.js"></script> | ||
<script src="../assets/js/jquery.min.js"></script> | ||
<script src="../dist/datepicker.js"></script> | ||
<script src="js/main.js"></script> | ||
<script src="methods/show.js"></script> | ||
<script src="methods/hide.js"></script> | ||
<script src="methods/pick.js"></script> | ||
<script src="methods/update.js"></script> | ||
<script src="methods/reset.js"></script> | ||
<script src="methods/getMonthName.js"></script> | ||
<script src="methods/getDayName.js"></script> | ||
<script src="methods/getDate.js"></script> | ||
<script src="methods/setDate.js"></script> | ||
<script src="methods/setStartDate.js"></script> | ||
<script src="methods/setEndDate.js"></script> | ||
<script src="methods/parseDate.js"></script> | ||
<script src="methods/formatDate.js"></script> | ||
<script src="methods/destroy.js"></script> | ||
</body> | ||
</html> |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
QUnit.test('method.destroy', function (assert) { | ||
var $input = window.createInput(); | ||
|
||
$input.datepicker(); | ||
assert.ok(typeof $input.data('datepicker') === 'object'); | ||
$input.datepicker('destroy'); | ||
assert.ok(typeof $input.data('datepicker') === 'undefined'); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
QUnit.test('method.formatDate', function (assert) { | ||
var $input = window.createInput(); | ||
|
||
assert.equal($input.datepicker('formatDate', new Date(2014, 1, 14)), '02/14/2014'); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
QUnit.test('method.getDate', function (assert) { | ||
var $input = window.createInput(); | ||
var initialDate = new Date(2014, 1, 14); | ||
var initialDateString = '02/14/2014'; | ||
|
||
$input.datepicker({ | ||
date: initialDate | ||
}); | ||
|
||
assert.equal($input.datepicker('getDate').getTime(), initialDate.getTime()); | ||
assert.equal($input.datepicker('getDate', true), initialDateString); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
QUnit.test('method.getDayName', function (assert) { | ||
var $input = window.createInput(); | ||
var options = $input.datepicker().data('datepicker').options; | ||
var day = $input.datepicker('getDate').getDay(); | ||
|
||
assert.equal($input.datepicker('getDayName'), options.days[day]); | ||
assert.equal($input.datepicker('getDayName', true), options.daysShort[day]); | ||
assert.equal($input.datepicker('getDayName', true, true), options.daysMin[day]); | ||
assert.equal($input.datepicker('getDayName', false, true), options.daysMin[day]); | ||
assert.equal($input.datepicker('getDayName', 0), options.days[0]); | ||
assert.equal($input.datepicker('getDayName', 0, true), options.daysShort[0]); | ||
assert.equal($input.datepicker('getDayName', 0, true, true), options.daysMin[0]); | ||
assert.equal($input.datepicker('getDayName', 0, false, true), options.daysMin[0]); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
QUnit.test('method.getMonthName', function (assert) { | ||
var $input = window.createInput(); | ||
var options = $input.datepicker().data('datepicker').options; | ||
var month = $input.datepicker('getDate').getMonth(); | ||
|
||
assert.equal($input.datepicker('getMonthName'), options.months[month]); | ||
assert.equal($input.datepicker('getMonthName', true), options.monthsShort[month]); | ||
assert.equal($input.datepicker('getMonthName', 0), options.months[0]); | ||
assert.equal($input.datepicker('getMonthName', 0, true), options.monthsShort[0]); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
QUnit.test('method.hide', function (assert) { | ||
var $input = window.createInput(); | ||
var datepicker = $input.datepicker().data('datepicker'); | ||
|
||
$input.datepicker('show'); | ||
assert.ok(datepicker.isShown); | ||
$input.datepicker('hide'); | ||
assert.ok(!datepicker.isShown); | ||
assert.ok(datepicker.$picker.is(':hidden')); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
QUnit.test('method.parseDate', function (assert) { | ||
var $input = window.createInput(); | ||
|
||
assert.equal($input.datepicker('parseDate', '02/14/2014').getTime(), new Date(2014, 1, 14).getTime()); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
QUnit.test('method.pick', function (assert) { | ||
var $input = window.createInput(); | ||
|
||
assert.equal($input.val(), ''); | ||
$input.datepicker('pick'); | ||
assert.equal($input.val(), $input.datepicker('getDate', true)); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
QUnit.test('method.reset', function (assert) { | ||
var initialValue = '02/14/2014'; | ||
var $input = window.createInput({ | ||
value: initialValue | ||
}); | ||
|
||
$input.datepicker('show'); | ||
$input.datepicker('setDate', '02/28/2014'); | ||
$input.datepicker('reset'); | ||
assert.equal($input.datepicker('getDate', true), initialValue); | ||
$input.datepicker('hide'); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
QUnit.test('method.setDate', function (assert) { | ||
var $input = window.createInput(); | ||
var initialDate = new Date(2014, 1, 14); | ||
var initialDate2 = '02/28/2015'; | ||
|
||
$input.datepicker('setDate', initialDate); | ||
assert.equal($input.datepicker('getDate').getTime(), initialDate.getTime()); | ||
|
||
$input.datepicker('setDate', initialDate2); | ||
assert.equal($input.datepicker('getDate', true), initialDate2); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
QUnit.test('method.setEndDate', function (assert) { | ||
var $input = window.createInput(); | ||
var initialDate = new Date(2014, 1, 14); | ||
|
||
$input.datepicker('setEndDate', initialDate); | ||
assert.equal($input.data('datepicker').endDate.getTime(), initialDate.getTime()); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
QUnit.test('method.setStartDate', function (assert) { | ||
var $input = window.createInput(); | ||
var initialDate = new Date(2014, 1, 14); | ||
|
||
$input.datepicker('setStartDate', initialDate); | ||
assert.equal($input.data('datepicker').startDate.getTime(), initialDate.getTime()); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
QUnit.test('method.show', function (assert) { | ||
var $input = window.createInput(); | ||
var datepicker = $input.datepicker().data('datepicker'); | ||
|
||
assert.ok(!datepicker.isShown); | ||
$input.datepicker('show'); | ||
assert.ok(datepicker.isShown); | ||
assert.ok(datepicker.$picker.is(':visible')); | ||
$input.datepicker('hide'); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
QUnit.test('method.update', function (assert) { | ||
var $input = window.createInput(); | ||
var datepicker = $input.datepicker().data('datepicker'); | ||
var val = '02/14/2014'; | ||
|
||
$input.val(val); | ||
$input.datepicker('update'); | ||
assert.equal($input.datepicker('getDate', true), val); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Test Datepicker's options</title> | ||
<link rel="stylesheet" href="../assets/css/qunit.css"> | ||
<link rel="stylesheet" href="../dist/datepicker.css"> | ||
<link rel="stylesheet" href="css/main.css"> | ||
</head> | ||
<body> | ||
<div id="qunit"></div> | ||
<div id="qunit-fixture"></div> | ||
<script src="../assets/js/qunit.js"></script> | ||
<script src="../assets/js/jquery.min.js"></script> | ||
<script src="../dist/datepicker.js"></script> | ||
<script src="js/main.js"></script> | ||
<script src="options/autoshow.js"></script> | ||
<script src="options/autohide.js"></script> | ||
<script src="options/autopick.js"></script> | ||
<script src="options/inline.js"></script> | ||
<script src="options/format.js"></script> | ||
<script src="options/date.js"></script> | ||
<script src="options/startDate.js"></script> | ||
<script src="options/endDate.js"></script> | ||
<script src="options/startView.js"></script> | ||
<script src="options/filter.js"></script> | ||
</body> | ||
</html> |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
QUnit.test('options.autohide', function (assert) { | ||
var $input = window.createInput(); | ||
var datepicker = $input.datepicker({ | ||
autohide: true | ||
}).data('datepicker'); | ||
|
||
$input.datepicker('show'); | ||
datepicker.$days.children().eq(20).click(); | ||
assert.ok(datepicker.$picker.is(':hidden')); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
QUnit.test('options.autopick', function (assert) { | ||
var $input = window.createInput(); | ||
|
||
$input.datepicker({ | ||
autopick: true | ||
}); | ||
|
||
assert.equal($input.val(), $input.datepicker('getDate', true)); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
QUnit.test('options.autoshow', function (assert) { | ||
var $input = window.createInput(); | ||
var datepicker = $input.datepicker({ | ||
autoshow: true | ||
}).data('datepicker'); | ||
|
||
assert.ok(datepicker.$picker.is(':visible')); | ||
$input.datepicker('hide'); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
QUnit.test('options.date: Date', function (assert) { | ||
var $input = window.createInput(); | ||
var initialDate = new Date(2014, 1, 14); | ||
|
||
$input.datepicker({ | ||
date: initialDate | ||
}); | ||
|
||
assert.equal($input.datepicker('getDate').getTime(), initialDate.getTime()); | ||
}); | ||
|
||
QUnit.test('options.date: String', function (assert) { | ||
var $input = window.createInput(); | ||
var initialDate = '02/14/2014'; | ||
|
||
$input.datepicker({ | ||
date: initialDate | ||
}); | ||
|
||
assert.equal($input.datepicker('getDate', true), initialDate); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
QUnit.test('options.endDate', function (assert) { | ||
var $input = window.createInput(); | ||
var endDate = new Date(2014, 1, 14); | ||
|
||
$input.datepicker({ | ||
endDate: endDate | ||
}); | ||
|
||
assert.ok($input.datepicker('getDate').getTime() <= endDate.getTime()); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
QUnit.test('options.filter', function (assert) { | ||
var $input = window.createInput(); | ||
var datepicker = $input.datepicker({ | ||
filter: function (date) { | ||
|
||
// Disable all Sundays | ||
if (date.getDay() === 0) { | ||
return false; | ||
} | ||
} | ||
}).data('datepicker'); | ||
|
||
$input.datepicker('show'); | ||
|
||
datepicker.$days.children().each(function (i) { | ||
if (i % 7 === 0) { | ||
assert.ok($(this).hasClass(datepicker.options.disabledClass)); | ||
} | ||
}); | ||
|
||
$input.datepicker('hide'); | ||
}); |
Oops, something went wrong.