vendor/assets/javascripts/pickadate/picker.date.js in pickadate-rails-3.5.2.0 vs vendor/assets/javascripts/pickadate/picker.date.js in pickadate-rails-3.5.3.0
- old
+ new
@@ -1,18 +1,22 @@
/*!
- * Date picker for pickadate.js v3.5.0
+ * Date picker for pickadate.js v3.5.3
* http://amsul.github.io/pickadate.js/date.htm
*/
(function ( factory ) {
- // Register as an anonymous module.
+ // AMD.
if ( typeof define == 'function' && define.amd )
define( ['picker','jquery'], factory )
- // Or using browser globals.
+ // Node.js/browserify.
+ else if ( typeof exports == 'object' )
+ module.exports = factory( require('./picker.js'), require('jquery') )
+
+ // Browser globals.
else factory( Picker, jQuery )
}(function( Picker, $ ) {
@@ -29,16 +33,24 @@
* The date picker constructor
*/
function DatePicker( picker, settings ) {
var calendar = this,
- elementValue = picker.$node[ 0 ].value,
+ element = picker.$node[ 0 ],
+ elementValue = element.value,
elementDataValue = picker.$node.data( 'value' ),
valueString = elementDataValue || elementValue,
formatString = elementDataValue ? settings.formatSubmit : settings.format,
isRTL = function() {
- return getComputedStyle( picker.$root[0] ).direction === 'rtl'
+
+ return element.currentStyle ?
+
+ // For IE.
+ element.currentStyle.direction == 'rtl' :
+
+ // For normal browsers.
+ getComputedStyle( picker.$root[0] ).direction == 'rtl'
}
calendar.settings = settings
calendar.$node = picker.$node
@@ -116,17 +128,21 @@
if ( value ) {
picker.set( 'highlight', [ value, picker.get( 'view' ).month, picker.get( 'highlight' ).date ] )
picker.$root.find( '.' + settings.klass.selectYear ).trigger( 'focus' )
}
})
- }).
+ }, 1 ).
on( 'open', function() {
- picker.$root.find( 'button, select' ).attr( 'disabled', false )
- }).
+ var includeToday = ''
+ if ( calendar.disabled( calendar.get('now') ) ) {
+ includeToday = ':not(.' + settings.klass.buttonToday + ')'
+ }
+ picker.$root.find( 'button' + includeToday + ', select' ).attr( 'disabled', false )
+ }, 1 ).
on( 'close', function() {
picker.$root.find( 'button, select' ).attr( 'disabled', true )
- })
+ }, 1 )
} //DatePicker
/**
@@ -377,15 +393,20 @@
*/
DatePicker.prototype.measure = function( type, value/*, options*/ ) {
var calendar = this
- // If it's anything false-y, remove the limits.
+ // If it’s anything false-y, remove the limits.
if ( !value ) {
value = type == 'min' ? -Infinity : Infinity
}
+ // If it’s a string, parse it.
+ else if ( typeof value == 'string' ) {
+ value = calendar.parse( type, value )
+ }
+
// If it's an integer, get a date relative to today.
else if ( _.isInteger( value ) ) {
value = calendar.now( type, value, { rel: value } )
}
@@ -1228,15 +1249,19 @@
// * For Firefox forms to submit, make sure to set the buttons’ `type` attributes as “button”.
_.node(
'div',
_.node( 'button', settings.today, settings.klass.buttonToday,
'type=button data-pick=' + nowObject.pick +
- ( isOpen ? '' : ' disabled' ) + ' ' +
+ ( isOpen && !calendar.disabled(nowObject) ? '' : ' disabled' ) + ' ' +
_.ariaAttr({ controls: calendar.$node[0].id }) ) +
_.node( 'button', settings.clear, settings.klass.buttonClear,
'type=button data-clear=1' +
( isOpen ? '' : ' disabled' ) + ' ' +
+ _.ariaAttr({ controls: calendar.$node[0].id }) ) +
+ _.node('button', settings.close, settings.klass.buttonClose,
+ 'type=button data-close=true ' +
+ ( isOpen ? '' : ' disabled' ) + ' ' +
_.ariaAttr({ controls: calendar.$node[0].id }) ),
settings.klass.footer
) //endreturn
} //DatePicker.prototype.nodes
@@ -1265,10 +1290,11 @@
weekdaysShort: [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ],
// Today and clear
today: 'Today',
clear: 'Clear',
+ close: 'Close',
// The format to show on the `input` element
format: 'd mmmm, yyyy',
// Classes
@@ -1299,10 +1325,11 @@
outfocus: prefix + 'day--outfocus',
footer: prefix + 'footer',
buttonClear: prefix + 'button--clear',
- buttonToday: prefix + 'button--today'
+ buttonToday: prefix + 'button--today',
+ buttonClose: prefix + 'button--close'
}
}
})( Picker.klasses().picker + '__' )