From 7dc9f334bdb498587351e6afb62b227f2754a8a7 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 16 Mar 2021 17:45:58 +0000 Subject: [PATCH] Use minified version of bootstrap-native As retrieved from https://github.com/thednp/bootstrap.native/blob/3.0.15/dist/bootstrap-native.min.js --- src/api/web.rs | 2 +- src/static/scripts/bootstrap-native.js | 1673 -------------------- src/static/scripts/bootstrap-native.min.js | 2 + src/static/templates/admin/base.hbs | 2 +- 4 files changed, 4 insertions(+), 1675 deletions(-) delete mode 100644 src/static/scripts/bootstrap-native.js create mode 100644 src/static/scripts/bootstrap-native.min.js diff --git a/src/api/web.rs b/src/api/web.rs index e6059e1f..3c1e54a5 100644 --- a/src/api/web.rs +++ b/src/api/web.rs @@ -83,7 +83,7 @@ fn static_files(filename: String) -> Result, Error> { "hibp.png" => Ok(Content(ContentType::PNG, include_bytes!("../static/images/hibp.png"))), "bootstrap.min.css" => Ok(Content(ContentType::CSS, include_bytes!("../static/scripts/bootstrap.min.css"))), - "bootstrap-native.js" => Ok(Content(ContentType::JavaScript, include_bytes!("../static/scripts/bootstrap-native.js"))), + "bootstrap-native.min.js" => Ok(Content(ContentType::JavaScript, include_bytes!("../static/scripts/bootstrap-native.min.js"))), "identicon.js" => Ok(Content(ContentType::JavaScript, include_bytes!("../static/scripts/identicon.js"))), "datatables.min.js" => Ok(Content(ContentType::JavaScript, include_bytes!("../static/scripts/datatables.min.js"))), "datatables.min.css" => Ok(Content(ContentType::CSS, include_bytes!("../static/scripts/datatables.min.css"))), diff --git a/src/static/scripts/bootstrap-native.js b/src/static/scripts/bootstrap-native.js deleted file mode 100644 index 8fafa16a..00000000 --- a/src/static/scripts/bootstrap-native.js +++ /dev/null @@ -1,1673 +0,0 @@ -/*! - * Native JavaScript for Bootstrap v3.0.15 (https://thednp.github.io/bootstrap.native/) - * Copyright 2015-2021 © dnp_theme - * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) - */ - (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - (global = global || self, global.BSN = factory()); -}(this, (function () { 'use strict'; - - var transitionEndEvent = 'webkitTransition' in document.head.style ? 'webkitTransitionEnd' : 'transitionend'; - - var supportTransition = 'webkitTransition' in document.head.style || 'transition' in document.head.style; - - var transitionDuration = 'webkitTransition' in document.head.style ? 'webkitTransitionDuration' : 'transitionDuration'; - - var transitionProperty = 'webkitTransition' in document.head.style ? 'webkitTransitionProperty' : 'transitionProperty'; - - function getElementTransitionDuration(element) { - var computedStyle = getComputedStyle(element), - property = computedStyle[transitionProperty], - duration = supportTransition && property && property !== 'none' - ? parseFloat(computedStyle[transitionDuration]) : 0; - return !isNaN(duration) ? duration * 1000 : 0; - } - - function emulateTransitionEnd(element,handler){ - var called = 0, duration = getElementTransitionDuration(element); - duration ? element.addEventListener( transitionEndEvent, function transitionEndWrapper(e){ - !called && handler(e), called = 1; - element.removeEventListener( transitionEndEvent, transitionEndWrapper); - }) - : setTimeout(function() { !called && handler(), called = 1; }, 17); - } - - function queryElement(selector, parent) { - var lookUp = parent && parent instanceof Element ? parent : document; - return selector instanceof Element ? selector : lookUp.querySelector(selector); - } - - function bootstrapCustomEvent(eventName, componentName, eventProperties) { - var OriginalCustomEvent = new CustomEvent( eventName + '.bs.' + componentName, {cancelable: true}); - if (typeof eventProperties !== 'undefined') { - Object.keys(eventProperties).forEach(function (key) { - Object.defineProperty(OriginalCustomEvent, key, { - value: eventProperties[key] - }); - }); - } - return OriginalCustomEvent; - } - - function dispatchCustomEvent(customEvent){ - this && this.dispatchEvent(customEvent); - } - - function Alert(element) { - var self = this, - alert, - closeCustomEvent = bootstrapCustomEvent('close','alert'), - closedCustomEvent = bootstrapCustomEvent('closed','alert'); - function triggerHandler() { - alert.classList.contains('fade') ? emulateTransitionEnd(alert,transitionEndHandler) : transitionEndHandler(); - } - function toggleEvents(action){ - action = action ? 'addEventListener' : 'removeEventListener'; - element[action]('click',clickHandler,false); - } - function clickHandler(e) { - alert = e && e.target.closest(".alert"); - element = queryElement('[data-dismiss="alert"]',alert); - element && alert && (element === e.target || element.contains(e.target)) && self.close(); - } - function transitionEndHandler() { - toggleEvents(); - alert.parentNode.removeChild(alert); - dispatchCustomEvent.call(alert,closedCustomEvent); - } - self.close = function () { - if ( alert && element && alert.classList.contains('show') ) { - dispatchCustomEvent.call(alert,closeCustomEvent); - if ( closeCustomEvent.defaultPrevented ) { return; } - self.dispose(); - alert.classList.remove('show'); - triggerHandler(); - } - }; - self.dispose = function () { - toggleEvents(); - delete element.Alert; - }; - element = queryElement(element); - alert = element.closest('.alert'); - element.Alert && element.Alert.dispose(); - if ( !element.Alert ) { - toggleEvents(1); - } - self.element = element; - element.Alert = self; - } - - function Button(element) { - var self = this, labels, - changeCustomEvent = bootstrapCustomEvent('change', 'button'); - function toggle(e) { - var input, - label = e.target.tagName === 'LABEL' ? e.target - : e.target.closest('LABEL') ? e.target.closest('LABEL') : null; - input = label && label.getElementsByTagName('INPUT')[0]; - if ( !input ) { return; } - dispatchCustomEvent.call(input, changeCustomEvent); - dispatchCustomEvent.call(element, changeCustomEvent); - if ( input.type === 'checkbox' ) { - if ( changeCustomEvent.defaultPrevented ) { return; } - if ( !input.checked ) { - label.classList.add('active'); - input.getAttribute('checked'); - input.setAttribute('checked','checked'); - input.checked = true; - } else { - label.classList.remove('active'); - input.getAttribute('checked'); - input.removeAttribute('checked'); - input.checked = false; - } - if (!element.toggled) { - element.toggled = true; - } - } - if ( input.type === 'radio' && !element.toggled ) { - if ( changeCustomEvent.defaultPrevented ) { return; } - if ( !input.checked || (e.screenX === 0 && e.screenY == 0) ) { - label.classList.add('active'); - label.classList.add('focus'); - input.setAttribute('checked','checked'); - input.checked = true; - element.toggled = true; - Array.from(labels).map(function (otherLabel){ - var otherInput = otherLabel.getElementsByTagName('INPUT')[0]; - if ( otherLabel !== label && otherLabel.classList.contains('active') ) { - dispatchCustomEvent.call(otherInput, changeCustomEvent); - otherLabel.classList.remove('active'); - otherInput.removeAttribute('checked'); - otherInput.checked = false; - } - }); - } - } - setTimeout( function () { element.toggled = false; }, 50 ); - } - function keyHandler(e) { - var key = e.which || e.keyCode; - key === 32 && e.target === document.activeElement && toggle(e); - } - function preventScroll(e) { - var key = e.which || e.keyCode; - key === 32 && e.preventDefault(); - } - function focusToggle(e) { - if (e.target.tagName === 'INPUT' ) { - var action = e.type === 'focusin' ? 'add' : 'remove'; - e.target.closest('.btn').classList[action]('focus'); - } - } - function toggleEvents(action) { - action = action ? 'addEventListener' : 'removeEventListener'; - element[action]('click',toggle,false ); - element[action]('keyup',keyHandler,false), element[action]('keydown',preventScroll,false); - element[action]('focusin',focusToggle,false), element[action]('focusout',focusToggle,false); - } - self.dispose = function () { - toggleEvents(); - delete element.Button; - }; - element = queryElement(element); - element.Button && element.Button.dispose(); - labels = element.getElementsByClassName('btn'); - if (!labels.length) { return; } - if ( !element.Button ) { - toggleEvents(1); - } - element.toggled = false; - element.Button = self; - Array.from(labels).map(function (btn){ - !btn.classList.contains('active') - && queryElement('input:checked',btn) - && btn.classList.add('active'); - btn.classList.contains('active') - && !queryElement('input:checked',btn) - && btn.classList.remove('active'); - }); - } - - var mouseHoverEvents = ('onmouseleave' in document) ? [ 'mouseenter', 'mouseleave'] : [ 'mouseover', 'mouseout' ]; - - var supportPassive = (function () { - var result = false; - try { - var opts = Object.defineProperty({}, 'passive', { - get: function() { - result = true; - } - }); - document.addEventListener('DOMContentLoaded', function wrap(){ - document.removeEventListener('DOMContentLoaded', wrap, opts); - }, opts); - } catch (e) {} - return result; - })(); - - var passiveHandler = supportPassive ? { passive: true } : false; - - function isElementInScrollRange(element) { - var bcr = element.getBoundingClientRect(), - viewportHeight = window.innerHeight || document.documentElement.clientHeight; - return bcr.top <= viewportHeight && bcr.bottom >= 0; - } - - function Carousel (element,options) { - options = options || {}; - var self = this, - vars, ops, - slideCustomEvent, slidCustomEvent, - slides, leftArrow, rightArrow, indicator, indicators; - function pauseHandler() { - if ( ops.interval !==false && !element.classList.contains('paused') ) { - element.classList.add('paused'); - !vars.isSliding && ( clearInterval(vars.timer), vars.timer = null ); - } - } - function resumeHandler() { - if ( ops.interval !== false && element.classList.contains('paused') ) { - element.classList.remove('paused'); - !vars.isSliding && ( clearInterval(vars.timer), vars.timer = null ); - !vars.isSliding && self.cycle(); - } - } - function indicatorHandler(e) { - e.preventDefault(); - if (vars.isSliding) { return; } - var eventTarget = e.target; - if ( eventTarget && !eventTarget.classList.contains('active') && eventTarget.getAttribute('data-slide-to') ) { - vars.index = parseInt( eventTarget.getAttribute('data-slide-to')); - } else { return false; } - self.slideTo( vars.index ); - } - function controlsHandler(e) { - e.preventDefault(); - if (vars.isSliding) { return; } - var eventTarget = e.currentTarget || e.srcElement; - if ( eventTarget === rightArrow ) { - vars.index++; - } else if ( eventTarget === leftArrow ) { - vars.index--; - } - self.slideTo( vars.index ); - } - function keyHandler(ref) { - var which = ref.which; - if (vars.isSliding) { return; } - switch (which) { - case 39: - vars.index++; - break; - case 37: - vars.index--; - break; - default: return; - } - self.slideTo( vars.index ); - } - function toggleEvents(action) { - action = action ? 'addEventListener' : 'removeEventListener'; - if ( ops.pause && ops.interval ) { - element[action]( mouseHoverEvents[0], pauseHandler, false ); - element[action]( mouseHoverEvents[1], resumeHandler, false ); - element[action]( 'touchstart', pauseHandler, passiveHandler ); - element[action]( 'touchend', resumeHandler, passiveHandler ); - } - ops.touch && slides.length > 1 && element[action]( 'touchstart', touchDownHandler, passiveHandler ); - rightArrow && rightArrow[action]( 'click', controlsHandler,false ); - leftArrow && leftArrow[action]( 'click', controlsHandler,false ); - indicator && indicator[action]( 'click', indicatorHandler,false ); - ops.keyboard && window[action]( 'keydown', keyHandler,false ); - } - function toggleTouchEvents(action) { - action = action ? 'addEventListener' : 'removeEventListener'; - element[action]( 'touchmove', touchMoveHandler, passiveHandler ); - element[action]( 'touchend', touchEndHandler, passiveHandler ); - } - function touchDownHandler(e) { - if ( vars.isTouch ) { return; } - vars.touchPosition.startX = e.changedTouches[0].pageX; - if ( element.contains(e.target) ) { - vars.isTouch = true; - toggleTouchEvents(1); - } - } - function touchMoveHandler(e) { - if ( !vars.isTouch ) { e.preventDefault(); return; } - vars.touchPosition.currentX = e.changedTouches[0].pageX; - if ( e.type === 'touchmove' && e.changedTouches.length > 1 ) { - e.preventDefault(); - return false; - } - } - function touchEndHandler (e) { - if ( !vars.isTouch || vars.isSliding ) { return } - vars.touchPosition.endX = vars.touchPosition.currentX || e.changedTouches[0].pageX; - if ( vars.isTouch ) { - if ( (!element.contains(e.target) || !element.contains(e.relatedTarget) ) - && Math.abs(vars.touchPosition.startX - vars.touchPosition.endX) < 75 ) { - return false; - } else { - if ( vars.touchPosition.currentX < vars.touchPosition.startX ) { - vars.index++; - } else if ( vars.touchPosition.currentX > vars.touchPosition.startX ) { - vars.index--; - } - vars.isTouch = false; - self.slideTo(vars.index); - } - toggleTouchEvents(); - } - } - function setActivePage(pageIndex) { - Array.from(indicators).map(function (x){x.classList.remove('active');}); - indicators[pageIndex] && indicators[pageIndex].classList.add('active'); - } - function transitionEndHandler(e){ - if (vars.touchPosition){ - var next = vars.index, - timeout = e && e.target !== slides[next] ? e.elapsedTime*1000+100 : 20, - activeItem = self.getActiveIndex(), - orientation = vars.direction === 'left' ? 'next' : 'prev'; - vars.isSliding && setTimeout(function () { - if (vars.touchPosition){ - vars.isSliding = false; - slides[next].classList.add('active'); - slides[activeItem].classList.remove('active'); - slides[next].classList.remove(("carousel-item-" + orientation)); - slides[next].classList.remove(("carousel-item-" + (vars.direction))); - slides[activeItem].classList.remove(("carousel-item-" + (vars.direction))); - dispatchCustomEvent.call(element, slidCustomEvent); - if ( !document.hidden && ops.interval && !element.classList.contains('paused') ) { - self.cycle(); - } - } - }, timeout); - } - } - self.cycle = function () { - if (vars.timer) { - clearInterval(vars.timer); - vars.timer = null; - } - vars.timer = setInterval(function () { - var idx = vars.index || self.getActiveIndex(); - isElementInScrollRange(element) && (idx++, self.slideTo( idx ) ); - }, ops.interval); - }; - self.slideTo = function (next) { - if (vars.isSliding) { return; } - var activeItem = self.getActiveIndex(), orientation, eventProperties; - if ( activeItem === next ) { - return; - } else if ( (activeItem < next ) || (activeItem === 0 && next === slides.length -1 ) ) { - vars.direction = 'left'; - } else if ( (activeItem > next) || (activeItem === slides.length - 1 && next === 0 ) ) { - vars.direction = 'right'; - } - if ( next < 0 ) { next = slides.length - 1; } - else if ( next >= slides.length ){ next = 0; } - orientation = vars.direction === 'left' ? 'next' : 'prev'; - eventProperties = { relatedTarget: slides[next], direction: vars.direction, from: activeItem, to: next }; - slideCustomEvent = bootstrapCustomEvent('slide', 'carousel', eventProperties); - slidCustomEvent = bootstrapCustomEvent('slid', 'carousel', eventProperties); - dispatchCustomEvent.call(element, slideCustomEvent); - if (slideCustomEvent.defaultPrevented) { return; } - vars.index = next; - vars.isSliding = true; - clearInterval(vars.timer); - vars.timer = null; - setActivePage( next ); - if ( getElementTransitionDuration(slides[next]) && element.classList.contains('slide') ) { - slides[next].classList.add(("carousel-item-" + orientation)); - slides[next].offsetWidth; - slides[next].classList.add(("carousel-item-" + (vars.direction))); - slides[activeItem].classList.add(("carousel-item-" + (vars.direction))); - emulateTransitionEnd(slides[next], transitionEndHandler); - } else { - slides[next].classList.add('active'); - slides[next].offsetWidth; - slides[activeItem].classList.remove('active'); - setTimeout(function () { - vars.isSliding = false; - if ( ops.interval && element && !element.classList.contains('paused') ) { - self.cycle(); - } - dispatchCustomEvent.call(element, slidCustomEvent); - }, 100 ); - } - }; - self.getActiveIndex = function () { return Array.from(slides).indexOf(element.getElementsByClassName('carousel-item active')[0]) || 0; }; - self.dispose = function () { - var itemClasses = ['left','right','prev','next']; - Array.from(slides).map(function (slide,idx) { - slide.classList.contains('active') && setActivePage( idx ); - itemClasses.map(function (cls) { return slide.classList.remove(("carousel-item-" + cls)); }); - }); - clearInterval(vars.timer); - toggleEvents(); - vars = {}; - ops = {}; - delete element.Carousel; - }; - element = queryElement( element ); - element.Carousel && element.Carousel.dispose(); - slides = element.getElementsByClassName('carousel-item'); - leftArrow = element.getElementsByClassName('carousel-control-prev')[0]; - rightArrow = element.getElementsByClassName('carousel-control-next')[0]; - indicator = element.getElementsByClassName('carousel-indicators')[0]; - indicators = indicator && indicator.getElementsByTagName( "LI" ) || []; - if (slides.length < 2) { return } - var - intervalAttribute = element.getAttribute('data-interval'), - intervalData = intervalAttribute === 'false' ? 0 : parseInt(intervalAttribute), - touchData = element.getAttribute('data-touch') === 'false' ? 0 : 1, - pauseData = element.getAttribute('data-pause') === 'hover' || false, - keyboardData = element.getAttribute('data-keyboard') === 'true' || false, - intervalOption = options.interval, - touchOption = options.touch; - ops = {}; - ops.keyboard = options.keyboard === true || keyboardData; - ops.pause = (options.pause === 'hover' || pauseData) ? 'hover' : false; - ops.touch = touchOption || touchData; - ops.interval = typeof intervalOption === 'number' ? intervalOption - : intervalOption === false || intervalData === 0 || intervalData === false ? 0 - : isNaN(intervalData) ? 5000 - : intervalData; - if (self.getActiveIndex()<0) { - slides.length && slides[0].classList.add('active'); - indicators.length && setActivePage(0); - } - vars = {}; - vars.direction = 'left'; - vars.index = 0; - vars.timer = null; - vars.isSliding = false; - vars.isTouch = false; - vars.touchPosition = { - startX : 0, - currentX : 0, - endX : 0 - }; - toggleEvents(1); - if ( ops.interval ){ self.cycle(); } - element.Carousel = self; - } - - function Collapse(element,options) { - options = options || {}; - var self = this; - var accordion = null, - collapse = null, - activeCollapse, - activeElement, - showCustomEvent, - shownCustomEvent, - hideCustomEvent, - hiddenCustomEvent; - function openAction(collapseElement, toggle) { - dispatchCustomEvent.call(collapseElement, showCustomEvent); - if ( showCustomEvent.defaultPrevented ) { return; } - collapseElement.isAnimating = true; - collapseElement.classList.add('collapsing'); - collapseElement.classList.remove('collapse'); - collapseElement.style.height = (collapseElement.scrollHeight) + "px"; - emulateTransitionEnd(collapseElement, function () { - collapseElement.isAnimating = false; - collapseElement.setAttribute('aria-expanded','true'); - toggle.setAttribute('aria-expanded','true'); - collapseElement.classList.remove('collapsing'); - collapseElement.classList.add('collapse'); - collapseElement.classList.add('show'); - collapseElement.style.height = ''; - dispatchCustomEvent.call(collapseElement, shownCustomEvent); - }); - } - function closeAction(collapseElement, toggle) { - dispatchCustomEvent.call(collapseElement, hideCustomEvent); - if ( hideCustomEvent.defaultPrevented ) { return; } - collapseElement.isAnimating = true; - collapseElement.style.height = (collapseElement.scrollHeight) + "px"; - collapseElement.classList.remove('collapse'); - collapseElement.classList.remove('show'); - collapseElement.classList.add('collapsing'); - collapseElement.offsetWidth; - collapseElement.style.height = '0px'; - emulateTransitionEnd(collapseElement, function () { - collapseElement.isAnimating = false; - collapseElement.setAttribute('aria-expanded','false'); - toggle.setAttribute('aria-expanded','false'); - collapseElement.classList.remove('collapsing'); - collapseElement.classList.add('collapse'); - collapseElement.style.height = ''; - dispatchCustomEvent.call(collapseElement, hiddenCustomEvent); - }); - } - self.toggle = function (e) { - if (e && e.target.tagName === 'A' || element.tagName === 'A') {e.preventDefault();} - if (element.contains(e.target) || e.target === element) { - if (!collapse.classList.contains('show')) { self.show(); } - else { self.hide(); } - } - }; - self.hide = function () { - if ( collapse.isAnimating ) { return; } - closeAction(collapse,element); - element.classList.add('collapsed'); - }; - self.show = function () { - if ( accordion ) { - activeCollapse = accordion.getElementsByClassName("collapse show")[0]; - activeElement = activeCollapse && (queryElement(("[data-target=\"#" + (activeCollapse.id) + "\"]"),accordion) - || queryElement(("[href=\"#" + (activeCollapse.id) + "\"]"),accordion) ); - } - if ( !collapse.isAnimating ) { - if ( activeElement && activeCollapse !== collapse ) { - closeAction(activeCollapse,activeElement); - activeElement.classList.add('collapsed'); - } - openAction(collapse,element); - element.classList.remove('collapsed'); - } - }; - self.dispose = function () { - element.removeEventListener('click',self.toggle,false); - delete element.Collapse; - }; - element = queryElement(element); - element.Collapse && element.Collapse.dispose(); - var accordionData = element.getAttribute('data-parent'); - showCustomEvent = bootstrapCustomEvent('show', 'collapse'); - shownCustomEvent = bootstrapCustomEvent('shown', 'collapse'); - hideCustomEvent = bootstrapCustomEvent('hide', 'collapse'); - hiddenCustomEvent = bootstrapCustomEvent('hidden', 'collapse'); - collapse = queryElement(options.target || element.getAttribute('data-target') || element.getAttribute('href')); - collapse.isAnimating = false; - accordion = element.closest(options.parent || accordionData); - if ( !element.Collapse ) { - element.addEventListener('click',self.toggle,false); - } - element.Collapse = self; - } - - function setFocus (element){ - element.focus ? element.focus() : element.setActive(); - } - - function Dropdown(element,option) { - var self = this, - showCustomEvent, - shownCustomEvent, - hideCustomEvent, - hiddenCustomEvent, - relatedTarget = null, - parent, menu, menuItems = [], - persist; - function preventEmptyAnchor(anchor) { - (anchor.href && anchor.href.slice(-1) === '#' || anchor.parentNode && anchor.parentNode.href - && anchor.parentNode.href.slice(-1) === '#') && this.preventDefault(); - } - function toggleDismiss() { - var action = element.open ? 'addEventListener' : 'removeEventListener'; - document[action]('click',dismissHandler,false); - document[action]('keydown',preventScroll,false); - document[action]('keyup',keyHandler,false); - document[action]('focus',dismissHandler,false); - } - function dismissHandler(e) { - var eventTarget = e.target, - hasData = eventTarget && (eventTarget.getAttribute('data-toggle') - || eventTarget.parentNode && eventTarget.parentNode.getAttribute - && eventTarget.parentNode.getAttribute('data-toggle')); - if ( e.type === 'focus' && (eventTarget === element || eventTarget === menu || menu.contains(eventTarget) ) ) { - return; - } - if ( (eventTarget === menu || menu.contains(eventTarget)) && (persist || hasData) ) { return; } - else { - relatedTarget = eventTarget === element || element.contains(eventTarget) ? element : null; - self.hide(); - } - preventEmptyAnchor.call(e,eventTarget); - } - function clickHandler(e) { - relatedTarget = element; - self.show(); - preventEmptyAnchor.call(e,e.target); - } - function preventScroll(e) { - var key = e.which || e.keyCode; - if( key === 38 || key === 40 ) { e.preventDefault(); } - } - function keyHandler(e) { - var key = e.which || e.keyCode, - activeItem = document.activeElement, - isSameElement = activeItem === element, - isInsideMenu = menu.contains(activeItem), - isMenuItem = activeItem.parentNode === menu || activeItem.parentNode.parentNode === menu, - idx = menuItems.indexOf(activeItem); - if ( isMenuItem ) { - idx = isSameElement ? 0 - : key === 38 ? (idx>1?idx-1:0) - : key === 40 ? (idx= windowWidth, - halfBottomExceed = rect.top + elementDimensions.h/2 + linkDimensions.h/2 >= windowHeight, - topExceed = rect.top - elementDimensions.h < 0, - leftExceed = rect.left - elementDimensions.w < 0, - bottomExceed = rect.top + elementDimensions.h + linkDimensions.h >= windowHeight, - rightExceed = rect.left + elementDimensions.w + linkDimensions.w >= windowWidth; - position = (position === 'left' || position === 'right') && leftExceed && rightExceed ? 'top' : position; - position = position === 'top' && topExceed ? 'bottom' : position; - position = position === 'bottom' && bottomExceed ? 'top' : position; - position = position === 'left' && leftExceed ? 'right' : position; - position = position === 'right' && rightExceed ? 'left' : position; - var topPosition, - leftPosition, - arrowTop, - arrowLeft, - arrowWidth, - arrowHeight; - element.className.indexOf(position) === -1 && (element.className = element.className.replace(tipPositions,position)); - arrowWidth = arrow.offsetWidth; arrowHeight = arrow.offsetHeight; - if ( position === 'left' || position === 'right' ) { - if ( position === 'left' ) { - leftPosition = rect.left + scroll.x - elementDimensions.w - ( isPopover ? arrowWidth : 0 ); - } else { - leftPosition = rect.left + scroll.x + linkDimensions.w; - } - if (halfTopExceed) { - topPosition = rect.top + scroll.y; - arrowTop = linkDimensions.h/2 - arrowWidth; - } else if (halfBottomExceed) { - topPosition = rect.top + scroll.y - elementDimensions.h + linkDimensions.h; - arrowTop = elementDimensions.h - linkDimensions.h/2 - arrowWidth; - } else { - topPosition = rect.top + scroll.y - elementDimensions.h/2 + linkDimensions.h/2; - arrowTop = elementDimensions.h/2 - (isPopover ? arrowHeight*0.9 : arrowHeight/2); - } - } else if ( position === 'top' || position === 'bottom' ) { - if ( position === 'top') { - topPosition = rect.top + scroll.y - elementDimensions.h - ( isPopover ? arrowHeight : 0 ); - } else { - topPosition = rect.top + scroll.y + linkDimensions.h; - } - if (halfLeftExceed) { - leftPosition = 0; - arrowLeft = rect.left + linkDimensions.w/2 - arrowWidth; - } else if (halfRightExceed) { - leftPosition = windowWidth - elementDimensions.w*1.01; - arrowLeft = elementDimensions.w - ( windowWidth - rect.left ) + linkDimensions.w/2 - arrowWidth/2; - } else { - leftPosition = rect.left + scroll.x - elementDimensions.w/2 + linkDimensions.w/2; - arrowLeft = elementDimensions.w/2 - ( isPopover ? arrowWidth : arrowWidth/2 ); - } - } - element.style.top = topPosition + 'px'; - element.style.left = leftPosition + 'px'; - arrowTop && (arrow.style.top = arrowTop + 'px'); - arrowLeft && (arrow.style.left = arrowLeft + 'px'); - } - - function Popover(element,options) { - options = options || {}; - var self = this; - var popover = null, - timer = 0, - isIphone = /(iPhone|iPod|iPad)/.test(navigator.userAgent), - titleString, - contentString, - ops = {}; - var triggerData, - animationData, - placementData, - dismissibleData, - delayData, - containerData, - closeBtn, - showCustomEvent, - shownCustomEvent, - hideCustomEvent, - hiddenCustomEvent, - containerElement, - containerDataElement, - modal, - navbarFixedTop, - navbarFixedBottom, - placementClass; - function dismissibleHandler(e) { - if (popover !== null && e.target === queryElement('.close',popover)) { - self.hide(); - } - } - function getContents() { - return { - 0 : options.title || element.getAttribute('data-title') || null, - 1 : options.content || element.getAttribute('data-content') || null - } - } - function removePopover() { - ops.container.removeChild(popover); - timer = null; popover = null; - } - function createPopover() { - titleString = getContents()[0] || null; - contentString = getContents()[1]; - contentString = !!contentString ? contentString.trim() : null; - popover = document.createElement('div'); - var popoverArrow = document.createElement('div'); - popoverArrow.classList.add('arrow'); - popover.appendChild(popoverArrow); - if ( contentString !== null && ops.template === null ) { - popover.setAttribute('role','tooltip'); - if (titleString !== null) { - var popoverTitle = document.createElement('h3'); - popoverTitle.classList.add('popover-header'); - popoverTitle.innerHTML = ops.dismissible ? titleString + closeBtn : titleString; - popover.appendChild(popoverTitle); - } - var popoverBodyMarkup = document.createElement('div'); - popoverBodyMarkup.classList.add('popover-body'); - popoverBodyMarkup.innerHTML = ops.dismissible && titleString === null ? contentString + closeBtn : contentString; - popover.appendChild(popoverBodyMarkup); - } else { - var popoverTemplate = document.createElement('div'); - popoverTemplate.innerHTML = ops.template.trim(); - popover.className = popoverTemplate.firstChild.className; - popover.innerHTML = popoverTemplate.firstChild.innerHTML; - var popoverHeader = queryElement('.popover-header',popover), - popoverBody = queryElement('.popover-body',popover); - titleString && popoverHeader && (popoverHeader.innerHTML = titleString.trim()); - contentString && popoverBody && (popoverBody.innerHTML = contentString.trim()); - } - ops.container.appendChild(popover); - popover.style.display = 'block'; - !popover.classList.contains( 'popover') && popover.classList.add('popover'); - !popover.classList.contains( ops.animation) && popover.classList.add(ops.animation); - !popover.classList.contains( placementClass) && popover.classList.add(placementClass); - } - function showPopover() { - !popover.classList.contains('show') && ( popover.classList.add('show') ); - } - function updatePopover() { - styleTip(element, popover, ops.placement, ops.container); - } - function forceFocus () { - if (popover === null) { element.focus(); } - } - function toggleEvents(action) { - action = action ? 'addEventListener' : 'removeEventListener'; - if (ops.trigger === 'hover') { - element[action]( mouseClickEvents.down, self.show ); - element[action]( mouseHoverEvents[0], self.show ); - if (!ops.dismissible) { element[action]( mouseHoverEvents[1], self.hide ); } - } else if ('click' == ops.trigger) { - element[action]( ops.trigger, self.toggle ); - } else if ('focus' == ops.trigger) { - isIphone && element[action]( 'click', forceFocus, false ); - element[action]( ops.trigger, self.toggle ); - } - } - function touchHandler(e){ - if ( popover && popover.contains(e.target) || e.target === element || element.contains(e.target)) ; else { - self.hide(); - } - } - function dismissHandlerToggle(action) { - action = action ? 'addEventListener' : 'removeEventListener'; - if (ops.dismissible) { - document[action]('click', dismissibleHandler, false ); - } else { - 'focus' == ops.trigger && element[action]( 'blur', self.hide ); - 'hover' == ops.trigger && document[action]( 'touchstart', touchHandler, passiveHandler ); - } - window[action]('resize', self.hide, passiveHandler ); - } - function showTrigger() { - dismissHandlerToggle(1); - dispatchCustomEvent.call(element, shownCustomEvent); - } - function hideTrigger() { - dismissHandlerToggle(); - removePopover(); - dispatchCustomEvent.call(element, hiddenCustomEvent); - } - self.toggle = function () { - if (popover === null) { self.show(); } - else { self.hide(); } - }; - self.show = function () { - clearTimeout(timer); - timer = setTimeout( function () { - if (popover === null) { - dispatchCustomEvent.call(element, showCustomEvent); - if ( showCustomEvent.defaultPrevented ) { return; } - createPopover(); - updatePopover(); - showPopover(); - !!ops.animation ? emulateTransitionEnd(popover, showTrigger) : showTrigger(); - } - }, 20 ); - }; - self.hide = function () { - clearTimeout(timer); - timer = setTimeout( function () { - if (popover && popover !== null && popover.classList.contains('show')) { - dispatchCustomEvent.call(element, hideCustomEvent); - if ( hideCustomEvent.defaultPrevented ) { return; } - popover.classList.remove('show'); - !!ops.animation ? emulateTransitionEnd(popover, hideTrigger) : hideTrigger(); - } - }, ops.delay ); - }; - self.dispose = function () { - self.hide(); - toggleEvents(); - delete element.Popover; - }; - element = queryElement(element); - element.Popover && element.Popover.dispose(); - triggerData = element.getAttribute('data-trigger'); - animationData = element.getAttribute('data-animation'); - placementData = element.getAttribute('data-placement'); - dismissibleData = element.getAttribute('data-dismissible'); - delayData = element.getAttribute('data-delay'); - containerData = element.getAttribute('data-container'); - closeBtn = ''; - showCustomEvent = bootstrapCustomEvent('show', 'popover'); - shownCustomEvent = bootstrapCustomEvent('shown', 'popover'); - hideCustomEvent = bootstrapCustomEvent('hide', 'popover'); - hiddenCustomEvent = bootstrapCustomEvent('hidden', 'popover'); - containerElement = queryElement(options.container); - containerDataElement = queryElement(containerData); - modal = element.closest('.modal'); - navbarFixedTop = element.closest('.fixed-top'); - navbarFixedBottom = element.closest('.fixed-bottom'); - ops.template = options.template ? options.template : null; - ops.trigger = options.trigger ? options.trigger : triggerData || 'hover'; - ops.animation = options.animation && options.animation !== 'fade' ? options.animation : animationData || 'fade'; - ops.placement = options.placement ? options.placement : placementData || 'top'; - ops.delay = parseInt(options.delay || delayData) || 200; - ops.dismissible = options.dismissible || dismissibleData === 'true' ? true : false; - ops.container = containerElement ? containerElement - : containerDataElement ? containerDataElement - : navbarFixedTop ? navbarFixedTop - : navbarFixedBottom ? navbarFixedBottom - : modal ? modal : document.body; - placementClass = "bs-popover-" + (ops.placement); - var popoverContents = getContents(); - titleString = popoverContents[0]; - contentString = popoverContents[1]; - if ( !contentString && !ops.template ) { return; } - if ( !element.Popover ) { - toggleEvents(1); - } - element.Popover = self; - } - - function ScrollSpy(element,options) { - options = options || {}; - var self = this, - vars, - targetData, - offsetData, - spyTarget, - scrollTarget, - ops = {}; - function updateTargets(){ - var links = spyTarget.getElementsByTagName('A'); - if (vars.length !== links.length) { - vars.items = []; - vars.targets = []; - Array.from(links).map(function (link){ - var href = link.getAttribute('href'), - targetItem = href && href.charAt(0) === '#' && href.slice(-1) !== '#' && queryElement(href); - if ( targetItem ) { - vars.items.push(link); - vars.targets.push(targetItem); - } - }); - vars.length = links.length; - } - } - function updateItem(index) { - var item = vars.items[index], - targetItem = vars.targets[index], - dropmenu = item.classList.contains('dropdown-item') && item.closest('.dropdown-menu'), - dropLink = dropmenu && dropmenu.previousElementSibling, - nextSibling = item.nextElementSibling, - activeSibling = nextSibling && nextSibling.getElementsByClassName('active').length, - targetRect = vars.isWindow && targetItem.getBoundingClientRect(), - isActive = item.classList.contains('active') || false, - topEdge = (vars.isWindow ? targetRect.top + vars.scrollOffset : targetItem.offsetTop) - ops.offset, - bottomEdge = vars.isWindow ? targetRect.bottom + vars.scrollOffset - ops.offset - : vars.targets[index+1] ? vars.targets[index+1].offsetTop - ops.offset - : element.scrollHeight, - inside = activeSibling || vars.scrollOffset >= topEdge && bottomEdge > vars.scrollOffset; - if ( !isActive && inside ) { - item.classList.add('active'); - if (dropLink && !dropLink.classList.contains('active') ) { - dropLink.classList.add('active'); - } - dispatchCustomEvent.call(element, bootstrapCustomEvent( 'activate', 'scrollspy', { relatedTarget: vars.items[index] })); - } else if ( isActive && !inside ) { - item.classList.remove('active'); - if (dropLink && dropLink.classList.contains('active') && !item.parentNode.getElementsByClassName('active').length ) { - dropLink.classList.remove('active'); - } - } else if ( isActive && inside || !inside && !isActive ) { - return; - } - } - function updateItems() { - updateTargets(); - vars.scrollOffset = vars.isWindow ? getScroll().y : element.scrollTop; - vars.items.map(function (l,idx){ return updateItem(idx); }); - } - function toggleEvents(action) { - action = action ? 'addEventListener' : 'removeEventListener'; - scrollTarget[action]('scroll', self.refresh, passiveHandler ); - window[action]( 'resize', self.refresh, passiveHandler ); - } - self.refresh = function () { - updateItems(); - }; - self.dispose = function () { - toggleEvents(); - delete element.ScrollSpy; - }; - element = queryElement(element); - element.ScrollSpy && element.ScrollSpy.dispose(); - targetData = element.getAttribute('data-target'); - offsetData = element.getAttribute('data-offset'); - spyTarget = queryElement(options.target || targetData); - scrollTarget = element.offsetHeight < element.scrollHeight ? element : window; - if (!spyTarget) { return } - ops.target = spyTarget; - ops.offset = parseInt(options.offset || offsetData) || 10; - vars = {}; - vars.length = 0; - vars.items = []; - vars.targets = []; - vars.isWindow = scrollTarget === window; - if ( !element.ScrollSpy ) { - toggleEvents(1); - } - self.refresh(); - element.ScrollSpy = self; - } - - function Tab(element,options) { - options = options || {}; - var self = this, - heightData, - tabs, dropdown, - showCustomEvent, - shownCustomEvent, - hideCustomEvent, - hiddenCustomEvent, - next, - tabsContentContainer = false, - activeTab, - activeContent, - nextContent, - containerHeight, - equalContents, - nextHeight, - animateHeight; - function triggerEnd() { - tabsContentContainer.style.height = ''; - tabsContentContainer.classList.remove('collapsing'); - tabs.isAnimating = false; - } - function triggerShow() { - if (tabsContentContainer) { - if ( equalContents ) { - triggerEnd(); - } else { - setTimeout(function () { - tabsContentContainer.style.height = nextHeight + "px"; - tabsContentContainer.offsetWidth; - emulateTransitionEnd(tabsContentContainer, triggerEnd); - },50); - } - } else { - tabs.isAnimating = false; - } - shownCustomEvent = bootstrapCustomEvent('shown', 'tab', { relatedTarget: activeTab }); - dispatchCustomEvent.call(next, shownCustomEvent); - } - function triggerHide() { - if (tabsContentContainer) { - activeContent.style.float = 'left'; - nextContent.style.float = 'left'; - containerHeight = activeContent.scrollHeight; - } - showCustomEvent = bootstrapCustomEvent('show', 'tab', { relatedTarget: activeTab }); - hiddenCustomEvent = bootstrapCustomEvent('hidden', 'tab', { relatedTarget: next }); - dispatchCustomEvent.call(next, showCustomEvent); - if ( showCustomEvent.defaultPrevented ) { return; } - nextContent.classList.add('active'); - activeContent.classList.remove('active'); - if (tabsContentContainer) { - nextHeight = nextContent.scrollHeight; - equalContents = nextHeight === containerHeight; - tabsContentContainer.classList.add('collapsing'); - tabsContentContainer.style.height = containerHeight + "px"; - tabsContentContainer.offsetHeight; - activeContent.style.float = ''; - nextContent.style.float = ''; - } - if ( nextContent.classList.contains('fade') ) { - setTimeout(function () { - nextContent.classList.add('show'); - emulateTransitionEnd(nextContent,triggerShow); - },20); - } else { triggerShow(); } - dispatchCustomEvent.call(activeTab, hiddenCustomEvent); - } - function getActiveTab() { - var activeTabs = tabs.getElementsByClassName('active'), activeTab; - if ( activeTabs.length === 1 && !activeTabs[0].parentNode.classList.contains('dropdown') ) { - activeTab = activeTabs[0]; - } else if ( activeTabs.length > 1 ) { - activeTab = activeTabs[activeTabs.length-1]; - } - return activeTab; - } - function getActiveContent() { return queryElement(getActiveTab().getAttribute('href')) } - function clickHandler(e) { - e.preventDefault(); - next = e.currentTarget; - !tabs.isAnimating && self.show(); - } - self.show = function () { - next = next || element; - if (!next.classList.contains('active')) { - nextContent = queryElement(next.getAttribute('href')); - activeTab = getActiveTab(); - activeContent = getActiveContent(); - hideCustomEvent = bootstrapCustomEvent( 'hide', 'tab', { relatedTarget: next }); - dispatchCustomEvent.call(activeTab, hideCustomEvent); - if (hideCustomEvent.defaultPrevented) { return; } - tabs.isAnimating = true; - activeTab.classList.remove('active'); - activeTab.setAttribute('aria-selected','false'); - next.classList.add('active'); - next.setAttribute('aria-selected','true'); - if ( dropdown ) { - if ( !element.parentNode.classList.contains('dropdown-menu') ) { - if (dropdown.classList.contains('active')) { dropdown.classList.remove('active'); } - } else { - if (!dropdown.classList.contains('active')) { dropdown.classList.add('active'); } - } - } - if (activeContent.classList.contains('fade')) { - activeContent.classList.remove('show'); - emulateTransitionEnd(activeContent, triggerHide); - } else { triggerHide(); } - } - }; - self.dispose = function () { - element.removeEventListener('click',clickHandler,false); - delete element.Tab; - }; - element = queryElement(element); - element.Tab && element.Tab.dispose(); - heightData = element.getAttribute('data-height'); - tabs = element.closest('.nav'); - dropdown = tabs && queryElement('.dropdown-toggle',tabs); - animateHeight = !supportTransition || (options.height === false || heightData === 'false') ? false : true; - tabs.isAnimating = false; - if ( !element.Tab ) { - element.addEventListener('click',clickHandler,false); - } - if (animateHeight) { tabsContentContainer = getActiveContent().parentNode; } - element.Tab = self; - } - - function Toast(element,options) { - options = options || {}; - var self = this, - toast, timer = 0, - animationData, - autohideData, - delayData, - showCustomEvent, - hideCustomEvent, - shownCustomEvent, - hiddenCustomEvent, - ops = {}; - function showComplete() { - toast.classList.remove( 'showing' ); - toast.classList.add( 'show' ); - dispatchCustomEvent.call(toast,shownCustomEvent); - if (ops.autohide) { self.hide(); } - } - function hideComplete() { - toast.classList.add( 'hide' ); - dispatchCustomEvent.call(toast,hiddenCustomEvent); - } - function close () { - toast.classList.remove('show' ); - ops.animation ? emulateTransitionEnd(toast, hideComplete) : hideComplete(); - } - function disposeComplete() { - clearTimeout(timer); - element.removeEventListener('click',self.hide,false); - delete element.Toast; - } - self.show = function () { - if (toast && !toast.classList.contains('show')) { - dispatchCustomEvent.call(toast,showCustomEvent); - if (showCustomEvent.defaultPrevented) { return; } - ops.animation && toast.classList.add( 'fade' ); - toast.classList.remove('hide' ); - toast.offsetWidth; - toast.classList.add('showing' ); - ops.animation ? emulateTransitionEnd(toast, showComplete) : showComplete(); - } - }; - self.hide = function (noTimer) { - if (toast && toast.classList.contains('show')) { - dispatchCustomEvent.call(toast,hideCustomEvent); - if(hideCustomEvent.defaultPrevented) { return; } - noTimer ? close() : (timer = setTimeout( close, ops.delay)); - } - }; - self.dispose = function () { - ops.animation ? emulateTransitionEnd(toast, disposeComplete) : disposeComplete(); - }; - element = queryElement(element); - element.Toast && element.Toast.dispose(); - toast = element.closest('.toast'); - animationData = element.getAttribute('data-animation'); - autohideData = element.getAttribute('data-autohide'); - delayData = element.getAttribute('data-delay'); - showCustomEvent = bootstrapCustomEvent('show', 'toast'); - hideCustomEvent = bootstrapCustomEvent('hide', 'toast'); - shownCustomEvent = bootstrapCustomEvent('shown', 'toast'); - hiddenCustomEvent = bootstrapCustomEvent('hidden', 'toast'); - ops.animation = options.animation === false || animationData === 'false' ? 0 : 1; - ops.autohide = options.autohide === false || autohideData === 'false' ? 0 : 1; - ops.delay = parseInt(options.delay || delayData) || 500; - if ( !element.Toast ) { - element.addEventListener('click',self.hide,false); - } - element.Toast = self; - } - - function Tooltip(element,options) { - options = options || {}; - var self = this, - tooltip = null, timer = 0, titleString, - animationData, - placementData, - delayData, - containerData, - showCustomEvent, - shownCustomEvent, - hideCustomEvent, - hiddenCustomEvent, - containerElement, - containerDataElement, - modal, - navbarFixedTop, - navbarFixedBottom, - placementClass, - ops = {}; - function getTitle() { - return element.getAttribute('title') - || element.getAttribute('data-title') - || element.getAttribute('data-original-title') - } - function removeToolTip() { - ops.container.removeChild(tooltip); - tooltip = null; timer = null; - } - function createToolTip() { - titleString = getTitle(); - if ( titleString ) { - tooltip = document.createElement('div'); - if (ops.template) { - var tooltipMarkup = document.createElement('div'); - tooltipMarkup.innerHTML = ops.template.trim(); - tooltip.className = tooltipMarkup.firstChild.className; - tooltip.innerHTML = tooltipMarkup.firstChild.innerHTML; - queryElement('.tooltip-inner',tooltip).innerHTML = titleString.trim(); - } else { - var tooltipArrow = document.createElement('div'); - tooltipArrow.classList.add('arrow'); - tooltip.appendChild(tooltipArrow); - var tooltipInner = document.createElement('div'); - tooltipInner.classList.add('tooltip-inner'); - tooltip.appendChild(tooltipInner); - tooltipInner.innerHTML = titleString; - } - tooltip.style.left = '0'; - tooltip.style.top = '0'; - tooltip.setAttribute('role','tooltip'); - !tooltip.classList.contains('tooltip') && tooltip.classList.add('tooltip'); - !tooltip.classList.contains(ops.animation) && tooltip.classList.add(ops.animation); - !tooltip.classList.contains(placementClass) && tooltip.classList.add(placementClass); - ops.container.appendChild(tooltip); - } - } - function updateTooltip() { - styleTip(element, tooltip, ops.placement, ops.container); - } - function showTooltip() { - !tooltip.classList.contains('show') && ( tooltip.classList.add('show') ); - } - function touchHandler(e){ - if ( tooltip && tooltip.contains(e.target) || e.target === element || element.contains(e.target)) ; else { - self.hide(); - } - } - function toggleAction(action){ - action = action ? 'addEventListener' : 'removeEventListener'; - document[action]( 'touchstart', touchHandler, passiveHandler ); - window[action]( 'resize', self.hide, passiveHandler ); - } - function showAction() { - toggleAction(1); - dispatchCustomEvent.call(element, shownCustomEvent); - } - function hideAction() { - toggleAction(); - removeToolTip(); - dispatchCustomEvent.call(element, hiddenCustomEvent); - } - function toggleEvents(action) { - action = action ? 'addEventListener' : 'removeEventListener'; - element[action](mouseClickEvents.down, self.show,false); - element[action](mouseHoverEvents[0], self.show,false); - element[action](mouseHoverEvents[1], self.hide,false); - } - self.show = function () { - clearTimeout(timer); - timer = setTimeout( function () { - if (tooltip === null) { - dispatchCustomEvent.call(element, showCustomEvent); - if (showCustomEvent.defaultPrevented) { return; } - if(createToolTip() !== false) { - updateTooltip(); - showTooltip(); - !!ops.animation ? emulateTransitionEnd(tooltip, showAction) : showAction(); - } - } - }, 20 ); - }; - self.hide = function () { - clearTimeout(timer); - timer = setTimeout( function () { - if (tooltip && tooltip.classList.contains('show')) { - dispatchCustomEvent.call(element, hideCustomEvent); - if (hideCustomEvent.defaultPrevented) { return; } - tooltip.classList.remove('show'); - !!ops.animation ? emulateTransitionEnd(tooltip, hideAction) : hideAction(); - } - }, ops.delay); - }; - self.toggle = function () { - if (!tooltip) { self.show(); } - else { self.hide(); } - }; - self.dispose = function () { - toggleEvents(); - self.hide(); - element.setAttribute('title', element.getAttribute('data-original-title')); - element.removeAttribute('data-original-title'); - delete element.Tooltip; - }; - element = queryElement(element); - element.Tooltip && element.Tooltip.dispose(); - animationData = element.getAttribute('data-animation'); - placementData = element.getAttribute('data-placement'); - delayData = element.getAttribute('data-delay'); - containerData = element.getAttribute('data-container'); - showCustomEvent = bootstrapCustomEvent('show', 'tooltip'); - shownCustomEvent = bootstrapCustomEvent('shown', 'tooltip'); - hideCustomEvent = bootstrapCustomEvent('hide', 'tooltip'); - hiddenCustomEvent = bootstrapCustomEvent('hidden', 'tooltip'); - containerElement = queryElement(options.container); - containerDataElement = queryElement(containerData); - modal = element.closest('.modal'); - navbarFixedTop = element.closest('.fixed-top'); - navbarFixedBottom = element.closest('.fixed-bottom'); - ops.animation = options.animation && options.animation !== 'fade' ? options.animation : animationData || 'fade'; - ops.placement = options.placement ? options.placement : placementData || 'top'; - ops.template = options.template ? options.template : null; - ops.delay = parseInt(options.delay || delayData) || 200; - ops.container = containerElement ? containerElement - : containerDataElement ? containerDataElement - : navbarFixedTop ? navbarFixedTop - : navbarFixedBottom ? navbarFixedBottom - : modal ? modal : document.body; - placementClass = "bs-tooltip-" + (ops.placement); - titleString = getTitle(); - if ( !titleString ) { return; } - if (!element.Tooltip) { - element.setAttribute('data-original-title',titleString); - element.removeAttribute('title'); - toggleEvents(1); - } - element.Tooltip = self; - } - - var componentsInit = {}; - - function initializeDataAPI( Constructor, collection ){ - Array.from(collection).map(function (x){ return new Constructor(x); }); - } - function initCallback(lookUp){ - lookUp = lookUp || document; - for (var component in componentsInit) { - initializeDataAPI( componentsInit[component][0], lookUp.querySelectorAll (componentsInit[component][1]) ); - } - } - - componentsInit.Alert = [ Alert, '[data-dismiss="alert"]']; - componentsInit.Button = [ Button, '[data-toggle="buttons"]' ]; - componentsInit.Carousel = [ Carousel, '[data-ride="carousel"]' ]; - componentsInit.Collapse = [ Collapse, '[data-toggle="collapse"]' ]; - componentsInit.Dropdown = [ Dropdown, '[data-toggle="dropdown"]']; - componentsInit.Modal = [ Modal, '[data-toggle="modal"]' ]; - componentsInit.Popover = [ Popover, '[data-toggle="popover"],[data-tip="popover"]' ]; - componentsInit.ScrollSpy = [ ScrollSpy, '[data-spy="scroll"]' ]; - componentsInit.Tab = [ Tab, '[data-toggle="tab"]' ]; - componentsInit.Toast = [ Toast, '[data-dismiss="toast"]' ]; - componentsInit.Tooltip = [ Tooltip, '[data-toggle="tooltip"],[data-tip="tooltip"]' ]; - document.body ? initCallback() : document.addEventListener( 'DOMContentLoaded', function initWrapper(){ - initCallback(); - document.removeEventListener('DOMContentLoaded',initWrapper,false); - }, false ); - - function removeElementDataAPI( ConstructorName, collection ){ - Array.from(collection).map(function (x){ return x[ConstructorName].dispose(); }); - } - function removeDataAPI(lookUp) { - lookUp = lookUp || document; - for (var component in componentsInit) { - removeElementDataAPI( component, lookUp.querySelectorAll (componentsInit[component][1]) ); - } - } - - var version = "3.0.15"; - - var index = { - Alert: Alert, - Button: Button, - Carousel: Carousel, - Collapse: Collapse, - Dropdown: Dropdown, - Modal: Modal, - Popover: Popover, - ScrollSpy: ScrollSpy, - Tab: Tab, - Toast: Toast, - Tooltip: Tooltip, - initCallback: initCallback, - removeDataAPI: removeDataAPI, - componentsInit: componentsInit, - Version: version - }; - - return index; - -}))); diff --git a/src/static/scripts/bootstrap-native.min.js b/src/static/scripts/bootstrap-native.min.js new file mode 100644 index 00000000..c264522f --- /dev/null +++ b/src/static/scripts/bootstrap-native.min.js @@ -0,0 +1,2 @@ +// Native JavaScript for Bootstrap v3.0.15 | 2021 © dnp_theme | MIT-License +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).BSN=e()}(this,(function(){"use strict";var t="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",e="webkitTransition"in document.head.style||"transition"in document.head.style,i="webkitTransition"in document.head.style?"webkitTransitionDuration":"transitionDuration",n="webkitTransition"in document.head.style?"webkitTransitionProperty":"transitionProperty";function o(t){var o=getComputedStyle(t),a=o[n],s=o[i],l=s.indexOf("ms")>-1?1:1e3,c=e&&a&&"none"!==a?parseFloat(s)*l:0;return isNaN(c)?0:c}function a(e,i){var n=0,a=new Event(t),s=o(e);s?(e.addEventListener(t,(function o(a){a.target===e&&(i.apply(e,[a]),e.removeEventListener(t,o),n=1)})),setTimeout((function(){!n&&e.dispatchEvent(a)}),s+17)):i.apply(e,[a])}function s(t,e){var i=e&&e instanceof Element?e:document;return t instanceof Element?t:i.querySelector(t)}function l(t,e,i){var n=new CustomEvent(t+".bs."+e,{cancelable:!0});return void 0!==i&&Object.keys(i).forEach((function(t){Object.defineProperty(n,t,{value:i[t]})})),n}function c(t){this&&this.dispatchEvent(t)}function r(t){var e,i=this,n=l("close","alert"),o=l("closed","alert");function r(e){t[e=e?"addEventListener":"removeEventListener"]("click",d,!1)}function d(n){e=n&&n.target.closest(".alert"),(t=s('[data-dismiss="alert"]',e))&&e&&(t===n.target||t.contains(n.target))&&i.close()}function u(){r(),e.parentNode.removeChild(e),c.call(e,o)}i.close=function(){if(e&&t&&e.classList.contains("show")){if(c.call(e,n),n.defaultPrevented)return;i.dispose(),e.classList.remove("show"),e.classList.contains("fade")?a(e,u):u()}},i.dispose=function(){r(),delete t.Alert},t=s(t),e=t.closest(".alert"),t.Alert&&t.Alert.dispose(),t.Alert||r(1),i.element=t,t.Alert=i}function d(t){var e,i=l("change","button");function n(n){var o,a="LABEL"===n.target.tagName?n.target:n.target.closest("LABEL")?n.target.closest("LABEL"):null;if(o=a&&a.getElementsByTagName("INPUT")[0]){if(c.call(o,i),c.call(t,i),"checkbox"===o.type){if(i.defaultPrevented)return;o.checked?(a.classList.remove("active"),o.getAttribute("checked"),o.removeAttribute("checked"),o.checked=!1):(a.classList.add("active"),o.getAttribute("checked"),o.setAttribute("checked","checked"),o.checked=!0),t.toggled||(t.toggled=!0)}if("radio"===o.type&&!t.toggled){if(i.defaultPrevented)return;(!o.checked||0===n.screenX&&0==n.screenY)&&(a.classList.add("active"),a.classList.add("focus"),o.setAttribute("checked","checked"),o.checked=!0,t.toggled=!0,Array.from(e).map((function(t){var e=t.getElementsByTagName("INPUT")[0];t!==a&&t.classList.contains("active")&&(c.call(e,i),t.classList.remove("active"),e.removeAttribute("checked"),e.checked=!1)})))}setTimeout((function(){t.toggled=!1}),50)}}function o(t){32===(t.which||t.keyCode)&&t.target===document.activeElement&&n(t)}function a(t){32===(t.which||t.keyCode)&&t.preventDefault()}function r(t){if("INPUT"===t.target.tagName){var e="focusin"===t.type?"add":"remove";t.target.closest(".btn").classList[e]("focus")}}function d(e){t[e=e?"addEventListener":"removeEventListener"]("click",n,!1),t[e]("keyup",o,!1),t[e]("keydown",a,!1),t[e]("focusin",r,!1),t[e]("focusout",r,!1)}this.dispose=function(){d(),delete t.Button},(t=s(t)).Button&&t.Button.dispose(),(e=t.getElementsByClassName("btn")).length&&(t.Button||d(1),t.toggled=!1,t.Button=this,Array.from(e).map((function(t){!t.classList.contains("active")&&s("input:checked",t)&&t.classList.add("active"),t.classList.contains("active")&&!s("input:checked",t)&&t.classList.remove("active")})))}var u="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],m=!!function(){var t=!1;try{var e=Object.defineProperty({},"passive",{get:function(){t=!0}});document.addEventListener("DOMContentLoaded",(function t(){document.removeEventListener("DOMContentLoaded",t,e)}),e)}catch(t){}return t}()&&{passive:!0};function f(t,e){e=e||{};var i,n,r,d,f,h,g,p,v,L=this;function b(){!1===n.interval||t.classList.contains("paused")||(t.classList.add("paused"),!i.isSliding&&(clearInterval(i.timer),i.timer=null))}function y(){!1!==n.interval&&t.classList.contains("paused")&&(t.classList.remove("paused"),!i.isSliding&&(clearInterval(i.timer),i.timer=null),!i.isSliding&&L.cycle())}function w(t){if(t.preventDefault(),!i.isSliding){var e=t.target;if(!e||e.classList.contains("active")||!e.getAttribute("data-slide-to"))return!1;i.index=parseInt(e.getAttribute("data-slide-to")),L.slideTo(i.index)}}function A(t){if(t.preventDefault(),!i.isSliding){var e=t.currentTarget||t.srcElement;e===g?i.index++:e===h&&i.index--,L.slideTo(i.index)}}function T(t){var e=t.which;if(!i.isSliding){switch(e){case 39:i.index++;break;case 37:i.index--;break;default:return}L.slideTo(i.index)}}function E(e){e=e?"addEventListener":"removeEventListener",n.pause&&n.interval&&(t[e](u[0],b,!1),t[e](u[1],y,!1),t[e]("touchstart",b,m),t[e]("touchend",y,m)),n.touch&&f.length>1&&t[e]("touchstart",x,m),g&&g[e]("click",A,!1),h&&h[e]("click",A,!1),p&&p[e]("click",w,!1),n.keyboard&&window[e]("keydown",T,!1)}function k(e){t[e=e?"addEventListener":"removeEventListener"]("touchmove",C,m),t[e]("touchend",N,m)}function x(e){i.isTouch||(i.touchPosition.startX=e.changedTouches[0].pageX,t.contains(e.target)&&(i.isTouch=!0,k(1)))}function C(t){if(i.isTouch)return i.touchPosition.currentX=t.changedTouches[0].pageX,"touchmove"===t.type&&t.changedTouches.length>1?(t.preventDefault(),!1):void 0;t.preventDefault()}function N(e){if(i.isTouch&&!i.isSliding&&(i.touchPosition.endX=i.touchPosition.currentX||e.changedTouches[0].pageX,i.isTouch)){if((!t.contains(e.target)||!t.contains(e.relatedTarget))&&Math.abs(i.touchPosition.startX-i.touchPosition.endX)<75)return!1;i.touchPosition.currentXi.touchPosition.startX&&i.index--,i.isTouch=!1,L.slideTo(i.index),k()}}function P(t){Array.from(v).map((function(t){t.classList.remove("active")})),v[t]&&v[t].classList.add("active")}function H(e){if(i.touchPosition){var o=i.index,a=e&&e.target!==f[o]?1e3*e.elapsedTime+100:20,s=L.getActiveIndex(),l="left"===i.direction?"next":"prev";i.isSliding&&setTimeout((function(){i.touchPosition&&(i.isSliding=!1,f[o].classList.add("active"),f[s].classList.remove("active"),f[o].classList.remove("carousel-item-"+l),f[o].classList.remove("carousel-item-"+i.direction),f[s].classList.remove("carousel-item-"+i.direction),c.call(t,d),document.hidden||!n.interval||t.classList.contains("paused")||L.cycle())}),a)}}if(L.cycle=function(){i.timer&&(clearInterval(i.timer),i.timer=null),i.timer=setInterval((function(){var e=i.index||L.getActiveIndex();(function(t){var e=t.getBoundingClientRect(),i=window.innerHeight||document.documentElement.clientHeight;return e.top<=i&&e.bottom>=0})(t)&&(e++,L.slideTo(e))}),n.interval)},L.slideTo=function(e){if(!i.isSliding){var s,u,m=L.getActiveIndex();m!==e&&(me||m===f.length-1&&0===e)&&(i.direction="right"),e<0?e=f.length-1:e>=f.length&&(e=0),s="left"===i.direction?"next":"prev",u={relatedTarget:f[e],direction:i.direction,from:m,to:e},r=l("slide","carousel",u),d=l("slid","carousel",u),c.call(t,r),r.defaultPrevented||(i.index=e,i.isSliding=!0,clearInterval(i.timer),i.timer=null,P(e),o(f[e])&&t.classList.contains("slide")?(f[e].classList.add("carousel-item-"+s),f[e].offsetWidth,f[e].classList.add("carousel-item-"+i.direction),f[m].classList.add("carousel-item-"+i.direction),a(f[e],H)):(f[e].classList.add("active"),f[e].offsetWidth,f[m].classList.remove("active"),setTimeout((function(){i.isSliding=!1,n.interval&&t&&!t.classList.contains("paused")&&L.cycle(),c.call(t,d)}),100))))}},L.getActiveIndex=function(){return Array.from(f).indexOf(t.getElementsByClassName("carousel-item active")[0])||0},L.dispose=function(){var e=["left","right","prev","next"];Array.from(f).map((function(t,i){t.classList.contains("active")&&P(i),e.map((function(e){return t.classList.remove("carousel-item-"+e)}))})),clearInterval(i.timer),E(),i={},n={},delete t.Carousel},(t=s(t)).Carousel&&t.Carousel.dispose(),f=t.getElementsByClassName("carousel-item"),h=t.getElementsByClassName("carousel-control-prev")[0],g=t.getElementsByClassName("carousel-control-next")[0],p=t.getElementsByClassName("carousel-indicators")[0],v=p&&p.getElementsByTagName("LI")||[],!(f.length<2)){var S=t.getAttribute("data-interval"),B="false"===S?0:parseInt(S),I="false"===t.getAttribute("data-touch")?0:1,M="hover"===t.getAttribute("data-pause")||!1,D="true"===t.getAttribute("data-keyboard")||!1,X=e.interval,W=e.touch;(n={}).keyboard=!0===e.keyboard||D,n.pause=!("hover"!==e.pause&&!M)&&"hover",n.touch=W||I,n.interval="number"==typeof X?X:!1===X||0===B||!1===B?0:isNaN(B)?5e3:B,L.getActiveIndex()<0&&(f.length&&f[0].classList.add("active"),v.length&&P(0)),(i={}).direction="left",i.index=0,i.timer=null,i.isSliding=!1,i.isTouch=!1,i.touchPosition={startX:0,currentX:0,endX:0},E(1),n.interval&&L.cycle(),t.Carousel=L}}function h(t,e){e=e||{};var i,n,o,r,d,u,m=this,f=null,h=null;function g(t,e){c.call(t,d),d.defaultPrevented||(t.isAnimating=!0,t.style.height=t.scrollHeight+"px",t.classList.remove("collapse"),t.classList.remove("show"),t.classList.add("collapsing"),t.offsetWidth,t.style.height="0px",a(t,(function(){t.isAnimating=!1,t.setAttribute("aria-expanded","false"),e.setAttribute("aria-expanded","false"),t.classList.remove("collapsing"),t.classList.add("collapse"),t.style.height="",c.call(t,u)})))}m.toggle=function(e){(e&&"A"===e.target.tagName||"A"===t.tagName)&&e.preventDefault(),(t.contains(e.target)||e.target===t)&&(h.classList.contains("show")?m.hide():m.show())},m.hide=function(){h.isAnimating||(g(h,t),t.classList.add("collapsed"))},m.show=function(){var e,l;f&&(i=f.getElementsByClassName("collapse show")[0],n=i&&(s('[data-target="#'+i.id+'"]',f)||s('[href="#'+i.id+'"]',f))),h.isAnimating||(n&&i!==h&&(g(i,n),n.classList.add("collapsed")),e=h,l=t,c.call(e,o),o.defaultPrevented||(e.isAnimating=!0,e.classList.add("collapsing"),e.classList.remove("collapse"),e.style.height=e.scrollHeight+"px",a(e,(function(){e.isAnimating=!1,e.setAttribute("aria-expanded","true"),l.setAttribute("aria-expanded","true"),e.classList.remove("collapsing"),e.classList.add("collapse"),e.classList.add("show"),e.style.height="",c.call(e,r)}))),t.classList.remove("collapsed"))},m.dispose=function(){t.removeEventListener("click",m.toggle,!1),delete t.Collapse},(t=s(t)).Collapse&&t.Collapse.dispose();var p=t.getAttribute("data-parent");o=l("show","collapse"),r=l("shown","collapse"),d=l("hide","collapse"),u=l("hidden","collapse"),null!==(h=s(e.target||t.getAttribute("data-target")||t.getAttribute("href")))&&(h.isAnimating=!1),f=t.closest(e.parent||p),t.Collapse||t.addEventListener("click",m.toggle,!1),t.Collapse=m}function g(t){t.focus?t.focus():t.setActive()}function p(t,e){var i,n,o,a,r,d,u,m=this,f=null,h=[];function p(t){(t.href&&"#"===t.href.slice(-1)||t.parentNode&&t.parentNode.href&&"#"===t.parentNode.href.slice(-1))&&this.preventDefault()}function v(){var e=t.open?"addEventListener":"removeEventListener";document[e]("click",L,!1),document[e]("keydown",y,!1),document[e]("keyup",w,!1),document[e]("focus",L,!1)}function L(e){var i=e.target,n=i&&(i.getAttribute("data-toggle")||i.parentNode&&i.parentNode.getAttribute&&i.parentNode.getAttribute("data-toggle"));("focus"!==e.type||i!==t&&i!==d&&!d.contains(i))&&(i!==d&&!d.contains(i)||!u&&!n)&&(f=i===t||t.contains(i)?t:null,m.hide(),p.call(e,i))}function b(e){f=t,m.show(),p.call(e,e.target)}function y(t){var e=t.which||t.keyCode;38!==e&&40!==e||t.preventDefault()}function w(e){var i=e.which||e.keyCode,n=document.activeElement,o=n===t,a=d.contains(n),s=n.parentNode===d||n.parentNode.parentNode===d,l=h.indexOf(n);s&&(l=o?0:38===i?l>1?l-1:0:40===i&&l=m,E=h.top+u/2+v/2>=f,k=h.top-u<0,x=h.left-d<0,C=h.top+u+v>=f,N=h.left+d+p>=m;i="right"===(i="left"===(i="bottom"===(i="top"===(i=("left"===i||"right"===i)&&x&&N?"top":i)&&k?"bottom":i)&&C?"top":i)&&x?"right":i)&&N?"left":i,-1===e.className.indexOf(i)&&(e.className=e.className.replace(/\b(top|bottom|left|right)+/,i)),c=y.offsetWidth,r=y.offsetHeight,"left"===i||"right"===i?(a="left"===i?h.left+g.x-d-(L?c:0):h.left+g.x+p,w?(o=h.top+g.y,s=v/2-c):E?(o=h.top+g.y-u+v,s=u-v/2-c):(o=h.top+g.y-u/2+v/2,s=u/2-(L?.9*r:r/2))):"top"!==i&&"bottom"!==i||(o="top"===i?h.top+g.y-u-(L?r:0):h.top+g.y+v,A?(a=0,l=h.left+p/2-c):T?(a=m-1.01*d,l=d-(m-h.left)+p/2-c/2):(a=h.left+g.x-d/2+p/2,l=d/2-(L?c:c/2))),e.style.top=o+"px",e.style.left=a+"px",s&&(y.style.top=s+"px"),l&&(y.style.left=l+"px")}function w(t,e){e=e||{};var i,n,o,r,d,f,h,g,p,v,b,w,A,T,E,k,x,C,N,P=this,H=null,S=0,B=/(iPhone|iPod|iPad)/.test(navigator.userAgent),I={};function M(t){null!==H&&t.target===s(".close",H)&&P.hide()}function D(){return{0:e.title||t.getAttribute("data-title")||null,1:e.content||t.getAttribute("data-content")||null}}function X(){null===H&&t.focus()}function W(e){e=e?"addEventListener":"removeEventListener","hover"===I.trigger?(t[e](L,P.show),t[e](u[0],P.show),I.dismissible||t[e](u[1],P.hide)):"click"==I.trigger?t[e](I.trigger,P.toggle):"focus"==I.trigger&&(B&&t[e]("click",X,!1),t[e](I.trigger,P.toggle))}function O(e){H&&H.contains(e.target)||e.target===t||t.contains(e.target)||P.hide()}function R(e){e=e?"addEventListener":"removeEventListener",I.dismissible?document[e]("click",M,!1):("focus"==I.trigger&&t[e]("blur",P.hide),"hover"==I.trigger&&document[e]("touchstart",O,m)),window[e]("resize",P.hide,m)}function j(){R(1),c.call(t,b)}function z(){R(),I.container.removeChild(H),S=null,H=null,c.call(t,A)}P.toggle=function(){null===H?P.show():P.hide()},P.show=function(){clearTimeout(S),S=setTimeout((function(){if(null===H){if(c.call(t,v),v.defaultPrevented)return;!function(){i=D()[0]||null,n=(n=D()[1])?n.trim():null,H=document.createElement("div");var t=document.createElement("div");if(t.classList.add("arrow"),H.appendChild(t),null!==n&&null===I.template){if(H.setAttribute("role","tooltip"),null!==i){var e=document.createElement("h3");e.classList.add("popover-header"),e.innerHTML=I.dismissible?i+p:i,H.appendChild(e)}var o=document.createElement("div");o.classList.add("popover-body"),o.innerHTML=I.dismissible&&null===i?n+p:n,H.appendChild(o)}else{var a=document.createElement("div");a.innerHTML=I.template.trim(),H.className=a.firstChild.className,H.innerHTML=a.firstChild.innerHTML;var l=s(".popover-header",H),c=s(".popover-body",H);i&&l&&(l.innerHTML=i.trim()),n&&c&&(c.innerHTML=n.trim())}I.container.appendChild(H),H.style.display="block",!H.classList.contains("popover")&&H.classList.add("popover"),!H.classList.contains(I.animation)&&H.classList.add(I.animation),!H.classList.contains(N)&&H.classList.add(N)}(),y(t,H,I.placement,I.container),!H.classList.contains("show")&&H.classList.add("show"),I.animation?a(H,j):j()}}),20)},P.hide=function(){clearTimeout(S),S=setTimeout((function(){if(H&&null!==H&&H.classList.contains("show")){if(c.call(t,w),w.defaultPrevented)return;H.classList.remove("show"),I.animation?a(H,z):z()}}),I.delay)},P.dispose=function(){P.hide(),W(),delete t.Popover},(t=s(t)).Popover&&t.Popover.dispose(),o=t.getAttribute("data-trigger"),r=t.getAttribute("data-animation"),d=t.getAttribute("data-placement"),f=t.getAttribute("data-dismissible"),h=t.getAttribute("data-delay"),g=t.getAttribute("data-container"),p='',v=l("show","popover"),b=l("shown","popover"),w=l("hide","popover"),A=l("hidden","popover"),T=s(e.container),E=s(g),k=t.closest(".modal"),x=t.closest(".fixed-top"),C=t.closest(".fixed-bottom"),I.template=e.template?e.template:null,I.trigger=e.trigger?e.trigger:o||"hover",I.animation=e.animation&&"fade"!==e.animation?e.animation:r||"fade",I.placement=e.placement?e.placement:d||"top",I.delay=parseInt(e.delay||h)||200,I.dismissible=!(!e.dismissible&&"true"!==f),I.container=T||(E||(x||(C||(k||document.body)))),N="bs-popover-"+I.placement;var U=D();i=U[0],((n=U[1])||I.template)&&(t.Popover||W(1),t.Popover=P)}function A(t,e){e=e||{};var i,n,o,a,r,d,u=this,f={};function h(){var e,o,a;(n=r.getElementsByTagName("A"),i.scrollTop=i.isWindow?b().y:t.scrollTop,i.length!==n.length||p()!==i.scrollHeight)&&(i.items=[],i.offsets=[],i.scrollHeight=p(),i.maxScroll=i.scrollHeight-(i.isWindow?window.innerHeight:t.getBoundingClientRect().height),Array.from(n).map((function(t){e=t.getAttribute("href"),(o=e&&"#"===e.charAt(0)&&"#"!==e.slice(-1)&&s(e))&&(i.items.push(t),a=o.getBoundingClientRect(),i.offsets.push((i.isWindow?a.top+i.scrollTop:o.offsetTop)-f.offset))})),i.length=i.items.length)}function g(t){d[t=t?"addEventListener":"removeEventListener"]("scroll",u.refresh,m),window[t]("resize",u.refresh,m)}function p(){return d.scrollHeight||Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)}function v(){Array.from(n).map((function(t){return t.classList.contains("active")&&t.classList.remove("active")}))}function L(e){v(),i.activeItem=e,e.classList.add("active");for(var n=[];e.parentNode!==document.body;)e=e.parentNode,["dropdown-menu","nav"].some((function(t){return e.classList.contains(t)}))&&n.push(e);n.map((function(t){var e=t.previousElementSibling;e&&!e.classList.contains("active")&&e.classList.add("active")})),c.call(t,l("activate","scrollspy",{relatedTarget:i.activeItem}))}u.refresh=function(){if(h(),i.scrollTop>=i.maxScroll){var t=i.items[i.length-1];i.activeItem!==t&&L(t)}else{if(i.activeItem&&i.scrollTop0)return i.activeItem=null,void v();for(var e=i.length;e--;)i.activeItem!==i.items[e]&&i.scrollTop>=i.offsets[e]&&(void 0===i.offsets[e+1]||i.scrollTop1&&(t=e[e.length-1]):t=e[0],t}function N(){return s(C().getAttribute("href"))}function P(t){t.preventDefault(),h=t.currentTarget,!o.isAnimating&&A.show()}A.show=function(){if(!(h=h||t).classList.contains("active")){if(v=s(h.getAttribute("href")),g=C(),p=N(),m=l("hide","tab",{relatedTarget:h}),c.call(g,m),m.defaultPrevented)return;o.isAnimating=!0,g.classList.remove("active"),g.setAttribute("aria-selected","false"),h.classList.add("active"),h.setAttribute("aria-selected","true"),r&&(t.parentNode.classList.contains("dropdown-menu")?r.classList.contains("active")||r.classList.add("active"):r.classList.contains("active")&&r.classList.remove("active")),p.classList.contains("fade")?(p.classList.remove("show"),a(p,x)):x()}},A.dispose=function(){t.removeEventListener("click",P,!1),delete t.Tab},(t=s(t)).Tab&&t.Tab.dispose(),n=t.getAttribute("data-height"),o=t.closest(".nav"),r=o&&s(".dropdown-toggle",o),w=!(!e||!1===i.height||"false"===n),o.isAnimating=!1,t.Tab||t.addEventListener("click",P,!1),w&&(T=N().parentNode),t.Tab=A}function E(t,e){e=e||{};var i,n,o,r,d,u,m,f,h=this,g=0,p={};function v(){i.classList.remove("showing"),i.classList.add("show"),c.call(i,m),p.autohide&&h.hide()}function L(){i.classList.add("hide"),c.call(i,f)}function b(){i.classList.remove("show"),p.animation?a(i,L):L()}function y(){clearTimeout(g),t.removeEventListener("click",h.hide,!1),delete t.Toast}h.show=function(){if(i&&!i.classList.contains("show")){if(c.call(i,d),d.defaultPrevented)return;p.animation&&i.classList.add("fade"),i.classList.remove("hide"),i.offsetWidth,i.classList.add("showing"),p.animation?a(i,v):v()}},h.hide=function(t){if(i&&i.classList.contains("show")){if(c.call(i,u),u.defaultPrevented)return;t?b():g=setTimeout(b,p.delay)}},h.dispose=function(){p.animation?a(i,y):y()},(t=s(t)).Toast&&t.Toast.dispose(),i=t.closest(".toast"),n=t.getAttribute("data-animation"),o=t.getAttribute("data-autohide"),r=t.getAttribute("data-delay"),d=l("show","toast"),u=l("hide","toast"),m=l("shown","toast"),f=l("hidden","toast"),p.animation=!1===e.animation||"false"===n?0:1,p.autohide=!1===e.autohide||"false"===o?0:1,p.delay=parseInt(e.delay||r)||500,t.Toast||t.addEventListener("click",h.hide,!1),t.Toast=h}function k(t,e){e=e||{};var i,n,o,r,d,f,h,g,p,v,b,w,A,T,E,k=this,x=null,C=0,N={};function P(){return t.getAttribute("title")||t.getAttribute("data-title")||t.getAttribute("data-original-title")}function H(e){x&&x.contains(e.target)||e.target===t||t.contains(e.target)||k.hide()}function S(t){t=t?"addEventListener":"removeEventListener",document[t]("touchstart",H,m),window[t]("resize",k.hide,m)}function B(){S(1),c.call(t,h)}function I(){S(),N.container.removeChild(x),x=null,C=null,c.call(t,p)}function M(e){t[e=e?"addEventListener":"removeEventListener"](L,k.show,!1),t[e](u[0],k.show,!1),t[e](u[1],k.hide,!1)}k.show=function(){clearTimeout(C),C=setTimeout((function(){if(null===x){if(c.call(t,f),f.defaultPrevented)return;!1!==function(){if(i=P()){if(x=document.createElement("div"),N.template){var t=document.createElement("div");t.innerHTML=N.template.trim(),x.className=t.firstChild.className,x.innerHTML=t.firstChild.innerHTML,s(".tooltip-inner",x).innerHTML=i.trim()}else{var e=document.createElement("div");e.classList.add("arrow"),x.appendChild(e);var n=document.createElement("div");n.classList.add("tooltip-inner"),x.appendChild(n),n.innerHTML=i}x.style.left="0",x.style.top="0",x.setAttribute("role","tooltip"),!x.classList.contains("tooltip")&&x.classList.add("tooltip"),!x.classList.contains(N.animation)&&x.classList.add(N.animation),!x.classList.contains(E)&&x.classList.add(E),N.container.appendChild(x)}}()&&(y(t,x,N.placement,N.container),!x.classList.contains("show")&&x.classList.add("show"),N.animation?a(x,B):B())}}),20)},k.hide=function(){clearTimeout(C),C=setTimeout((function(){if(x&&x.classList.contains("show")){if(c.call(t,g),g.defaultPrevented)return;x.classList.remove("show"),N.animation?a(x,I):I()}}),N.delay)},k.toggle=function(){x?k.hide():k.show()},k.dispose=function(){M(),k.hide(),t.setAttribute("title",t.getAttribute("data-original-title")),t.removeAttribute("data-original-title"),delete t.Tooltip},(t=s(t)).Tooltip&&t.Tooltip.dispose(),n=t.getAttribute("data-animation"),o=t.getAttribute("data-placement"),r=t.getAttribute("data-delay"),d=t.getAttribute("data-container"),f=l("show","tooltip"),h=l("shown","tooltip"),g=l("hide","tooltip"),p=l("hidden","tooltip"),v=s(e.container),b=s(d),w=t.closest(".modal"),A=t.closest(".fixed-top"),T=t.closest(".fixed-bottom"),N.animation=e.animation&&"fade"!==e.animation?e.animation:n||"fade",N.placement=e.placement?e.placement:o||"top",N.template=e.template?e.template:null,N.delay=parseInt(e.delay||r)||200,N.container=v||(b||(A||(T||(w||document.body)))),E="bs-tooltip-"+N.placement,(i=P())&&(t.Tooltip||(t.setAttribute("data-original-title",i),t.removeAttribute("title"),M(1)),t.Tooltip=k)}var x={};function C(t,e){Array.from(e).map((function(e){return new t(e)}))}function N(t){for(var e in t=t||document,x)C(x[e][0],t.querySelectorAll(x[e][1]))}function P(t,e){Array.from(e).map((function(e){return e[t].dispose()}))}x.Alert=[r,'[data-dismiss="alert"]'],x.Button=[d,'[data-toggle="buttons"]'],x.Carousel=[f,'[data-ride="carousel"]'],x.Collapse=[h,'[data-toggle="collapse"]'],x.Dropdown=[p,'[data-toggle="dropdown"]'],x.Modal=[v,'[data-toggle="modal"]'],x.Popover=[w,'[data-toggle="popover"],[data-tip="popover"]'],x.ScrollSpy=[A,'[data-spy="scroll"]'],x.Tab=[T,'[data-toggle="tab"]'],x.Toast=[E,'[data-dismiss="toast"]'],x.Tooltip=[k,'[data-toggle="tooltip"],[data-tip="tooltip"]'],document.body?N():document.addEventListener("DOMContentLoaded",(function t(){N(),document.removeEventListener("DOMContentLoaded",t,!1)}),!1);return{Alert:r,Button:d,Carousel:f,Collapse:h,Dropdown:p,Modal:v,Popover:w,ScrollSpy:A,Tab:T,Toast:E,Tooltip:k,initCallback:N,removeDataAPI:function(t){for(var e in t=t||document,x)P(e,t.querySelectorAll(x[e][1]))},componentsInit:x,Version:"3.0.15"}})); diff --git a/src/static/templates/admin/base.hbs b/src/static/templates/admin/base.hbs index 08edb0cb..efc3f2b6 100644 --- a/src/static/templates/admin/base.hbs +++ b/src/static/templates/admin/base.hbs @@ -131,6 +131,6 @@ })(); - +