Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to pickadate 3.6.4 #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Pickadate-Rails [![Gem Version](https://badge.fury.io/rb/pickadate-rails.png)](http://badge.fury.io/rb/pickadate-rails)

## Pickadate Version: 3.5.6
## Pickadate Version: 3.6.4

Easily add [pickadate.js](https://github.com/amsul/pickadate.js) to your Rails 3.1+ application using the asset pipeline.

Expand Down
2 changes: 1 addition & 1 deletion lib/pickadate-rails/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module PickadateRails
VERSION = "3.5.6.0"
VERSION = "3.6.4.0"
end
9 changes: 1 addition & 8 deletions vendor/assets/javascripts/pickadate/legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@
* Legacy browser support
*/

// isArray support
if ( !Array.isArray ) {
Array.isArray = function( value ) {
return {}.toString.call( value ) == '[object Array]'
}
}


// Map array support
if ( ![].map ) {
Expand Down Expand Up @@ -137,4 +130,4 @@ String.prototype.split = function(separator, limit) {
output.push(str.slice(lastLastIndex))
}
return output.length > limit ? output.slice(0, limit) : output
}
};
19 changes: 11 additions & 8 deletions vendor/assets/javascripts/pickadate/picker.date.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*!
* Date picker for pickadate.js v3.5.6
* Date picker for pickadate.js v3.6.4
* 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' )
Expand Down Expand Up @@ -396,9 +396,14 @@ DatePicker.prototype.normalize = function( value/*, options*/ ) {
DatePicker.prototype.measure = function( type, value/*, options*/ ) {

var calendar = this

// If it's an integer, get a date relative to today.
if ( _.isInteger( value ) ) {
value = calendar.now( type, value, { rel: value } )
}

// If it’s anything false-y, remove the limits.
if ( !value ) {
else if ( !value ) {
value = type == 'min' ? -Infinity : Infinity
}

Expand All @@ -407,11 +412,6 @@ DatePicker.prototype.measure = function( type, value/*, options*/ ) {
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 } )
}

return value
} ///DatePicker.prototype.measure

Expand Down Expand Up @@ -1299,6 +1299,9 @@ DatePicker.defaults = (function( prefix ) {
closeOnSelect: true,
closeOnClear: true,

// Update input value on select/clear
updateInput: true,

// The format to show on the `input` element
format: 'd mmmm, yyyy',

Expand Down
110 changes: 85 additions & 25 deletions vendor/assets/javascripts/pickadate/picker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* pickadate.js v3.5.6, 2015/04/20
* pickadate.js v3.6.4, 2019/05/25
* By Amsul, http://amsul.ca
* Hosted on http://amsul.github.io/pickadate.js
* Licensed under MIT
Expand All @@ -16,6 +16,9 @@
module.exports = factory( require('jquery') )

// Browser globals.
else if ( typeof window == 'object' )
window.Picker = factory( jQuery )

else this.Picker = factory( jQuery )

}(function( $ ) {
Expand All @@ -41,7 +44,8 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) {

// The state of the picker.
STATE = {
id: ELEMENT.id || 'P' + Math.abs( ~~(Math.random() * new Date()) )
id: ELEMENT.id || 'P' + Math.abs( ~~(Math.random() * new Date()) ),
handlingOpen: false,
},


Expand Down Expand Up @@ -254,7 +258,7 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) {

// Prevent the page from scrolling.
if ( IS_DEFAULT_THEME ) {
$html.
$('body').
css( 'overflow', 'hidden' ).
css( 'padding-right', '+=' + getScrollbarWidth() )
}
Expand All @@ -264,8 +268,19 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) {

// Bind the document events.
$document.on( 'click.' + STATE.id + ' focusin.' + STATE.id, function( event ) {
// If the picker is currently midway through processing
// the opening sequence of events then don't handle clicks
// on any part of the DOM. This is caused by a bug in Chrome 73
// where a click event is being generated with the incorrect
// path in it.
// In short, if someone does a click that finishes after the
// new element is created then the path contains only the
// parent element and not the input element itself.
if (STATE.handlingOpen) {
return;
}

var target = event.target
var target = getRealEventTarget( event, ELEMENT )

// If the target of the event is not the element, close the picker picker.
// * Don’t worry about clicks or focusins on the root because those don’t bubble up.
Expand All @@ -274,7 +289,9 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) {
// * In Firefox stopPropagation() doesn’t prevent right-click events from bubbling,
// which causes the picker to unexpectedly close when right-clicking it. So make
// sure the event wasn’t a right-click.
if ( target != ELEMENT && target != document && event.which != 3 ) {
// * In Chrome 62 and up, password autofill causes a simulated focusin event which
// closes the picker.
if ( ! event.isSimulated && target != ELEMENT && target != document && event.which != 3 ) {

// If the target was the holder that covers the screen,
// keep the element focused to maintain tabindex.
Expand All @@ -291,7 +308,7 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) {
keycodeToMove = P.component.key[ keycode ],

// Grab the target.
target = event.target
target = getRealEventTarget( event, ELEMENT )


// On escape, close the picker and give focus.
Expand Down Expand Up @@ -379,7 +396,7 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) {

// Allow the page to scroll.
if ( IS_DEFAULT_THEME ) {
$html.
$('body').
css( 'overflow', '' ).
css( 'padding-right', '-=' + getScrollbarWidth() )
}
Expand Down Expand Up @@ -432,7 +449,7 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) {
}

// Then, check to update the element value and broadcast a change.
if ( thingItem == 'select' || thingItem == 'clear' ) {
if ( ( thingItem == 'select' || thingItem == 'clear' ) && SETTINGS.updateInput ) {
$ELEMENT.
val( thingItem == 'clear' ? '' : P.get( thingItem, SETTINGS.format ) ).
trigger( 'change' )
Expand Down Expand Up @@ -605,8 +622,6 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) {
) //endreturn
} //createWrappedComponent



/**
* Prepare the input element with all bindings.
*/
Expand All @@ -624,20 +639,38 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) {
val( $ELEMENT.data('value') ?
P.get('select', SETTINGS.format) :
ELEMENT.value
).

// On focus/click, open the picker.
on( 'focus.' + STATE.id + ' click.' + STATE.id,
function(event) {
event.preventDefault()
P.open()
}
)

// Mousedown handler to capture when the user starts interacting
// with the picker. This is used in working around a bug in Chrome 73.
.on('mousedown', function() {
STATE.handlingOpen = true;
var handler = function() {
// By default mouseup events are fired before a click event.
// By using a timeout we can force the mouseup to be handled
// after the corresponding click event is handled.
setTimeout(function() {
$(document).off('mouseup', handler);
STATE.handlingOpen = false;
}, 0);
};
$(document).on('mouseup', handler);
});


// Only bind keydown events if the element isn’t editable.
if ( !SETTINGS.editable ) {

$ELEMENT.

// On focus/click, open the picker.
on( 'focus.' + STATE.id + ' click.' + STATE.id, function(event) {
event.preventDefault()
P.open()
}).

// Handle keyboard event based on the picker being opened or not.
on( 'keydown.' + STATE.id, handleKeydownEvent )
}
Expand Down Expand Up @@ -691,7 +724,7 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) {
// from bubbling to the doc.
'mousedown click': function( event ) {

var target = event.target
var target = getRealEventTarget( event, ELEMENT )

// Make sure the target isn’t the root holder so it can bubble up.
if ( target != P.$holder[0] ) {
Expand All @@ -708,7 +741,7 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) {

// Re-focus onto the holder so that users can click away
// from elements focused within the picker.
P.$holder[0].focus()
P.$holder.eq(0).focus()
}
}
}
Expand All @@ -725,11 +758,11 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) {
// * For IE, non-focusable elements can be active elements as well
// (http://stackoverflow.com/a/2684561).
activeElement = getActiveElement()
activeElement = activeElement && ( activeElement.type || activeElement.href )
activeElement = activeElement && ( (activeElement.type || activeElement.href ) ? activeElement : null);

// If it’s disabled or nothing inside is actively focused, re-focus the element.
if ( targetDisabled || activeElement && !$.contains( P.$root[0], activeElement ) ) {
P.$holder[0].focus()
P.$holder.eq(0).focus()
}

// If something is superficially changed, update the `highlight` based on the `nav`.
Expand Down Expand Up @@ -814,11 +847,13 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) {

if (IS_DEFAULT_THEME && supportsTransitions) {
P.$holder.find('.' + CLASSES.frame).one('transitionend', function() {
P.$holder[0].focus()
P.$holder.eq(0).focus()
})
}
else {
P.$holder[0].focus()
setTimeout(function() {
P.$holder.eq(0).focus()
}, 0)
}
}

Expand Down Expand Up @@ -957,6 +992,34 @@ function getScrollbarWidth() {



/**
* Get the target element from the event.
* If ELEMENT is supplied and present in the event path (ELEMENT is ancestor of the target),
* returns ELEMENT instead
*/
function getRealEventTarget( event, ELEMENT ) {

var path = []

if ( event.path ) {
path = event.path
}

if ( event.originalEvent && event.originalEvent.path ) {
path = event.originalEvent.path
}

if ( path && path.length > 0 ) {
if ( ELEMENT && path.indexOf( ELEMENT ) >= 0 ) {
return ELEMENT
} else {
return path[0]
}
}

return event.target
}

/**
* PickerConstructor helper methods.
*/
Expand Down Expand Up @@ -1158,6 +1221,3 @@ return PickerConstructor


}));



7 changes: 5 additions & 2 deletions vendor/assets/javascripts/pickadate/picker.time.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*!
* Time picker for pickadate.js v3.5.6
* Time picker for pickadate.js v3.6.4
* 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' )
Expand Down Expand Up @@ -977,6 +977,9 @@ TimePicker.defaults = (function( prefix ) {
closeOnSelect: true,
closeOnClear: true,

// Update input value on select/clear
updateInput: true,

// Classes
klass: {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### The following convention is used for choosing a format for the translation files:

1. Google for “Microsoft Style Guide LANGUAGE COUNTRY”.
2. Check the standard suggestions for Long Date Formats.
3. Set this as the `format` option using [pickadate’s formatting rules](http://amsul.ca/pickadate.js/date.htm#formatting-rules).

Make sure `formatSubmit` is always `yyyy/mm/dd` to ensure our servers always get the value formatted the same.
2 changes: 2 additions & 0 deletions vendor/assets/javascripts/pickadate/translations/NAMING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ COUNTRY = The uppercase ISO 3166-1 country code.
```

> See http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements

When there is no `COUNTRY` in the filename, it is assumed the generic language is used in multiple countries.
6 changes: 3 additions & 3 deletions vendor/assets/javascripts/pickadate/translations/ca_ES.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ jQuery.extend( jQuery.fn.pickadate.defaults, {
weekdaysFull: [ 'diumenge', 'dilluns', 'dimarts', 'dimecres', 'dijous', 'divendres', 'dissabte' ],
weekdaysShort: [ 'diu', 'dil', 'dim', 'dmc', 'dij', 'div', 'dis' ],
today: 'avui',
clear: 'esborrar',
close: 'tancar',
clear: 'esborra',
close: 'tanca',
firstDay: 1,
format: 'dddd d !de mmmm !de yyyy',
formatSubmit: 'yyyy/mm/dd'
});

jQuery.extend( jQuery.fn.pickatime.defaults, {
clear: 'esborrar'
clear: 'esborra'
});
3 changes: 2 additions & 1 deletion vendor/assets/javascripts/pickadate/translations/cs_CZ.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ jQuery.extend( jQuery.fn.pickadate.defaults, {
clear: 'vymazat',
firstDay: 1,
format: 'd. mmmm yyyy',
formatSubmit: 'yyyy/mm/dd'
formatSubmit: 'yyyy/mm/dd',
close: 'zavřít'
});

jQuery.extend( jQuery.fn.pickatime.defaults, {
Expand Down
Loading