vendor/assets/javascripts/pickadate/picker.time.js in pickadate-rails-3.5.5.0 vs vendor/assets/javascripts/pickadate/picker.time.js in pickadate-rails-3.5.6.0
- old
+ new
@@ -1,16 +1,15 @@
-
/*!
- * Time picker for pickadate.js v3.5.3
+ * Time picker for pickadate.js v3.5.6
* http://amsul.github.io/pickadate.js/time.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') )
@@ -75,12 +74,11 @@
// When there’s a value, set the `select`, which in turn
// also sets the `highlight` and `view`.
if ( valueString ) {
clock.set( 'select', valueString, {
- format: formatString,
- fromValue: !!elementValue
+ format: formatString
})
}
// If there’s no value, default to highlighting “today”.
else {
@@ -175,19 +173,19 @@
clock.
set( 'min', clockItem.min, options ).
set( 'max', clockItem.max, options )
}
else if ( type.match( /^(flip|min|max|disable|enable)$/ ) ) {
- if ( type == 'min' ) {
- clock.set( 'max', clockItem.max, options )
- }
if ( clockItem.select && clock.disabled( clockItem.select ) ) {
- clock.set( 'select', clockItem.select, options )
+ clock.set( 'select', value, options )
}
if ( clockItem.highlight && clock.disabled( clockItem.highlight ) ) {
- clock.set( 'highlight', clockItem.highlight, options )
+ clock.set( 'highlight', value, options )
}
+ if ( type == 'min' ) {
+ clock.set( 'max', clockItem.max, options )
+ }
}
return clock
} //TimePicker.prototype.set
@@ -255,11 +253,11 @@
// The time in total minutes.
time: ( MINUTES_IN_DAY + value ) % MINUTES_IN_DAY,
// Reference to the “relative” value to pick.
- pick: value
+ pick: value % MINUTES_IN_DAY
}
} //TimePicker.prototype.create
/**
@@ -899,11 +897,12 @@
item: function( loopedTime ) {
loopedTime = clock.create( loopedTime )
var timeMinutes = loopedTime.pick,
isSelected = selectedObject && selectedObject.pick == timeMinutes,
isHighlighted = highlightedObject && highlightedObject.pick == timeMinutes,
- isDisabled = disabledCollection && clock.disabled( loopedTime )
+ isDisabled = disabledCollection && clock.disabled( loopedTime ),
+ formattedTime = _.trigger( clock.formats.toString, clock, [ settings.format, loopedTime ] )
return [
_.trigger( clock.formats.toString, clock, [ _.trigger( settings.formatLabel, clock, [ loopedTime ] ) || settings.format, loopedTime ] ),
(function( klasses ) {
if ( isSelected ) {
@@ -924,15 +923,12 @@
return klasses.join( ' ' )
})( [ settings.klass.listItem ] ),
'data-pick=' + loopedTime.pick + ' ' + _.ariaAttr({
role: 'option',
- selected: isSelected && clock.$node.val() === _.trigger(
- clock.formats.toString,
- clock,
- [ settings.format, loopedTime ]
- ) ? true : null,
+ label: formattedTime,
+ selected: isSelected && clock.$node.val() === formattedTime ? true : null,
activedescendant: isHighlighted ? true : null,
disabled: isDisabled ? true : null
})
]
}
@@ -959,14 +955,13 @@
-/* ==========================================================================
- Extend the picker to add the component with the defaults.
- ========================================================================== */
-
+/**
+ * Extend the picker to add the component with the defaults.
+ */
TimePicker.defaults = (function( prefix ) {
return {
// Clear
@@ -975,9 +970,13 @@
// The format to show on the `input` element
format: 'h:i A',
// The interval between each time
interval: 30,
+
+ // Picker close behavior
+ closeOnSelect: true,
+ closeOnClear: true,
// Classes
klass: {
picker: prefix + ' ' + prefix + '--time',