Skip to content

Commit

Permalink
Merge latest master into extensible branch
Browse files Browse the repository at this point in the history
  • Loading branch information
eternicode committed Jul 18, 2013
2 parents 1735651 + 091f01b commit b638b91
Show file tree
Hide file tree
Showing 24 changed files with 588 additions and 58 deletions.
8 changes: 8 additions & 0 deletions .hgtags
@@ -0,0 +1,8 @@
b965e03abfcb10d66c8dad96d54d6f8e1c5d8501 v1.0.0
7a490672b362af7640bbeb68553a0e0a5a95cb9e v1.0.1
9a730557f14d79c2ce2d28eacb24bdf52ac2e042 1.0.2-rc.1
62604d506e5ba9d85ee6c2d86723b9b3d817e7bd 1.0.2-rc.1.1
f6211e251c021331decc16bfbcf25577dd354ef4 1.0.2-rc.2
493d2332f0cb7f2dd308c442920da86063ff2e0f 1.0.2
77a6755dc3df3ada745024648535562587fab630 1.1.0
fe9e4106def42741adba1606245ab0eab32acb55 1.1.1
52 changes: 52 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,58 @@
Changelog
=========

1.1.1
----------

Fixes a bug when setting startDate or endDate during initialization.


1.1.0
----------

New features:
* Date range picker.
* Data API / noConflict.
* `getDate` and `setDate` methods.
* `format` method for events; this allows you to easily format the `date` associated with the event.
* New options:
* `beforeShowDay` option: a dev-provided function that can enable/disable dates, add css classes, and add tooltips.
* `clearBtn`, a button for resetting the picker.

Internal changes:
* Cleaner and more reliable method for extracting options from all potential sources (defaults, locale overrides, data-attrs, and instantiation options, in that order). This also populates `$.fn.datepicker.defaults` with the default values, and uses this hash as the actual source of defaults, meaning you can globally change the default value for a given option.

Bugs squashed:
* Resolved a conflict with bootstrap's native `.switch` class.
* Fixed a bug with components where they would be stuck with a stale value when editing the value manually.
* The `date` attributes on events are now local dates instead of internal UTC dates.
* Separate `Date` objects for internal selected and view date references.
* Clicking multiple times inside inputs no longer hides the picker.

Minor improvements:
* Better text color for highlighted "today" date.
* Last year in decade view now marked as "new" instead of "old".
* Formats now properly handle trailing separators.

Locale changes:
* Added Albanian, Estonian, and Macedonian
* Added `weekStart` for Russian
* Added `weekStart` and `format` for Finnish

Potentially backward-incompatible changes:
* Options revamp:
* This fixes bugs in the correlation of some data-attrs to their associated option names. If you use `data-date-weekstart`, `data-date-startdate`, or `data-date-enddate`, you should update these to `data-date-week-start`, `data-date-start-date`, or `data-date-end-date`, respectively.
* All options for datepicker are now properties on the datepicker's `o` property; options are no longer stored on the Datepicker instance itself. If you have code that accesses options stored on the datepicker instance (eg, `datepicker.format`), you will need to update it to access those options via the `o` property (eg, `datepicker.o.format`). "Raw" options are available via the `_o` property.

1.0.2
----------

Small optimizations release

* Reduced the number of times `update` is called on initialization.
* Datepicker now detaches the picker dropdown when it is hidden, and appends it when shown. This removes the picker from the DOM when it is not in use.
* No longer listens to document/window events unless picker is visible.

v1.0.1
------

Expand Down
16 changes: 15 additions & 1 deletion README.md
Expand Up @@ -8,12 +8,14 @@ contributed to by him (yet?)

Versions are incremented according to [semver](http://semver.org/).

[Online Demo](http://eternicode.github.com/bootstrap-datepicker/)

# Requirements

* [Bootstrap](http://twitter.github.com/bootstrap/) 2.0.4+
* [jQuery](http://jquery.com/) 1.7.1+

These are the specific versions bootstrap-datpicker is tested against (`js` files) and built against (`css` files). Use other versions at your own risk.
These are the specific versions bootstrap-datepicker is tested against (`js` files) and built against (`css` files). Use other versions at your own risk.

# Example

Expand Down Expand Up @@ -161,6 +163,8 @@ $.fn.bootstrapDP = datepicker; // give $().bootstrapDP the boots

All options that take a "Date" can handle a `Date` object or a String formatted according to the given `format`. If the default backend is used, they can also handle a timedelta relative to today, eg '-1d', '+6m +1y', etc, where valid units are 'd' (day), 'w' (week), 'm' (month), and 'y' (year).

Most options can be provided via data-attributes. An option can be converted to a data-attribute by taking its name, replacing each uppercase letter with its lowercase equivalent preceded by a dash, and prepending "data-date-" to the result. For example, `startDate` would be `data-date-start-date`, `format` would be `data-date-format`, and `daysOfWeekDisabled` would be `data-date-days-of-week-disabled`.

### format

String. Default: 'mm/dd/yyyy'
Expand Down Expand Up @@ -278,6 +282,16 @@ A function that takes a date as a parameter and returns one of the following val
* `classes`: same as the String value above
* `tooltip`: a tooltip to apply to this date, via the `title` HTML attribute

### orientation

String. Default: "auto"

A space-separated string consisting of one or two of "left" or "right", "top" or "bottom", and "auto" (may be omitted); for example, "top left", "bottom" (horizontal orientation will default to "auto"), "right" (vertical orientation will default to "auto"), "auto top". Allows for fixed placement of the picker popup.

"orientation" refers to the location of the picker popup's "anchor"; you can also think of it as the location of the trigger element (input, component, etc) relative to the picker.

"auto" triggers "smart orientation" of the picker. Horizontal orientation will default to "left" and left offset will be tweaked to keep the picker inside the browser viewport; vertical orientation will simply choose "top" or "bottom", whichever will show more of the picker in the viewport.

## Markup

Format a component.
Expand Down
2 changes: 1 addition & 1 deletion component.json → bower.json
@@ -1,6 +1,6 @@
{
"name": "bootstrap-datepicker",
"version": "1.0.0",
"version": "1.1.1",
"main": ["js/bootstrap-datepicker.js","css/datepicker.css"],
"dependencies": {
"jquery" : ">=1.7.1",
Expand Down
38 changes: 35 additions & 3 deletions css/datepicker.css
Expand Up @@ -37,21 +37,47 @@
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-bottom: 7px solid #ccc;
border-top: 0;
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;
border-top: 0;
position: absolute;
top: -6px;
}
.datepicker-dropdown.datepicker-orient-left:before {
left: 6px;
}
.datepicker-dropdown.datepicker-orient-left:after {
left: 7px;
}
.datepicker-dropdown.datepicker-orient-right:before {
right: 6px;
}
.datepicker-dropdown.datepicker-orient-right:after {
right: 7px;
}
.datepicker-dropdown.datepicker-orient-top:before {
top: -7px;
}
.datepicker-dropdown.datepicker-orient-top:after {
top: -6px;
}
.datepicker-dropdown.datepicker-orient-bottom:before {
bottom: -7px;
border-bottom: 0;
border-top: 7px solid #999;
}
.datepicker-dropdown.datepicker-orient-bottom:after {
bottom: -6px;
border-bottom: 0;
border-top: 6px solid #ffffff;
}
.datepicker > div {
display: none;
}
Expand All @@ -66,6 +92,12 @@
}
.datepicker table {
margin: 0;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.datepicker td,
.datepicker th {
Expand Down
16 changes: 13 additions & 3 deletions js/backends/bootstrap-datepicker.default.js
Expand Up @@ -34,6 +34,8 @@
},
parseDate: function(date, format, language) {
if (date instanceof Date) return date;
if (typeof format === 'string')
format = this.parseFormat(format);
if (/^[\-+]\d+[dmwy]([\s,]+[\-+]\d+[dmwy])*$/.test(date)) {
var part_re = /([\-+]\d+)([dmwy])/,
parts = date.match(/([\-+]\d+)([dmwy])/g),
Expand Down Expand Up @@ -67,6 +69,8 @@
yyyy: function(d,v){ return d.setUTCFullYear(v); },
yy: function(d,v){ return d.setUTCFullYear(2000+v); },
m: function(d,v){
if (isNaN(d))
return d;
v -= 1;
while (v<0) v += 12;
v %= 12;
Expand Down Expand Up @@ -115,15 +119,21 @@
}
parsed[part] = val;
}
for (var i=0, s; i<setters_order.length; i++){
for (var i=0, _date, s; i<setters_order.length; i++){
s = setters_order[i];
if (s in parsed && !isNaN(parsed[s]))
setters_map[s](date, parsed[s]);
if (s in parsed && !isNaN(parsed[s])){
_date = new Date(date);
setters_map[s](_date, parsed[s]);
if (!isNaN(_date))
date = _date;
}
}
}
return date;
},
formatDate: function(date, format, language){
if (typeof format === 'string')
format = this.parseFormat(format)
var val = {
d: date.getUTCDate(),
D: dates[language].daysShort[date.getUTCDay()],
Expand Down

0 comments on commit b638b91

Please sign in to comment.