import popper.js
Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
This commit is contained in:
parent
615dc56d16
commit
16fb2bb919
241 changed files with 34099 additions and 0 deletions
|
|
@ -0,0 +1,14 @@
|
|||
export default function appendNewPopper(id, text, container) {
|
||||
const jasmineWrapper = document.getElementById('jasmineWrapper');
|
||||
|
||||
const popper = document.createElement('div');
|
||||
popper.id = id;
|
||||
popper.className = 'popper';
|
||||
popper.textContent = text || 'popper';
|
||||
const arrow = document.createElement('div');
|
||||
arrow.className = 'popper__arrow';
|
||||
arrow.setAttribute('x-arrow', '');
|
||||
popper.appendChild(arrow);
|
||||
(container || jasmineWrapper).appendChild(popper);
|
||||
return popper;
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
export default function appendNewRef(id, text, container) {
|
||||
const jasmineWrapper = document.getElementById('jasmineWrapper');
|
||||
|
||||
const ref = document.createElement('div');
|
||||
ref.id = id;
|
||||
ref.className = 'ref';
|
||||
ref.textContent = text || 'reference';
|
||||
(container || jasmineWrapper).appendChild(ref);
|
||||
return ref;
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
(function() {
|
||||
if (typeof window.CustomEvent === 'function') {
|
||||
return false;
|
||||
}
|
||||
|
||||
function CustomEvent(event, params) {
|
||||
params = params || { bubbles: false, cancelable: false, detail: undefined };
|
||||
const evt = document.createEvent('CustomEvent');
|
||||
evt.initCustomEvent(
|
||||
event,
|
||||
params.bubbles,
|
||||
params.cancelable,
|
||||
params.detail
|
||||
);
|
||||
return evt;
|
||||
}
|
||||
|
||||
CustomEvent.prototype = window.Event.prototype;
|
||||
|
||||
window.CustomEvent = CustomEvent;
|
||||
})();
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
export default function getRect(element) {
|
||||
return element.getBoundingClientRect();
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
// https://codepen.io/FezVrasta/pen/YVBoEN
|
||||
export default function isMSBrowser() {
|
||||
const ua = window.navigator.userAgent;
|
||||
|
||||
const msie = ua.indexOf('MSIE ');
|
||||
if (msie > 0) {
|
||||
// IE 10 or older => return version number
|
||||
return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
|
||||
}
|
||||
|
||||
const trident = ua.indexOf('Trident/');
|
||||
if (trident > 0) {
|
||||
// IE 11 => return version number
|
||||
const rv = ua.indexOf('rv:');
|
||||
return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
|
||||
}
|
||||
|
||||
const edge = ua.indexOf('Edge/');
|
||||
if (edge > 0) {
|
||||
// Edge (IE 12+) => return version number
|
||||
return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
|
||||
}
|
||||
|
||||
// other browser
|
||||
return false;
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import makeElement from './makeElement';
|
||||
|
||||
/**
|
||||
* Create an element that's connected to the DOM.
|
||||
*/
|
||||
export default function makeConnectedElement() {
|
||||
const jasmineWrapper = document.getElementById('jasmineWrapper');
|
||||
return jasmineWrapper.appendChild(makeElement());
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
import makeConnectedElement from './makeConnectedElement';
|
||||
|
||||
/**
|
||||
* Create a scrollable element that's connected to the DOM.
|
||||
*/
|
||||
export default function makeConnectedScrollElement() {
|
||||
const elem = makeConnectedElement();
|
||||
elem.style.overflow = 'scroll';
|
||||
return elem;
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
/**
|
||||
* Create an element.
|
||||
*/
|
||||
export default function makeElement() {
|
||||
return document.createElement('div');
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
export default function prepend(node, parent) {
|
||||
parent.insertBefore(node, parent.firstChild);
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
export default function simulateScroll(
|
||||
element,
|
||||
{ scrollTop, scrollLeft, delay }
|
||||
) {
|
||||
const scrollingElement = element === document.body
|
||||
? document.scrollingElement || document.documentElement
|
||||
: element;
|
||||
|
||||
const applyScroll = () => {
|
||||
if (scrollTop !== undefined) {
|
||||
scrollingElement.scrollTop = scrollTop;
|
||||
}
|
||||
if (scrollLeft !== undefined) {
|
||||
scrollingElement.scrollLeft = scrollLeft;
|
||||
}
|
||||
};
|
||||
|
||||
if (delay !== undefined) {
|
||||
setTimeout(applyScroll, delay);
|
||||
} else {
|
||||
applyScroll();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
export default function then(callback, delay = 100) {
|
||||
setTimeout(callback, jasmine.THEN_DELAY);
|
||||
jasmine.THEN_DELAY += delay;
|
||||
}
|
||||
|
||||
beforeEach(() => (jasmine.THEN_DELAY = 0));
|
||||
Loading…
Add table
Add a link
Reference in a new issue