vendor/assets/javascripts/pickadate/picker.date.js in pickadate-rails-3.5.5.0 vs vendor/assets/javascripts/pickadate/picker.date.js in pickadate-rails-3.5.6.0
- old
+ new
@@ -1,16 +1,15 @@
-
/*!
- * Date picker for pickadate.js v3.5.3
+ * Date picker for pickadate.js v3.5.6
* http://amsul.github.io/pickadate.js/date.htm
*/
(function ( factory ) {
// AMD.
if ( typeof define == 'function' && define.amd )
- define( ['picker','jquery'], factory )
+ define( ['picker', 'jquery'], factory )
// Node.js/browserify.
else if ( typeof exports == 'object' )
module.exports = factory( require('./picker.js'), require('jquery') )
@@ -81,11 +80,14 @@
set( 'now' )
// When there’s a value, set the `select`, which in turn
// also sets the `highlight` and `view`.
if ( valueString ) {
- calendar.set( 'select', valueString, { format: formatString })
+ calendar.set( 'select', valueString, {
+ format: formatString,
+ defaultValue: true
+ })
}
// If there’s no value, default to highlighting “today”.
else {
calendar.
@@ -103,11 +105,11 @@
go: function( timeChange ) {
var highlightedObject = calendar.item.highlight,
targetDate = new Date( highlightedObject.year, highlightedObject.month, highlightedObject.date + timeChange )
calendar.set(
'highlight',
- [ targetDate.getFullYear(), targetDate.getMonth(), targetDate.getDate() ],
+ targetDate,
{ interval: timeChange }
)
this.render()
}
}
@@ -474,11 +476,11 @@
// Cases to **not** validate for:
// • Navigating months.
// • Not inverted and date enabled.
// • Inverted and all dates disabled.
// • ..and anything else.
- if ( !options || !options.nav ) if (
+ if ( !options || (!options.nav && !options.defaultValue) ) if (
/* 1 */ ( !isFlippedBase && calendar.disabled( dateObject ) ) ||
/* 2 */ ( isFlippedBase && calendar.disabled( dateObject ) && ( hasEnabledWeekdays || hasEnabledBeforeTarget || hasEnabledAfterTarget ) ) ||
/* 3 */ ( !isFlippedBase && (dateObject.pick <= minLimitObject.pick || dateObject.pick >= maxLimitObject.pick) )
) {
@@ -643,11 +645,12 @@
// Return the length of the first word in a collection.
function getWordLengthFromCollection( string, collection, dateObject ) {
// Grab the first word from the string.
- var word = string.match( /\w+/ )[ 0 ]
+ // Regex pattern from http://stackoverflow.com/q/150033
+ var word = string.match( /[^\x00-\x7F]+|\w+/ )[ 0 ]
// If there's no month index, add it to the date object
if ( !dateObject.mm && !dateObject.m ) {
dateObject.m = collection.indexOf( word ) + 1
}
@@ -1183,11 +1186,12 @@
// Convert the time date from a relative date to a target date.
targetDate = calendar.create([ viewsetObject.year, viewsetObject.month, targetDate + ( settings.firstDay ? 1 : 0 ) ])
var isSelected = selectedObject && selectedObject.pick == targetDate.pick,
isHighlighted = highlightedObject && highlightedObject.pick == targetDate.pick,
- isDisabled = disabledCollection && calendar.disabled( targetDate ) || targetDate.pick < minLimitObject.pick || targetDate.pick > maxLimitObject.pick
+ isDisabled = disabledCollection && calendar.disabled( targetDate ) || targetDate.pick < minLimitObject.pick || targetDate.pick > maxLimitObject.pick,
+ formattedDate = _.trigger( calendar.formats.toString, calendar, [ settings.format, targetDate ] )
return [
_.node(
'div',
targetDate.date,
@@ -1218,15 +1222,12 @@
return klasses.join( ' ' )
})([ settings.klass.day ]),
'data-pick=' + targetDate.pick + ' ' + _.ariaAttr({
role: 'gridcell',
- selected: isSelected && calendar.$node.val() === _.trigger(
- calendar.formats.toString,
- calendar,
- [ settings.format, targetDate ]
- ) ? true : null,
+ label: formattedDate,
+ selected: isSelected && calendar.$node.val() === formattedDate ? true : null,
activedescendant: isHighlighted ? true : null,
disabled: isDisabled ? true : null
})
),
'',
@@ -1291,9 +1292,13 @@
// Today and clear
today: 'Today',
clear: 'Clear',
close: 'Close',
+
+ // Picker close behavior
+ closeOnSelect: true,
+ closeOnClear: true,
// The format to show on the `input` element
format: 'd mmmm, yyyy',
// Classes