From 0822c0c128d3b71b13109bb8c0f94f73174440fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Mon, 31 Aug 2020 16:40:21 +0200 Subject: [PATCH] Update admin page dependencies --- Cargo.lock | 10 +- src/api/web.rs | 2 +- ...strap-native-v4.js => bootstrap-native.js} | 1464 ++++++++--------- src/static/scripts/bootstrap.css | 84 +- src/static/templates/admin/base.hbs | 2 +- 5 files changed, 749 insertions(+), 813 deletions(-) rename src/static/scripts/{bootstrap-native-v4.js => bootstrap-native.js} (63%) diff --git a/Cargo.lock b/Cargo.lock index 2fda50c5..adfaa45c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -286,9 +286,9 @@ dependencies = [ [[package]] name = "chrono-tz" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65d96be7c3e993c9ee4356442db24ba364c924b6b8331866be6b6952bfe74b9d" +checksum = "2554a3155fec064362507487171dcc4edc3df60cb10f3a1fb10ed8094822b120" dependencies = [ "chrono", "parse-zoneinfo", @@ -965,11 +965,11 @@ dependencies = [ [[package]] name = "hyperx" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81d7ed6ec7d25c4de28b999a5693f14609a8b756137b1b4cb4927d119f59ef25" +checksum = "9eae1ec4abdc4530fb001ebf585fd14e52ed17f0aacd3e13de497b71ed451750" dependencies = [ - "base64 0.11.0", + "base64 0.12.3", "bytes 0.5.6", "http", "httparse", diff --git a/src/api/web.rs b/src/api/web.rs index 306b58cc..889aaa30 100644 --- a/src/api/web.rs +++ b/src/api/web.rs @@ -78,7 +78,7 @@ fn static_files(filename: String) -> Result, Error> { "hibp.png" => Ok(Content(ContentType::PNG, include_bytes!("../static/images/hibp.png"))), "bootstrap.css" => Ok(Content(ContentType::CSS, include_bytes!("../static/scripts/bootstrap.css"))), - "bootstrap-native-v4.js" => Ok(Content(ContentType::JavaScript, include_bytes!("../static/scripts/bootstrap-native-v4.js"))), + "bootstrap-native.js" => Ok(Content(ContentType::JavaScript, include_bytes!("../static/scripts/bootstrap-native.js"))), "md5.js" => Ok(Content(ContentType::JavaScript, include_bytes!("../static/scripts/md5.js"))), "identicon.js" => Ok(Content(ContentType::JavaScript, include_bytes!("../static/scripts/identicon.js"))), _ => err!(format!("Static file not found: {}", filename)), diff --git a/src/static/scripts/bootstrap-native-v4.js b/src/static/scripts/bootstrap-native.js similarity index 63% rename from src/static/scripts/bootstrap-native-v4.js rename to src/static/scripts/bootstrap-native.js index b1cf682f..cfb6ae3f 100644 --- a/src/static/scripts/bootstrap-native-v4.js +++ b/src/static/scripts/bootstrap-native.js @@ -1,78 +1,47 @@ /*! - * Native JavaScript for Bootstrap v3.0.1 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap v3.0.10 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2020 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ -(function (global, factory) { + (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'; - function hasClass(element,classNAME) { - return element.classList.contains(classNAME) - } + var transitionEndEvent = 'webkitTransition' in document.head.style ? 'webkitTransitionEnd' : 'transitionend'; - function removeClass(element,classNAME) { - element.classList.remove(classNAME); - } + var supportTransition = 'webkitTransition' in document.head.style || 'transition' in document.head.style; - function on (element, event, handler, options) { - options = options || false; - element.addEventListener(event, handler, options); - } + var transitionDuration = 'webkitTransition' in document.head.style ? 'webkitTransitionDuration' : 'transitionDuration'; - function off (element, event, handler, options) { - options = options || false; - element.removeEventListener(event, handler, options); - } - - function one (element, event, handler, options) { - on(element, event, function handlerWrapper(e){ - if (e.target === element) { - handler(e); - off(element, event, handlerWrapper, options); - } - }, options); - } - - var transitionEndEvent = 'webkitTransition' in document.body.style ? 'webkitTransitionEnd' : 'transitionend'; - - var supportTransition = 'webkitTransition' in document.body.style || 'transition' in document.body.style; - - var transitionDuration = 'webkitTransition' in document.body.style ? 'webkitTransitionDuration' : 'transitionDuration'; - - function getElementTransitionDuration (element) { - var duration = supportTransition ? window.getComputedStyle(element)[transitionDuration] : 0; - duration = parseFloat(duration); + function getElementTransitionDuration(element) { + var duration = supportTransition ? parseFloat(getComputedStyle(element)[transitionDuration]) : 0; duration = typeof duration === 'number' && !isNaN(duration) ? duration * 1000 : 0; return duration; } - function emulateTransitionEnd (element,handler){ + function emulateTransitionEnd(element,handler){ var called = 0, duration = getElementTransitionDuration(element); - duration ? one(element, transitionEndEvent, function(e){ !called && handler(e), called = 1; }) + 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) { + function queryElement(selector, parent) { var lookUp = parent && parent instanceof Element ? parent : document; return selector instanceof Element ? selector : lookUp.querySelector(selector); } - function tryWrapper (fn,origin){ - try{ fn(); } - catch(e){ - console.error((origin + ": " + e)); - } - } - - function bootstrapCustomEvent (eventName, componentName, related) { + function bootstrapCustomEvent(eventName, componentName, related) { var OriginalCustomEvent = new CustomEvent( eventName + '.bs.' + componentName, {cancelable: true}); OriginalCustomEvent.relatedTarget = related; return OriginalCustomEvent; } - function dispatchCustomEvent (customEvent){ + + function dispatchCustomEvent(customEvent){ this && this.dispatchEvent(customEvent); } @@ -82,7 +51,11 @@ closeCustomEvent = bootstrapCustomEvent('close','alert'), closedCustomEvent = bootstrapCustomEvent('closed','alert'); function triggerHandler() { - hasClass(alert,'fade') ? emulateTransitionEnd(alert,transitionEndHandler) : transitionEndHandler(); + 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"); @@ -90,37 +63,31 @@ element && alert && (element === e.target || element.contains(e.target)) && self.close(); } function transitionEndHandler() { - off(element, 'click', clickHandler); + toggleEvents(); alert.parentNode.removeChild(alert); dispatchCustomEvent.call(alert,closedCustomEvent); } self.close = function () { - if ( alert && element && hasClass(alert,'show') ) { + if ( alert && element && alert.classList.contains('show') ) { dispatchCustomEvent.call(alert,closeCustomEvent); if ( closeCustomEvent.defaultPrevented ) { return; } self.dispose(); - removeClass(alert,'show'); + alert.classList.remove('show'); triggerHandler(); } }; self.dispose = function () { - off(element, 'click', clickHandler); + toggleEvents(); delete element.Alert; }; - tryWrapper(function (){ - element = queryElement(element); - alert = element.closest('.alert'); - element.Alert && element.Alert.dispose(); - if ( !element.Alert ) { - on(element, 'click', clickHandler); - } - self.element = element; - element.Alert = self; - },"BSN.Alert"); - } - - function addClass(element,classNAME) { - element.classList.add(classNAME); + 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) { @@ -137,12 +104,12 @@ if ( input.type === 'checkbox' ) { if ( changeCustomEvent.defaultPrevented ) { return; } if ( !input.checked ) { - addClass(label,'active'); + label.classList.add('active'); input.getAttribute('checked'); input.setAttribute('checked','checked'); input.checked = true; } else { - removeClass(label,'active'); + label.classList.remove('active'); input.getAttribute('checked'); input.removeAttribute('checked'); input.checked = false; @@ -154,16 +121,16 @@ if ( input.type === 'radio' && !element.toggled ) { if ( changeCustomEvent.defaultPrevented ) { return; } if ( !input.checked || (e.screenX === 0 && e.screenY == 0) ) { - addClass(label,'active'); - addClass(label,'focus'); + 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 && hasClass(otherLabel,'active') ) { + if ( otherLabel !== label && otherLabel.classList.contains('active') ) { dispatchCustomEvent.call(otherInput, changeCustomEvent); - removeClass(otherLabel,'active'); + otherLabel.classList.remove('active'); otherInput.removeAttribute('checked'); otherInput.checked = false; } @@ -181,43 +148,40 @@ key === 32 && e.preventDefault(); } function focusToggle(e) { - var action = e.type === 'focusin' ? addClass : removeClass; if (e.target.tagName === 'INPUT' ) { - action(e.target.closest('.btn'),'focus'); + var action = e.type === 'focusin' ? 'add' : 'remove'; + e.target.closest('.btn').classList[action]('focus'); } } function toggleEvents(action) { - action( element, 'click', toggle ); - action( element, 'keyup', keyHandler ), action( element, 'keydown', preventScroll ); - action( element, 'focusin', focusToggle), action( element, 'focusout', focusToggle); + 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(off); + toggleEvents(); delete element.Button; }; - tryWrapper(function (){ - element = queryElement(element); - element.Button && element.Button.dispose(); - labels = element.getElementsByClassName('btn'); - if (!labels.length) { return; } - if ( !element.Button ) { - toggleEvents(on); - } - element.toggled = false; - element.Button = self; - Array.from(labels).map(function (btn){ - !hasClass(btn,'active') - && queryElement('input:checked',btn) - && addClass(btn,'active'); - hasClass(btn,'active') - && !queryElement('input:checked',btn) - && removeClass(btn,'active'); - }); - },"BSN.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 touchEvents = { start: 'touchstart', end: 'touchend', move:'touchmove', cancel:'touchcancel' }; - var mouseHoverEvents = ('onmouseleave' in document) ? [ 'mouseenter', 'mouseleave'] : [ 'mouseover', 'mouseout' ]; var supportPassive = (function () { @@ -228,7 +192,9 @@ result = true; } }); - one(document, 'DOMContentLoaded', function (){}, opts); + document.addEventListener('DOMContentLoaded', function wrap(){ + document.removeEventListener('DOMContentLoaded', wrap, opts); + }, opts); } catch (e) {} return result; })(); @@ -244,18 +210,18 @@ function Carousel (element,options) { options = options || {}; var self = this, - vars, ops = {}, + vars, ops, slideCustomEvent, slidCustomEvent, slides, leftArrow, rightArrow, indicator, indicators; function pauseHandler() { - if ( ops.interval !==false && !hasClass(element,'paused') ) { - addClass(element,'paused'); + 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 && hasClass(element,'paused') ) { - removeClass(element,'paused'); + if ( ops.interval !== false && element.classList.contains('paused') ) { + element.classList.remove('paused'); !vars.isSliding && ( clearInterval(vars.timer), vars.timer = null ); !vars.isSliding && self.cycle(); } @@ -264,8 +230,8 @@ e.preventDefault(); if (vars.isSliding) { return; } var eventTarget = e.target; - if ( eventTarget && !hasClass(eventTarget,'active') && eventTarget.getAttribute('data-slide-to') ) { - vars.index = parseInt( eventTarget.getAttribute('data-slide-to'), 10 ); + 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 ); } @@ -295,28 +261,30 @@ self.slideTo( vars.index ); } function toggleEvents(action) { + action = action ? 'addEventListener' : 'removeEventListener'; if ( ops.pause && ops.interval ) { - action( element, mouseHoverEvents[0], pauseHandler ); - action( element, mouseHoverEvents[1], resumeHandler ); - action( element, touchEvents.start, pauseHandler, passiveHandler ); - action( element, touchEvents.end, resumeHandler, passiveHandler ); + element[action]( mouseHoverEvents[0], pauseHandler, false ); + element[action]( mouseHoverEvents[1], resumeHandler, false ); + element[action]( 'touchstart', pauseHandler, passiveHandler ); + element[action]( 'touchend', resumeHandler, passiveHandler ); } - slides.length > 1 && action( element, touchEvents.start, touchDownHandler, passiveHandler ); - rightArrow && action( rightArrow, 'click', controlsHandler ); - leftArrow && action( leftArrow, 'click', controlsHandler ); - indicator && action( indicator, 'click', indicatorHandler ); - ops.keyboard && action( window, 'keydown', keyHandler ); + 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( element, touchEvents.move, touchMoveHandler, passiveHandler ); - action( element, touchEvents.end, touchEndHandler, passiveHandler ); + 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(on); + toggleTouchEvents(1); } } function touchMoveHandler(e) { @@ -343,12 +311,12 @@ vars.isTouch = false; self.slideTo(vars.index); } - toggleTouchEvents(off); + toggleTouchEvents(); } } function setActivePage(pageIndex) { - Array.from(indicators).map(function (x){removeClass(x,'active');}); - indicators[pageIndex] && addClass(indicators[pageIndex], 'active'); + Array.from(indicators).map(function (x){x.classList.remove('active');}); + indicators[pageIndex] && indicators[pageIndex].classList.add('active'); } function transitionEndHandler(e){ if (vars.touchPosition){ @@ -359,13 +327,13 @@ vars.isSliding && setTimeout(function () { if (vars.touchPosition){ vars.isSliding = false; - addClass(slides[next],'active'); - removeClass(slides[activeItem],'active'); - removeClass(slides[next],("carousel-item-" + orientation)); - removeClass(slides[next],("carousel-item-" + (vars.direction))); - removeClass(slides[activeItem],("carousel-item-" + (vars.direction))); + 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 && !hasClass(element,'paused') ) { + if ( !document.hidden && ops.interval && !element.classList.contains('paused') ) { self.cycle(); } } @@ -404,19 +372,19 @@ clearInterval(vars.timer); vars.timer = null; setActivePage( next ); - if ( getElementTransitionDuration(slides[next]) && hasClass(element,'slide') ) { - addClass(slides[next],("carousel-item-" + orientation)); + if ( getElementTransitionDuration(slides[next]) && element.classList.contains('slide') ) { + slides[next].classList.add(("carousel-item-" + orientation)); slides[next].offsetWidth; - addClass(slides[next],("carousel-item-" + (vars.direction))); - addClass(slides[activeItem],("carousel-item-" + (vars.direction))); + slides[next].classList.add(("carousel-item-" + (vars.direction))); + slides[activeItem].classList.add(("carousel-item-" + (vars.direction))); emulateTransitionEnd(slides[next], transitionEndHandler); } else { - addClass(slides[next],'active'); + slides[next].classList.add('active'); slides[next].offsetWidth; - removeClass(slides[activeItem],'active'); + slides[activeItem].classList.remove('active'); setTimeout(function () { vars.isSliding = false; - if ( ops.interval && element && !hasClass(element,'paused') ) { + if ( ops.interval && element && !element.classList.contains('paused') ) { self.cycle(); } dispatchCustomEvent.call(element, slidCustomEvent); @@ -427,16 +395,43 @@ self.dispose = function () { var itemClasses = ['left','right','prev','next']; Array.from(slides).map(function (slide,idx) { - if (hasClass(slide,'active')){ - setActivePage( idx ); - } - itemClasses.map(function (cls) { return removeClass(slide,("carousel-item-" + cls)); }); + slide.classList.contains('active') && setActivePage( idx ); + itemClasses.map(function (cls) { return slide.classList.remove(("carousel-item-" + cls)); }); }); clearInterval(vars.timer); - toggleEvents(off); + 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; @@ -448,37 +443,9 @@ currentX : 0, endX : 0 }; - tryWrapper(function (){ - element = queryElement( element ); - element.Carousel && element.Carousel.dispose(); - var - intervalAttribute = element.getAttribute('data-interval'), - intervalOption = options.interval, - intervalData = intervalAttribute === 'false' ? 0 : parseInt(intervalAttribute), - pauseData = element.getAttribute('data-pause') === 'hover' || false, - keyboardData = element.getAttribute('data-keyboard') === 'true' || false; - 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" ) || []; - ops.keyboard = options.keyboard === true || keyboardData; - ops.pause = (options.pause === 'hover' || pauseData) ? 'hover' : false; - ops.interval = typeof intervalOption === 'number' ? intervalOption - : intervalOption === false || intervalData === 0 || intervalData === false ? 0 - : isNaN(intervalData) ? 5000 - : intervalData; - if (slides.length < 2) { return; } - if ( !element.Carousel ) { - toggleEvents(on); - } - if (self.getActiveIndex()<0) { - slides.length && addClass(slides[0],'active'); - indicators.length && setActivePage(0); - } - if ( ops.interval ){ self.cycle(); } - element.Carousel = self; - },"BSN.Carousel"); + toggleEvents(1); + if ( ops.interval ){ self.cycle(); } + element.Carousel = self; } function Collapse(element,options) { @@ -496,16 +463,16 @@ dispatchCustomEvent.call(collapseElement, showCustomEvent); if ( showCustomEvent.defaultPrevented ) { return; } collapseElement.isAnimating = true; - addClass(collapseElement,'collapsing'); - removeClass(collapseElement,'collapse'); + 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'); - removeClass(collapseElement,'collapsing'); - addClass(collapseElement, 'collapse'); - addClass(collapseElement,'show'); + collapseElement.classList.remove('collapsing'); + collapseElement.classList.add('collapse'); + collapseElement.classList.add('show'); collapseElement.style.height = ''; dispatchCustomEvent.call(collapseElement, shownCustomEvent); }); @@ -515,17 +482,17 @@ if ( hideCustomEvent.defaultPrevented ) { return; } collapseElement.isAnimating = true; collapseElement.style.height = (collapseElement.scrollHeight) + "px"; - removeClass(collapseElement,'collapse'); - removeClass(collapseElement,'show'); - addClass(collapseElement,'collapsing'); + 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'); - removeClass(collapseElement,'collapsing'); - addClass(collapseElement,'collapse'); + collapseElement.classList.remove('collapsing'); + collapseElement.classList.add('collapse'); collapseElement.style.height = ''; dispatchCustomEvent.call(collapseElement, hiddenCustomEvent); }); @@ -533,14 +500,14 @@ self.toggle = function (e) { if (e && e.target.tagName === 'A' || element.tagName === 'A') {e.preventDefault();} if (element.contains(e.target) || e.target === element) { - if (!hasClass(collapse,'show')) { self.show(); } + if (!collapse.classList.contains('show')) { self.show(); } else { self.hide(); } } }; self.hide = function () { if ( collapse.isAnimating ) { return; } closeAction(collapse,element); - addClass(element,'collapsed'); + element.classList.add('collapsed'); }; self.show = function () { if ( accordion ) { @@ -551,17 +518,16 @@ if ( !collapse.isAnimating ) { if ( activeElement && activeCollapse !== collapse ) { closeAction(activeCollapse,activeElement); - addClass(activeElement,'collapsed'); + activeElement.classList.add('collapsed'); } openAction(collapse,element); - removeClass(element,'collapsed'); + element.classList.remove('collapsed'); } }; self.dispose = function () { - off(element, 'click', self.toggle); + element.removeEventListener('click',self.toggle,false); delete element.Collapse; }; - tryWrapper(function (){ element = queryElement(element); element.Collapse && element.Collapse.dispose(); var accordionData = element.getAttribute('data-parent'); @@ -573,28 +539,351 @@ collapse.isAnimating = false; accordion = element.closest(options.parent || accordionData); if ( !element.Collapse ) { - on(element, 'click', self.toggle); + element.addEventListener('click',self.toggle,false); } element.Collapse = self; - },"BSN.Collapse"); } - var mouseClickEvents = { down: 'mousedown', up: 'mouseup' }; - - var support3DTransform = 'webkitPerspective' in document.body.style || 'perspective' in document.body.style; - - var supportTransform = 'webkitTransform' in document.body.style || 'transform' in document.body.style; - function setFocus (element){ element.focus ? element.focus() : element.setActive(); } - function getScroll () { + + 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, @@ -664,340 +953,6 @@ arrowLeft && (arrow.style.left = arrowLeft + 'px'); } - 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 ? on : off; - action(document, 'click', dismissHandler); - action(document, 'keydown', preventScroll); - action(document, 'keyup', keyHandler); - action(document, 'focus', dismissHandler, true); - } - 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(ref) { - var which = ref.which; - var keyCode = ref.keyCode; - var key = which || keyCode, - activeItem = document.activeElement, - isSameElement = activeItem === element, - isInsideMenu = menu.contains(activeItem), - isMenuItem = activeItem.parentNode === menu || activeItem.parentNode.parentNode === menu; - var idx = menuItems.indexOf(activeItem); - if ( isMenuItem ) { - idx = isSameElement ? 0 - : key === 38 ? (idx>1?idx-1:0) - : key === 40 ? (idx= topEdge && bottomEdge > vars.scrollOffset; if ( !isActive && inside ) { - addClass(item,'active'); - if (dropLink && !hasClass(dropLink,'active') ) { - addClass(dropLink,'active'); + item.classList.add('active'); + if (dropLink && !dropLink.classList.contains('active') ) { + dropLink.classList.add('active'); } dispatchCustomEvent.call(element, bootstrapCustomEvent( 'activate', 'scrollspy', vars.items[index])); } else if ( isActive && !inside ) { - removeClass(item,'active'); - if (dropLink && hasClass(dropLink,'active') && !item.parentNode.getElementsByClassName('active').length ) { - removeClass(dropLink,'active'); + 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; @@ -1254,37 +1209,36 @@ vars.items.map(function (l,idx){ return updateItem(idx); }); } function toggleEvents(action) { - action( scrollTarget, 'scroll', self.refresh, passiveHandler ); - action( window, 'resize', self.refresh, passiveHandler ); + action = action ? 'addEventListener' : 'removeEventListener'; + scrollTarget[action]('scroll', self.refresh, passiveHandler ); + window[action]( 'resize', self.refresh, passiveHandler ); } self.refresh = function () { updateItems(); }; self.dispose = function () { - toggleEvents(off); + toggleEvents(); delete element.ScrollSpy; }; - tryWrapper(function (){ - 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(on); - } - self.refresh(); - element.ScrollSpy = self; - },"BSN.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) { @@ -1307,7 +1261,7 @@ animateHeight; function triggerEnd() { tabsContentContainer.style.height = ''; - removeClass(tabsContentContainer,'collapsing'); + tabsContentContainer.classList.remove('collapsing'); tabs.isAnimating = false; } function triggerShow() { @@ -1337,20 +1291,20 @@ hiddenCustomEvent = bootstrapCustomEvent('hidden', 'tab', next); dispatchCustomEvent.call(next, showCustomEvent); if ( showCustomEvent.defaultPrevented ) { return; } - addClass(nextContent,'active'); - removeClass(activeContent,'active'); + nextContent.classList.add('active'); + activeContent.classList.remove('active'); if (tabsContentContainer) { nextHeight = nextContent.scrollHeight; equalContents = nextHeight === containerHeight; - addClass(tabsContentContainer,'collapsing'); + tabsContentContainer.classList.add('collapsing'); tabsContentContainer.style.height = containerHeight + "px"; tabsContentContainer.offsetHeight; activeContent.style.float = ''; nextContent.style.float = ''; } - if ( hasClass(nextContent, 'fade') ) { + if ( nextContent.classList.contains('fade') ) { setTimeout(function () { - addClass(nextContent,'show'); + nextContent.classList.add('show'); emulateTransitionEnd(nextContent,triggerShow); },20); } else { triggerShow(); } @@ -1358,7 +1312,7 @@ } function getActiveTab() { var activeTabs = tabs.getElementsByClassName('active'), activeTab; - if ( activeTabs.length === 1 && !hasClass(activeTabs[0].parentNode,'dropdown') ) { + if ( activeTabs.length === 1 && !activeTabs[0].parentNode.classList.contains('dropdown') ) { activeTab = activeTabs[0]; } else if ( activeTabs.length > 1 ) { activeTab = activeTabs[activeTabs.length-1]; @@ -1373,7 +1327,7 @@ } self.show = function () { next = next || element; - if (!hasClass(next,'active')) { + if (!next.classList.contains('active')) { nextContent = queryElement(next.getAttribute('href')); activeTab = getActiveTab(); activeContent = getActiveContent(); @@ -1381,41 +1335,39 @@ dispatchCustomEvent.call(activeTab, hideCustomEvent); if (hideCustomEvent.defaultPrevented) { return; } tabs.isAnimating = true; - removeClass(activeTab,'active'); + activeTab.classList.remove('active'); activeTab.setAttribute('aria-selected','false'); - addClass(next,'active'); + next.classList.add('active'); next.setAttribute('aria-selected','true'); if ( dropdown ) { - if ( !hasClass(element.parentNode,'dropdown-menu') ) { - if (hasClass(dropdown,'active')) { removeClass(dropdown,'active'); } + if ( !element.parentNode.classList.contains('dropdown-menu') ) { + if (dropdown.classList.contains('active')) { dropdown.classList.remove('active'); } } else { - if (!hasClass(dropdown,'active')) { addClass(dropdown,'active'); } + if (!dropdown.classList.contains('active')) { dropdown.classList.add('active'); } } } - if (hasClass(activeContent, 'fade')) { - removeClass(activeContent,'show'); + if (activeContent.classList.contains('fade')) { + activeContent.classList.remove('show'); emulateTransitionEnd(activeContent, triggerHide); } else { triggerHide(); } } }; self.dispose = function () { - off(element, 'click', clickHandler); + element.removeEventListener('click',clickHandler,false); delete element.Tab; }; - tryWrapper(function (){ - 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 ) { - on(element, 'click', clickHandler); - } - if (animateHeight) { tabsContentContainer = getActiveContent().parentNode; } - element.Tab = self; - },'BSN.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) { @@ -1431,37 +1383,37 @@ hiddenCustomEvent, ops = {}; function showComplete() { - removeClass( toast, 'showing' ); - addClass( toast, 'show' ); + toast.classList.remove( 'showing' ); + toast.classList.add( 'show' ); dispatchCustomEvent.call(toast,shownCustomEvent); if (ops.autohide) { self.hide(); } } function hideComplete() { - addClass( toast, 'hide' ); + toast.classList.add( 'hide' ); dispatchCustomEvent.call(toast,hiddenCustomEvent); } function close () { - removeClass( toast,'show' ); + toast.classList.remove('show' ); ops.animation ? emulateTransitionEnd(toast, hideComplete) : hideComplete(); } function disposeComplete() { clearTimeout(timer); - off(element, 'click', self.hide); + element.removeEventListener('click',self.hide,false); delete element.Toast; } self.show = function () { - if (toast && !hasClass(toast,'show')) { + if (toast && !toast.classList.contains('show')) { dispatchCustomEvent.call(toast,showCustomEvent); if (showCustomEvent.defaultPrevented) { return; } - ops.animation && addClass( toast,'fade' ); - removeClass( toast,'hide' ); + ops.animation && toast.classList.add( 'fade' ); + toast.classList.remove('hide' ); toast.offsetWidth; - addClass( toast,'showing' ); + toast.classList.add('showing' ); ops.animation ? emulateTransitionEnd(toast, showComplete) : showComplete(); } }; self.hide = function (noTimer) { - if (toast && hasClass(toast,'show')) { + if (toast && toast.classList.contains('show')) { dispatchCustomEvent.call(toast,hideCustomEvent); if(hideCustomEvent.defaultPrevented) { return; } noTimer ? close() : (timer = setTimeout( close, ops.delay)); @@ -1470,25 +1422,23 @@ self.dispose = function () { ops.animation ? emulateTransitionEnd(toast, disposeComplete) : disposeComplete(); }; - tryWrapper(function (){ - 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 ) { - on(element, 'click', self.hide); - } - element.Toast = self; - },'BSN.Toast'); + 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) { @@ -1531,19 +1481,19 @@ queryElement('.tooltip-inner',tooltip).innerHTML = titleString.trim(); } else { var tooltipArrow = document.createElement('div'); - addClass(tooltipArrow,'arrow'); + tooltipArrow.classList.add('arrow'); tooltip.appendChild(tooltipArrow); var tooltipInner = document.createElement('div'); - addClass(tooltipInner,'tooltip-inner'); + tooltipInner.classList.add('tooltip-inner'); tooltip.appendChild(tooltipInner); tooltipInner.innerHTML = titleString; } tooltip.style.left = '0'; tooltip.style.top = '0'; tooltip.setAttribute('role','tooltip'); - !hasClass(tooltip, 'tooltip') && addClass(tooltip, 'tooltip'); - !hasClass(tooltip, ops.animation) && addClass(tooltip, ops.animation); - !hasClass(tooltip, placementClass) && addClass(tooltip, placementClass); + !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); } } @@ -1551,28 +1501,32 @@ styleTip(element, tooltip, ops.placement, ops.container); } function showTooltip() { - !hasClass(tooltip,'show') && ( addClass(tooltip,'show') ); + !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() { - on( document, touchEvents.start, touchHandler, passiveHandler ); - on( window, 'resize', self.hide, passiveHandler ); + toggleAction(1); dispatchCustomEvent.call(element, shownCustomEvent); } function hideAction() { - off( document, touchEvents.start, touchHandler, passiveHandler ); - off( window, 'resize', self.hide, passiveHandler ); + toggleAction(); removeToolTip(); dispatchCustomEvent.call(element, hiddenCustomEvent); } function toggleEvents(action) { - action(element, mouseClickEvents.down, self.show); - action(element, mouseHoverEvents[0], self.show); - action(element, mouseHoverEvents[1], self.hide); + 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); @@ -1591,10 +1545,10 @@ self.hide = function () { clearTimeout(timer); timer = setTimeout( function () { - if (tooltip && hasClass(tooltip,'show')) { + if (tooltip && tooltip.classList.contains('show')) { dispatchCustomEvent.call(element, hideCustomEvent); if (hideCustomEvent.defaultPrevented) { return; } - removeClass(tooltip,'show'); + tooltip.classList.remove('show'); !!ops.animation ? emulateTransitionEnd(tooltip, hideAction) : hideAction(); } }, ops.delay); @@ -1604,69 +1558,58 @@ else { self.hide(); } }; self.dispose = function () { - toggleEvents(off); + toggleEvents(); self.hide(); element.setAttribute('title', element.getAttribute('data-original-title')); element.removeAttribute('data-original-title'); delete element.Tooltip; }; - tryWrapper(function (){ - 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(on); - } - element.Tooltip = self; - },'BSN.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 = {}; - var initCallback = function (lookUp){ + function initializeDataAPI( Constructor, collection ){ + Array.from(collection).map(function (x){ return new Constructor(x); }); + } + function initCallback(lookUp){ lookUp = lookUp || document; - var initializeDataAPI = function( Constructor, collection ){ - Array.from(collection).map(function (x){ return new Constructor(x); }); - }; for (var component in componentsInit) { initializeDataAPI( componentsInit[component][0], lookUp.querySelectorAll (componentsInit[component][1]) ); } - }; - var removeDataAPI = function (lookUp) { - lookUp = lookUp || document; - var removeElementDataAPI = function( ConstructorName, collection ){ - Array.from(collection).map(function (x){ return x[ConstructorName].dispose(); }); - }; - for (var component in componentsInit) { - removeElementDataAPI( component, lookUp.querySelectorAll (componentsInit[component][1]) ); - } - }; + } componentsInit.Alert = [ Alert, '[data-dismiss="alert"]']; componentsInit.Button = [ Button, '[data-toggle="buttons"]' ]; @@ -1679,9 +1622,22 @@ componentsInit.Tab = [ Tab, '[data-toggle="tab"]' ]; componentsInit.Toast = [ Toast, '[data-dismiss="toast"]' ]; componentsInit.Tooltip = [ Tooltip, '[data-toggle="tooltip"],[data-tip="tooltip"]' ]; - document.body ? initCallback() : one( document, 'DOMContentLoaded', initCallback ); + document.body ? initCallback() : document.addEventListener( 'DOMContentLoaded', function initWrapper(){ + initCallback(); + document.removeEventListener('DOMContentLoaded',initWrapper,false); + }, false ); - var version = "3.0.1"; + 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.10"; var index = { Alert: Alert, diff --git a/src/static/scripts/bootstrap.css b/src/static/scripts/bootstrap.css index e461d3fb..0bb38131 100644 --- a/src/static/scripts/bootstrap.css +++ b/src/static/scripts/bootstrap.css @@ -1,10 +1,10 @@ /*! - * Bootstrap v4.5.0 (https://getbootstrap.com/) + * Bootstrap v4.5.2 (https://getbootstrap.com/) * Copyright 2011-2020 The Bootstrap Authors * Copyright 2011-2020 Twitter, Inc. - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ -:root { + :root { --blue: #007bff; --indigo: #6610f2; --purple: #6f42c1; @@ -163,12 +163,12 @@ a:hover { text-decoration: underline; } -a:not([href]) { +a:not([href]):not([class]) { color: inherit; text-decoration: none; } -a:not([href]):hover { +a:not([href]):not([class]):hover { color: inherit; text-decoration: none; } @@ -539,39 +539,12 @@ pre code { overflow-y: scroll; } -.container { - width: 100%; - padding-right: 15px; - padding-left: 15px; - margin-right: auto; - margin-left: auto; -} - -@media (min-width: 576px) { - .container { - max-width: 540px; - } -} - -@media (min-width: 768px) { - .container { - max-width: 720px; - } -} - -@media (min-width: 992px) { - .container { - max-width: 960px; - } -} - -@media (min-width: 1200px) { - .container { - max-width: 1140px; - } -} - -.container-fluid, .container-sm, .container-md, .container-lg, .container-xl { +.container, +.container-fluid, +.container-sm, +.container-md, +.container-lg, +.container-xl { width: 100%; padding-right: 15px; padding-left: 15px; @@ -640,7 +613,6 @@ pre code { flex-basis: 0; -ms-flex-positive: 1; flex-grow: 1; - min-width: 0; max-width: 100%; } @@ -884,7 +856,6 @@ pre code { flex-basis: 0; -ms-flex-positive: 1; flex-grow: 1; - min-width: 0; max-width: 100%; } .row-cols-sm-1 > * { @@ -1087,7 +1058,6 @@ pre code { flex-basis: 0; -ms-flex-positive: 1; flex-grow: 1; - min-width: 0; max-width: 100%; } .row-cols-md-1 > * { @@ -1290,7 +1260,6 @@ pre code { flex-basis: 0; -ms-flex-positive: 1; flex-grow: 1; - min-width: 0; max-width: 100%; } .row-cols-lg-1 > * { @@ -1493,7 +1462,6 @@ pre code { flex-basis: 0; -ms-flex-positive: 1; flex-grow: 1; - min-width: 0; max-width: 100%; } .row-cols-xl-1 > * { @@ -2259,6 +2227,7 @@ textarea.form-control { .valid-tooltip { position: absolute; top: 100%; + left: 0; z-index: 5; display: none; max-width: 100%; @@ -2359,6 +2328,7 @@ textarea.form-control { .invalid-tooltip { position: absolute; top: 100%; + left: 0; z-index: 5; display: none; max-width: 100%; @@ -3776,6 +3746,7 @@ input[type="button"].btn-block { .custom-control { position: relative; + z-index: 1; display: block; min-height: 1.5rem; padding-left: 1.5rem; @@ -4312,12 +4283,14 @@ input[type="button"].btn-block { background-color: #007bff; } +.nav-fill > .nav-link, .nav-fill .nav-item { -ms-flex: 1 1 auto; flex: 1 1 auto; text-align: center; } +.nav-justified > .nav-link, .nav-justified .nav-item { -ms-flex-preferred-size: 0; flex-basis: 0; @@ -4775,6 +4748,11 @@ input[type="button"].btn-block { border-bottom-left-radius: calc(0.25rem - 1px); } +.card > .card-header + .list-group, +.card > .list-group + .card-footer { + border-top: 0; +} + .card-body { -ms-flex: 1 1 auto; flex: 1 1 auto; @@ -4814,10 +4792,6 @@ input[type="button"].btn-block { border-radius: calc(0.25rem - 1px) calc(0.25rem - 1px) 0 0; } -.card-header + .list-group .list-group-item:first-child { - border-top: 0; -} - .card-footer { padding: 0.75rem 1.25rem; background-color: rgba(0, 0, 0, 0.03); @@ -4847,6 +4821,7 @@ input[type="button"].btn-block { bottom: 0; left: 0; padding: 1.25rem; + border-radius: calc(0.25rem - 1px); } .card-img, @@ -4958,6 +4933,10 @@ input[type="button"].btn-block { } } +.accordion { + overflow-anchor: none; +} + .accordion > .card { overflow: hidden; } @@ -5876,15 +5855,14 @@ a.close.disabled { } .toast { + -ms-flex-preferred-size: 350px; + flex-basis: 350px; max-width: 350px; - overflow: hidden; font-size: 0.875rem; background-color: rgba(255, 255, 255, 0.85); background-clip: padding-box; border: 1px solid rgba(0, 0, 0, 0.1); box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.1); - -webkit-backdrop-filter: blur(10px); - backdrop-filter: blur(10px); opacity: 0; border-radius: 0.25rem; } @@ -5916,6 +5894,8 @@ a.close.disabled { background-color: rgba(255, 255, 255, 0.85); background-clip: padding-box; border-bottom: 1px solid rgba(0, 0, 0, 0.05); + border-top-left-radius: calc(0.25rem - 1px); + border-top-right-radius: calc(0.25rem - 1px); } .toast-body { @@ -10182,7 +10162,8 @@ a.text-dark:hover, a.text-dark:focus { } .text-break { - word-wrap: break-word !important; + word-break: break-word !important; + overflow-wrap: break-word !important; } .text-reset { @@ -10275,4 +10256,3 @@ a.text-dark:hover, a.text-dark:focus { border-color: #dee2e6; } } -/*# sourceMappingURL=bootstrap.css.map */ \ No newline at end of file diff --git a/src/static/templates/admin/base.hbs b/src/static/templates/admin/base.hbs index c9cd40dc..3d368a15 100644 --- a/src/static/templates/admin/base.hbs +++ b/src/static/templates/admin/base.hbs @@ -122,6 +122,6 @@ })(); - + \ No newline at end of file