2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-05 08:59:27 +08:00

DEV: pikaday 1.8.0 (#7536)

This commit is contained in:
Joffrey JAFFEUX 2019-05-13 15:09:04 +02:00 committed by GitHub
parent 53d2232731
commit 3912d6f806
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 11 deletions

View file

@ -1,7 +1,7 @@
/*!
* Pikaday
*
* Copyright © 2014 David Bushell | BSD & MIT license | https://github.com/dbushell/Pikaday
* Copyright © 2014 David Bushell | BSD & MIT license | https://github.com/Pikaday/Pikaday
*/
(function (root, factory)
@ -183,6 +183,9 @@
// automatically show/hide the picker on `field` focus (default `true` if `field` is set)
bound: undefined,
// data-attribute on the input field with an aria assistance tekst (only applied when `bound` is set)
ariaLabel: 'Use the arrow keys to pick a date',
// position of the datepicker, relative to the field (default to bottom & left)
// ('bottom' & 'left' keywords are not used, 'top' & 'right' are modifier on the bottom/left position)
position: 'bottom left',
@ -1023,13 +1026,13 @@
if (opts.bound) {
// let the screen reader user know to use arrow keys
opts.field.setAttribute('aria-label', 'Use the arrow keys to pick a date');
opts.field.setAttribute('aria-label', opts.ariaLabel);
}
},
adjustPosition: function()
{
var field, pEl, width, height, viewportWidth, viewportHeight, scrollTop, left, top, clientRect;
var field, pEl, width, height, viewportWidth, viewportHeight, scrollTop, left, top, clientRect, leftAligned, bottomAligned;
if (this._o.container) return;
@ -1042,6 +1045,8 @@
viewportWidth = window.innerWidth || document.documentElement.clientWidth;
viewportHeight = window.innerHeight || document.documentElement.clientHeight;
scrollTop = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
leftAligned = true;
bottomAligned = true;
if (typeof field.getBoundingClientRect === 'function') {
clientRect = field.getBoundingClientRect();
@ -1064,6 +1069,7 @@
)
) {
left = left - width + field.offsetWidth;
leftAligned = false;
}
if ((this._o.reposition && top + height > viewportHeight + scrollTop) ||
(
@ -1072,10 +1078,16 @@
)
) {
top = top - height - field.offsetHeight;
bottomAligned = false;
}
this.el.style.left = left + 'px';
this.el.style.top = top + 'px';
addClass(this.el, leftAligned ? 'left-aligned' : 'right-aligned');
addClass(this.el, bottomAligned ? 'bottom-aligned' : 'top-aligned');
removeClass(this.el, !leftAligned ? 'left-aligned' : 'right-aligned');
removeClass(this.el, !bottomAligned ? 'bottom-aligned' : 'top-aligned');
},
/**