Add: datepicker for Bootstrap
This commit is contained in:
Executable
+2
@@ -0,0 +1,2 @@
|
||||
instrumented/
|
||||
tests/coverage.html
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
instrumented/
|
||||
tests/coverage.html
|
||||
Executable
+202
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
Executable
+402
@@ -0,0 +1,402 @@
|
||||
## This fork was created for *inline* version of datepicker and currently merged into upstream https://github.com/eternicode/bootstrap-datepicker.
|
||||
Please use original repo for pull requests, thanks!
|
||||
|
||||
# Home
|
||||
|
||||
This is a fork of Stefan Petre's [original code](http://www.eyecon.ro/bootstrap-datepicker/);
|
||||
thanks go to him for getting this thing started!
|
||||
|
||||
Please note that this fork is not used on Stefan's page at this time, nor is it maintained or
|
||||
contributed to by him (yet?)
|
||||
|
||||
# Example
|
||||
|
||||
Attached to a field with the format specified via options:
|
||||
|
||||
```html
|
||||
<input type="text" value="02-16-2012" id="datepicker">
|
||||
```
|
||||
```javascript
|
||||
$('#datepicker').datepicker({
|
||||
format: 'mm-dd-yyyy'
|
||||
});
|
||||
```
|
||||
|
||||
Attached to a field with the format specified via data tag:
|
||||
|
||||
```html
|
||||
<input type="text" value="02/16/12" data-date-format="mm/dd/yy" id="datepicker" >
|
||||
```
|
||||
```javascript
|
||||
$('#datepicker').datepicker();
|
||||
```
|
||||
|
||||
As component:
|
||||
|
||||
```html
|
||||
<div class="input-append date" id="datepicker" data-date="12-02-2012" data-date-format="dd-mm-yyyy">
|
||||
<input size="16" type="text" value="12-02-2012" readonly>
|
||||
<span class="add-on"><i class="icon-th"></i></span>
|
||||
</div>
|
||||
```
|
||||
```javascript
|
||||
$('#datepicker').datepicker();
|
||||
```
|
||||
|
||||
Attached to non-field element, using events to work with the date values.
|
||||
|
||||
```html
|
||||
<div class="alert alert-error" id="alert">
|
||||
<strong>Oh snap!</strong>
|
||||
</div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Start date
|
||||
<a href="#" class="btn small" id="date-start" data-date-format="yyyy-mm-dd" data-date="2012-02-20">Change</a>
|
||||
</th>
|
||||
<th>
|
||||
End date
|
||||
<a href="#" class="btn small" id="date-end" data-date-format="yyyy-mm-dd" data-date="2012-02-25">Change</a>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td id="date-start-display">2012-02-20</td>
|
||||
<td id="date-end-display">2012-02-25</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
```
|
||||
```javascript
|
||||
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');
|
||||
});
|
||||
```
|
||||
|
||||
As inline datepicker:
|
||||
|
||||
```html
|
||||
<div id="datepicker"></div>
|
||||
```
|
||||
```javascript
|
||||
$('#datepicker').datepicker();
|
||||
```
|
||||
|
||||
|
||||
# Using bootstrap-datepicker.js
|
||||
|
||||
Call the datepicker via javascript:
|
||||
|
||||
```javascript
|
||||
$('#datepicker').datepicker()
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
Requires bootstrap's dropdown component (`dropdowns.less`) for some styles, and bootstrap's sprites (`sprites.less` and associated images) for arrows.
|
||||
|
||||
A standalone .css file (including necessary dropdown styles and alternative, text-based arrows) can be generated by running `build/build_standalone.less` through the `lessc` compiler:
|
||||
|
||||
```bash
|
||||
$ lessc build/build_standalone.less datepicker.css
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
All options that take a "Date" can handle a `Date` object; a String formatted according to the given `format`; or a timedelta relative to today, eg '-1d', '+6m +1y', etc, where valid units are 'd' (day), 'w' (week), 'm' (month), and 'y' (year).
|
||||
|
||||
### format
|
||||
|
||||
String. Default: 'mm/dd/yyyy'
|
||||
|
||||
The date format, combination of d, dd, D, DD, m, mm, M, MM, yy, yyyy.
|
||||
|
||||
* d, dd: Numeric date, no leading zero and leading zero, respectively. Eg, 5, 05.
|
||||
* D, DD: Abbreviated and full weekday names, respectively. Eg, Mon, Monday.
|
||||
* m, mm: Numeric month, no leading zero and leading zero, respectively. Eg, 7, 07.
|
||||
* M, MM: Abbreviated and full month names, respectively. Eg, Jan, January
|
||||
* yy, yyyy: 2- and 4-digit years, respectively. Eg, 12, 2012.
|
||||
|
||||
### weekStart
|
||||
|
||||
Integer. Default: 0
|
||||
|
||||
Day of the week start. 0 (Sunday) to 6 (Saturday)
|
||||
|
||||
### startDate
|
||||
|
||||
Date. Default: Beginning of time
|
||||
|
||||
The earliest date that may be selected; all earlier dates will be disabled.
|
||||
|
||||
### endDate
|
||||
|
||||
Date. Default: End of time
|
||||
|
||||
The latest date that may be selected; all later dates will be disabled.
|
||||
|
||||
### daysOfWeekDisabled
|
||||
|
||||
String, Array. Default: '', []
|
||||
|
||||
Days of the week that should be disabled. Values are 0 (Sunday) to 6 (Saturday). Multiple values should be comma-separated. Example: disable weekends: `'0,6'` or `[0,6]`.
|
||||
|
||||
### autoclose
|
||||
|
||||
Boolean. Default: false
|
||||
|
||||
Whether or not to close the datepicker immediately when a date is selected.
|
||||
|
||||
### startView
|
||||
|
||||
Number, String. Default: 0, 'month'
|
||||
|
||||
The view that the datepicker should show when it is opened. Accepts values of 0 or 'month' for month view (the default), 1 or 'year' for the 12-month overview, and 2 or 'decade' for the 10-year overview. Useful for date-of-birth datepickers.
|
||||
|
||||
### todayBtn
|
||||
|
||||
Boolean, "linked". Default: false
|
||||
|
||||
If true or "linked", displays a "Today" button at the bottom of the datepicker to select the current date. If true, the "Today" button will only move the current date into view; if "linked", the current date will also be selected.
|
||||
|
||||
### todayHighlight
|
||||
|
||||
Boolean. Default: false
|
||||
|
||||
If true, highlights the current date.
|
||||
|
||||
### keyboardNavigation
|
||||
|
||||
Boolean. Default: true
|
||||
|
||||
Whether or not to allow date navigation by arrow keys.
|
||||
|
||||
### language
|
||||
|
||||
String. Default: 'en'
|
||||
|
||||
The two-letter code of the language to use for month and day names. These will also be used as the input's value (and subsequently sent to the server in the case of form submissions). If an unknown language code is given, English will be used. See I18N below.
|
||||
|
||||
### forceParse
|
||||
|
||||
Boolean. Default: true
|
||||
|
||||
Whether or not to force parsing of the input value when the picker is closed. That is, when an invalid date is left in the input field by the user, the picker will forcibly parse that value, and set the input's value to the new, valid date, conforming to the given `format`.
|
||||
|
||||
## Markup
|
||||
|
||||
Format a component.
|
||||
|
||||
```html
|
||||
<div class="input-append date" id="datepicker" data-date="12-02-2012" data-date-format="dd-mm-yyyy">
|
||||
<input class="span2" size="16" type="text" value="12-02-2012">
|
||||
<span class="add-on"><i class="icon-th"></i></span>
|
||||
</div>
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
### .datepicker(options)
|
||||
|
||||
Initializes an datepicker.
|
||||
|
||||
### remove
|
||||
|
||||
Arguments: None
|
||||
|
||||
Remove the datepicker. Removes attached events, internal attached objects, and
|
||||
added HTML elements.
|
||||
|
||||
$('#datepicker').datepicker('remove');
|
||||
|
||||
### show
|
||||
|
||||
Arguments: None
|
||||
|
||||
Show the datepicker.
|
||||
|
||||
```javascript
|
||||
$('#datepicker').datepicker('show');
|
||||
```
|
||||
|
||||
### hide
|
||||
|
||||
Arguments: None
|
||||
|
||||
Hide the datepicker.
|
||||
|
||||
```javascript
|
||||
$('#datepicker').datepicker('hide');
|
||||
```
|
||||
|
||||
### update
|
||||
|
||||
Arguments: None
|
||||
|
||||
Update the datepicker with the current input value.
|
||||
|
||||
```javascript
|
||||
$('#datepicker').datepicker('update');
|
||||
```
|
||||
|
||||
### setStartDate
|
||||
|
||||
Arguments:
|
||||
|
||||
* startDate (String)
|
||||
|
||||
Sets a new lower date limit on the datepicker.
|
||||
|
||||
```javascript
|
||||
$('#datepicker').datepicker('setStartDate', '2012-01-01');
|
||||
```
|
||||
|
||||
Omit startDate (or provide an otherwise falsey value) to unset the limit.
|
||||
|
||||
```javascript
|
||||
$('#datepicker').datepicker('setStartDate');
|
||||
$('#datepicker').datepicker('setStartDate', null);
|
||||
```
|
||||
|
||||
### setEndDate
|
||||
|
||||
Arguments:
|
||||
|
||||
* endDate (String)
|
||||
|
||||
Sets a new upper date limit on the datepicker.
|
||||
|
||||
```javascript
|
||||
$('#datepicker').datepicker('setEndDate', '2012-12-31');
|
||||
```
|
||||
|
||||
Omit endDate (or provide an otherwise falsey value) to unset the limit.
|
||||
|
||||
```javascript
|
||||
$('#datepicker').datepicker('setEndDate');
|
||||
$('#datepicker').datepicker('setEndDate', null);
|
||||
```
|
||||
|
||||
### setDaysOfWeekDisabled
|
||||
|
||||
Arguments:
|
||||
|
||||
* daysOfWeekDisabled (String|Array)
|
||||
|
||||
Sets the days of week that should be disabled.
|
||||
|
||||
```javascript
|
||||
$('#datepicker').datepicker('setDaysOfWeekDisabled', [0,6]);
|
||||
```
|
||||
|
||||
Omit daysOfWeekDisabled (or provide an otherwise falsey value) to unset the disabled days.
|
||||
|
||||
```javascript
|
||||
$('#datepicker').datepicker('setDaysOfWeekDisabled');
|
||||
$('#datepicker').datepicker('setDaysOfWeekDisabled', null);
|
||||
```
|
||||
|
||||
## Events
|
||||
|
||||
Datepicker class exposes a few events for manipulating the dates.
|
||||
|
||||
### show
|
||||
|
||||
Fired when the date picker is displayed.
|
||||
|
||||
### hide
|
||||
|
||||
Fired when the date picker is hidden.
|
||||
|
||||
### changeDate
|
||||
|
||||
Fired when the date is changed.
|
||||
|
||||
```javascript
|
||||
$('#date-end')
|
||||
.datepicker()
|
||||
.on('changeDate', function(ev){
|
||||
if (ev.date.valueOf() < date-start-display.valueOf()){
|
||||
....
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### changeYear
|
||||
|
||||
Fired when the *view* year is changed from decade view.
|
||||
|
||||
### changeMonth
|
||||
|
||||
Fired when the *view* month is changed from year view.
|
||||
|
||||
## Keyboard support
|
||||
|
||||
The datepicker includes some keyboard navigation:
|
||||
|
||||
### up, down, left, right arrow keys
|
||||
|
||||
By themselves, left/right will move backward/forward one day, up/down will move back/forward one week.
|
||||
|
||||
With the shift key, up/left will move backward one month, down/right will move forward one month.
|
||||
|
||||
With the ctrl key, up/left will move backward one year, down/right will move forward oone year.
|
||||
|
||||
Shift+ctrl behaves the same as ctrl -- that is, it does not change both month and year simultaneously, only the year.
|
||||
|
||||
### escape
|
||||
|
||||
The escape key can be used to hide and re-show the datepicker; this is necessary if the user wants to manually edit the value.
|
||||
|
||||
### enter
|
||||
|
||||
When the picker is visible, enter will simply hide it. When the picker is not visible, enter will have normal effects -- submitting the current form, etc.
|
||||
|
||||
## I18N
|
||||
|
||||
The plugin supports i18n for the month and weekday names and the `weekStart` option. The default is English ('en'); other available translations are avilable in the `js/locales/` directory, simply include your desired locale after the plugin. To add more languages, simply add a key to `$.fn.datepicker.dates`, before calling `.datepicker()`. Example:
|
||||
|
||||
```javascript
|
||||
$.fn.datepicker.dates['en'] = {
|
||||
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
|
||||
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
|
||||
daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
|
||||
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
||||
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
||||
today: "Today"
|
||||
};
|
||||
```
|
||||
|
||||
Right-to-left languages may also include `rtl: true` to make the calendar display appropriately.
|
||||
|
||||
If your browser (or those of your users) is displaying characters wrong, chances are the browser is loading the javascript file with a non-unicode encoding. Simply add `charset="UTF-8"` to your `script` tag:
|
||||
|
||||
```html
|
||||
<script type="text/javascript" src="bootstrap-datepicker.XX.js" charset="UTF-8"></script>
|
||||
```
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
// Datepicker .less buildfile. Includes select mixins/variables from bootstrap
|
||||
// and imports the included datepicker.less to output a minimal datepicker.css
|
||||
//
|
||||
// Usage:
|
||||
// lessc build.less datepicker.css
|
||||
//
|
||||
// Variables and mixins copied from bootstrap 2.0.2
|
||||
|
||||
// Variables
|
||||
@grayLight: #999;
|
||||
@grayLighter: #eee;
|
||||
@white: #fff;
|
||||
@linkColor: #08c;
|
||||
@btnPrimaryBackground: @linkColor;
|
||||
@orange: #f89406;
|
||||
|
||||
// Mixins
|
||||
|
||||
// Border Radius
|
||||
.border-radius(@radius: 5px) {
|
||||
-webkit-border-radius: @radius;
|
||||
-moz-border-radius: @radius;
|
||||
border-radius: @radius;
|
||||
}
|
||||
|
||||
// Button backgrounds
|
||||
.buttonBackground(@startColor, @endColor) {
|
||||
.gradientBar(@startColor, @endColor);
|
||||
.reset-filter();
|
||||
&:hover, &:active, &.active, &.disabled, &[disabled] {
|
||||
background-color: @endColor;
|
||||
}
|
||||
&:active,
|
||||
&.active {
|
||||
background-color: darken(@endColor, 10%) e("\9");
|
||||
}
|
||||
}
|
||||
|
||||
// Reset filters for IE
|
||||
.reset-filter() {
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
|
||||
}
|
||||
|
||||
// Gradient Bar Colors for buttons and alerts
|
||||
.gradientBar(@primaryColor, @secondaryColor) {
|
||||
#gradient > .vertical(@primaryColor, @secondaryColor);
|
||||
border-color: @secondaryColor @secondaryColor darken(@secondaryColor, 15%);
|
||||
border-color: rgba(0,0,0,.1) rgba(0,0,0,.1) fadein(rgba(0,0,0,.1), 15%);
|
||||
}
|
||||
|
||||
// Gradients
|
||||
#gradient {
|
||||
.vertical(@startColor: #555, @endColor: #333) {
|
||||
background-color: mix(@startColor, @endColor, 60%);
|
||||
background-image: -moz-linear-gradient(top, @startColor, @endColor); // FF 3.6+
|
||||
background-image: -ms-linear-gradient(top, @startColor, @endColor); // IE10
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@startColor), to(@endColor)); // Safari 4+, Chrome 2+
|
||||
background-image: -webkit-linear-gradient(top, @startColor, @endColor); // Safari 5.1+, Chrome 10+
|
||||
background-image: -o-linear-gradient(top, @startColor, @endColor); // Opera 11.10
|
||||
background-image: linear-gradient(top, @startColor, @endColor); // The standard
|
||||
background-repeat: repeat-x;
|
||||
filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",@startColor,@endColor)); // IE9 and down
|
||||
}
|
||||
}
|
||||
|
||||
@import "../less/datepicker.less";
|
||||
@@ -0,0 +1,69 @@
|
||||
// Datepicker standalone .less buildfile. Includes all necessary mixins/variables/rules from bootstrap
|
||||
// and imports the included datepicker.less to output a minimal standalone datepicker.css
|
||||
//
|
||||
// Usage:
|
||||
// lessc build_standalone.less datepicker.css
|
||||
//
|
||||
// Variables, mixins, and rules copied from bootstrap 2.0.2
|
||||
|
||||
@import "build.less";
|
||||
|
||||
// Dropdown css
|
||||
|
||||
@zindexDropdown: 1000;
|
||||
@grayDark: #333;
|
||||
@baseLineHeight: 18px;
|
||||
@tableBackground: transparent; // overall background-color
|
||||
@dropdownBackground: @white;
|
||||
@dropdownBorder: rgba(0,0,0,.2);
|
||||
@dropdownLinkColor: @grayDark;
|
||||
@dropdownLinkColorHover: @white;
|
||||
@dropdownLinkBackgroundHover: @linkColor;
|
||||
|
||||
// Drop shadows
|
||||
.box-shadow(@shadow) {
|
||||
-webkit-box-shadow: @shadow;
|
||||
-moz-box-shadow: @shadow;
|
||||
box-shadow: @shadow;
|
||||
}
|
||||
|
||||
// The dropdown menu (ul)
|
||||
// ----------------------
|
||||
.datepicker.dropdown-menu {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
left: 0;
|
||||
z-index: @zindexDropdown;
|
||||
float: left;
|
||||
display: none; // none by default, but block on "open" of the menu
|
||||
min-width: 160px;
|
||||
list-style: none;
|
||||
background-color: @dropdownBackground;
|
||||
border: 1px solid #ccc;
|
||||
border: 1px solid rgba(0,0,0,.2);
|
||||
.border-radius(5px);
|
||||
.box-shadow(0 5px 10px rgba(0,0,0,.2));
|
||||
-webkit-background-clip: padding-box;
|
||||
-moz-background-clip: padding;
|
||||
background-clip: padding-box;
|
||||
*border-right-width: 2px;
|
||||
*border-bottom-width: 2px;
|
||||
|
||||
// Normally inherited from bootstrap's `body`
|
||||
color: #333333;
|
||||
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
|
||||
font-size:13px;
|
||||
line-height: @baseLineHeight;
|
||||
|
||||
th, td {
|
||||
padding: 4px 5px;
|
||||
}
|
||||
}
|
||||
|
||||
// Alternative arrows
|
||||
// May require `charset="UTF-8"` in your `<link>` tag
|
||||
.datepicker {
|
||||
.prev, .next {font-style:normal;}
|
||||
.prev:after {content:"«";}
|
||||
.next:after {content:"»";}
|
||||
}
|
||||
+291
@@ -0,0 +1,291 @@
|
||||
/*!
|
||||
* Datepicker for Bootstrap
|
||||
*
|
||||
* Copyright 2012 Stefan Petre
|
||||
* Improvements by Andrew Rowls
|
||||
* Licensed under the Apache License v2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*/
|
||||
.datepicker {
|
||||
padding: 4px;
|
||||
margin-top: 1px;
|
||||
-webkit-border-radius: 4px;
|
||||
-moz-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
direction: ltr;
|
||||
/*.dow {
|
||||
border-top: 1px solid #ddd !important;
|
||||
}*/
|
||||
|
||||
}
|
||||
.datepicker-inline {
|
||||
width: 220px;
|
||||
}
|
||||
.datepicker.datepicker-rtl {
|
||||
direction: rtl;
|
||||
}
|
||||
.datepicker.datepicker-rtl table tr td span {
|
||||
float: right;
|
||||
}
|
||||
.datepicker-dropdown {
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
.datepicker-dropdown:before {
|
||||
content: '';
|
||||
display: inline-block;
|
||||
border-left: 7px solid transparent;
|
||||
border-right: 7px solid transparent;
|
||||
border-bottom: 7px solid #ccc;
|
||||
border-bottom-color: rgba(0, 0, 0, 0.2);
|
||||
position: absolute;
|
||||
top: -7px;
|
||||
left: 6px;
|
||||
}
|
||||
.datepicker-dropdown:after {
|
||||
content: '';
|
||||
display: inline-block;
|
||||
border-left: 6px solid transparent;
|
||||
border-right: 6px solid transparent;
|
||||
border-bottom: 6px solid #ffffff;
|
||||
position: absolute;
|
||||
top: -6px;
|
||||
left: 7px;
|
||||
}
|
||||
.datepicker > div {
|
||||
display: none;
|
||||
}
|
||||
.datepicker.days div.datepicker-days {
|
||||
display: block;
|
||||
}
|
||||
.datepicker.months div.datepicker-months {
|
||||
display: block;
|
||||
}
|
||||
.datepicker.years div.datepicker-years {
|
||||
display: block;
|
||||
}
|
||||
.datepicker table {
|
||||
margin: 0;
|
||||
}
|
||||
.datepicker td,
|
||||
.datepicker th {
|
||||
text-align: center;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
-webkit-border-radius: 4px;
|
||||
-moz-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
border: none;
|
||||
}
|
||||
.table-striped .datepicker table tr td,
|
||||
.table-striped .datepicker table tr th {
|
||||
background-color: transparent;
|
||||
}
|
||||
.datepicker table tr td.day:hover {
|
||||
background: #eeeeee;
|
||||
cursor: pointer;
|
||||
}
|
||||
.datepicker table tr td.old,
|
||||
.datepicker table tr td.new {
|
||||
color: #999999;
|
||||
}
|
||||
.datepicker table tr td.disabled,
|
||||
.datepicker table tr td.disabled:hover {
|
||||
background: none;
|
||||
color: #999999;
|
||||
cursor: default;
|
||||
}
|
||||
.datepicker table tr td.today,
|
||||
.datepicker table tr td.today:hover,
|
||||
.datepicker table tr td.today.disabled,
|
||||
.datepicker table tr td.today.disabled:hover {
|
||||
background-color: #fde19a;
|
||||
background-image: -moz-linear-gradient(top, #fdd49a, #fdf59a);
|
||||
background-image: -ms-linear-gradient(top, #fdd49a, #fdf59a);
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fdd49a), to(#fdf59a));
|
||||
background-image: -webkit-linear-gradient(top, #fdd49a, #fdf59a);
|
||||
background-image: -o-linear-gradient(top, #fdd49a, #fdf59a);
|
||||
background-image: linear-gradient(top, #fdd49a, #fdf59a);
|
||||
background-repeat: repeat-x;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fdd49a', endColorstr='#fdf59a', GradientType=0);
|
||||
border-color: #fdf59a #fdf59a #fbed50;
|
||||
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
|
||||
}
|
||||
.datepicker table tr td.today:hover,
|
||||
.datepicker table tr td.today:hover:hover,
|
||||
.datepicker table tr td.today.disabled:hover,
|
||||
.datepicker table tr td.today.disabled:hover:hover,
|
||||
.datepicker table tr td.today:active,
|
||||
.datepicker table tr td.today:hover:active,
|
||||
.datepicker table tr td.today.disabled:active,
|
||||
.datepicker table tr td.today.disabled:hover:active,
|
||||
.datepicker table tr td.today.active,
|
||||
.datepicker table tr td.today:hover.active,
|
||||
.datepicker table tr td.today.disabled.active,
|
||||
.datepicker table tr td.today.disabled:hover.active,
|
||||
.datepicker table tr td.today.disabled,
|
||||
.datepicker table tr td.today:hover.disabled,
|
||||
.datepicker table tr td.today.disabled.disabled,
|
||||
.datepicker table tr td.today.disabled:hover.disabled,
|
||||
.datepicker table tr td.today[disabled],
|
||||
.datepicker table tr td.today:hover[disabled],
|
||||
.datepicker table tr td.today.disabled[disabled],
|
||||
.datepicker table tr td.today.disabled:hover[disabled] {
|
||||
background-color: #fdf59a;
|
||||
}
|
||||
.datepicker table tr td.today:active,
|
||||
.datepicker table tr td.today:hover:active,
|
||||
.datepicker table tr td.today.disabled:active,
|
||||
.datepicker table tr td.today.disabled:hover:active,
|
||||
.datepicker table tr td.today.active,
|
||||
.datepicker table tr td.today:hover.active,
|
||||
.datepicker table tr td.today.disabled.active,
|
||||
.datepicker table tr td.today.disabled:hover.active {
|
||||
background-color: #fbf069 \9;
|
||||
}
|
||||
.datepicker table tr td.active,
|
||||
.datepicker table tr td.active:hover,
|
||||
.datepicker table tr td.active.disabled,
|
||||
.datepicker table tr td.active.disabled:hover {
|
||||
background-color: #006dcc;
|
||||
background-image: -moz-linear-gradient(top, #0088cc, #0044cc);
|
||||
background-image: -ms-linear-gradient(top, #0088cc, #0044cc);
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc));
|
||||
background-image: -webkit-linear-gradient(top, #0088cc, #0044cc);
|
||||
background-image: -o-linear-gradient(top, #0088cc, #0044cc);
|
||||
background-image: linear-gradient(top, #0088cc, #0044cc);
|
||||
background-repeat: repeat-x;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0088cc', endColorstr='#0044cc', GradientType=0);
|
||||
border-color: #0044cc #0044cc #002a80;
|
||||
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
|
||||
color: #fff;
|
||||
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
.datepicker table tr td.active:hover,
|
||||
.datepicker table tr td.active:hover:hover,
|
||||
.datepicker table tr td.active.disabled:hover,
|
||||
.datepicker table tr td.active.disabled:hover:hover,
|
||||
.datepicker table tr td.active:active,
|
||||
.datepicker table tr td.active:hover:active,
|
||||
.datepicker table tr td.active.disabled:active,
|
||||
.datepicker table tr td.active.disabled:hover:active,
|
||||
.datepicker table tr td.active.active,
|
||||
.datepicker table tr td.active:hover.active,
|
||||
.datepicker table tr td.active.disabled.active,
|
||||
.datepicker table tr td.active.disabled:hover.active,
|
||||
.datepicker table tr td.active.disabled,
|
||||
.datepicker table tr td.active:hover.disabled,
|
||||
.datepicker table tr td.active.disabled.disabled,
|
||||
.datepicker table tr td.active.disabled:hover.disabled,
|
||||
.datepicker table tr td.active[disabled],
|
||||
.datepicker table tr td.active:hover[disabled],
|
||||
.datepicker table tr td.active.disabled[disabled],
|
||||
.datepicker table tr td.active.disabled:hover[disabled] {
|
||||
background-color: #0044cc;
|
||||
}
|
||||
.datepicker table tr td.active:active,
|
||||
.datepicker table tr td.active:hover:active,
|
||||
.datepicker table tr td.active.disabled:active,
|
||||
.datepicker table tr td.active.disabled:hover:active,
|
||||
.datepicker table tr td.active.active,
|
||||
.datepicker table tr td.active:hover.active,
|
||||
.datepicker table tr td.active.disabled.active,
|
||||
.datepicker table tr td.active.disabled:hover.active {
|
||||
background-color: #003399 \9;
|
||||
}
|
||||
.datepicker table tr td span {
|
||||
display: block;
|
||||
width: 23%;
|
||||
height: 54px;
|
||||
line-height: 54px;
|
||||
float: left;
|
||||
margin: 1%;
|
||||
cursor: pointer;
|
||||
-webkit-border-radius: 4px;
|
||||
-moz-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.datepicker table tr td span:hover {
|
||||
background: #eeeeee;
|
||||
}
|
||||
.datepicker table tr td span.disabled,
|
||||
.datepicker table tr td span.disabled:hover {
|
||||
background: none;
|
||||
color: #999999;
|
||||
cursor: default;
|
||||
}
|
||||
.datepicker table tr td span.active,
|
||||
.datepicker table tr td span.active:hover,
|
||||
.datepicker table tr td span.active.disabled,
|
||||
.datepicker table tr td span.active.disabled:hover {
|
||||
background-color: #006dcc;
|
||||
background-image: -moz-linear-gradient(top, #0088cc, #0044cc);
|
||||
background-image: -ms-linear-gradient(top, #0088cc, #0044cc);
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc));
|
||||
background-image: -webkit-linear-gradient(top, #0088cc, #0044cc);
|
||||
background-image: -o-linear-gradient(top, #0088cc, #0044cc);
|
||||
background-image: linear-gradient(top, #0088cc, #0044cc);
|
||||
background-repeat: repeat-x;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0088cc', endColorstr='#0044cc', GradientType=0);
|
||||
border-color: #0044cc #0044cc #002a80;
|
||||
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
|
||||
color: #fff;
|
||||
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
.datepicker table tr td span.active:hover,
|
||||
.datepicker table tr td span.active:hover:hover,
|
||||
.datepicker table tr td span.active.disabled:hover,
|
||||
.datepicker table tr td span.active.disabled:hover:hover,
|
||||
.datepicker table tr td span.active:active,
|
||||
.datepicker table tr td span.active:hover:active,
|
||||
.datepicker table tr td span.active.disabled:active,
|
||||
.datepicker table tr td span.active.disabled:hover:active,
|
||||
.datepicker table tr td span.active.active,
|
||||
.datepicker table tr td span.active:hover.active,
|
||||
.datepicker table tr td span.active.disabled.active,
|
||||
.datepicker table tr td span.active.disabled:hover.active,
|
||||
.datepicker table tr td span.active.disabled,
|
||||
.datepicker table tr td span.active:hover.disabled,
|
||||
.datepicker table tr td span.active.disabled.disabled,
|
||||
.datepicker table tr td span.active.disabled:hover.disabled,
|
||||
.datepicker table tr td span.active[disabled],
|
||||
.datepicker table tr td span.active:hover[disabled],
|
||||
.datepicker table tr td span.active.disabled[disabled],
|
||||
.datepicker table tr td span.active.disabled:hover[disabled] {
|
||||
background-color: #0044cc;
|
||||
}
|
||||
.datepicker table tr td span.active:active,
|
||||
.datepicker table tr td span.active:hover:active,
|
||||
.datepicker table tr td span.active.disabled:active,
|
||||
.datepicker table tr td span.active.disabled:hover:active,
|
||||
.datepicker table tr td span.active.active,
|
||||
.datepicker table tr td span.active:hover.active,
|
||||
.datepicker table tr td span.active.disabled.active,
|
||||
.datepicker table tr td span.active.disabled:hover.active {
|
||||
background-color: #003399 \9;
|
||||
}
|
||||
.datepicker table tr td span.old {
|
||||
color: #999999;
|
||||
}
|
||||
.datepicker th.switch {
|
||||
width: 145px;
|
||||
}
|
||||
.datepicker thead tr:first-child th,
|
||||
.datepicker tfoot tr:first-child th {
|
||||
cursor: pointer;
|
||||
}
|
||||
.datepicker thead tr:first-child th:hover,
|
||||
.datepicker tfoot tr:first-child th:hover {
|
||||
background: #eeeeee;
|
||||
}
|
||||
.input-append.date .add-on i,
|
||||
.input-prepend.date .add-on i {
|
||||
display: block;
|
||||
cursor: pointer;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
+962
@@ -0,0 +1,962 @@
|
||||
/* =========================================================
|
||||
* bootstrap-datepicker.js
|
||||
* http://www.eyecon.ro/bootstrap-datepicker
|
||||
* =========================================================
|
||||
* Copyright 2012 Stefan Petre
|
||||
* Improvements by Andrew Rowls
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ========================================================= */
|
||||
|
||||
!function( $ ) {
|
||||
|
||||
function UTCDate(){
|
||||
return new Date(Date.UTC.apply(Date, arguments));
|
||||
}
|
||||
function UTCToday(){
|
||||
var today = new Date();
|
||||
return UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
|
||||
}
|
||||
|
||||
// Picker object
|
||||
|
||||
var Datepicker = function(element, options) {
|
||||
var that = this;
|
||||
|
||||
this.element = $(element);
|
||||
this.language = options.language||this.element.data('date-language')||"en";
|
||||
this.language = this.language in dates ? this.language : "en";
|
||||
this.isRTL = dates[this.language].rtl||false;
|
||||
this.format = DPGlobal.parseFormat(options.format||this.element.data('date-format')||'mm/dd/yyyy');
|
||||
this.isInline = false;
|
||||
this.isInput = this.element.is('input');
|
||||
this.component = this.element.is('.date') ? this.element.find('.add-on') : false;
|
||||
this.hasInput = this.component && this.element.find('input').length;
|
||||
if(this.component && this.component.length === 0)
|
||||
this.component = false;
|
||||
|
||||
this._attachEvents();
|
||||
|
||||
this.forceParse = true;
|
||||
if ('forceParse' in options) {
|
||||
this.forceParse = options.forceParse;
|
||||
} else if ('dateForceParse' in this.element.data()) {
|
||||
this.forceParse = this.element.data('date-force-parse');
|
||||
}
|
||||
|
||||
|
||||
this.picker = $(DPGlobal.template)
|
||||
.appendTo(this.isInline ? this.element : 'body')
|
||||
.on({
|
||||
click: $.proxy(this.click, this),
|
||||
mousedown: $.proxy(this.mousedown, this)
|
||||
});
|
||||
|
||||
if(this.isInline) {
|
||||
this.picker.addClass('datepicker-inline');
|
||||
} else {
|
||||
this.picker.addClass('datepicker-dropdown dropdown-menu');
|
||||
}
|
||||
if (this.isRTL){
|
||||
this.picker.addClass('datepicker-rtl');
|
||||
this.picker.find('.prev i, .next i')
|
||||
.toggleClass('icon-arrow-left icon-arrow-right');
|
||||
}
|
||||
$(document).on('mousedown', function (e) {
|
||||
// Clicked outside the datepicker, hide it
|
||||
if ($(e.target).closest('.datepicker').length === 0) {
|
||||
that.hide();
|
||||
}
|
||||
});
|
||||
|
||||
this.autoclose = false;
|
||||
if ('autoclose' in options) {
|
||||
this.autoclose = options.autoclose;
|
||||
} else if ('dateAutoclose' in this.element.data()) {
|
||||
this.autoclose = this.element.data('date-autoclose');
|
||||
}
|
||||
|
||||
this.keyboardNavigation = true;
|
||||
if ('keyboardNavigation' in options) {
|
||||
this.keyboardNavigation = options.keyboardNavigation;
|
||||
} else if ('dateKeyboardNavigation' in this.element.data()) {
|
||||
this.keyboardNavigation = this.element.data('date-keyboard-navigation');
|
||||
}
|
||||
|
||||
this.viewMode = this.startViewMode = 0;
|
||||
switch(options.startView || this.element.data('date-start-view')){
|
||||
case 2:
|
||||
case 'decade':
|
||||
this.viewMode = this.startViewMode = 2;
|
||||
break;
|
||||
case 1:
|
||||
case 'year':
|
||||
this.viewMode = this.startViewMode = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
this.todayBtn = (options.todayBtn||this.element.data('date-today-btn')||false);
|
||||
this.todayHighlight = (options.todayHighlight||this.element.data('date-today-highlight')||false);
|
||||
|
||||
this.weekStart = ((options.weekStart||this.element.data('date-weekstart')||dates[this.language].weekStart||0) % 7);
|
||||
this.weekEnd = ((this.weekStart + 6) % 7);
|
||||
this.startDate = -Infinity;
|
||||
this.endDate = Infinity;
|
||||
this.daysOfWeekDisabled = [];
|
||||
this.setStartDate(options.startDate||this.element.data('date-startdate'));
|
||||
this.setEndDate(options.endDate||this.element.data('date-enddate'));
|
||||
this.setDaysOfWeekDisabled(options.daysOfWeekDisabled||this.element.data('date-days-of-week-disabled'));
|
||||
this.fillDow();
|
||||
this.fillMonths();
|
||||
this.update();
|
||||
this.showMode();
|
||||
|
||||
if(this.isInline) {
|
||||
this.show();
|
||||
}
|
||||
};
|
||||
|
||||
Datepicker.prototype = {
|
||||
constructor: Datepicker,
|
||||
|
||||
_events: [],
|
||||
_attachEvents: function(){
|
||||
this._detachEvents();
|
||||
if (this.isInput) { // single input
|
||||
this._events = [
|
||||
[this.element, {
|
||||
focus: $.proxy(this.show, this),
|
||||
keyup: $.proxy(this.update, this),
|
||||
keydown: $.proxy(this.keydown, this)
|
||||
}]
|
||||
];
|
||||
}
|
||||
else if (this.component && this.hasInput){ // component: input + button
|
||||
this._events = [
|
||||
// For components that are not readonly, allow keyboard nav
|
||||
[this.element.find('input'), {
|
||||
focus: $.proxy(this.show, this),
|
||||
keyup: $.proxy(this.update, this),
|
||||
keydown: $.proxy(this.keydown, this)
|
||||
}],
|
||||
[this.component, {
|
||||
click: $.proxy(this.show, this)
|
||||
}]
|
||||
];
|
||||
}
|
||||
else if (this.element.is('div')) { // inline datepicker
|
||||
this.isInline = true;
|
||||
}
|
||||
else {
|
||||
this._events = [
|
||||
[this.element, {
|
||||
click: $.proxy(this.show, this)
|
||||
}]
|
||||
];
|
||||
}
|
||||
for (var i=0, el, ev; i<this._events.length; i++){
|
||||
el = this._events[i][0];
|
||||
ev = this._events[i][1];
|
||||
el.on(ev);
|
||||
}
|
||||
},
|
||||
_detachEvents: function(){
|
||||
for (var i=0, el, ev; i<this._events.length; i++){
|
||||
el = this._events[i][0];
|
||||
ev = this._events[i][1];
|
||||
el.off(ev);
|
||||
}
|
||||
this._events = [];
|
||||
},
|
||||
|
||||
show: function(e) {
|
||||
this.picker.show();
|
||||
this.height = this.component ? this.component.outerHeight() : this.element.outerHeight();
|
||||
this.update();
|
||||
this.place();
|
||||
$(window).on('resize', $.proxy(this.place, this));
|
||||
if (e ) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}
|
||||
this.element.trigger({
|
||||
type: 'show',
|
||||
date: this.date
|
||||
});
|
||||
},
|
||||
|
||||
hide: function(e){
|
||||
if(this.isInline) return;
|
||||
this.picker.hide();
|
||||
$(window).off('resize', this.place);
|
||||
this.viewMode = this.startViewMode;
|
||||
this.showMode();
|
||||
if (!this.isInput) {
|
||||
$(document).off('mousedown', this.hide);
|
||||
}
|
||||
|
||||
if (
|
||||
this.forceParse &&
|
||||
(
|
||||
this.isInput && this.element.val() ||
|
||||
this.hasInput && this.element.find('input').val()
|
||||
)
|
||||
)
|
||||
this.setValue();
|
||||
this.element.trigger({
|
||||
type: 'hide',
|
||||
date: this.date
|
||||
});
|
||||
},
|
||||
|
||||
remove: function() {
|
||||
this._detachEvents();
|
||||
this.picker.remove();
|
||||
delete this.element.data().datepicker;
|
||||
},
|
||||
|
||||
getDate: function() {
|
||||
var d = this.getUTCDate();
|
||||
return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
|
||||
},
|
||||
|
||||
getUTCDate: function() {
|
||||
return this.date;
|
||||
},
|
||||
|
||||
setDate: function(d) {
|
||||
this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
|
||||
},
|
||||
|
||||
setUTCDate: function(d) {
|
||||
this.date = d;
|
||||
this.setValue();
|
||||
},
|
||||
|
||||
setValue: function() {
|
||||
var formatted = this.getFormattedDate();
|
||||
if (!this.isInput) {
|
||||
if (this.component){
|
||||
this.element.find('input').val(formatted);
|
||||
}
|
||||
this.element.data('date', formatted);
|
||||
} else {
|
||||
this.element.val(formatted);
|
||||
}
|
||||
},
|
||||
|
||||
getFormattedDate: function(format) {
|
||||
if (format === undefined)
|
||||
format = this.format;
|
||||
return DPGlobal.formatDate(this.date, format, this.language);
|
||||
},
|
||||
|
||||
setStartDate: function(startDate){
|
||||
this.startDate = startDate||-Infinity;
|
||||
if (this.startDate !== -Infinity) {
|
||||
this.startDate = DPGlobal.parseDate(this.startDate, this.format, this.language);
|
||||
}
|
||||
this.update();
|
||||
this.updateNavArrows();
|
||||
},
|
||||
|
||||
setEndDate: function(endDate){
|
||||
this.endDate = endDate||Infinity;
|
||||
if (this.endDate !== Infinity) {
|
||||
this.endDate = DPGlobal.parseDate(this.endDate, this.format, this.language);
|
||||
}
|
||||
this.update();
|
||||
this.updateNavArrows();
|
||||
},
|
||||
|
||||
setDaysOfWeekDisabled: function(daysOfWeekDisabled){
|
||||
this.daysOfWeekDisabled = daysOfWeekDisabled||[];
|
||||
if (!$.isArray(this.daysOfWeekDisabled)) {
|
||||
this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
|
||||
}
|
||||
this.daysOfWeekDisabled = $.map(this.daysOfWeekDisabled, function (d) {
|
||||
return parseInt(d, 10);
|
||||
});
|
||||
this.update();
|
||||
this.updateNavArrows();
|
||||
},
|
||||
|
||||
place: function(){
|
||||
if(this.isInline) return;
|
||||
var zIndex = parseInt(this.element.parents().filter(function() {
|
||||
return $(this).css('z-index') != 'auto';
|
||||
}).first().css('z-index'))+10;
|
||||
var offset = this.component ? this.component.offset() : this.element.offset();
|
||||
var height = this.component ? this.component.outerHeight(true) : this.element.outerHeight(true);
|
||||
this.picker.css({
|
||||
top: offset.top + height,
|
||||
left: offset.left,
|
||||
zIndex: zIndex
|
||||
});
|
||||
},
|
||||
|
||||
update: function(){
|
||||
var date, fromArgs = false;
|
||||
if(arguments && arguments.length && (typeof arguments[0] === 'string' || arguments[0] instanceof Date)) {
|
||||
date = arguments[0];
|
||||
fromArgs = true;
|
||||
} else {
|
||||
date = this.isInput ? this.element.val() : this.element.data('date') || this.element.find('input').val();
|
||||
}
|
||||
|
||||
this.date = DPGlobal.parseDate(date, this.format, this.language);
|
||||
|
||||
if(fromArgs) this.setValue();
|
||||
|
||||
var oldViewDate = this.viewDate;
|
||||
if (this.date < this.startDate) {
|
||||
this.viewDate = new Date(this.startDate);
|
||||
} else if (this.date > this.endDate) {
|
||||
this.viewDate = new Date(this.endDate);
|
||||
} else {
|
||||
this.viewDate = new Date(this.date);
|
||||
}
|
||||
|
||||
if (oldViewDate && oldViewDate.getTime() != this.viewDate.getTime()){
|
||||
this.element.trigger({
|
||||
type: 'changeDate',
|
||||
date: this.viewDate
|
||||
});
|
||||
}
|
||||
this.fill();
|
||||
},
|
||||
|
||||
fillDow: function(){
|
||||
var dowCnt = this.weekStart,
|
||||
html = '<tr>';
|
||||
while (dowCnt < this.weekStart + 7) {
|
||||
html += '<th class="dow">'+dates[this.language].daysMin[(dowCnt++)%7]+'</th>';
|
||||
}
|
||||
html += '</tr>';
|
||||
this.picker.find('.datepicker-days thead').append(html);
|
||||
},
|
||||
|
||||
fillMonths: function(){
|
||||
var html = '',
|
||||
i = 0;
|
||||
while (i < 12) {
|
||||
html += '<span class="month">'+dates[this.language].monthsShort[i++]+'</span>';
|
||||
}
|
||||
this.picker.find('.datepicker-months td').html(html);
|
||||
},
|
||||
|
||||
fill: function() {
|
||||
var d = new Date(this.viewDate),
|
||||
year = d.getUTCFullYear(),
|
||||
month = d.getUTCMonth(),
|
||||
startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
|
||||
startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
|
||||
endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
|
||||
endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
|
||||
currentDate = this.date && this.date.valueOf(),
|
||||
today = new Date();
|
||||
this.picker.find('.datepicker-days thead th:eq(1)')
|
||||
.text(dates[this.language].months[month]+' '+year);
|
||||
this.picker.find('tfoot th.today')
|
||||
.text(dates[this.language].today)
|
||||
.toggle(this.todayBtn !== false);
|
||||
this.updateNavArrows();
|
||||
this.fillMonths();
|
||||
var prevMonth = UTCDate(year, month-1, 28,0,0,0,0),
|
||||
day = DPGlobal.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
|
||||
prevMonth.setUTCDate(day);
|
||||
prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
|
||||
var nextMonth = new Date(prevMonth);
|
||||
nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
|
||||
nextMonth = nextMonth.valueOf();
|
||||
var html = [];
|
||||
var clsName;
|
||||
while(prevMonth.valueOf() < nextMonth) {
|
||||
if (prevMonth.getUTCDay() == this.weekStart) {
|
||||
html.push('<tr>');
|
||||
}
|
||||
clsName = '';
|
||||
if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
|
||||
clsName += ' old';
|
||||
} else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
|
||||
clsName += ' new';
|
||||
}
|
||||
// Compare internal UTC date with local today, not UTC today
|
||||
if (this.todayHighlight &&
|
||||
prevMonth.getUTCFullYear() == today.getFullYear() &&
|
||||
prevMonth.getUTCMonth() == today.getMonth() &&
|
||||
prevMonth.getUTCDate() == today.getDate()) {
|
||||
clsName += ' today';
|
||||
}
|
||||
if (currentDate && prevMonth.valueOf() == currentDate) {
|
||||
clsName += ' active';
|
||||
}
|
||||
if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
|
||||
$.inArray(prevMonth.getUTCDay(), this.daysOfWeekDisabled) !== -1) {
|
||||
clsName += ' disabled';
|
||||
}
|
||||
html.push('<td class="day'+clsName+'">'+prevMonth.getUTCDate() + '</td>');
|
||||
if (prevMonth.getUTCDay() == this.weekEnd) {
|
||||
html.push('</tr>');
|
||||
}
|
||||
prevMonth.setUTCDate(prevMonth.getUTCDate()+1);
|
||||
}
|
||||
this.picker.find('.datepicker-days tbody').empty().append(html.join(''));
|
||||
var currentYear = this.date && this.date.getUTCFullYear();
|
||||
|
||||
var months = this.picker.find('.datepicker-months')
|
||||
.find('th:eq(1)')
|
||||
.text(year)
|
||||
.end()
|
||||
.find('span').removeClass('active');
|
||||
if (currentYear && currentYear == year) {
|
||||
months.eq(this.date.getUTCMonth()).addClass('active');
|
||||
}
|
||||
if (year < startYear || year > endYear) {
|
||||
months.addClass('disabled');
|
||||
}
|
||||
if (year == startYear) {
|
||||
months.slice(0, startMonth).addClass('disabled');
|
||||
}
|
||||
if (year == endYear) {
|
||||
months.slice(endMonth+1).addClass('disabled');
|
||||
}
|
||||
|
||||
html = '';
|
||||
year = parseInt(year/10, 10) * 10;
|
||||
var yearCont = this.picker.find('.datepicker-years')
|
||||
.find('th:eq(1)')
|
||||
.text(year + '-' + (year + 9))
|
||||
.end()
|
||||
.find('td');
|
||||
year -= 1;
|
||||
for (var i = -1; i < 11; i++) {
|
||||
html += '<span class="year'+(i == -1 || i == 10 ? ' old' : '')+(currentYear == year ? ' active' : '')+(year < startYear || year > endYear ? ' disabled' : '')+'">'+year+'</span>';
|
||||
year += 1;
|
||||
}
|
||||
yearCont.html(html);
|
||||
},
|
||||
|
||||
updateNavArrows: function() {
|
||||
var d = new Date(this.viewDate),
|
||||
year = d.getUTCFullYear(),
|
||||
month = d.getUTCMonth();
|
||||
switch (this.viewMode) {
|
||||
case 0:
|
||||
if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
|
||||
this.picker.find('.prev').css({visibility: 'hidden'});
|
||||
} else {
|
||||
this.picker.find('.prev').css({visibility: 'visible'});
|
||||
}
|
||||
if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
|
||||
this.picker.find('.next').css({visibility: 'hidden'});
|
||||
} else {
|
||||
this.picker.find('.next').css({visibility: 'visible'});
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
|
||||
this.picker.find('.prev').css({visibility: 'hidden'});
|
||||
} else {
|
||||
this.picker.find('.prev').css({visibility: 'visible'});
|
||||
}
|
||||
if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
|
||||
this.picker.find('.next').css({visibility: 'hidden'});
|
||||
} else {
|
||||
this.picker.find('.next').css({visibility: 'visible'});
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
click: function(e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
var target = $(e.target).closest('span, td, th');
|
||||
if (target.length == 1) {
|
||||
switch(target[0].nodeName.toLowerCase()) {
|
||||
case 'th':
|
||||
switch(target[0].className) {
|
||||
case 'switch':
|
||||
this.showMode(1);
|
||||
break;
|
||||
case 'prev':
|
||||
case 'next':
|
||||
var dir = DPGlobal.modes[this.viewMode].navStep * (target[0].className == 'prev' ? -1 : 1);
|
||||
switch(this.viewMode){
|
||||
case 0:
|
||||
this.viewDate = this.moveMonth(this.viewDate, dir);
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
this.viewDate = this.moveYear(this.viewDate, dir);
|
||||
break;
|
||||
}
|
||||
this.fill();
|
||||
break;
|
||||
case 'today':
|
||||
var date = new Date();
|
||||
date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
|
||||
|
||||
this.showMode(-2);
|
||||
var which = this.todayBtn == 'linked' ? null : 'view';
|
||||
this._setDate(date, which);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'span':
|
||||
if (!target.is('.disabled')) {
|
||||
this.viewDate.setUTCDate(1);
|
||||
if (target.is('.month')) {
|
||||
var month = target.parent().find('span').index(target);
|
||||
this.viewDate.setUTCMonth(month);
|
||||
this.element.trigger({
|
||||
type: 'changeMonth',
|
||||
date: this.viewDate
|
||||
});
|
||||
} else {
|
||||
var year = parseInt(target.text(), 10)||0;
|
||||
this.viewDate.setUTCFullYear(year);
|
||||
this.element.trigger({
|
||||
type: 'changeYear',
|
||||
date: this.viewDate
|
||||
});
|
||||
}
|
||||
this.showMode(-1);
|
||||
this.fill();
|
||||
}
|
||||
break;
|
||||
case 'td':
|
||||
if (target.is('.day') && !target.is('.disabled')){
|
||||
var day = parseInt(target.text(), 10)||1;
|
||||
var year = this.viewDate.getUTCFullYear(),
|
||||
month = this.viewDate.getUTCMonth();
|
||||
if (target.is('.old')) {
|
||||
if (month === 0) {
|
||||
month = 11;
|
||||
year -= 1;
|
||||
} else {
|
||||
month -= 1;
|
||||
}
|
||||
} else if (target.is('.new')) {
|
||||
if (month == 11) {
|
||||
month = 0;
|
||||
year += 1;
|
||||
} else {
|
||||
month += 1;
|
||||
}
|
||||
}
|
||||
this._setDate(UTCDate(year, month, day,0,0,0,0));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_setDate: function(date, which){
|
||||
if (!which || which == 'date')
|
||||
this.date = date;
|
||||
if (!which || which == 'view')
|
||||
this.viewDate = date;
|
||||
this.fill();
|
||||
this.setValue();
|
||||
this.element.trigger({
|
||||
type: 'changeDate',
|
||||
date: this.date
|
||||
});
|
||||
var element;
|
||||
if (this.isInput) {
|
||||
element = this.element;
|
||||
} else if (this.component){
|
||||
element = this.element.find('input');
|
||||
}
|
||||
if (element) {
|
||||
element.change();
|
||||
if (this.autoclose && (!which || which == 'date')) {
|
||||
this.hide();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
moveMonth: function(date, dir){
|
||||
if (!dir) return date;
|
||||
var new_date = new Date(date.valueOf()),
|
||||
day = new_date.getUTCDate(),
|
||||
month = new_date.getUTCMonth(),
|
||||
mag = Math.abs(dir),
|
||||
new_month, test;
|
||||
dir = dir > 0 ? 1 : -1;
|
||||
if (mag == 1){
|
||||
test = dir == -1
|
||||
// If going back one month, make sure month is not current month
|
||||
// (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
|
||||
? function(){ return new_date.getUTCMonth() == month; }
|
||||
// If going forward one month, make sure month is as expected
|
||||
// (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
|
||||
: function(){ return new_date.getUTCMonth() != new_month; };
|
||||
new_month = month + dir;
|
||||
new_date.setUTCMonth(new_month);
|
||||
// Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
|
||||
if (new_month < 0 || new_month > 11)
|
||||
new_month = (new_month + 12) % 12;
|
||||
} else {
|
||||
// For magnitudes >1, move one month at a time...
|
||||
for (var i=0; i<mag; i++)
|
||||
// ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
|
||||
new_date = this.moveMonth(new_date, dir);
|
||||
// ...then reset the day, keeping it in the new month
|
||||
new_month = new_date.getUTCMonth();
|
||||
new_date.setUTCDate(day);
|
||||
test = function(){ return new_month != new_date.getUTCMonth(); };
|
||||
}
|
||||
// Common date-resetting loop -- if date is beyond end of month, make it
|
||||
// end of month
|
||||
while (test()){
|
||||
new_date.setUTCDate(--day);
|
||||
new_date.setUTCMonth(new_month);
|
||||
}
|
||||
return new_date;
|
||||
},
|
||||
|
||||
moveYear: function(date, dir){
|
||||
return this.moveMonth(date, dir*12);
|
||||
},
|
||||
|
||||
dateWithinRange: function(date){
|
||||
return date >= this.startDate && date <= this.endDate;
|
||||
},
|
||||
|
||||
keydown: function(e){
|
||||
if (this.picker.is(':not(:visible)')){
|
||||
if (e.keyCode == 27) // allow escape to hide and re-show picker
|
||||
this.show();
|
||||
return;
|
||||
}
|
||||
var dateChanged = false,
|
||||
dir, day, month,
|
||||
newDate, newViewDate;
|
||||
switch(e.keyCode){
|
||||
case 27: // escape
|
||||
this.hide();
|
||||
e.preventDefault();
|
||||
break;
|
||||
case 37: // left
|
||||
case 39: // right
|
||||
if (!this.keyboardNavigation) break;
|
||||
dir = e.keyCode == 37 ? -1 : 1;
|
||||
if (e.ctrlKey){
|
||||
newDate = this.moveYear(this.date, dir);
|
||||
newViewDate = this.moveYear(this.viewDate, dir);
|
||||
} else if (e.shiftKey){
|
||||
newDate = this.moveMonth(this.date, dir);
|
||||
newViewDate = this.moveMonth(this.viewDate, dir);
|
||||
} else {
|
||||
newDate = new Date(this.date);
|
||||
newDate.setUTCDate(this.date.getUTCDate() + dir);
|
||||
newViewDate = new Date(this.viewDate);
|
||||
newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
|
||||
}
|
||||
if (this.dateWithinRange(newDate)){
|
||||
this.date = newDate;
|
||||
this.viewDate = newViewDate;
|
||||
this.setValue();
|
||||
this.update();
|
||||
e.preventDefault();
|
||||
dateChanged = true;
|
||||
}
|
||||
break;
|
||||
case 38: // up
|
||||
case 40: // down
|
||||
if (!this.keyboardNavigation) break;
|
||||
dir = e.keyCode == 38 ? -1 : 1;
|
||||
if (e.ctrlKey){
|
||||
newDate = this.moveYear(this.date, dir);
|
||||
newViewDate = this.moveYear(this.viewDate, dir);
|
||||
} else if (e.shiftKey){
|
||||
newDate = this.moveMonth(this.date, dir);
|
||||
newViewDate = this.moveMonth(this.viewDate, dir);
|
||||
} else {
|
||||
newDate = new Date(this.date);
|
||||
newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
|
||||
newViewDate = new Date(this.viewDate);
|
||||
newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
|
||||
}
|
||||
if (this.dateWithinRange(newDate)){
|
||||
this.date = newDate;
|
||||
this.viewDate = newViewDate;
|
||||
this.setValue();
|
||||
this.update();
|
||||
e.preventDefault();
|
||||
dateChanged = true;
|
||||
}
|
||||
break;
|
||||
case 13: // enter
|
||||
this.hide();
|
||||
e.preventDefault();
|
||||
break;
|
||||
case 9: // tab
|
||||
this.hide();
|
||||
break;
|
||||
}
|
||||
if (dateChanged){
|
||||
this.element.trigger({
|
||||
type: 'changeDate',
|
||||
date: this.date
|
||||
});
|
||||
var element;
|
||||
if (this.isInput) {
|
||||
element = this.element;
|
||||
} else if (this.component){
|
||||
element = this.element.find('input');
|
||||
}
|
||||
if (element) {
|
||||
element.change();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
showMode: function(dir) {
|
||||
if (dir) {
|
||||
this.viewMode = Math.max(0, Math.min(2, this.viewMode + dir));
|
||||
}
|
||||
/*
|
||||
vitalets: fixing bug of very special conditions:
|
||||
jquery 1.7.1 + webkit + show inline datepicker in bootstrap popover.
|
||||
Method show() does not set display css correctly and datepicker is not shown.
|
||||
Changed to .css('display', 'block') solve the problem.
|
||||
See https://github.com/vitalets/x-editable/issues/37
|
||||
|
||||
In jquery 1.7.2+ everything works fine.
|
||||
*/
|
||||
//this.picker.find('>div').hide().filter('.datepicker-'+DPGlobal.modes[this.viewMode].clsName).show();
|
||||
this.picker.find('>div').hide().filter('.datepicker-'+DPGlobal.modes[this.viewMode].clsName).css('display', 'block');
|
||||
this.updateNavArrows();
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.datepicker = function ( option ) {
|
||||
var args = Array.apply(null, arguments);
|
||||
args.shift();
|
||||
return this.each(function () {
|
||||
var $this = $(this),
|
||||
data = $this.data('datepicker'),
|
||||
options = typeof option == 'object' && option;
|
||||
if (!data) {
|
||||
$this.data('datepicker', (data = new Datepicker(this, $.extend({}, $.fn.datepicker.defaults,options))));
|
||||
}
|
||||
if (typeof option == 'string' && typeof data[option] == 'function') {
|
||||
data[option].apply(data, args);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.datepicker.defaults = {
|
||||
};
|
||||
$.fn.datepicker.Constructor = Datepicker;
|
||||
var dates = $.fn.datepicker.dates = {
|
||||
en: {
|
||||
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
|
||||
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
|
||||
daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
|
||||
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
||||
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
||||
today: "Today"
|
||||
}
|
||||
};
|
||||
|
||||
var DPGlobal = {
|
||||
modes: [
|
||||
{
|
||||
clsName: 'days',
|
||||
navFnc: 'Month',
|
||||
navStep: 1
|
||||
},
|
||||
{
|
||||
clsName: 'months',
|
||||
navFnc: 'FullYear',
|
||||
navStep: 1
|
||||
},
|
||||
{
|
||||
clsName: 'years',
|
||||
navFnc: 'FullYear',
|
||||
navStep: 10
|
||||
}],
|
||||
isLeapYear: function (year) {
|
||||
return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0));
|
||||
},
|
||||
getDaysInMonth: function (year, month) {
|
||||
return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
|
||||
},
|
||||
validParts: /dd?|DD?|mm?|MM?|yy(?:yy)?/g,
|
||||
nonpunctuation: /[^ -\/:-@\[\u3400-\u9fff-`{-~\t\n\r]+/g,
|
||||
parseFormat: function(format){
|
||||
// IE treats \0 as a string end in inputs (truncating the value),
|
||||
// so it's a bad format delimiter, anyway
|
||||
var separators = format.replace(this.validParts, '\0').split('\0'),
|
||||
parts = format.match(this.validParts);
|
||||
if (!separators || !separators.length || !parts || parts.length === 0){
|
||||
throw new Error("Invalid date format.");
|
||||
}
|
||||
return {separators: separators, parts: parts};
|
||||
},
|
||||
parseDate: function(date, format, language) {
|
||||
if (date instanceof Date) return date;
|
||||
if (/^[\-+]\d+[dmwy]([\s,]+[\-+]\d+[dmwy])*$/.test(date)) {
|
||||
var part_re = /([\-+]\d+)([dmwy])/,
|
||||
parts = date.match(/([\-+]\d+)([dmwy])/g),
|
||||
part, dir;
|
||||
date = new Date();
|
||||
for (var i=0; i<parts.length; i++) {
|
||||
part = part_re.exec(parts[i]);
|
||||
dir = parseInt(part[1]);
|
||||
switch(part[2]){
|
||||
case 'd':
|
||||
date.setUTCDate(date.getUTCDate() + dir);
|
||||
break;
|
||||
case 'm':
|
||||
date = Datepicker.prototype.moveMonth.call(Datepicker.prototype, date, dir);
|
||||
break;
|
||||
case 'w':
|
||||
date.setUTCDate(date.getUTCDate() + dir * 7);
|
||||
break;
|
||||
case 'y':
|
||||
date = Datepicker.prototype.moveYear.call(Datepicker.prototype, date, dir);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return UTCDate(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), 0, 0, 0);
|
||||
}
|
||||
var parts = date && date.match(this.nonpunctuation) || [],
|
||||
date = new Date(),
|
||||
parsed = {},
|
||||
setters_order = ['yyyy', 'yy', 'M', 'MM', 'm', 'mm', 'd', 'dd'],
|
||||
setters_map = {
|
||||
yyyy: function(d,v){ return d.setUTCFullYear(v); },
|
||||
yy: function(d,v){ return d.setUTCFullYear(2000+v); },
|
||||
m: function(d,v){
|
||||
v -= 1;
|
||||
while (v<0) v += 12;
|
||||
v %= 12;
|
||||
d.setUTCMonth(v);
|
||||
while (d.getUTCMonth() != v)
|
||||
d.setUTCDate(d.getUTCDate()-1);
|
||||
return d;
|
||||
},
|
||||
d: function(d,v){ return d.setUTCDate(v); }
|
||||
},
|
||||
val, filtered, part;
|
||||
setters_map['M'] = setters_map['MM'] = setters_map['mm'] = setters_map['m'];
|
||||
setters_map['dd'] = setters_map['d'];
|
||||
date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
|
||||
var fparts = format.parts.slice();
|
||||
// Remove noop parts
|
||||
if (parts.length != fparts.length) {
|
||||
fparts = $(fparts).filter(function(i,p){
|
||||
return $.inArray(p, setters_order) !== -1;
|
||||
}).toArray();
|
||||
}
|
||||
// Process remainder
|
||||
if (parts.length == fparts.length) {
|
||||
for (var i=0, cnt = fparts.length; i < cnt; i++) {
|
||||
val = parseInt(parts[i], 10);
|
||||
part = fparts[i];
|
||||
if (isNaN(val)) {
|
||||
switch(part) {
|
||||
case 'MM':
|
||||
filtered = $(dates[language].months).filter(function(){
|
||||
var m = this.slice(0, parts[i].length),
|
||||
p = parts[i].slice(0, m.length);
|
||||
return m == p;
|
||||
});
|
||||
val = $.inArray(filtered[0], dates[language].months) + 1;
|
||||
break;
|
||||
case 'M':
|
||||
filtered = $(dates[language].monthsShort).filter(function(){
|
||||
var m = this.slice(0, parts[i].length),
|
||||
p = parts[i].slice(0, m.length);
|
||||
return m == p;
|
||||
});
|
||||
val = $.inArray(filtered[0], dates[language].monthsShort) + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
parsed[part] = val;
|
||||
}
|
||||
for (var i=0, s; i<setters_order.length; i++){
|
||||
s = setters_order[i];
|
||||
if (s in parsed && !isNaN(parsed[s]))
|
||||
setters_map[s](date, parsed[s]);
|
||||
}
|
||||
}
|
||||
return date;
|
||||
},
|
||||
formatDate: function(date, format, language){
|
||||
var val = {
|
||||
d: date.getUTCDate(),
|
||||
D: dates[language].daysShort[date.getUTCDay()],
|
||||
DD: dates[language].days[date.getUTCDay()],
|
||||
m: date.getUTCMonth() + 1,
|
||||
M: dates[language].monthsShort[date.getUTCMonth()],
|
||||
MM: dates[language].months[date.getUTCMonth()],
|
||||
yy: date.getUTCFullYear().toString().substring(2),
|
||||
yyyy: date.getUTCFullYear()
|
||||
};
|
||||
val.dd = (val.d < 10 ? '0' : '') + val.d;
|
||||
val.mm = (val.m < 10 ? '0' : '') + val.m;
|
||||
var date = [],
|
||||
seps = $.extend([], format.separators);
|
||||
for (var i=0, cnt = format.parts.length; i < cnt; i++) {
|
||||
if (seps.length)
|
||||
date.push(seps.shift());
|
||||
date.push(val[format.parts[i]]);
|
||||
}
|
||||
return date.join('');
|
||||
},
|
||||
headTemplate: '<thead>'+
|
||||
'<tr>'+
|
||||
'<th class="prev"><i class="icon-arrow-left"/></th>'+
|
||||
'<th colspan="5" class="switch"></th>'+
|
||||
'<th class="next"><i class="icon-arrow-right"/></th>'+
|
||||
'</tr>'+
|
||||
'</thead>',
|
||||
contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>',
|
||||
footTemplate: '<tfoot><tr><th colspan="7" class="today"></th></tr></tfoot>'
|
||||
};
|
||||
DPGlobal.template = '<div class="datepicker">'+
|
||||
'<div class="datepicker-days">'+
|
||||
'<table class=" table-condensed">'+
|
||||
DPGlobal.headTemplate+
|
||||
'<tbody></tbody>'+
|
||||
DPGlobal.footTemplate+
|
||||
'</table>'+
|
||||
'</div>'+
|
||||
'<div class="datepicker-months">'+
|
||||
'<table class="table-condensed">'+
|
||||
DPGlobal.headTemplate+
|
||||
DPGlobal.contTemplate+
|
||||
DPGlobal.footTemplate+
|
||||
'</table>'+
|
||||
'</div>'+
|
||||
'<div class="datepicker-years">'+
|
||||
'<table class="table-condensed">'+
|
||||
DPGlobal.headTemplate+
|
||||
DPGlobal.contTemplate+
|
||||
DPGlobal.footTemplate+
|
||||
'</table>'+
|
||||
'</div>'+
|
||||
'</div>';
|
||||
|
||||
$.fn.datepicker.DPGlobal = DPGlobal;
|
||||
|
||||
}( window.jQuery );
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Bulgarian translation for bootstrap-datepicker
|
||||
* Apostol Apostolov <apostol.s.apostolov@gmail.com>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['bg'] = {
|
||||
days: ["Неделя", "Понеделник", "Вторник", "Сряда", "Четвъртък", "Петък", "Събота", "Неделя"],
|
||||
daysShort: ["Нед", "Пон", "Вто", "Сря", "Чет", "Пет", "Съб", "Нед"],
|
||||
daysMin: ["Н", "П", "В", "С", "Ч", "П", "С", "Н"],
|
||||
months: ["Януари", "Февруари", "Март", "Април", "Май", "Юни", "Юли", "Август", "Септември", "Октомври", "Ноември", "Декември"],
|
||||
monthsShort: ["Ян", "Фев", "Мар", "Апр", "Май", "Юни", "Юли", "Авг", "Сеп", "Окт", "Ное", "Дек"],
|
||||
today: "днес"
|
||||
};
|
||||
}(jQuery));
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Catalan translation for bootstrap-datepicker
|
||||
* J. Garcia <jogaco.en@gmail.com>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['ca'] = {
|
||||
days: ["Diumenge", "Dilluns", "Dimarts", "Dimecres", "Dijous", "Divendres", "Dissabte", "Diumenge"],
|
||||
daysShort: ["Diu", "Dil", "Dmt", "Dmc", "Dij", "Div", "Dis", "Diu"],
|
||||
daysMin: ["dg", "dl", "dt", "dc", "dj", "dv", "ds", "dg"],
|
||||
months: ["Gener", "Febrer", "Març", "Abril", "Maig", "Juny", "Juliol", "Agost", "Setembre", "Octubre", "Novembre", "Desembre"],
|
||||
monthsShort: ["Gen", "Feb", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Oct", "Nov", "Des"],
|
||||
today: "Avui"
|
||||
};
|
||||
}(jQuery));
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Czech translation for bootstrap-datepicker
|
||||
* Matěj Koubík <matej@koubik.name>
|
||||
* Fixes by Michal Remiš <michal.remis@gmail.com>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['cs'] = {
|
||||
days: ["Neděle", "Pondělí", "Úterý", "Středa", "Čtvrtek", "Pátek", "Sobota", "Neděle"],
|
||||
daysShort: ["Ned", "Pon", "Úte", "Stř", "Čtv", "Pát", "Sob", "Ned"],
|
||||
daysMin: ["Ne", "Po", "Út", "St", "Čt", "Pá", "So", "Ne"],
|
||||
months: ["Leden", "Únor", "Březen", "Duben", "Květen", "Červen", "Červenec", "Srpen", "Září", "Říjen", "Listopad", "Prosinec"],
|
||||
monthsShort: ["Led", "Úno", "Bře", "Dub", "Kvě", "Čer", "Čnc", "Srp", "Zář", "Říj", "Lis", "Pro"],
|
||||
today: "Dnes"
|
||||
};
|
||||
}(jQuery));
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Danish translation for bootstrap-datepicker
|
||||
* Christian Pedersen <http://github.com/chripede>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['da'] = {
|
||||
days: ["Søndag", "Mandag", "Tirsdag", "Onsdag", "Torsdag", "Fredag", "Lørdag", "Søndag"],
|
||||
daysShort: ["Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør", "Søn"],
|
||||
daysMin: ["Sø", "Ma", "Ti", "On", "To", "Fr", "Lø", "Sø"],
|
||||
months: ["Januar", "Februar", "Marts", "April", "Maj", "Juni", "Juli", "August", "September", "Oktober", "November", "December"],
|
||||
monthsShort: ["Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec"],
|
||||
today: "I Dag"
|
||||
};
|
||||
}(jQuery));
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* German translation for bootstrap-datepicker
|
||||
* Sam Zurcher <sam@orelias.ch>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['de'] = {
|
||||
days: ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag"],
|
||||
daysShort: ["Son", "Mon", "Die", "Mit", "Don", "Fre", "Sam", "Son"],
|
||||
daysMin: ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"],
|
||||
months: ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"],
|
||||
monthsShort: ["Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"],
|
||||
today: "Heute",
|
||||
weekStart: 1
|
||||
};
|
||||
}(jQuery));
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Greek translation for bootstrap-datepicker
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['el'] = {
|
||||
days: ["Κυριακή", "Δευτέρα", "Τρίτη", "Τετάρτη", "Πέμπτη", "Παρασκευή", "Σάββατο", "Κυριακή"],
|
||||
daysShort: ["Κυρ", "Δευ", "Τρι", "Τετ", "Πεμ", "Παρ", "Σαβ", "Κυρ"],
|
||||
daysMin: ["Κυ", "Δε", "Τρ", "Τε", "Πε", "Πα", "Σα", "Κυ"],
|
||||
months: ["Ιανουάριος", "Φεβρουάριος", "Μάρτιος", "Απρίλιος", "Μάιος", "Ιούνιος", "Ιούλιος", "Αύγουστος", "Σεπτέμβριος", "Οκτώβριος", "Νοέμβριος", "Δεκέμβριος"],
|
||||
monthsShort: ["Ιαν", "Φεβ", "Μαρ", "Απρ", "Μάι", "Ιουν", "Ιουλ", "Αυγ", "Σεπ", "Οκτ", "Νοε", "Δεκ"],
|
||||
today: "Σήμερα"
|
||||
};
|
||||
}(jQuery));
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Spanish translation for bootstrap-datepicker
|
||||
* Bruno Bonamin <bruno.bonamin@gmail.com>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['es'] = {
|
||||
days: ["Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado", "Domingo"],
|
||||
daysShort: ["Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb", "Dom"],
|
||||
daysMin: ["Do", "Lu", "Ma", "Mi", "Ju", "Vi", "Sa", "Do"],
|
||||
months: ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"],
|
||||
monthsShort: ["Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic"],
|
||||
today: "Hoy"
|
||||
};
|
||||
}(jQuery));
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Finnish translation for bootstrap-datepicker
|
||||
* Jaakko Salonen <https://github.com/jsalonen>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['fi'] = {
|
||||
days: ["sunnuntai", "maanantai", "tiistai", "keskiviikko", "torstai", "perjantai", "lauantai", "sunnuntai"],
|
||||
daysShort: ["sun", "maa", "tii", "kes", "tor", "per", "lau", "sun"],
|
||||
daysMin: ["su", "ma", "ti", "ke", "to", "pe", "la", "su"],
|
||||
months: ["tammikuu", "helmikuu", "maaliskuu", "huhtikuu", "toukokuu", "kesäkuu", "heinäkuu", "elokuu", "syyskuu", "lokakuu", "marraskuu", "joulukuu"],
|
||||
monthsShort: ["tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mar", "jou"],
|
||||
today: "tänään"
|
||||
};
|
||||
}(jQuery));
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* French translation for bootstrap-datepicker
|
||||
* Nico Mollet <nico.mollet@gmail.com>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['fr'] = {
|
||||
days: ["Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche"],
|
||||
daysShort: ["Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam", "Dim"],
|
||||
daysMin: ["D", "L", "Ma", "Me", "J", "V", "S", "D"],
|
||||
months: ["Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"],
|
||||
monthsShort: ["Jan", "Fev", "Mar", "Avr", "Mai", "Jui", "Jul", "Aou", "Sep", "Oct", "Nov", "Dec"],
|
||||
today: "Aujourd'hui",
|
||||
weekStart: 1
|
||||
};
|
||||
}(jQuery));
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Hebrew translation for bootstrap-datepicker
|
||||
* Sagie Maoz <sagie@maoz.info>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['he'] = {
|
||||
days: ["ראשון", "שני", "שלישי", "רביעי", "חמישי", "שישי", "שבת", "ראשון"],
|
||||
daysShort: ["א", "ב", "ג", "ד", "ה", "ו", "ש", "א"],
|
||||
daysMin: ["א", "ב", "ג", "ד", "ה", "ו", "ש", "א"],
|
||||
months: ["ינואר", "פברואר", "מרץ", "אפריל", "מאי", "יוני", "יולי", "אוגוסט", "ספטמבר", "אוקטובר", "נובמבר", "דצמבר"],
|
||||
monthsShort: ["ינו", "פבר", "מרץ", "אפר", "מאי", "יונ", "יול", "אוג", "ספט", "אוק", "נוב", "דצמ"],
|
||||
today: "היום",
|
||||
rtl: true
|
||||
};
|
||||
}(jQuery));
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Croatian localisation
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['hr'] = {
|
||||
days: ["Nedjelja", "Ponedjelja", "Utorak", "Srijeda", "Četrtak", "Petak", "Subota", "Nedjelja"],
|
||||
daysShort: ["Ned", "Pon", "Uto", "Srr", "Čet", "Pet", "Sub", "Ned"],
|
||||
daysMin: ["Ne", "Po", "Ut", "Sr", "Če", "Pe", "Su", "Ne"],
|
||||
months: ["Siječanj", "Veljača", "Ožujak", "Travanj", "Svibanj", "Lipanj", "Srpanj", "Kolovoz", "Rujan", "Listopad", "Studeni", "Prosinac"],
|
||||
monthsShort: ["Sije", "Velj", "Ožu", "Tra", "Svi", "Lip", "Jul", "Kol", "Ruj", "Lis", "Stu", "Pro"],
|
||||
today: "Danas"
|
||||
};
|
||||
}(jQuery));
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Bahasa translation for bootstrap-datepicker
|
||||
* Azwar Akbar <azwar.akbar@gmail.com>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['id'] = {
|
||||
days: ["Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu", "Minggu"],
|
||||
daysShort: ["Mgu", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab", "Mgu"],
|
||||
daysMin: ["Mg", "Sn", "Sl", "Ra", "Ka", "Ju", "Sa", "Mg"],
|
||||
months: ["Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"],
|
||||
monthsShort: ["Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Ags", "Sep", "Okt", "Nov", "Des"]
|
||||
};
|
||||
}(jQuery));
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Icelandic translation for bootstrap-datepicker
|
||||
* Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['is'] = {
|
||||
days: ["Sunnudagur", "Mánudagur", "Þriðjudagur", "Miðvikudagur", "Fimmtudagur", "Föstudagur", "Laugardagur", "Sunnudagur"],
|
||||
daysShort: ["Sun", "Mán", "Þri", "Mið", "Fim", "Fös", "Lau", "Sun"],
|
||||
daysMin: ["Su", "Má", "Þr", "Mi", "Fi", "Fö", "La", "Su"],
|
||||
months: ["Janúar", "Febrúar", "Mars", "Apríl", "Maí", "Júní", "Júlí", "Ágúst", "September", "Október", "Nóvember", "Desember"],
|
||||
monthsShort: ["Jan", "Feb", "Mar", "Apr", "Maí", "Jún", "Júl", "Ágú", "Sep", "Okt", "Nóv", "Des"],
|
||||
today: "Í Dag"
|
||||
};
|
||||
}(jQuery));
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Italian translation for bootstrap-datepicker
|
||||
* Enrico Rubboli <rubboli@gmail.com>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['it'] = {
|
||||
days: ["Domenica", "Lunedi", "Martedi", "Mercoledi", "Giovedi", "Venerdi", "Sabato", "Domenica"],
|
||||
daysShort: ["Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab", "Dom"],
|
||||
daysMin: ["Do", "Lu", "Ma", "Me", "Gi", "Ve", "Sa", "Do"],
|
||||
months: ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"],
|
||||
monthsShort: ["Gen", "Feb", "Mar", "Apr", "Mag", "Giu", "Lug", "Ago", "Set", "Ott", "Nov", "Dic"],
|
||||
today: "Oggi"
|
||||
};
|
||||
}(jQuery));
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Japanese translation for bootstrap-datepicker
|
||||
* Norio Suzuki <https://github.com/suzuki/>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['ja'] = {
|
||||
days: ["日曜", "月曜", "火曜", "水曜", "木曜", "金曜", "土曜", "日曜"],
|
||||
daysShort: ["日", "月", "火", "水", "木", "金", "土", "日"],
|
||||
daysMin: ["日", "月", "火", "水", "木", "金", "土", "日"],
|
||||
months: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
|
||||
monthsShort: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"]
|
||||
};
|
||||
}(jQuery));
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Korean translation for bootstrap-datepicker
|
||||
* Gu Youn <http://github.com/guyoun>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['kr'] = {
|
||||
days: ["일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일", "일요일"],
|
||||
daysShort: ["일", "월", "화", "수", "목", "금", "토", "일"],
|
||||
daysMin: ["일", "월", "화", "수", "목", "금", "토", "일"],
|
||||
months: ["1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"],
|
||||
monthsShort: ["1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"]
|
||||
};
|
||||
}(jQuery));
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Lithuanian translation for bootstrap-datepicker
|
||||
* Šarūnas Gliebus <ssharunas@yahoo.co.uk>
|
||||
*/
|
||||
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['lt'] = {
|
||||
days: ["Sekmadienis", "Pirmadienis", "Antradienis", "Trečiadienis", "Ketvirtadienis", "Penktadienis", "Šeštadienis", "Sekmadienis"],
|
||||
daysShort: ["S", "Pr", "A", "T", "K", "Pn", "Š", "S"],
|
||||
daysMin: ["Sk", "Pr", "An", "Tr", "Ke", "Pn", "Št", "Sk"],
|
||||
months: ["Sausis", "Vasaris", "Kovas", "Balandis", "Gegužė", "Birželis", "Liepa", "Rugpjūtis", "Rugsėjis", "Spalis", "Lapkritis", "Gruodis"],
|
||||
monthsShort: ["Sau", "Vas", "Kov", "Bal", "Geg", "Bir", "Lie", "Rugp", "Rugs", "Spa", "Lap", "Gru"],
|
||||
today: "Šiandien",
|
||||
weekStart: 1
|
||||
};
|
||||
}(jQuery));
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Latvian translation for bootstrap-datepicker
|
||||
* Artis Avotins <artis@apit.lv>
|
||||
*/
|
||||
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['lv'] = {
|
||||
days: ["Svētdiena", "Pirmdiena", "Otrdiena", "Trešdiena", "Ceturtdiena", "Piektdiena", "Sestdiena", "Svētdiena"],
|
||||
daysShort: ["Sv", "P", "O", "T", "C", "Pk", "S", "Sv"],
|
||||
daysMin: ["Sv", "Pr", "Ot", "Tr", "Ce", "Pk", "St", "Sv"],
|
||||
months: ["Janvāris", "Februāris", "Marts", "Aprīlis", "Maijs", "Jūnijs", "Jūlijs", "Augusts", "Septembris", "Oktobris", "Novembris", "Decembris"],
|
||||
monthsShort: ["Jan", "Feb", "Mar", "Apr", "Mai", "Jūn", "Jūl", "Aug", "Sep", "Okt", "Nov", "Dec."],
|
||||
today: "Šodien",
|
||||
weekStart: 1
|
||||
};
|
||||
}(jQuery));
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Malay translation for bootstrap-datepicker
|
||||
* Ateman Faiz <noorulfaiz@gmail.com>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['ms'] = {
|
||||
days: ["Ahad", "Isnin", "Selasa", "Rabu", "Khamis", "Jumaat", "Sabtu", "Ahad"],
|
||||
daysShort: ["Aha", "Isn", "Sel", "Rab", "Kha", "Jum", "Sab", "Aha"],
|
||||
daysMin: ["Ah", "Is", "Se", "Ra", "Kh", "Ju", "Sa", "Ah"],
|
||||
months: ["Januari", "Februari", "Mac", "April", "Mei", "Jun", "Julai", "Ogos", "September", "Oktober", "November", "Disember"],
|
||||
monthsShort: ["Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Ogo", "Sep", "Okt", "Nov", "Dis"],
|
||||
today: "Hari Ini"
|
||||
};
|
||||
}(jQuery));
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Norwegian (bokmål) translation for bootstrap-datepicker
|
||||
* Fredrik Sundmyhr <http://github.com/fsundmyhr>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['nb'] = {
|
||||
days: ["Søndag", "Mandag", "Tirsdag", "Onsdag", "Torsdag", "Fredag", "Lørdag", "Søndag"],
|
||||
daysShort: ["Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør", "Søn"],
|
||||
daysMin: ["Sø", "Ma", "Ti", "On", "To", "Fr", "Lø", "Sø"],
|
||||
months: ["Januar", "Februar", "Mars", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Desember"],
|
||||
monthsShort: ["Jan", "Feb", "Mar", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Des"],
|
||||
today: "I Dag"
|
||||
};
|
||||
}(jQuery));
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Dutch translation for bootstrap-datepicker
|
||||
* Reinier Goltstein <mrgoltstein@gmail.com>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['nl'] = {
|
||||
days: ["Zondag", "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag", "Zondag"],
|
||||
daysShort: ["Zo", "Ma", "Di", "Wo", "Do", "Vr", "Za", "Zo"],
|
||||
daysMin: ["Zo", "Ma", "Di", "Wo", "Do", "Vr", "Za", "Zo"],
|
||||
months: ["Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December"],
|
||||
monthsShort: ["Jan", "Feb", "Mrt", "Apr", "Mei", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec"],
|
||||
today: "Vandaag"
|
||||
};
|
||||
}(jQuery));
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Polish translation for bootstrap-datepicker
|
||||
* Robert <rtpm@gazeta.pl>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['pl'] = {
|
||||
days: ["Niedziela", "Poniedziałek", "Wtorek", "Środa", "Czwartek", "Piątek", "Sobota", "Niedziela"],
|
||||
daysShort: ["Nie", "Pn", "Wt", "Śr", "Czw", "Pt", "So", "Nie"],
|
||||
daysMin: ["N", "Pn", "Wt", "Śr", "Cz", "Pt", "So", "N"],
|
||||
months: ["Styczeń", "Luty", "Marzec", "Kwiecień", "Maj", "Czerwiec", "Lipiec", "Sierpień", "Wrzesień", "Październik", "Listopad", "Grudzień"],
|
||||
monthsShort: ["Sty", "Lu", "Mar", "Kw", "Maj", "Cze", "Lip", "Sie", "Wrz", "Pa", "Lis", "Gru"],
|
||||
today: "Dzisiaj",
|
||||
weekStart: 1
|
||||
};
|
||||
}(jQuery));
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Brazilian translation for bootstrap-datepicker
|
||||
* Cauan Cabral <cauan@radig.com.br>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['pt-BR'] = {
|
||||
days: ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado", "Domingo"],
|
||||
daysShort: ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb", "Dom"],
|
||||
daysMin: ["Do", "Se", "Te", "Qu", "Qu", "Se", "Sa", "Do"],
|
||||
months: ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"],
|
||||
monthsShort: ["Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez"],
|
||||
today: "Hoje"
|
||||
};
|
||||
}(jQuery));
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Portuguese translation for bootstrap-datepicker
|
||||
* Original code: Cauan Cabral <cauan@radig.com.br>
|
||||
* Tiago Melo <tiago.blackcode@gmail.com>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['pt'] = {
|
||||
days: ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado", "Domingo"],
|
||||
daysShort: ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb", "Dom"],
|
||||
daysMin: ["Do", "Se", "Te", "Qu", "Qu", "Se", "Sa", "Do"],
|
||||
months: ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"],
|
||||
monthsShort: ["Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez"]
|
||||
};
|
||||
}(jQuery));
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Romanian translation for bootstrap-datepicker
|
||||
* Cristian Vasile <cristi.mie@gmail.com>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['ro'] = {
|
||||
days: ["Duminică", "Luni", "Marţi", "Miercuri", "Joi", "Vineri", "Sâmbătă", "Duminică"],
|
||||
daysShort: ["Dum", "Lun", "Mar", "Mie", "Joi", "Vin", "Sâm", "Dum"],
|
||||
daysMin: ["Du", "Lu", "Ma", "Mi", "Jo", "Vi", "Sâ", "Du"],
|
||||
months: ["Ianuarie", "Februarie", "Martie", "Aprilie", "Mai", "Iunie", "Iulie", "August", "Septembrie", "Octombrie", "Noiembrie", "Decembrie"],
|
||||
monthsShort: ["Ian", "Feb", "Mar", "Apr", "Mai", "Iun", "Iul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
||||
today: "Astăzi",
|
||||
weekStart: 1
|
||||
};
|
||||
}(jQuery));
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Serbian latin translation for bootstrap-datepicker
|
||||
* Bojan Milosavlević <milboj@gmail.com>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['rs'] = {
|
||||
days: ["Nedelja","Ponedeljak", "Utorak", "Sreda", "Četvrtak", "Petak", "Subota", "Nedelja"],
|
||||
daysShort: ["Ned", "Pon", "Uto", "Sre", "Čet", "Pet", "Sub", "Ned"],
|
||||
daysMin: ["N", "Po", "U", "Sr", "Č", "Pe", "Su", "N"],
|
||||
months: ["Januar", "Februar", "Mart", "April", "Maj", "Jun", "Jul", "Avgust", "Septembar", "Oktobar", "Novembar", "Decembar"],
|
||||
monthsShort: ["Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Avg", "Sep", "Okt", "Nov", "Dec"],
|
||||
today: "Danas"
|
||||
};
|
||||
}(jQuery));
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Serbian cyrillic translation for bootstrap-datepicker
|
||||
* Bojan Milosavlević <milboj@gmail.com>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['rs'] = {
|
||||
days: ["Недеља","Понедељак", "Уторак", "Среда", "Четвртак", "Петак", "Субота", "Недеља"],
|
||||
daysShort: ["Нед", "Пон", "Уто", "Сре", "Чет", "Пет", "Суб", "Нед"],
|
||||
daysMin: ["Н", "По", "У", "Ср", "Ч", "Пе", "Су", "Н"],
|
||||
months: ["Јануар", "Фебруар", "Март", "Април", "Мај", "Јун", "Јул", "Август", "Септембар", "Октобар", "Новембар", "Децембар"],
|
||||
monthsShort: ["Јан", "Феб", "Мар", "Апр", "Мај", "Јун", "Јул", "Авг", "Сеп", "Окт", "Нов", "Дец"],
|
||||
today: "Данас"
|
||||
};
|
||||
}(jQuery));
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Russian translation for bootstrap-datepicker
|
||||
* Victor Taranenko <darwin@snowdale.com>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['ru'] = {
|
||||
days: ["Воскресенье", "Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота", "Воскресенье"],
|
||||
daysShort: ["Вск", "Пнд", "Втр", "Срд", "Чтв", "Птн", "Суб", "Вск"],
|
||||
daysMin: ["Вс", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Вс"],
|
||||
months: ["Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "Декабрь"],
|
||||
monthsShort: ["Янв", "Фев", "Мар", "Апр", "Май", "Июн", "Июл", "Авг", "Сен", "Окт", "Ноя", "Дек"],
|
||||
today: "Сегодня"
|
||||
};
|
||||
}(jQuery));
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Slovak translation for bootstrap-datepicker
|
||||
* Marek Lichtner <marek@licht.sk>
|
||||
* Fixes by Michal Remiš <michal.remis@gmail.com>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates["sk"] = {
|
||||
days: ["Nedeľa", "Pondelok", "Utorok", "Streda", "Štvrtok", "Piatok", "Sobota", "Nedeľa"],
|
||||
daysShort: ["Ned", "Pon", "Uto", "Str", "Štv", "Pia", "Sob", "Ned"],
|
||||
daysMin: ["Ne", "Po", "Ut", "St", "Št", "Pia", "So", "Ne"],
|
||||
months: ["Január", "Február", "Marec", "Apríl", "Máj", "Jún", "Júl", "August", "September", "Október", "November", "December"],
|
||||
monthsShort: ["Jan", "Feb", "Mar", "Apr", "Máj", "Jún", "Júl", "Aug", "Sep", "Okt", "Nov", "Dec"],
|
||||
today: "Dnes"
|
||||
};
|
||||
}(jQuery));
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Slovene translation for bootstrap-datepicker
|
||||
* Gregor Rudolf <gregor.rudolf@gmail.com>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['sl'] = {
|
||||
days: ["Nedelja", "Ponedeljek", "Torek", "Sreda", "Četrtek", "Petek", "Sobota", "Nedelja"],
|
||||
daysShort: ["Ned", "Pon", "Tor", "Sre", "Čet", "Pet", "Sob", "Ned"],
|
||||
daysMin: ["Ne", "Po", "To", "Sr", "Če", "Pe", "So", "Ne"],
|
||||
months: ["Januar", "Februar", "Marec", "April", "Maj", "Junij", "Julij", "Avgust", "September", "Oktober", "November", "December"],
|
||||
monthsShort: ["Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Avg", "Sep", "Okt", "Nov", "Dec"],
|
||||
today: "Danes"
|
||||
};
|
||||
}(jQuery));
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Swedish translation for bootstrap-datepicker
|
||||
* Patrik Ragnarsson <patrik@starkast.net>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['sv'] = {
|
||||
days: ["Söndag", "Måndag", "Tisdag", "Onsdag", "Torsdag", "Fredag", "Lördag", "Söndag"],
|
||||
daysShort: ["Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör", "Sön"],
|
||||
daysMin: ["Sö", "Må", "Ti", "On", "To", "Fr", "Lö", "Sö"],
|
||||
months: ["Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December"],
|
||||
monthsShort: ["Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec"],
|
||||
today: "I Dag"
|
||||
};
|
||||
}(jQuery));
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Swahili translation for bootstrap-datepicker
|
||||
* Edwin Mugendi <https://github.com/edwinmugendi>
|
||||
* Source: http://scriptsource.org/cms/scripts/page.php?item_id=entry_detail&uid=xnfaqyzcku
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['sw'] = {
|
||||
days: ["Jumapili", "Jumatatu", "Jumanne", "Jumatano", "Alhamisi", "Ijumaa", "Jumamosi", "Jumapili"],
|
||||
daysShort: ["J2", "J3", "J4", "J5", "Alh", "Ij", "J1", "J2"],
|
||||
daysMin: ["2", "3", "4", "5", "A", "I", "1", "2"],
|
||||
months: ["Januari", "Februari", "Machi", "Aprili", "Mei", "Juni", "Julai", "Agosti", "Septemba", "Oktoba", "Novemba", "Desemba"],
|
||||
monthsShort: ["Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ago", "Sep", "Okt", "Nov", "Des"],
|
||||
today: "Leo"
|
||||
};
|
||||
}(jQuery));
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Thai translation for bootstrap-datepicker
|
||||
* Suchau Jiraprapot <seroz24@gmail.com>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['th'] = {
|
||||
days: ["อาทิตย์", "จันทร์", "อังคาร", "พุธ", "พฤหัส", "ศุกร์", "เสาร์", "อาทิตย์"],
|
||||
daysShort: ["อา", "จ", "อ", "พ", "พฤ", "ศ", "ส", "อา"],
|
||||
daysMin: ["อา", "จ", "อ", "พ", "พฤ", "ศ", "ส", "อา"],
|
||||
months: ["มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม"],
|
||||
monthsShort: ["ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค."],
|
||||
today: "วันนี้"
|
||||
};
|
||||
}(jQuery));
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Turkish translation for bootstrap-datepicker
|
||||
* Serkan Algur <kaisercrazy_2@hotmail.com>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['tr'] = {
|
||||
days: ["Pazar", "Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma", "Cumartesi", "Pazar"],
|
||||
daysShort: ["Pz", "Pzt", "Sal", "Çrş", "Prş", "Cu", "Cts", "Pz"],
|
||||
daysMin: ["Pz", "Pzt", "Sa", "Çr", "Pr", "Cu", "Ct", "Pz"],
|
||||
months: ["Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"],
|
||||
monthsShort: ["Oca", "Şub", "Mar", "Nis", "May", "Haz", "Tem", "Ağu", "Eyl", "Eki", "Kas", "Ara"],
|
||||
today: "Bugün"
|
||||
};
|
||||
}(jQuery));
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Ukrainian translation for bootstrap-datepicker
|
||||
* Andrey Vityuk <andrey [dot] vityuk [at] gmail.com>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['uk'] = {
|
||||
days: ["Неділя", "Понеділок", "Вівторок", "Середа", "Четвер", "П'ятниця", "Субота", "Неділя"],
|
||||
daysShort: ["Нед", "Пнд", "Втр", "Срд", "Чтв", "Птн", "Суб", "Нед"],
|
||||
daysMin: ["Нд", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Нд"],
|
||||
months: ["Січень", "Лютий", "Березень", "Квітень", "Травень", "Червень", "Липень", "Серпень", "Вересень", "Жовтень", "Листопад", "Грудень"],
|
||||
monthsShort: ["Січ", "Лют", "Бер", "Кві", "Тра", "Чер", "Лип", "Сер", "Вер", "Жов", "Лис", "Гру"],
|
||||
today: "Сьогодні"
|
||||
};
|
||||
}(jQuery));
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Simplified Chinese translation for bootstrap-datepicker
|
||||
* Yuan Cheung <advanimal@gmail.com>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['zh-CN'] = {
|
||||
days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"],
|
||||
daysShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六", "周日"],
|
||||
daysMin: ["日", "一", "二", "三", "四", "五", "六", "日"],
|
||||
months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
|
||||
monthsShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
|
||||
today: "今日"
|
||||
};
|
||||
}(jQuery));
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Traditional Chinese translation for bootstrap-datepicker
|
||||
* Rung-Sheng Jang <daniel@i-trend.co.cc>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.datepicker.dates['zh-TW'] = {
|
||||
days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"],
|
||||
daysShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六", "周日"],
|
||||
daysMin: ["日", "一", "二", "三", "四", "五", "六", "日"],
|
||||
months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
|
||||
monthsShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"]
|
||||
};
|
||||
}(jQuery));
|
||||
+168
@@ -0,0 +1,168 @@
|
||||
/*!
|
||||
* Datepicker for Bootstrap
|
||||
*
|
||||
* Copyright 2012 Stefan Petre
|
||||
* Improvements by Andrew Rowls
|
||||
* Licensed under the Apache License v2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*/
|
||||
|
||||
.datepicker {
|
||||
padding: 4px;
|
||||
margin-top: 1px;
|
||||
.border-radius(4px);
|
||||
&-inline {
|
||||
width: 220px;
|
||||
}
|
||||
direction: ltr;
|
||||
&&-rtl {
|
||||
direction: rtl;
|
||||
table tr td span {
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
&-dropdown {
|
||||
top: 0;
|
||||
left: 0;
|
||||
&:before {
|
||||
content: '';
|
||||
display: inline-block;
|
||||
border-left: 7px solid transparent;
|
||||
border-right: 7px solid transparent;
|
||||
border-bottom: 7px solid #ccc;
|
||||
border-bottom-color: rgba(0,0,0,.2);
|
||||
position: absolute;
|
||||
top: -7px;
|
||||
left: 6px;
|
||||
}
|
||||
&:after {
|
||||
content: '';
|
||||
display: inline-block;
|
||||
border-left: 6px solid transparent;
|
||||
border-right: 6px solid transparent;
|
||||
border-bottom: 6px solid @white;
|
||||
position: absolute;
|
||||
top: -6px;
|
||||
left: 7px;
|
||||
}
|
||||
}
|
||||
>div {
|
||||
display: none;
|
||||
}
|
||||
&.days div.datepicker-days {
|
||||
display: block;
|
||||
}
|
||||
&.months div.datepicker-months {
|
||||
display: block;
|
||||
}
|
||||
&.years div.datepicker-years {
|
||||
display: block;
|
||||
}
|
||||
table{
|
||||
margin: 0;
|
||||
}
|
||||
td,
|
||||
th{
|
||||
text-align: center;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
.border-radius(4px);
|
||||
|
||||
border: none;
|
||||
}
|
||||
// Inline display inside a table presents some problems with
|
||||
// border and background colors.
|
||||
.table-striped & table tr {
|
||||
td, th {
|
||||
background-color:transparent;
|
||||
}
|
||||
}
|
||||
table tr td {
|
||||
&.day:hover {
|
||||
background: @grayLighter;
|
||||
cursor: pointer;
|
||||
}
|
||||
&.old,
|
||||
&.new {
|
||||
color: @grayLight;
|
||||
}
|
||||
&.disabled,
|
||||
&.disabled:hover {
|
||||
background: none;
|
||||
color: @grayLight;
|
||||
cursor: default;
|
||||
}
|
||||
&.today,
|
||||
&.today:hover,
|
||||
&.today.disabled,
|
||||
&.today.disabled:hover {
|
||||
@todayBackground: lighten(@orange, 30%);
|
||||
.buttonBackground(@todayBackground, spin(@todayBackground, 20));
|
||||
}
|
||||
&.active,
|
||||
&.active:hover,
|
||||
&.active.disabled,
|
||||
&.active.disabled:hover {
|
||||
.buttonBackground(@btnPrimaryBackground, spin(@btnPrimaryBackground, 20));
|
||||
color: #fff;
|
||||
text-shadow: 0 -1px 0 rgba(0,0,0,.25);
|
||||
}
|
||||
span {
|
||||
display: block;
|
||||
width: 23%;
|
||||
height: 54px;
|
||||
line-height: 54px;
|
||||
float: left;
|
||||
margin: 1%;
|
||||
cursor: pointer;
|
||||
.border-radius(4px);
|
||||
&:hover {
|
||||
background: @grayLighter;
|
||||
}
|
||||
&.disabled,
|
||||
&.disabled:hover {
|
||||
background:none;
|
||||
color: @grayLight;
|
||||
cursor: default;
|
||||
}
|
||||
&.active,
|
||||
&.active:hover,
|
||||
&.active.disabled,
|
||||
&.active.disabled:hover {
|
||||
.buttonBackground(@btnPrimaryBackground, spin(@btnPrimaryBackground, 20));
|
||||
color: #fff;
|
||||
text-shadow: 0 -1px 0 rgba(0,0,0,.25);
|
||||
}
|
||||
&.old {
|
||||
color: @grayLight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
th.switch {
|
||||
width: 145px;
|
||||
}
|
||||
|
||||
thead tr:first-child th,
|
||||
tfoot tr:first-child th {
|
||||
cursor: pointer;
|
||||
&:hover{
|
||||
background: @grayLighter;
|
||||
}
|
||||
}
|
||||
/*.dow {
|
||||
border-top: 1px solid #ddd !important;
|
||||
}*/
|
||||
}
|
||||
.input-append,
|
||||
.input-prepend {
|
||||
&.date {
|
||||
.add-on i {
|
||||
display: block;
|
||||
cursor: pointer;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
Unit tests, written with [QUnit](http://docs.jquery.com/QUnit), are used to
|
||||
expose bugs for squashing, prevent bugs from respawning, and suppress new
|
||||
bugs when adding new features and making changes.
|
||||
|
||||
# Running the tests
|
||||
|
||||
The simplest way to run the tests is to open `tests/tests.html` in your browser.
|
||||
The test suites will automatically run themselves and present their results.
|
||||
|
||||
To run the tests from the command line, download and install
|
||||
[PhantomJS](http://phantomjs.org/), and run `run-qunit.js` with it:
|
||||
|
||||
$ cd tests/
|
||||
$ phantomjs run-qunit.js tests.html
|
||||
|
||||
Failed tests and their failed assertions will be printed to the console. A
|
||||
results summary will be printed at the end.
|
||||
|
||||
To generate coverage statistics, use [JSCoverage](http://siliconforks.com/jscoverage/)
|
||||
to instrument the js files:
|
||||
|
||||
$ cd tests/
|
||||
$ jscoverage ../js/ ../instrumented/
|
||||
$ phantomjs run-qunit.js tests.html
|
||||
|
||||
Coverage percentage will be included in the output summary, and a highlighted
|
||||
line-by-line html file will be generated.
|
||||
|
||||
# Shout-out
|
||||
|
||||
Thanks to Rod @ While One Fork for the
|
||||
[CIS guide](http://whileonefork.blogspot.com/2011/10/integrating-javascript-tests-into-cli.html)
|
||||
on putting the above together.
|
||||
|
||||
# Adding tests
|
||||
|
||||
Tests go in js files in the `tests/suites/` directory tree. QUnit organizes
|
||||
tests into suites called "modules"; there is one module per js file. If the
|
||||
tests you are adding do not fit into an existing module, create a new one at
|
||||
`tests/suites/<new module>.js`, where `<new module>` is a broad yet
|
||||
descriptive name for the suite. If tests have many year-specific cases (ie,
|
||||
behave differently in leap years vs normal years, or have specific buggy
|
||||
behavior in a certain year), create the module in a new directory,
|
||||
`tests/suites/<new module>/<year>.js`, where `<new module>` is the decriptive
|
||||
name and `<year>` is the four-digit year the tests pertain to.
|
||||
|
||||
In order for new tests to be run, they must be imported into `tests/tests.html`.
|
||||
Find the script includes headed by the html comment `<!-- Test suites -->`, and
|
||||
add a new one to the list which includes the new js files.
|
||||
|
||||
# Can I use this?
|
||||
|
||||
By all means, please do! Just note that I stopped working on this structure
|
||||
once it fit my needs, there's no real support for it, and it may change in the
|
||||
future. Otherwise, have at it.
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
.code {
|
||||
white-space: pre-wrap;
|
||||
font-family: monospace;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.miss {
|
||||
background-color: #FF0000;
|
||||
}
|
||||
|
||||
.hit, .undef {
|
||||
background-color: #94FF7C;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
COLORIZED_LINE_HTML
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
(function(){
|
||||
//we want this at global scope so outside callers can find it. In a more realistic implementation we
|
||||
//should probably put it in a namespace.
|
||||
window.getCoverageByLine = function(silent) {
|
||||
var key = null;
|
||||
var lines = null;
|
||||
var source = null;
|
||||
//look for code coverage data
|
||||
if (typeof window._$jscoverage === 'object') {
|
||||
for (key in _$jscoverage) {}
|
||||
lines = _$jscoverage[key];
|
||||
}
|
||||
|
||||
if (!lines && !silent) {
|
||||
console.log('code coverage data is NOT available');
|
||||
}
|
||||
|
||||
return { 'key': key, 'lines': lines };
|
||||
};
|
||||
|
||||
QUnit.done = function(t) {
|
||||
var cvgInfo = getCoverageByLine(true);
|
||||
if (!!cvgInfo.key) {
|
||||
var testableLines = 0;
|
||||
var testedLines = 0;
|
||||
var untestableLines = 0;
|
||||
for (lineIdx in cvgInfo.lines) {
|
||||
var cvg = cvgInfo.lines[lineIdx];
|
||||
if (typeof cvg === 'number') {
|
||||
testableLines += 1;
|
||||
if (cvg > 0) {
|
||||
testedLines += 1;
|
||||
}
|
||||
} else {
|
||||
untestableLines += 1;
|
||||
}
|
||||
}
|
||||
var coverage = '' + Math.floor(100 * testedLines / testableLines) + '%';
|
||||
|
||||
var result = document.getElementById('qunit-testresult');
|
||||
if (result != null) {
|
||||
result.innerHTML = result.innerHTML + ' ' + coverage + ' test coverage of ' + cvgInfo.key;
|
||||
} else {
|
||||
console.log('can\'t find test-result element to update');
|
||||
}
|
||||
}
|
||||
};
|
||||
}());
|
||||
+4
File diff suppressed because one or more lines are too long
+26
@@ -0,0 +1,26 @@
|
||||
;(function(){
|
||||
|
||||
window.patch_date = function patch(f){
|
||||
var NativeDate = window.Date;
|
||||
var date = function date(y,m,d,h,i,s,j){
|
||||
switch(arguments.length){
|
||||
case 0: return date.now ? new NativeDate(date.now) : new NativeDate();
|
||||
case 1: return new NativeDate(y);
|
||||
case 2: return new NativeDate(y,m);
|
||||
case 3: return new NativeDate(y,m,d);
|
||||
case 4: return new NativeDate(y,m,d,h);
|
||||
case 5: return new NativeDate(y,m,d,h,i);
|
||||
case 6: return new NativeDate(y,m,d,h,i,s);
|
||||
case 7: return new NativeDate(y,y,m,d,h,i,s,j);
|
||||
}
|
||||
};
|
||||
date.UTC = NativeDate.UTC;
|
||||
return function(){
|
||||
Array.prototype.push.call(arguments, date);
|
||||
window.Date = date;
|
||||
res = f.apply(this, arguments);
|
||||
window.Date = NativeDate;
|
||||
}
|
||||
}
|
||||
|
||||
}());
|
||||
@@ -0,0 +1,29 @@
|
||||
// Dummy logging calls (ie, if tests are run in IE)
|
||||
window.console = window.console || {};
|
||||
window.console.log = window.console.log || function(){};
|
||||
window.console.debug = window.console.debug || function(){};
|
||||
window.console.info = window.console.info || function(){};
|
||||
window.console.warn = window.console.warn || function(){};
|
||||
window.console.error = window.console.error || function(){};
|
||||
|
||||
(function() {
|
||||
var modName, testName;
|
||||
|
||||
//arg: { name }
|
||||
QUnit.testStart = function(t) {
|
||||
modName = t.module;
|
||||
testName = t.name;
|
||||
};
|
||||
|
||||
//arg: { name, failed, passed, total }
|
||||
QUnit.testDone = function(t) {
|
||||
if (t.failed)
|
||||
console.log('Test "' + t.module + ': ' + t.name + '" completed: ' + (0 === t.failed ? 'pass' : 'FAIL') + '\n')
|
||||
};
|
||||
|
||||
//{ result, actual, expected, message }
|
||||
QUnit.log = function(t) {
|
||||
if (!t.result)
|
||||
console.log('Test "' + modName + ': ' + testName + '" assertion failed. Expected <' + t.expected + '> Actual <' + t.actual + '>' + (t.message ? ': \'' + t.message + '\'' : ''));
|
||||
};
|
||||
}());
|
||||
+235
@@ -0,0 +1,235 @@
|
||||
/**
|
||||
* QUnit v1.5.0 - A JavaScript Unit Testing Framework
|
||||
*
|
||||
* http://docs.jquery.com/QUnit
|
||||
*
|
||||
* Copyright (c) 2012 John Resig, Jörn Zaefferer
|
||||
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
||||
* or GPL (GPL-LICENSE.txt) licenses.
|
||||
*/
|
||||
|
||||
/** Font Family and Sizes */
|
||||
|
||||
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
|
||||
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
|
||||
#qunit-tests { font-size: smaller; }
|
||||
|
||||
|
||||
/** Resets */
|
||||
|
||||
#qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
||||
/** Header */
|
||||
|
||||
#qunit-header {
|
||||
padding: 0.5em 0 0.5em 1em;
|
||||
|
||||
color: #8699a4;
|
||||
background-color: #0d3349;
|
||||
|
||||
font-size: 1.5em;
|
||||
line-height: 1em;
|
||||
font-weight: normal;
|
||||
|
||||
border-radius: 15px 15px 0 0;
|
||||
-moz-border-radius: 15px 15px 0 0;
|
||||
-webkit-border-top-right-radius: 15px;
|
||||
-webkit-border-top-left-radius: 15px;
|
||||
}
|
||||
|
||||
#qunit-header a {
|
||||
text-decoration: none;
|
||||
color: #c2ccd1;
|
||||
}
|
||||
|
||||
#qunit-header a:hover,
|
||||
#qunit-header a:focus {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#qunit-header label {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
#qunit-banner {
|
||||
height: 5px;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar {
|
||||
padding: 0.5em 0 0.5em 2em;
|
||||
color: #5E740B;
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
#qunit-userAgent {
|
||||
padding: 0.5em 0 0.5em 2.5em;
|
||||
background-color: #2b81af;
|
||||
color: #fff;
|
||||
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
|
||||
}
|
||||
|
||||
|
||||
/** Tests: Pass/Fail */
|
||||
|
||||
#qunit-tests {
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
#qunit-tests li {
|
||||
padding: 0.4em 0.5em 0.4em 2.5em;
|
||||
border-bottom: 1px solid #fff;
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#qunit-tests li strong {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#qunit-tests li a {
|
||||
padding: 0.5em;
|
||||
color: #c2ccd1;
|
||||
text-decoration: none;
|
||||
}
|
||||
#qunit-tests li a:hover,
|
||||
#qunit-tests li a:focus {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#qunit-tests ol {
|
||||
margin-top: 0.5em;
|
||||
padding: 0.5em;
|
||||
|
||||
background-color: #fff;
|
||||
|
||||
border-radius: 15px;
|
||||
-moz-border-radius: 15px;
|
||||
-webkit-border-radius: 15px;
|
||||
|
||||
box-shadow: inset 0px 2px 13px #999;
|
||||
-moz-box-shadow: inset 0px 2px 13px #999;
|
||||
-webkit-box-shadow: inset 0px 2px 13px #999;
|
||||
}
|
||||
|
||||
#qunit-tests table {
|
||||
border-collapse: collapse;
|
||||
margin-top: .2em;
|
||||
}
|
||||
|
||||
#qunit-tests th {
|
||||
text-align: right;
|
||||
vertical-align: top;
|
||||
padding: 0 .5em 0 0;
|
||||
}
|
||||
|
||||
#qunit-tests td {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
#qunit-tests pre {
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
#qunit-tests del {
|
||||
background-color: #e0f2be;
|
||||
color: #374e0c;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#qunit-tests ins {
|
||||
background-color: #ffcaca;
|
||||
color: #500;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/*** Test Counts */
|
||||
|
||||
#qunit-tests b.counts { color: black; }
|
||||
#qunit-tests b.passed { color: #5E740B; }
|
||||
#qunit-tests b.failed { color: #710909; }
|
||||
|
||||
#qunit-tests li li {
|
||||
margin: 0.5em;
|
||||
padding: 0.4em 0.5em 0.4em 0.5em;
|
||||
background-color: #fff;
|
||||
border-bottom: none;
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
/*** Passing Styles */
|
||||
|
||||
#qunit-tests li li.pass {
|
||||
color: #5E740B;
|
||||
background-color: #fff;
|
||||
border-left: 26px solid #C6E746;
|
||||
}
|
||||
|
||||
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
|
||||
#qunit-tests .pass .test-name { color: #366097; }
|
||||
|
||||
#qunit-tests .pass .test-actual,
|
||||
#qunit-tests .pass .test-expected { color: #999999; }
|
||||
|
||||
#qunit-banner.qunit-pass { background-color: #C6E746; }
|
||||
|
||||
/*** Failing Styles */
|
||||
|
||||
#qunit-tests li li.fail {
|
||||
color: #710909;
|
||||
background-color: #fff;
|
||||
border-left: 26px solid #EE5757;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
#qunit-tests > li:last-child {
|
||||
border-radius: 0 0 15px 15px;
|
||||
-moz-border-radius: 0 0 15px 15px;
|
||||
-webkit-border-bottom-right-radius: 15px;
|
||||
-webkit-border-bottom-left-radius: 15px;
|
||||
}
|
||||
|
||||
#qunit-tests .fail { color: #000000; background-color: #EE5757; }
|
||||
#qunit-tests .fail .test-name,
|
||||
#qunit-tests .fail .module-name { color: #000000; }
|
||||
|
||||
#qunit-tests .fail .test-actual { color: #EE5757; }
|
||||
#qunit-tests .fail .test-expected { color: green; }
|
||||
|
||||
#qunit-banner.qunit-fail { background-color: #EE5757; }
|
||||
|
||||
|
||||
/** Result */
|
||||
|
||||
#qunit-testresult {
|
||||
padding: 0.5em 0.5em 0.5em 2.5em;
|
||||
|
||||
color: #2b81af;
|
||||
background-color: #D2E0E6;
|
||||
|
||||
border-bottom: 1px solid white;
|
||||
}
|
||||
#qunit-testresult .module-name {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/** Fixture */
|
||||
|
||||
#qunit-fixture {
|
||||
position: absolute;
|
||||
top: -10000px;
|
||||
left: -10000px;
|
||||
width: 1000px;
|
||||
height: 1000px;
|
||||
}
|
||||
+1669
File diff suppressed because it is too large
Load Diff
+21
@@ -0,0 +1,21 @@
|
||||
function UTCDate(){
|
||||
return new Date(Date.UTC.apply(Date, arguments));
|
||||
}
|
||||
|
||||
|
||||
function format_date(date){
|
||||
var y = date.getUTCFullYear(),
|
||||
m = date.getUTCMonth() + 1,
|
||||
d = date.getUTCDate(),
|
||||
h = date.getUTCHours(),
|
||||
i = date.getUTCMinutes(),
|
||||
s = date.getUTCSeconds(),
|
||||
l = date.getUTCMilliseconds();
|
||||
function z(i){return (i <= 9 ? '0'+i : i);}
|
||||
return y+'-'+z(m)+'-'+z(d)+' '+z(h)+':'+z(i)+':'+z(s)+'.'+z(l);
|
||||
}
|
||||
|
||||
|
||||
function datesEqual(actual, expected, message){
|
||||
QUnit.push(QUnit.equiv(actual, expected), format_date(actual), format_date(expected), message);
|
||||
}
|
||||
+157
@@ -0,0 +1,157 @@
|
||||
var system = require('system');
|
||||
|
||||
/**
|
||||
* Wait until the test condition is true or a timeout occurs. Useful for waiting
|
||||
* on a server response or for a ui change (fadeIn, etc.) to occur.
|
||||
*
|
||||
* @param testFx javascript condition that evaluates to a boolean,
|
||||
* it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
|
||||
* as a callback function.
|
||||
* @param onReady what to do when testFx condition is fulfilled,
|
||||
* it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
|
||||
* as a callback function.
|
||||
* @param timeOutMillis the max amount of time to wait. If not specified, 3 sec is used.
|
||||
*/
|
||||
function waitFor(testFx, onReady, timeOutMillis) {
|
||||
var maxtimeOutMillis = timeOutMillis ? timeOutMillis : 10001, //< Default Max Timout is 3s
|
||||
start = new Date().getTime(),
|
||||
condition = false,
|
||||
interval = setInterval(function() {
|
||||
if ( (new Date().getTime() - start < maxtimeOutMillis) && !condition ) {
|
||||
// If not time-out yet and condition not yet fulfilled
|
||||
condition = (typeof(testFx) === "string" ? eval(testFx) : testFx()); //< defensive code
|
||||
} else {
|
||||
if(!condition) {
|
||||
// If condition still not fulfilled (timeout but condition is 'false')
|
||||
console.log("'waitFor()' timeout");
|
||||
phantom.exit(1);
|
||||
} else {
|
||||
// Condition fulfilled (timeout and/or condition is 'true')
|
||||
//console.log("'waitFor()' finished in " + (new Date().getTime() - start) + "ms.");
|
||||
typeof(onReady) === "string" ? eval(onReady) : onReady(); //< Do what it's supposed to do once the condition is fulfilled
|
||||
clearInterval(interval); //< Stop this interval
|
||||
}
|
||||
}
|
||||
}, 100); //< repeat check every 100ms
|
||||
};
|
||||
|
||||
if (system.args.length !== 2) {
|
||||
console.log('Usage: run-qunit.js URL');
|
||||
phantom.exit(1);
|
||||
}
|
||||
|
||||
var fs = require('fs');
|
||||
var page = require('webpage').create();
|
||||
|
||||
// Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
|
||||
page.onConsoleMessage = function(msg) {
|
||||
console.log(msg);
|
||||
};
|
||||
page.onError = function (msg, trace) {
|
||||
console.log(msg);
|
||||
trace.forEach(function(item) {
|
||||
console.log(' ', item.file, ':', item.line);
|
||||
})
|
||||
}
|
||||
|
||||
var _openPath = phantom.args[0].replace(/^.*(\\|\/)/, '');
|
||||
var openPath = _openPath;
|
||||
var origdir = '../js/';
|
||||
var basedir = '../instrumented/';
|
||||
var coverageBase = fs.read('_coverage.html');
|
||||
|
||||
if (fs.exists(basedir)){
|
||||
var script = /<script.*><\/script>/g,
|
||||
src = /src=(["'])(.*?)\1/,
|
||||
contents = fs.read(openPath),
|
||||
_contents = contents,
|
||||
srcs = [],
|
||||
s;
|
||||
while (script.exec(contents)){
|
||||
s = src.exec(RegExp.lastMatch)[2];
|
||||
if (s && s.indexOf(origdir) != -1)
|
||||
_contents = _contents.replace(s, s.replace(origdir, basedir))
|
||||
}
|
||||
if (_contents != contents){
|
||||
openPath += '.cov.html';
|
||||
fs.write(openPath, _contents);
|
||||
}
|
||||
}
|
||||
|
||||
page.open(openPath, function(status){
|
||||
if (status !== "success") {
|
||||
console.log("Unable to access network");
|
||||
phantom.exit(1);
|
||||
} else {
|
||||
// Inject instrumented sources if they exist
|
||||
if (fs.exists(basedir))
|
||||
for (var i=0; i<srcs.length; i++)
|
||||
page.includeJs(srcs[i]);
|
||||
waitFor(function(){
|
||||
return page.evaluate(function(){
|
||||
var el = document.getElementById('qunit-testresult');
|
||||
if (el && el.innerText.match('completed')) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}, function(){
|
||||
// output colorized code coverage
|
||||
// reach into page context and pull out coverage info. stringify to pass context boundaries.
|
||||
var coverageInfo = JSON.parse(page.evaluate(function() { return JSON.stringify(getCoverageByLine()); }));
|
||||
if (coverageInfo.key){
|
||||
var lineCoverage = coverageInfo.lines;
|
||||
var originalFile = origdir + fs.separator + coverageInfo.key;
|
||||
var source = coverageInfo.source;
|
||||
var fileLines = readFileLines(originalFile);
|
||||
|
||||
var colorized = '';
|
||||
|
||||
for (var idx=0; idx < lineCoverage.length; idx++) {
|
||||
//+1: coverage lines count from 1.
|
||||
var cvg = lineCoverage[idx + 1];
|
||||
var hitmiss = '';
|
||||
if (typeof cvg === 'number') {
|
||||
hitmiss = ' ' + (cvg>0 ? 'hit' : 'miss');
|
||||
} else {
|
||||
hitmiss = ' ' + 'undef';
|
||||
}
|
||||
var htmlLine = fileLines[idx]
|
||||
if (!source)
|
||||
htmlLine = htmlLine.replace('<', '<').replace('>', '>');
|
||||
colorized += '<div class="code' + hitmiss + '">' + htmlLine + '</div>\n';
|
||||
};
|
||||
colorized = coverageBase.replace('COLORIZED_LINE_HTML', colorized);
|
||||
|
||||
fs.write('coverage.html', colorized, 'w');
|
||||
|
||||
console.log('Coverage for ' + coverageInfo.key + ' in coverage.html');
|
||||
}
|
||||
if (_openPath != openPath)
|
||||
fs.remove(openPath);
|
||||
|
||||
var failedNum = page.evaluate(function(){
|
||||
var el = document.getElementById('qunit-testresult');
|
||||
console.log(el.innerText);
|
||||
try {
|
||||
return el.getElementsByClassName('failed')[0].innerHTML;
|
||||
} catch (e) { }
|
||||
return 10000;
|
||||
});
|
||||
phantom.exit((parseInt(failedNum, 10) > 0) ? 1 : 0);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function readFileLines(filename) {
|
||||
var stream = fs.open(filename, 'r');
|
||||
var lines = [];
|
||||
var line;
|
||||
while (!stream.atEnd()) {
|
||||
lines.push(stream.readLine());
|
||||
}
|
||||
stream.close();
|
||||
|
||||
return lines;
|
||||
}
|
||||
|
||||
+157
@@ -0,0 +1,157 @@
|
||||
module('Component', {
|
||||
setup: function(){
|
||||
this.component = $('<div class="input-append date" id="datepicker">'+
|
||||
'<input size="16" type="text" value="12-02-2012" readonly>'+
|
||||
'<span class="add-on"><i class="icon-th"></i></span>'+
|
||||
'</div>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.datepicker({format: "dd-mm-yyyy"});
|
||||
this.input = this.component.find('input');
|
||||
this.addon = this.component.find('.add-on');
|
||||
this.dp = this.component.data('datepicker')
|
||||
this.picker = this.dp.picker;
|
||||
},
|
||||
teardown: function(){
|
||||
this.picker.remove();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
test('Component gets date/viewDate from input value', function(){
|
||||
datesEqual(this.dp.date, UTCDate(2012, 1, 12));
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 1, 12));
|
||||
});
|
||||
|
||||
test('Activation by component', function(){
|
||||
ok(!this.picker.is(':visible'));
|
||||
this.addon.click();
|
||||
ok(this.picker.is(':visible'));
|
||||
});
|
||||
|
||||
test('simple keyboard nav test', function(){
|
||||
var target;
|
||||
|
||||
// Keyboard nav only works with non-readonly inputs
|
||||
this.input.removeAttr('readonly');
|
||||
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'February 2012', 'Title is "February 2012"');
|
||||
datesEqual(this.dp.date, UTCDate(2012, 1, 12));
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 1, 12));
|
||||
|
||||
// Focus/open
|
||||
this.addon.click();
|
||||
|
||||
// Navigation: -1 day, left arrow key
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 37
|
||||
});
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 1, 11));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 1, 11));
|
||||
// Month not changed
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'February 2012', 'Title is "February 2012"');
|
||||
|
||||
// Navigation: +1 month, shift + right arrow key
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 39,
|
||||
shiftKey: true
|
||||
});
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 2, 11));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 11));
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'March 2012', 'Title is "March 2012"');
|
||||
|
||||
// Navigation: -1 year, ctrl + left arrow key
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 37,
|
||||
ctrlKey: true
|
||||
});
|
||||
datesEqual(this.dp.viewDate, UTCDate(2011, 2, 11));
|
||||
datesEqual(this.dp.date, UTCDate(2011, 2, 11));
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'March 2011', 'Title is "March 2011"');
|
||||
});
|
||||
|
||||
test('setValue', function(){
|
||||
this.dp.date = UTCDate(2012, 2, 13)
|
||||
this.dp.setValue()
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 13));
|
||||
equal(this.input.val(), '13-03-2012');
|
||||
});
|
||||
|
||||
test('update', function(){
|
||||
this.input.val('13-03-2012');
|
||||
this.dp.update()
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 13));
|
||||
});
|
||||
|
||||
test('Navigating to/from decade view', function(){
|
||||
var target;
|
||||
|
||||
this.addon.click();
|
||||
this.input.val('31-03-2012');
|
||||
this.dp.update();
|
||||
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
ok(target.is(':visible'), 'View switcher is visible');
|
||||
|
||||
target.click();
|
||||
ok(this.picker.find('.datepicker-months').is(':visible'), 'Month picker is visible');
|
||||
equal(this.dp.viewMode, 1);
|
||||
// Not modified when switching modes
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 2, 31));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 31));
|
||||
|
||||
target = this.picker.find('.datepicker-months thead th.switch');
|
||||
ok(target.is(':visible'), 'View switcher is visible');
|
||||
|
||||
target.click();
|
||||
ok(this.picker.find('.datepicker-years').is(':visible'), 'Year picker is visible');
|
||||
equal(this.dp.viewMode, 2);
|
||||
// Not modified when switching modes
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 2, 31));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 31));
|
||||
|
||||
// Change years to test internal state changes
|
||||
target = this.picker.find('.datepicker-years tbody span:contains(2011)');
|
||||
target.click();
|
||||
equal(this.dp.viewMode, 1);
|
||||
// Only viewDate modified
|
||||
datesEqual(this.dp.viewDate, UTCDate(2011, 2, 1));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 31));
|
||||
|
||||
target = this.picker.find('.datepicker-months tbody span:contains(Apr)');
|
||||
target.click();
|
||||
equal(this.dp.viewMode, 0);
|
||||
// Only viewDate modified
|
||||
datesEqual(this.dp.viewDate, UTCDate(2011, 3, 1));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 31));
|
||||
});
|
||||
|
||||
test('Selecting date resets viewDate and date', function(){
|
||||
var target;
|
||||
|
||||
this.addon.click();
|
||||
this.input.val('31-03-2012');
|
||||
this.dp.update();
|
||||
|
||||
// Rendered correctly
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days tbody td:first');
|
||||
equal(target.text(), '26'); // Should be Feb 26
|
||||
|
||||
// Updated internally on click
|
||||
target.click();
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 1, 26))
|
||||
datesEqual(this.dp.date, UTCDate(2012, 1, 26))
|
||||
|
||||
// Re-rendered on click
|
||||
target = this.picker.find('.datepicker-days tbody td:first');
|
||||
equal(target.text(), '29'); // Should be Jan 29
|
||||
});
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
module('Events', {
|
||||
setup: function(){
|
||||
this.input = $('<input type="text" value="31-03-2011">')
|
||||
.appendTo('#qunit-fixture')
|
||||
.datepicker({format: "dd-mm-yyyy"})
|
||||
.focus(); // Activate for visibility checks
|
||||
this.dp = this.input.data('datepicker')
|
||||
this.picker = this.dp.picker;
|
||||
},
|
||||
teardown: function(){
|
||||
this.picker.remove();
|
||||
}
|
||||
});
|
||||
|
||||
test('Selecting a year from decade view triggers pickYear', function(){
|
||||
var target,
|
||||
triggered = 0;
|
||||
|
||||
this.input.on('changeYear', function(){
|
||||
triggered++;
|
||||
});
|
||||
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
ok(target.is(':visible'), 'View switcher is visible');
|
||||
|
||||
target.click();
|
||||
ok(this.picker.find('.datepicker-months').is(':visible'), 'Month picker is visible');
|
||||
equal(this.dp.viewMode, 1);
|
||||
// Not modified when switching modes
|
||||
datesEqual(this.dp.viewDate, UTCDate(2011, 2, 31));
|
||||
datesEqual(this.dp.date, UTCDate(2011, 2, 31));
|
||||
|
||||
target = this.picker.find('.datepicker-months thead th.switch');
|
||||
ok(target.is(':visible'), 'View switcher is visible');
|
||||
|
||||
target.click();
|
||||
ok(this.picker.find('.datepicker-years').is(':visible'), 'Year picker is visible');
|
||||
equal(this.dp.viewMode, 2);
|
||||
// Not modified when switching modes
|
||||
datesEqual(this.dp.viewDate, UTCDate(2011, 2, 31));
|
||||
datesEqual(this.dp.date, UTCDate(2011, 2, 31));
|
||||
|
||||
// Change years to test internal state changes
|
||||
target = this.picker.find('.datepicker-years tbody span:contains(2010)');
|
||||
target.click();
|
||||
equal(this.dp.viewMode, 1);
|
||||
// Only viewDate modified
|
||||
datesEqual(this.dp.viewDate, UTCDate(2010, 2, 1));
|
||||
datesEqual(this.dp.date, UTCDate(2011, 2, 31));
|
||||
equal(triggered, 1);
|
||||
});
|
||||
|
||||
test('Selecting a month from year view triggers pickMonth', function(){
|
||||
var target,
|
||||
triggered = 0;
|
||||
|
||||
this.input.on('changeMonth', function(){
|
||||
triggered++;
|
||||
});
|
||||
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
ok(target.is(':visible'), 'View switcher is visible');
|
||||
|
||||
target.click();
|
||||
ok(this.picker.find('.datepicker-months').is(':visible'), 'Month picker is visible');
|
||||
equal(this.dp.viewMode, 1);
|
||||
// Not modified when switching modes
|
||||
datesEqual(this.dp.viewDate, UTCDate(2011, 2, 31));
|
||||
datesEqual(this.dp.date, UTCDate(2011, 2, 31));
|
||||
|
||||
target = this.picker.find('.datepicker-months tbody span:contains(Apr)');
|
||||
target.click();
|
||||
equal(this.dp.viewMode, 0);
|
||||
// Only viewDate modified
|
||||
datesEqual(this.dp.viewDate, UTCDate(2011, 3, 1));
|
||||
datesEqual(this.dp.date, UTCDate(2011, 2, 31));
|
||||
equal(triggered, 1);
|
||||
});
|
||||
+226
@@ -0,0 +1,226 @@
|
||||
module('Formats', {
|
||||
setup: function(){
|
||||
this.input = $('<input type="text">').appendTo('#qunit-fixture');
|
||||
this.date = UTCDate(2012, 2, 15, 0, 0, 0, 0); // March 15, 2012
|
||||
},
|
||||
teardown: function(){
|
||||
this.input.data('datepicker').picker.remove();
|
||||
}
|
||||
});
|
||||
|
||||
test('d: Day of month, no leading zero.', function(){
|
||||
this.input
|
||||
.val('2012-03-05')
|
||||
.datepicker({format: 'yyyy-mm-d'})
|
||||
.datepicker('setValue');
|
||||
equal(this.input.val().split('-')[2], '5');
|
||||
});
|
||||
|
||||
test('dd: Day of month, leading zero.', function(){
|
||||
this.input
|
||||
.val('2012-03-5')
|
||||
.datepicker({format: 'yyyy-mm-dd'})
|
||||
.datepicker('setValue');
|
||||
equal(this.input.val().split('-')[2], '05');
|
||||
});
|
||||
|
||||
test('D: Day of week, short.', function(){
|
||||
this.input
|
||||
.val('2012-03-05')
|
||||
.datepicker({format: 'yyyy-mm-dd-D'})
|
||||
.datepicker('setValue');
|
||||
equal(this.input.val().split('-')[3], 'Mon');
|
||||
});
|
||||
|
||||
test('DD: Day of week, long.', function(){
|
||||
this.input
|
||||
.val('2012-03-05')
|
||||
.datepicker({format: 'yyyy-mm-dd-DD'})
|
||||
.datepicker('setValue');
|
||||
equal(this.input.val().split('-')[3], 'Monday');
|
||||
});
|
||||
|
||||
test('m: Month, no leading zero.', function(){
|
||||
this.input
|
||||
.val('2012-03-05')
|
||||
.datepicker({format: 'yyyy-m-dd'})
|
||||
.datepicker('setValue');
|
||||
equal(this.input.val().split('-')[1], '3');
|
||||
});
|
||||
|
||||
test('mm: Month, leading zero.', function(){
|
||||
this.input
|
||||
.val('2012-3-5')
|
||||
.datepicker({format: 'yyyy-mm-dd'})
|
||||
.datepicker('setValue');
|
||||
equal(this.input.val().split('-')[1], '03');
|
||||
});
|
||||
|
||||
test('M: Month shortname.', function(){
|
||||
this.input
|
||||
.val('2012-Mar-05')
|
||||
.datepicker({format: 'yyyy-M-dd'})
|
||||
.datepicker('setValue');
|
||||
equal(this.input.val().split('-')[1], 'Mar');
|
||||
});
|
||||
|
||||
test('MM: Month full name.', function(){
|
||||
this.input
|
||||
.val('2012-March-5')
|
||||
.datepicker({format: 'yyyy-MM-dd'})
|
||||
.datepicker('setValue');
|
||||
equal(this.input.val().split('-')[1], 'March');
|
||||
});
|
||||
|
||||
test('yy: Year, two-digit.', function(){
|
||||
this.input
|
||||
.val('2012-03-05')
|
||||
.datepicker({format: 'yy-mm-dd'})
|
||||
.datepicker('setValue');
|
||||
equal(this.input.val().split('-')[0], '12');
|
||||
});
|
||||
|
||||
test('yyyy: Year, four-digit.', function(){
|
||||
this.input
|
||||
.val('2012-03-5')
|
||||
.datepicker({format: 'yyyy-mm-dd'})
|
||||
.datepicker('setValue');
|
||||
equal(this.input.val().split('-')[0], '2012');
|
||||
});
|
||||
|
||||
test('dd-mm-yyyy: Regression: Prevent potential month overflow in small-to-large formats (Mar 31, 2012 -> Mar 01, 2012)', function(){
|
||||
this.input
|
||||
.val('31-03-2012')
|
||||
.datepicker({format: 'dd-mm-yyyy'})
|
||||
.datepicker('setValue');
|
||||
equal(this.input.val(), '31-03-2012');
|
||||
});
|
||||
|
||||
test('dd-mm-yyyy: Leap day', function(){
|
||||
this.input
|
||||
.val('29-02-2012')
|
||||
.datepicker({format: 'dd-mm-yyyy'})
|
||||
.datepicker('setValue');
|
||||
equal(this.input.val(), '29-02-2012');
|
||||
});
|
||||
|
||||
test('yyyy-mm-dd: Alternative format', function(){
|
||||
this.input
|
||||
.val('2012-02-12')
|
||||
.datepicker({format: 'yyyy-mm-dd'})
|
||||
.datepicker('setValue');
|
||||
equal(this.input.val(), '2012-02-12');
|
||||
});
|
||||
|
||||
test('yyyy-MM-dd: Regression: Infinite loop when numbers used for month', function(){
|
||||
this.input
|
||||
.val('2012-02-12')
|
||||
.datepicker({format: 'yyyy-MM-dd'})
|
||||
.datepicker('setValue');
|
||||
equal(this.input.val(), '2012-February-12');
|
||||
});
|
||||
|
||||
test('+1d: Tomorrow', patch_date(function(Date){
|
||||
Date.now = UTCDate(2012, 2, 15);
|
||||
this.input
|
||||
.val('+1d')
|
||||
.datepicker({format: 'dd-mm-yyyy'})
|
||||
.datepicker('setValue');
|
||||
equal(this.input.val(), '16-03-2012');
|
||||
}));
|
||||
|
||||
test('-1d: Yesterday', patch_date(function(Date){
|
||||
Date.now = UTCDate(2012, 2, 15);
|
||||
this.input
|
||||
.val('-1d')
|
||||
.datepicker({format: 'dd-mm-yyyy'})
|
||||
.datepicker('setValue');
|
||||
equal(this.input.val(), '14-03-2012');
|
||||
}));
|
||||
|
||||
test('+1w: Next week', patch_date(function(Date){
|
||||
Date.now = UTCDate(2012, 2, 15);
|
||||
this.input
|
||||
.val('+1w')
|
||||
.datepicker({format: 'dd-mm-yyyy'})
|
||||
.datepicker('setValue');
|
||||
equal(this.input.val(), '22-03-2012');
|
||||
}));
|
||||
|
||||
test('-1w: Last week', patch_date(function(Date){
|
||||
Date.now = UTCDate(2012, 2, 15);
|
||||
this.input
|
||||
.val('-1w')
|
||||
.datepicker({format: 'dd-mm-yyyy'})
|
||||
.datepicker('setValue');
|
||||
equal(this.input.val(), '08-03-2012');
|
||||
}));
|
||||
|
||||
test('+1m: Next month', patch_date(function(Date){
|
||||
Date.now = UTCDate(2012, 2, 15);
|
||||
this.input
|
||||
.val('+1m')
|
||||
.datepicker({format: 'dd-mm-yyyy'})
|
||||
.datepicker('setValue');
|
||||
equal(this.input.val(), '15-04-2012');
|
||||
}));
|
||||
|
||||
test('-1m: Last month', patch_date(function(Date){
|
||||
Date.now = UTCDate(2012, 2, 15);
|
||||
this.input
|
||||
.val('-1m')
|
||||
.datepicker({format: 'dd-mm-yyyy'})
|
||||
.datepicker('setValue');
|
||||
equal(this.input.val(), '15-02-2012');
|
||||
}));
|
||||
|
||||
test('+1y: Next year', patch_date(function(Date){
|
||||
Date.now = UTCDate(2012, 2, 15);
|
||||
this.input
|
||||
.val('+1y')
|
||||
.datepicker({format: 'dd-mm-yyyy'})
|
||||
.datepicker('setValue');
|
||||
equal(this.input.val(), '15-03-2013');
|
||||
}));
|
||||
|
||||
test('-1y: Last year', patch_date(function(Date){
|
||||
Date.now = UTCDate(2012, 2, 15);
|
||||
this.input
|
||||
.val('-1y')
|
||||
.datepicker({format: 'dd-mm-yyyy'})
|
||||
.datepicker('setValue');
|
||||
equal(this.input.val(), '15-03-2011');
|
||||
}));
|
||||
|
||||
test('-1y +2m: Multiformat', patch_date(function(Date){
|
||||
Date.now = UTCDate(2012, 2, 15);
|
||||
this.input
|
||||
.val('-1y +2m')
|
||||
.datepicker({format: 'dd-mm-yyyy'})
|
||||
.datepicker('setValue');
|
||||
equal(this.input.val(), '15-05-2011');
|
||||
}));
|
||||
|
||||
test('Regression: End-of-month bug', patch_date(function(Date){
|
||||
Date.now = UTCDate(2012, 4, 31);
|
||||
this.input
|
||||
.val('29-02-2012')
|
||||
.datepicker({format: 'dd-mm-yyyy'})
|
||||
.datepicker('setValue');
|
||||
equal(this.input.val(), '29-02-2012');
|
||||
}));
|
||||
|
||||
test('Invalid formats are force-parsed into a valid date on tab', patch_date(function(Date){
|
||||
Date.now = UTCDate(2012, 4, 31);
|
||||
this.input
|
||||
.val('44-44-4444')
|
||||
.datepicker({format: 'yyyy-MM-dd'})
|
||||
.focus();
|
||||
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 9
|
||||
});
|
||||
|
||||
equal(this.input.val(), '56-September-30');
|
||||
}));
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
module('Inline', {
|
||||
setup: function(){
|
||||
this.component = $('<div data-date="12-02-2012"></div>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.datepicker({format: "dd-mm-yyyy"});
|
||||
this.dp = this.component.data('datepicker')
|
||||
this.picker = this.dp.picker;
|
||||
},
|
||||
teardown: function(){
|
||||
this.picker.remove();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
test('Picker gets date/viewDate from data-date attr', function(){
|
||||
datesEqual(this.dp.date, UTCDate(2012, 1, 12));
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 1, 12));
|
||||
});
|
||||
|
||||
|
||||
test('Visible after init', function(){
|
||||
ok(this.picker.is(':visible'));
|
||||
});
|
||||
|
||||
test('update', function(){
|
||||
this.dp.update('13-03-2012')
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 13));
|
||||
});
|
||||
@@ -0,0 +1,86 @@
|
||||
module('Keyboard Navigation 2011', {
|
||||
setup: function(){
|
||||
/*
|
||||
Tests start with picker on March 31, 2011. Fun facts:
|
||||
|
||||
* March 1, 2011 was on a Tuesday
|
||||
* March 31, 2011 was on a Thursday
|
||||
*/
|
||||
this.input = $('<input type="text" value="31-03-2011">')
|
||||
.appendTo('#qunit-fixture')
|
||||
.datepicker({format: "dd-mm-yyyy"})
|
||||
.focus(); // Activate for visibility checks
|
||||
this.dp = this.input.data('datepicker')
|
||||
this.picker = this.dp.picker;
|
||||
},
|
||||
teardown: function(){
|
||||
this.picker.remove();
|
||||
}
|
||||
});
|
||||
|
||||
test('Regression: by week (up/down arrows); up from Mar 6, 2011 should go to Feb 27, 2011', function(){
|
||||
var target;
|
||||
|
||||
this.input.val('06-03-2011').datepicker('update');
|
||||
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'March 2011', 'Title is "March 2011"');
|
||||
datesEqual(this.dp.viewDate, UTCDate(2011, 2, 6));
|
||||
datesEqual(this.dp.date, UTCDate(2011, 2, 6));
|
||||
|
||||
// Navigation: -1 week, up arrow key
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 38
|
||||
});
|
||||
datesEqual(this.dp.viewDate, UTCDate(2011, 1, 27));
|
||||
datesEqual(this.dp.date, UTCDate(2011, 1, 27));
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'February 2011', 'Title is "February 2011"');
|
||||
});
|
||||
|
||||
test('Regression: by day (left/right arrows); left from Mar 1, 2011 should go to Feb 28, 2011', function(){
|
||||
var target;
|
||||
|
||||
this.input.val('01-03-2011').datepicker('update');
|
||||
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'March 2011', 'Title is "March 2011"');
|
||||
datesEqual(this.dp.viewDate, UTCDate(2011, 2, 1));
|
||||
datesEqual(this.dp.date, UTCDate(2011, 2, 1));
|
||||
|
||||
// Navigation: -1 day left arrow key
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 37
|
||||
});
|
||||
datesEqual(this.dp.viewDate, UTCDate(2011, 1, 28));
|
||||
datesEqual(this.dp.date, UTCDate(2011, 1, 28));
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'February 2011', 'Title is "February 2011"');
|
||||
});
|
||||
|
||||
test('Regression: by month (shift + left/right arrows); left from Mar 15, 2011 should go to Feb 15, 2011', function(){
|
||||
var target;
|
||||
|
||||
this.input.val('15-03-2011').datepicker('update');
|
||||
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'March 2011', 'Title is "March 2011"');
|
||||
datesEqual(this.dp.viewDate, UTCDate(2011, 2, 15));
|
||||
datesEqual(this.dp.date, UTCDate(2011, 2, 15));
|
||||
|
||||
// Navigation: -1 month, shift + left arrow key
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 37,
|
||||
shiftKey: true
|
||||
});
|
||||
datesEqual(this.dp.viewDate, UTCDate(2011, 1, 15));
|
||||
datesEqual(this.dp.date, UTCDate(2011, 1, 15));
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'February 2011', 'Title is "February 2011"');
|
||||
});
|
||||
@@ -0,0 +1,410 @@
|
||||
module('Keyboard Navigation 2012', {
|
||||
setup: function(){
|
||||
/*
|
||||
Tests start with picker on March 31, 2012. Fun facts:
|
||||
|
||||
* February 1, 2012 was on a Wednesday
|
||||
* February 29, 2012 was on a Wednesday
|
||||
* March 1, 2012 was on a Thursday
|
||||
* March 31, 2012 was on a Saturday
|
||||
*/
|
||||
this.input = $('<input type="text" value="31-03-2012">')
|
||||
.appendTo('#qunit-fixture')
|
||||
.datepicker({format: "dd-mm-yyyy"})
|
||||
.focus(); // Activate for visibility checks
|
||||
this.dp = this.input.data('datepicker')
|
||||
this.picker = this.dp.picker;
|
||||
},
|
||||
teardown: function(){
|
||||
this.picker.remove();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
test('by day (right/left arrows)', function(){
|
||||
var target;
|
||||
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'March 2012', 'Title is "March 2012"');
|
||||
|
||||
// Navigation: -1 day, left arrow key
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 37
|
||||
});
|
||||
// Both updated on keyboard navigation
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 2, 30));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 30));
|
||||
// Month not changed
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'March 2012', 'Title is "March 2012"');
|
||||
|
||||
// Navigation: +1 day, right arrow key
|
||||
for (var i=0; i<2; i++)
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 39
|
||||
});
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 3, 1));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 3, 1));
|
||||
// Month changed: April 1 (this is not a joke!)
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'April 2012', 'Title is "April 2012"');
|
||||
});
|
||||
|
||||
test('by week (up/down arrows)', function(){
|
||||
var target;
|
||||
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'March 2012', 'Title is "March 2012"');
|
||||
|
||||
// Navigation: -1 week, up arrow key
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 38
|
||||
});
|
||||
// Both updated on keyboard navigation
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 2, 24));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 24));
|
||||
// Month not changed
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'March 2012', 'Title is "March 2012"');
|
||||
|
||||
// Navigation: +1 week, down arrow key
|
||||
for (var i=0; i<2; i++)
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 40
|
||||
});
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 3, 7));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 3, 7));
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'April 2012', 'Title is "April 2012"');
|
||||
});
|
||||
|
||||
test('by month, v1 (shift + left/right arrows)', function(){
|
||||
var target;
|
||||
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'March 2012', 'Title is "March 2012"');
|
||||
|
||||
// Navigation: -1 month, shift + left arrow key
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 37,
|
||||
shiftKey: true
|
||||
});
|
||||
// Both updated on keyboard navigation, w/ graceful date ends
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 1, 29));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 1, 29));
|
||||
// Month not changed
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'February 2012', 'Title is "February 2012"');
|
||||
|
||||
// Navigation: +1 month, shift + right arrow key
|
||||
for (var i=0; i<2; i++)
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 39,
|
||||
shiftKey: true
|
||||
});
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 3, 29));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 3, 29));
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'April 2012', 'Title is "April 2012"');
|
||||
});
|
||||
|
||||
test('by month, v2 (shift + up/down arrows)', function(){
|
||||
var target;
|
||||
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'March 2012', 'Title is "March 2012"');
|
||||
|
||||
// Navigation: -1 month, shift + up arrow key
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 38,
|
||||
shiftKey: true
|
||||
});
|
||||
// Both updated on keyboard navigation, w/ graceful date ends
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 1, 29));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 1, 29));
|
||||
// Month not changed
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'February 2012', 'Title is "February 2012"');
|
||||
|
||||
// Navigation: +1 month, shift + down arrow key
|
||||
for (var i=0; i<2; i++)
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 40,
|
||||
shiftKey: true
|
||||
});
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 3, 29));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 3, 29));
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'April 2012', 'Title is "April 2012"');
|
||||
});
|
||||
|
||||
test('by year, v1 (ctrl + left/right arrows)', function(){
|
||||
var target;
|
||||
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'March 2012', 'Title is "March 2012"');
|
||||
|
||||
// Navigation: -1 year, ctrl + left arrow key
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 37,
|
||||
ctrlKey: true
|
||||
});
|
||||
// Both updated on keyboard navigation
|
||||
datesEqual(this.dp.viewDate, UTCDate(2011, 2, 31));
|
||||
datesEqual(this.dp.date, UTCDate(2011, 2, 31));
|
||||
// Month not changed
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'March 2011', 'Title is "March 2011"');
|
||||
|
||||
// Navigation: +1 year, ctrl + right arrow key
|
||||
for (var i=0; i<2; i++)
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 39,
|
||||
ctrlKey: true
|
||||
});
|
||||
datesEqual(this.dp.viewDate, UTCDate(2013, 2, 31));
|
||||
datesEqual(this.dp.date, UTCDate(2013, 2, 31));
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'March 2013', 'Title is "March 2013"');
|
||||
});
|
||||
|
||||
test('by year, v2 (ctrl + up/down arrows)', function(){
|
||||
var target;
|
||||
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'March 2012', 'Title is "March 2012"');
|
||||
|
||||
// Navigation: -1 year, ctrl + up arrow key
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 38,
|
||||
ctrlKey: true
|
||||
});
|
||||
// Both updated on keyboard navigation
|
||||
datesEqual(this.dp.viewDate, UTCDate(2011, 2, 31));
|
||||
datesEqual(this.dp.date, UTCDate(2011, 2, 31));
|
||||
// Month not changed
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'March 2011', 'Title is "March 2011"');
|
||||
|
||||
// Navigation: +1 year, ctrl + down arrow key
|
||||
for (var i=0; i<2; i++)
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 40,
|
||||
ctrlKey: true
|
||||
});
|
||||
datesEqual(this.dp.viewDate, UTCDate(2013, 2, 31));
|
||||
datesEqual(this.dp.date, UTCDate(2013, 2, 31));
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'March 2013', 'Title is "March 2013"');
|
||||
});
|
||||
|
||||
test('by year, v3 (ctrl + shift + left/right arrows)', function(){
|
||||
var target;
|
||||
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'March 2012', 'Title is "March 2012"');
|
||||
|
||||
// Navigation: -1 year, ctrl + left arrow key
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 37,
|
||||
ctrlKey: true,
|
||||
shiftKey: true
|
||||
});
|
||||
// Both updated on keyboard navigation
|
||||
datesEqual(this.dp.viewDate, UTCDate(2011, 2, 31));
|
||||
datesEqual(this.dp.date, UTCDate(2011, 2, 31));
|
||||
// Month not changed
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'March 2011', 'Title is "March 2011"');
|
||||
|
||||
// Navigation: +1 year, ctrl + right arrow key
|
||||
for (var i=0; i<2; i++)
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 39,
|
||||
ctrlKey: true,
|
||||
shiftKey: true
|
||||
});
|
||||
datesEqual(this.dp.viewDate, UTCDate(2013, 2, 31));
|
||||
datesEqual(this.dp.date, UTCDate(2013, 2, 31));
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'March 2013', 'Title is "March 2013"');
|
||||
});
|
||||
|
||||
test('by year, v4 (ctrl + shift + up/down arrows)', function(){
|
||||
var target;
|
||||
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'March 2012', 'Title is "March 2012"');
|
||||
|
||||
// Navigation: -1 year, ctrl + up arrow key
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 38,
|
||||
ctrlKey: true,
|
||||
shiftKey: true
|
||||
});
|
||||
// Both updated on keyboard navigation
|
||||
datesEqual(this.dp.viewDate, UTCDate(2011, 2, 31));
|
||||
datesEqual(this.dp.date, UTCDate(2011, 2, 31));
|
||||
// Month not changed
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'March 2011', 'Title is "March 2011"');
|
||||
|
||||
// Navigation: +1 year, ctrl + down arrow key
|
||||
for (var i=0; i<2; i++)
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 40,
|
||||
ctrlKey: true,
|
||||
shiftKey: true
|
||||
});
|
||||
datesEqual(this.dp.viewDate, UTCDate(2013, 2, 31));
|
||||
datesEqual(this.dp.date, UTCDate(2013, 2, 31));
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'March 2013', 'Title is "March 2013"');
|
||||
});
|
||||
|
||||
test('by year, from leap day', function(){
|
||||
var target;
|
||||
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
|
||||
this.input.val('29-02-2012').datepicker('update');
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 1, 29));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 1, 29));
|
||||
equal(target.text(), 'February 2012', 'Title is "February 2012"');
|
||||
|
||||
// Navigation: -1 year
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 37,
|
||||
ctrlKey: true
|
||||
});
|
||||
// Both updated on keyboard navigation; graceful month-end
|
||||
datesEqual(this.dp.viewDate, UTCDate(2011, 1, 28));
|
||||
datesEqual(this.dp.date, UTCDate(2011, 1, 28));
|
||||
// Month not changed
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'February 2011', 'Title is "February 2011"');
|
||||
|
||||
// Navigation: +1 year, back to leap year
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 39,
|
||||
ctrlKey: true
|
||||
});
|
||||
// Both updated on keyboard navigation; graceful month-end
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 1, 28));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 1, 28));
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'February 2012', 'Title is "February 2012"');
|
||||
|
||||
// Navigation: +1 year
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 39,
|
||||
ctrlKey: true
|
||||
});
|
||||
// Both updated on keyboard navigation; graceful month-end
|
||||
datesEqual(this.dp.viewDate, UTCDate(2013, 1, 28));
|
||||
datesEqual(this.dp.date, UTCDate(2013, 1, 28));
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'February 2013', 'Title is "February 2013"');
|
||||
});
|
||||
|
||||
test('Selection (enter)', function(){
|
||||
var target;
|
||||
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'March 2012', 'Title is "March 2012"');
|
||||
|
||||
// Navigation: -1 day, left arrow key
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 37
|
||||
});
|
||||
// Both updated on keyboard navigation
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 2, 30));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 30));
|
||||
// Month not changed
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'March 2012', 'Title is "March 2012"');
|
||||
|
||||
// Selection: Enter
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 13
|
||||
});
|
||||
// Both updated on keyboard navigation
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 2, 30));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 30));
|
||||
// Month not changed
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'March 2012', 'Title is "March 2012"');
|
||||
|
||||
ok(this.picker.is(':not(:visible)'), 'Picker is hidden');
|
||||
});
|
||||
|
||||
test('Toggle hide/show (escape); navigation while hidden is suppressed', function(){
|
||||
var target;
|
||||
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
equal(target.text(), 'March 2012', 'Title is "March 2012"');
|
||||
|
||||
ok(this.picker.is(':visible'), 'Picker is visible');
|
||||
|
||||
// Hide
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 27
|
||||
});
|
||||
|
||||
ok(this.picker.is(':not(:visible)'), 'Picker is hidden');
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 2, 31));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 31));
|
||||
|
||||
// left arrow key, *doesn't* navigate
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 37
|
||||
});
|
||||
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 2, 31));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 31));
|
||||
|
||||
// Show
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 27
|
||||
});
|
||||
|
||||
ok(this.picker.is(':visible'), 'Picker is visible');
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 2, 31));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 31));
|
||||
});
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
module('Keyboard Navigation (All)', {
|
||||
setup: function(){
|
||||
this.input = $('<input type="text">')
|
||||
.appendTo('#qunit-fixture')
|
||||
.datepicker({format: "dd-mm-yyyy"})
|
||||
.focus(); // Activate for visibility checks
|
||||
this.dp = this.input.data('datepicker')
|
||||
this.picker = this.dp.picker;
|
||||
},
|
||||
teardown: function(){
|
||||
this.picker.remove();
|
||||
}
|
||||
});
|
||||
|
||||
test('TAB hides picker', function(){
|
||||
var target;
|
||||
|
||||
ok(this.picker.is(':visible'), 'Picker is visible');
|
||||
|
||||
this.input.trigger({
|
||||
type: 'keydown',
|
||||
keyCode: 9
|
||||
});
|
||||
|
||||
ok(this.picker.is(':not(:visible)'), 'Picker is hidden');
|
||||
});
|
||||
@@ -0,0 +1,66 @@
|
||||
module('Mouse Navigation 2011', {
|
||||
setup: function(){
|
||||
/*
|
||||
Tests start with picker on March 31, 2011.
|
||||
*/
|
||||
this.input = $('<input type="text" value="31-03-2011">')
|
||||
.appendTo('#qunit-fixture')
|
||||
.datepicker({format: "dd-mm-yyyy"})
|
||||
.focus(); // Activate for visibility checks
|
||||
this.dp = this.input.data('datepicker')
|
||||
this.picker = this.dp.picker;
|
||||
},
|
||||
teardown: function(){
|
||||
this.picker.remove();
|
||||
}
|
||||
});
|
||||
|
||||
test('Selecting date from previous month while in January changes month and year displayed', function(){
|
||||
var target;
|
||||
|
||||
this.input.val('01-01-2011');
|
||||
this.dp.update();
|
||||
datesEqual(this.dp.viewDate, UTCDate(2011, 0, 1))
|
||||
datesEqual(this.dp.date, UTCDate(2011, 0, 1))
|
||||
|
||||
// Rendered correctly
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days tbody td:first');
|
||||
equal(target.text(), '26'); // Should be Dec 26
|
||||
equal(this.picker.find('.datepicker-days thead th.switch').text(), 'January 2011');
|
||||
|
||||
// Updated internally on click
|
||||
target.click();
|
||||
equal(this.picker.find('.datepicker-days thead th.switch').text(), 'December 2010');
|
||||
datesEqual(this.dp.viewDate, UTCDate(2010, 11, 26))
|
||||
datesEqual(this.dp.date, UTCDate(2010, 11, 26))
|
||||
|
||||
// Re-rendered on click
|
||||
target = this.picker.find('.datepicker-days tbody td:first');
|
||||
equal(target.text(), '28'); // Should be Nov 28
|
||||
});
|
||||
|
||||
test('Selecting date from next month while in December changes month and year displayed', function(){
|
||||
var target;
|
||||
|
||||
this.input.val('01-12-2010');
|
||||
this.dp.update();
|
||||
datesEqual(this.dp.viewDate, UTCDate(2010, 11, 1))
|
||||
datesEqual(this.dp.date, UTCDate(2010, 11, 1))
|
||||
|
||||
// Rendered correctly
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days tbody td:last');
|
||||
equal(target.text(), '8'); // Should be Jan 8
|
||||
equal(this.picker.find('.datepicker-days thead th.switch').text(), 'December 2010');
|
||||
|
||||
// Updated internally on click
|
||||
target.click();
|
||||
equal(this.picker.find('.datepicker-days thead th.switch').text(), 'January 2011');
|
||||
datesEqual(this.dp.viewDate, UTCDate(2011, 0, 8))
|
||||
datesEqual(this.dp.date, UTCDate(2011, 0, 8))
|
||||
|
||||
// Re-rendered on click
|
||||
target = this.picker.find('.datepicker-days tbody td:first');
|
||||
equal(target.text(), '26'); // Should be Dec 26
|
||||
});
|
||||
@@ -0,0 +1,251 @@
|
||||
module('Mouse Navigation 2012', {
|
||||
setup: function(){
|
||||
/*
|
||||
Tests start with picker on March 31, 2012. Fun facts:
|
||||
|
||||
* February 1, 2012 was on a Wednesday
|
||||
* February 29, 2012 was on a Wednesday
|
||||
* March 1, 2012 was on a Thursday
|
||||
* March 31, 2012 was on a Saturday
|
||||
*/
|
||||
this.input = $('<input type="text" value="31-03-2012">')
|
||||
.appendTo('#qunit-fixture')
|
||||
.datepicker({format: "dd-mm-yyyy"})
|
||||
.focus(); // Activate for visibility checks
|
||||
this.dp = this.input.data('datepicker')
|
||||
this.picker = this.dp.picker;
|
||||
},
|
||||
teardown: function(){
|
||||
this.picker.remove();
|
||||
}
|
||||
});
|
||||
|
||||
test('Selecting date resets viewDate and date', function(){
|
||||
var target;
|
||||
|
||||
// Rendered correctly
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days tbody td:nth(7)');
|
||||
equal(target.text(), '4'); // Should be Mar 4
|
||||
|
||||
// Updated internally on click
|
||||
target.click();
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 2, 4))
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 4))
|
||||
|
||||
// Re-rendered on click
|
||||
target = this.picker.find('.datepicker-days tbody td:first');
|
||||
equal(target.text(), '26'); // Should be Feb 29
|
||||
});
|
||||
|
||||
test('Navigating next/prev by month', function(){
|
||||
var target;
|
||||
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days thead th.prev');
|
||||
ok(target.is(':visible'), 'Month:prev nav is visible');
|
||||
|
||||
// Updated internally on click
|
||||
target.click();
|
||||
// Should handle month-length changes gracefully
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 1, 29));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 31));
|
||||
|
||||
// Re-rendered on click
|
||||
target = this.picker.find('.datepicker-days tbody td:first');
|
||||
equal(target.text(), '29'); // Should be Jan 29
|
||||
|
||||
target = this.picker.find('.datepicker-days thead th.next');
|
||||
ok(target.is(':visible'), 'Month:next nav is visible');
|
||||
|
||||
// Updated internally on click
|
||||
target.click().click();
|
||||
// Graceful moonth-end handling carries over
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 3, 29));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 31));
|
||||
|
||||
// Re-rendered on click
|
||||
target = this.picker.find('.datepicker-days tbody td:first');
|
||||
equal(target.text(), '25'); // Should be Mar 25
|
||||
// (includes "old" days at start of month, even if that's all the first week-row consists of)
|
||||
});
|
||||
|
||||
test('Navigating to/from year view', function(){
|
||||
var target;
|
||||
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
ok(target.is(':visible'), 'View switcher is visible');
|
||||
|
||||
target.click();
|
||||
ok(this.picker.find('.datepicker-months').is(':visible'), 'Month picker is visible');
|
||||
equal(this.dp.viewMode, 1);
|
||||
// Not modified when switching modes
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 2, 31));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 31));
|
||||
|
||||
// Change months to test internal state
|
||||
target = this.picker.find('.datepicker-months tbody span:contains(Apr)');
|
||||
target.click();
|
||||
equal(this.dp.viewMode, 0);
|
||||
// Only viewDate modified
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 3, 1)); // Apr 30
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 31));
|
||||
});
|
||||
|
||||
test('Navigating to/from decade view', function(){
|
||||
var target;
|
||||
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
ok(target.is(':visible'), 'View switcher is visible');
|
||||
|
||||
target.click();
|
||||
ok(this.picker.find('.datepicker-months').is(':visible'), 'Month picker is visible');
|
||||
equal(this.dp.viewMode, 1);
|
||||
// Not modified when switching modes
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 2, 31));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 31));
|
||||
|
||||
target = this.picker.find('.datepicker-months thead th.switch');
|
||||
ok(target.is(':visible'), 'View switcher is visible');
|
||||
|
||||
target.click();
|
||||
ok(this.picker.find('.datepicker-years').is(':visible'), 'Year picker is visible');
|
||||
equal(this.dp.viewMode, 2);
|
||||
// Not modified when switching modes
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 2, 31));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 31));
|
||||
|
||||
// Change years to test internal state changes
|
||||
target = this.picker.find('.datepicker-years tbody span:contains(2011)');
|
||||
target.click();
|
||||
equal(this.dp.viewMode, 1);
|
||||
// Only viewDate modified
|
||||
datesEqual(this.dp.viewDate, UTCDate(2011, 2, 1));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 31));
|
||||
|
||||
target = this.picker.find('.datepicker-months tbody span:contains(Apr)');
|
||||
target.click();
|
||||
equal(this.dp.viewMode, 0);
|
||||
// Only viewDate modified
|
||||
datesEqual(this.dp.viewDate, UTCDate(2011, 3, 1));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 31));
|
||||
});
|
||||
|
||||
test('Navigating prev/next in year view', function(){
|
||||
var target;
|
||||
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
ok(target.is(':visible'), 'View switcher is visible');
|
||||
|
||||
target.click();
|
||||
ok(this.picker.find('.datepicker-months').is(':visible'), 'Month picker is visible');
|
||||
equal(this.dp.viewMode, 1);
|
||||
equal(this.picker.find('.datepicker-months thead th.switch').text(), '2012');
|
||||
// Not modified when switching modes
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 2, 31));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 31));
|
||||
|
||||
// Go to next year (2013)
|
||||
target = this.picker.find('.datepicker-months thead th.next');
|
||||
target.click();
|
||||
equal(this.picker.find('.datepicker-months thead th.switch').text(), '2013');
|
||||
// Only viewDate modified
|
||||
datesEqual(this.dp.viewDate, UTCDate(2013, 2, 31));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 31));
|
||||
|
||||
// Go to prev year (x2 == 2011)
|
||||
target = this.picker.find('.datepicker-months thead th.prev');
|
||||
target.click().click();
|
||||
equal(this.picker.find('.datepicker-months thead th.switch').text(), '2011');
|
||||
// Only viewDate modified
|
||||
datesEqual(this.dp.viewDate, UTCDate(2011, 2, 31));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 31));
|
||||
});
|
||||
|
||||
test('Navigating prev/next in decade view', function(){
|
||||
var target;
|
||||
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days thead th.switch');
|
||||
ok(target.is(':visible'), 'View switcher is visible');
|
||||
|
||||
target.click();
|
||||
ok(this.picker.find('.datepicker-months').is(':visible'), 'Month picker is visible');
|
||||
equal(this.dp.viewMode, 1);
|
||||
// Not modified when switching modes
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 2, 31));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 31));
|
||||
|
||||
target = this.picker.find('.datepicker-months thead th.switch');
|
||||
ok(target.is(':visible'), 'View switcher is visible');
|
||||
|
||||
target.click();
|
||||
ok(this.picker.find('.datepicker-years').is(':visible'), 'Year picker is visible');
|
||||
equal(this.dp.viewMode, 2);
|
||||
equal(this.picker.find('.datepicker-years thead th.switch').text(), '2010-2019');
|
||||
// Not modified when switching modes
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 2, 31));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 31));
|
||||
|
||||
// Go to next decade (2020-29)
|
||||
target = this.picker.find('.datepicker-years thead th.next');
|
||||
target.click();
|
||||
equal(this.picker.find('.datepicker-years thead th.switch').text(), '2020-2029');
|
||||
// Only viewDate modified
|
||||
datesEqual(this.dp.viewDate, UTCDate(2022, 2, 31));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 31));
|
||||
|
||||
// Go to prev year (x2 == 2000-09)
|
||||
target = this.picker.find('.datepicker-years thead th.prev');
|
||||
target.click().click();
|
||||
equal(this.picker.find('.datepicker-years thead th.switch').text(), '2000-2009');
|
||||
// Only viewDate modified
|
||||
datesEqual(this.dp.viewDate, UTCDate(2002, 2, 31));
|
||||
datesEqual(this.dp.date, UTCDate(2012, 2, 31));
|
||||
});
|
||||
|
||||
test('Selecting date from previous month resets viewDate and date, changing month displayed', function(){
|
||||
var target;
|
||||
|
||||
// Rendered correctly
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days tbody td:first');
|
||||
equal(target.text(), '26'); // Should be Feb 26
|
||||
equal(this.picker.find('.datepicker-days thead th.switch').text(), 'March 2012');
|
||||
|
||||
// Updated internally on click
|
||||
target.click();
|
||||
equal(this.picker.find('.datepicker-days thead th.switch').text(), 'February 2012');
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 1, 26))
|
||||
datesEqual(this.dp.date, UTCDate(2012, 1, 26))
|
||||
|
||||
// Re-rendered on click
|
||||
target = this.picker.find('.datepicker-days tbody td:first');
|
||||
equal(target.text(), '29'); // Should be Jan 29
|
||||
});
|
||||
|
||||
test('Selecting date from next month resets viewDate and date, changing month displayed', function(){
|
||||
var target;
|
||||
|
||||
this.input.val('01-04-2012');
|
||||
this.dp.update();
|
||||
|
||||
// Rendered correctly
|
||||
equal(this.dp.viewMode, 0);
|
||||
target = this.picker.find('.datepicker-days tbody td:last');
|
||||
equal(target.text(), '5'); // Should be May 5
|
||||
equal(this.picker.find('.datepicker-days thead th.switch').text(), 'April 2012');
|
||||
|
||||
// Updated internally on click
|
||||
target.click();
|
||||
equal(this.picker.find('.datepicker-days thead th.switch').text(), 'May 2012');
|
||||
datesEqual(this.dp.viewDate, UTCDate(2012, 4, 5))
|
||||
datesEqual(this.dp.date, UTCDate(2012, 4, 5))
|
||||
|
||||
// Re-rendered on click
|
||||
target = this.picker.find('.datepicker-days tbody td:first');
|
||||
equal(target.text(), '29'); // Should be Apr 29
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
module('Mouse Navigation (All)', {
|
||||
setup: function(){
|
||||
this.input = $('<input type="text">')
|
||||
.appendTo('#qunit-fixture')
|
||||
.datepicker({format: "dd-mm-yyyy"})
|
||||
.focus(); // Activate for visibility checks
|
||||
this.dp = this.input.data('datepicker')
|
||||
this.picker = this.dp.picker;
|
||||
},
|
||||
teardown: function(){
|
||||
this.picker.remove();
|
||||
}
|
||||
});
|
||||
|
||||
test('Clicking datepicker does not hide datepicker', function(){
|
||||
ok(this.picker.is(':visible'), 'Picker is visible');
|
||||
this.picker.trigger('mousedown');
|
||||
ok(this.picker.is(':visible'), 'Picker is still visible');
|
||||
});
|
||||
|
||||
test('Clicking outside datepicker hides datepicker', function(){
|
||||
var $otherelement = $('<div />');
|
||||
$('body').append($otherelement);
|
||||
|
||||
ok(this.picker.is(':visible'), 'Picker is visible');
|
||||
this.input.trigger('click');
|
||||
ok(this.picker.is(':visible'), 'Picker is still visible');
|
||||
|
||||
$otherelement.trigger('mousedown');
|
||||
ok(this.picker.is(':not(:visible)'), 'Picker is hidden');
|
||||
|
||||
$otherelement.remove();
|
||||
});
|
||||
+285
@@ -0,0 +1,285 @@
|
||||
module('Options', {
|
||||
setup: function(){},
|
||||
teardown: function(){
|
||||
return
|
||||
$('#qunit-fixture *').each(function(){
|
||||
var t = $(this);
|
||||
if ('datepicker' in t.data())
|
||||
t.data('datepicker').picker.remove();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
test('Autoclose', function(){
|
||||
var input = $('<input />')
|
||||
.appendTo('#qunit-fixture')
|
||||
.val('2012-03-05')
|
||||
.datepicker({
|
||||
format: 'yyyy-mm-dd',
|
||||
autoclose: true
|
||||
}),
|
||||
dp = input.data('datepicker'),
|
||||
picker = dp.picker,
|
||||
target;
|
||||
|
||||
|
||||
input.focus();
|
||||
ok(picker.is(':visible'), 'Picker is visible');
|
||||
target = picker.find('.datepicker-days tbody td:nth(7)');
|
||||
equal(target.text(), '4'); // Mar 4
|
||||
|
||||
target.click();
|
||||
ok(picker.is(':not(:visible)'), 'Picker is hidden');
|
||||
datesEqual(dp.date, UTCDate(2012, 2, 4));
|
||||
datesEqual(dp.viewDate, UTCDate(2012, 2, 4));
|
||||
});
|
||||
|
||||
test('Startview: year view (integer)', function(){
|
||||
var input = $('<input />')
|
||||
.appendTo('#qunit-fixture')
|
||||
.val('2012-03-05')
|
||||
.datepicker({
|
||||
format: 'yyyy-mm-dd',
|
||||
startView: 1
|
||||
}),
|
||||
dp = input.data('datepicker'),
|
||||
picker = dp.picker,
|
||||
target;
|
||||
|
||||
input.focus();
|
||||
ok(picker.find('.datepicker-days').is(':not(:visible)'), 'Days view hidden');
|
||||
ok(picker.find('.datepicker-months').is(':visible'), 'Months view visible');
|
||||
ok(picker.find('.datepicker-years').is(':not(:visible)'), 'Years view hidden');
|
||||
});
|
||||
|
||||
test('Startview: year view (string)', function(){
|
||||
var input = $('<input />')
|
||||
.appendTo('#qunit-fixture')
|
||||
.val('2012-03-05')
|
||||
.datepicker({
|
||||
format: 'yyyy-mm-dd',
|
||||
startView: 'year'
|
||||
}),
|
||||
dp = input.data('datepicker'),
|
||||
picker = dp.picker,
|
||||
target;
|
||||
|
||||
input.focus();
|
||||
ok(picker.find('.datepicker-days').is(':not(:visible)'), 'Days view hidden');
|
||||
ok(picker.find('.datepicker-months').is(':visible'), 'Months view visible');
|
||||
ok(picker.find('.datepicker-years').is(':not(:visible)'), 'Years view hidden');
|
||||
});
|
||||
|
||||
test('Startview: decade view (integer)', function(){
|
||||
var input = $('<input />')
|
||||
.appendTo('#qunit-fixture')
|
||||
.val('2012-03-05')
|
||||
.datepicker({
|
||||
format: 'yyyy-mm-dd',
|
||||
startView: 2
|
||||
}),
|
||||
dp = input.data('datepicker'),
|
||||
picker = dp.picker,
|
||||
target;
|
||||
|
||||
input.focus();
|
||||
ok(picker.find('.datepicker-days').is(':not(:visible)'), 'Days view hidden');
|
||||
ok(picker.find('.datepicker-months').is(':not(:visible)'), 'Months view hidden');
|
||||
ok(picker.find('.datepicker-years').is(':visible'), 'Years view visible');
|
||||
});
|
||||
|
||||
test('Startview: decade view (string)', function(){
|
||||
var input = $('<input />')
|
||||
.appendTo('#qunit-fixture')
|
||||
.val('2012-03-05')
|
||||
.datepicker({
|
||||
format: 'yyyy-mm-dd',
|
||||
startView: 'decade'
|
||||
}),
|
||||
dp = input.data('datepicker'),
|
||||
picker = dp.picker,
|
||||
target;
|
||||
|
||||
input.focus();
|
||||
ok(picker.find('.datepicker-days').is(':not(:visible)'), 'Days view hidden');
|
||||
ok(picker.find('.datepicker-months').is(':not(:visible)'), 'Months view hidden');
|
||||
ok(picker.find('.datepicker-years').is(':visible'), 'Years view visible');
|
||||
});
|
||||
|
||||
test('Today Button: today button not default', function(){
|
||||
var input = $('<input />')
|
||||
.appendTo('#qunit-fixture')
|
||||
.val('2012-03-05')
|
||||
.datepicker({
|
||||
format: 'yyyy-mm-dd'
|
||||
}),
|
||||
dp = input.data('datepicker'),
|
||||
picker = dp.picker,
|
||||
target;
|
||||
|
||||
input.focus();
|
||||
ok(picker.find('.datepicker-days').is(':visible'), 'Days view visible');
|
||||
ok(picker.find('.datepicker-days tfoot .today').is(':not(:visible)'), 'Today button not visible');
|
||||
});
|
||||
|
||||
test('Today Button: today visibility when enabled', function(){
|
||||
var input = $('<input />')
|
||||
.appendTo('#qunit-fixture')
|
||||
.val('2012-03-05')
|
||||
.datepicker({
|
||||
format: 'yyyy-mm-dd',
|
||||
todayBtn: true
|
||||
}),
|
||||
dp = input.data('datepicker'),
|
||||
picker = dp.picker,
|
||||
target;
|
||||
|
||||
input.focus();
|
||||
ok(picker.find('.datepicker-days').is(':visible'), 'Days view visible');
|
||||
ok(picker.find('.datepicker-days tfoot .today').is(':visible'), 'Today button visible');
|
||||
|
||||
picker.find('.datepicker-days thead th.switch').click();
|
||||
ok(picker.find('.datepicker-months').is(':visible'), 'Months view visible');
|
||||
ok(picker.find('.datepicker-months tfoot .today').is(':visible'), 'Today button visible');
|
||||
|
||||
picker.find('.datepicker-months thead th.switch').click();
|
||||
ok(picker.find('.datepicker-years').is(':visible'), 'Years view visible');
|
||||
ok(picker.find('.datepicker-years tfoot .today').is(':visible'), 'Today button visible');
|
||||
});
|
||||
|
||||
test('Today Button: data-api', function(){
|
||||
var input = $('<input data-date-today-btn="true" />')
|
||||
.appendTo('#qunit-fixture')
|
||||
.val('2012-03-05')
|
||||
.datepicker({
|
||||
format: 'yyyy-mm-dd'
|
||||
}),
|
||||
dp = input.data('datepicker'),
|
||||
picker = dp.picker,
|
||||
target;
|
||||
|
||||
input.focus();
|
||||
ok(picker.find('.datepicker-days').is(':visible'), 'Days view visible');
|
||||
ok(picker.find('.datepicker-days tfoot .today').is(':visible'), 'Today button visible');
|
||||
});
|
||||
|
||||
test('Today Button: moves to today\'s date', function(){
|
||||
var input = $('<input />')
|
||||
.appendTo('#qunit-fixture')
|
||||
.val('2012-03-05')
|
||||
.datepicker({
|
||||
format: 'yyyy-mm-dd',
|
||||
todayBtn: true
|
||||
}),
|
||||
dp = input.data('datepicker'),
|
||||
picker = dp.picker,
|
||||
target;
|
||||
|
||||
input.focus();
|
||||
ok(picker.find('.datepicker-days').is(':visible'), 'Days view visible');
|
||||
ok(picker.find('.datepicker-days tfoot .today').is(':visible'), 'Today button visible');
|
||||
|
||||
target = picker.find('.datepicker-days tfoot .today');
|
||||
target.click();
|
||||
|
||||
var d = new Date(),
|
||||
today = UTCDate(d.getFullYear(), d.getMonth(), d.getDate());
|
||||
datesEqual(dp.viewDate, today);
|
||||
datesEqual(dp.date, UTCDate(2012, 2, 5));
|
||||
});
|
||||
|
||||
test('Today Button: "linked" selects today\'s date', function(){
|
||||
var input = $('<input />')
|
||||
.appendTo('#qunit-fixture')
|
||||
.val('2012-03-05')
|
||||
.datepicker({
|
||||
format: 'yyyy-mm-dd',
|
||||
todayBtn: "linked"
|
||||
}),
|
||||
dp = input.data('datepicker'),
|
||||
picker = dp.picker,
|
||||
target;
|
||||
|
||||
input.focus();
|
||||
ok(picker.find('.datepicker-days').is(':visible'), 'Days view visible');
|
||||
ok(picker.find('.datepicker-days tfoot .today').is(':visible'), 'Today button visible');
|
||||
|
||||
target = picker.find('.datepicker-days tfoot .today');
|
||||
target.click();
|
||||
|
||||
var d = new Date(),
|
||||
today = UTCDate(d.getFullYear(), d.getMonth(), d.getDate());
|
||||
datesEqual(dp.viewDate, today);
|
||||
datesEqual(dp.date, today);
|
||||
});
|
||||
|
||||
test('Today Highlight: today\'s date is not highlighted by default', patch_date(function(Date){
|
||||
Date.now = UTCDate(2012, 2, 15);
|
||||
var input = $('<input />')
|
||||
.appendTo('#qunit-fixture')
|
||||
.val('2012-03-05')
|
||||
.datepicker({
|
||||
format: 'yyyy-mm-dd'
|
||||
}),
|
||||
dp = input.data('datepicker'),
|
||||
picker = dp.picker,
|
||||
target;
|
||||
|
||||
input.focus();
|
||||
ok(picker.find('.datepicker-days').is(':visible'), 'Days view visible');
|
||||
equal(picker.find('.datepicker-days thead .switch').text(), 'March 2012', 'Title is "March 2012"');
|
||||
|
||||
target = picker.find('.datepicker-days tbody td:contains(15)');
|
||||
ok(!target.hasClass('today'), 'Today is not marked with "today" class');
|
||||
target = picker.find('.datepicker-days tbody td:contains(14)');
|
||||
ok(!target.hasClass('today'), 'Yesterday is not marked with "today" class');
|
||||
target = picker.find('.datepicker-days tbody td:contains(16)');
|
||||
ok(!target.hasClass('today'), 'Tomorrow is not marked with "today" class');
|
||||
}));
|
||||
|
||||
test('Today Highlight: today\'s date is highlighted when not active', patch_date(function(Date){
|
||||
Date.now = new Date(2012, 2, 15);
|
||||
var input = $('<input />')
|
||||
.appendTo('#qunit-fixture')
|
||||
.val('2012-03-05')
|
||||
.datepicker({
|
||||
format: 'yyyy-mm-dd',
|
||||
todayHighlight: true
|
||||
}),
|
||||
dp = input.data('datepicker'),
|
||||
picker = dp.picker,
|
||||
target;
|
||||
|
||||
input.focus();
|
||||
ok(picker.find('.datepicker-days').is(':visible'), 'Days view visible');
|
||||
equal(picker.find('.datepicker-days thead .switch').text(), 'March 2012', 'Title is "March 2012"');
|
||||
|
||||
target = picker.find('.datepicker-days tbody td:contains(15)');
|
||||
ok(target.hasClass('today'), 'Today is marked with "today" class');
|
||||
target = picker.find('.datepicker-days tbody td:contains(14)');
|
||||
ok(!target.hasClass('today'), 'Yesterday is not marked with "today" class');
|
||||
target = picker.find('.datepicker-days tbody td:contains(16)');
|
||||
ok(!target.hasClass('today'), 'Tomorrow is not marked with "today" class');
|
||||
}));
|
||||
|
||||
test('DaysOfWeekDisabled', function(){
|
||||
var input = $('<input />')
|
||||
.appendTo('#qunit-fixture')
|
||||
.val('2012-10-26')
|
||||
.datepicker({
|
||||
format: 'yyyy-mm-dd',
|
||||
daysOfWeekDisabled: '1,5'
|
||||
}),
|
||||
dp = input.data('datepicker'),
|
||||
picker = dp.picker,
|
||||
target;
|
||||
|
||||
|
||||
input.focus();
|
||||
target = picker.find('.datepicker-days tbody td:nth(22)');
|
||||
ok(target.hasClass('disabled'), 'Day of week is disabled');
|
||||
target = picker.find('.datepicker-days tbody td:nth(24)');
|
||||
ok(!target.hasClass('disabled'), 'Day of week is enabled');
|
||||
target = picker.find('.datepicker-days tbody td:nth(26)');
|
||||
ok(target.hasClass('disabled'), 'Day of week is disabled');
|
||||
});
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="assets/qunit.css" />
|
||||
<script src="assets/qunit.js"></script>
|
||||
<script src="assets/qunit-logging.js"></script> <!-- console.log for test failures -->
|
||||
<script src="assets/coverage.js"></script>
|
||||
<script src="assets/jquery-1.7.1.min.js"></script>
|
||||
<script src="../js/bootstrap-datepicker.js"></script>
|
||||
|
||||
<style>
|
||||
.datepicker {
|
||||
/* Appended to body, abs-pos off the page */
|
||||
position: absolute;
|
||||
display: none;
|
||||
top: -9999em;
|
||||
left: -9999em;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- Utilities -->
|
||||
<script src="assets/utils.js"></script>
|
||||
<script src="assets/mock.js"></script>
|
||||
|
||||
<!-- Test suites -->
|
||||
<script src="suites/formats.js"></script>
|
||||
<script src="suites/mouse_navigation/all.js"></script>
|
||||
<script src="suites/mouse_navigation/2012.js"></script>
|
||||
<script src="suites/mouse_navigation/2011.js"></script>
|
||||
<script src="suites/keyboard_navigation/all.js"></script>
|
||||
<script src="suites/keyboard_navigation/2012.js"></script>
|
||||
<script src="suites/keyboard_navigation/2011.js"></script>
|
||||
<script src="suites/component.js"></script>
|
||||
<script src="suites/events.js"></script>
|
||||
<script src="suites/options.js"></script>
|
||||
<script src="suites/inline.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">bootstrap-datepicker</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture"></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -41,6 +41,10 @@
|
||||
<script type="text/javascript" src="./../js/player_list.js"></script>
|
||||
<script type="text/javascript" src="./../js/player_list_navigator.js"></script>
|
||||
<script type="text/javascript" src="./../js/player_list_manager.js"></script>
|
||||
|
||||
<link href="./../../../resources/bootstrap/datepicker/css/datepicker.css" rel="stylesheet">
|
||||
<script src="./../../../resources/bootstrap/datepicker/js/bootstrap-datepicker.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$("#header").load("./../module/maestro_header.html");
|
||||
|
||||
@@ -10,6 +10,10 @@ $(document).ready(function() {
|
||||
});
|
||||
*/
|
||||
|
||||
$('#datepicker').datepicker({
|
||||
format: 'mm-dd-yyyy'
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -41,10 +45,13 @@ function copyToClipboard() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<!-- <input type="text" value="02-16-2012" id="datepicker"> -->
|
||||
|
||||
|
||||
<div class="card border-dark mb-3">
|
||||
<div class="card-header">검색 조건</div>
|
||||
@@ -61,7 +68,14 @@ function copyToClipboard() {
|
||||
<button type="button" class="btn btn-outline-primary btn-sm" onClick="">-1d</button>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<input type="text" class="form-control" id="formGroupExampleInput" placeholder="Example input">
|
||||
<div class="input-group input-append date" id="datepicker" data-date-format="yyyy-mm-dd">
|
||||
<input type="text" class="form-control" aria-describedby="button-addon2" size="16" readonly>
|
||||
<div class="input-group-append">
|
||||
<button class="add-on btn btn-primary" id="button-addon2">
|
||||
<span class="oi oi-calendar" title="icon calendar" aria-hidden="true"></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button type="button" class="btn btn-outline-primary btn-sm" onClick="">+1d</button>
|
||||
|
||||
Reference in New Issue
Block a user