/** * DO NOT EDIT THIS FILE. * See the following change record for more information, * https://www.drupal.org/node/2815083 * @preserve **/ ($ => { let cachedScrollbarWidth = null; const { max, abs } = Math; const regexHorizontal = /left|center|right/; const regexVertical = /top|center|bottom/; const regexOffset = /[+-]\d+(\.[\d]+)?%?/; const regexPosition = /^\w+/; const regexPercent = /%$/; const _position = $.fn.position; function getOffsets(offsets, width, height) { return [parseFloat(offsets[0]) * (regexPercent.test(offsets[0]) ? width / 100 : 1), parseFloat(offsets[1]) * (regexPercent.test(offsets[1]) ? height / 100 : 1)]; } function parseCss(element, property) { return parseInt($.css(element, property), 10) || 0; } function getDimensions(elem) { const raw = elem[0]; if (raw.nodeType === 9) { return { width: elem.width(), height: elem.height(), offset: { top: 0, left: 0 } }; } if ($.isWindow(raw)) { return { width: elem.width(), height: elem.height(), offset: { top: elem.scrollTop(), left: elem.scrollLeft() } }; } if (raw.preventDefault) { return { width: 0, height: 0, offset: { top: raw.pageY, left: raw.pageX } }; } return { width: elem.outerWidth(), height: elem.outerHeight(), offset: elem.offset() }; } const collisions = { fit: { left(position, data) { const { within } = data; const withinOffset = within.isWindow ? within.scrollLeft : within.offset.left; const outerWidth = within.width; const collisionPosLeft = position.left - data.collisionPosition.marginLeft; const overLeft = withinOffset - collisionPosLeft; const overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset; let newOverRight; if (data.collisionWidth > outerWidth) { if (overLeft > 0 && overRight <= 0) { newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset; position.left += overLeft - newOverRight; } else if (overRight > 0 && overLeft <= 0) { position.left = withinOffset; } else if (overLeft > overRight) { position.left = withinOffset + outerWidth - data.collisionWidth; } else { position.left = withinOffset; } } else if (overLeft > 0) { position.left += overLeft; } else if (overRight > 0) { position.left -= overRight; } else { position.left = max(position.left - collisionPosLeft, position.left); } }, top(position, data) { const { within } = data; const withinOffset = within.isWindow ? within.scrollTop : within.offset.top; const outerHeight = data.within.height; const collisionPosTop = position.top - data.collisionPosition.marginTop; const overTop = withinOffset - collisionPosTop; const overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset; let newOverBottom; if (data.collisionHeight > outerHeight) { if (overTop > 0 && overBottom <= 0) { newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset; position.top += overTop - newOverBottom; } else if (overBottom > 0 && overTop <= 0) { position.top = withinOffset; } else if (overTop > overBottom) { position.top = withinOffset + outerHeight - data.collisionHeight; } else { position.top = withinOffset; } } else if (overTop > 0) { position.top += overTop; } else if (overBottom > 0) { position.top -= overBottom; } else { position.top = max(position.top - collisionPosTop, position.top); } } }, flip: { left(position, data) { const { within } = data; const withinOffset = within.offset.left + within.scrollLeft; const outerWidth = within.width; const offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left; const collisionPosLeft = position.left - data.collisionPosition.marginLeft; const overLeft = collisionPosLeft - offsetLeft; const overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft; const myOffset = data.my[0] === 'left' ? -data.elemWidth : data.my[0] === 'right' ? data.elemWidth : 0; const atOffset = data.at[0] === 'left' ? data.targetWidth : data.at[0] === 'right' ? -data.targetWidth : 0; const offset = -2 * data.offset[0]; let newOverRight; let newOverLeft; if (overLeft < 0) { newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset; if (newOverRight < 0 || newOverRight < abs(overLeft)) { position.left += myOffset + atOffset + offset; } } else if (overRight > 0) { newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft; if (newOverLeft > 0 || abs(newOverLeft) < overRight) { position.left += myOffset + atOffset + offset; } } }, top(position, data) { const { within } = data; const withinOffset = within.offset.top + within.scrollTop; const outerHeight = within.height; const offsetTop = within.isWindow ? within.scrollTop : within.offset.top; const collisionPosTop = position.top - data.collisionPosition.marginTop; const overTop = collisionPosTop - offsetTop; const overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop; const top = data.my[1] === 'top'; const myOffset = top ? -data.elemHeight : data.my[1] === 'bottom' ? data.elemHeight : 0; const atOffset = data.at[1] === 'top' ? data.targetHeight : data.at[1] === 'bottom' ? -data.targetHeight : 0; const offset = -2 * data.offset[1]; let newOverTop; let newOverBottom; if (overTop < 0) { newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset; if (newOverBottom < 0 || newOverBottom < abs(overTop)) { position.top += myOffset + atOffset + offset; } } else if (overBottom > 0) { newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop; if (newOverTop > 0 || abs(newOverTop) < overBottom) { position.top += myOffset + atOffset + offset; } } } }, flipfit: { left(...args) { collisions.flip.left.apply(this, args); collisions.fit.left.apply(this, args); }, top(...args) { collisions.flip.top.apply(this, args); collisions.fit.top.apply(this, args); } } }; $.position = { scrollbarWidth() { if (cachedScrollbarWidth !== undefined) { return cachedScrollbarWidth; } const div = $('