1/*! 2 * Native JavaScript for Bootstrap Collapse v3.0.14 (https://thednp.github.io/bootstrap.native/) 3 * Copyright 2015-2020 © dnp_theme 4 * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) 5 */ 6(function (global, factory) { 7 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : 8 typeof define === 'function' && define.amd ? define(factory) : 9 (global = global || self, global.Collapse = factory()); 10}(this, (function () { 'use strict'; 11 12 var transitionEndEvent = 'webkitTransition' in document.head.style ? 'webkitTransitionEnd' : 'transitionend'; 13 14 var supportTransition = 'webkitTransition' in document.head.style || 'transition' in document.head.style; 15 16 var transitionDuration = 'webkitTransition' in document.head.style ? 'webkitTransitionDuration' : 'transitionDuration'; 17 18 var transitionProperty = 'webkitTransition' in document.head.style ? 'webkitTransitionProperty' : 'transitionProperty'; 19 20 function getElementTransitionDuration(element) { 21 var computedStyle = getComputedStyle(element), 22 property = computedStyle[transitionProperty], 23 duration = supportTransition && property && property !== 'none' 24 ? parseFloat(computedStyle[transitionDuration]) : 0; 25 return !isNaN(duration) ? duration * 1000 : 0; 26 } 27 28 function emulateTransitionEnd(element,handler){ 29 var called = 0, duration = getElementTransitionDuration(element); 30 duration ? element.addEventListener( transitionEndEvent, function transitionEndWrapper(e){ 31 !called && handler(e), called = 1; 32 element.removeEventListener( transitionEndEvent, transitionEndWrapper); 33 }) 34 : setTimeout(function() { !called && handler(), called = 1; }, 17); 35 } 36 37 function queryElement(selector, parent) { 38 var lookUp = parent && parent instanceof Element ? parent : document; 39 return selector instanceof Element ? selector : lookUp.querySelector(selector); 40 } 41 42 function bootstrapCustomEvent(eventName, componentName, eventProperties) { 43 var OriginalCustomEvent = new CustomEvent( eventName + '.bs.' + componentName, {cancelable: true}); 44 if (typeof eventProperties !== 'undefined') { 45 Object.keys(eventProperties).forEach(function (key) { 46 Object.defineProperty(OriginalCustomEvent, key, { 47 value: eventProperties[key] 48 }); 49 }); 50 } 51 return OriginalCustomEvent; 52 } 53 54 function dispatchCustomEvent(customEvent){ 55 this && this.dispatchEvent(customEvent); 56 } 57 58 function Collapse(element,options) { 59 options = options || {}; 60 var self = this; 61 var accordion = null, 62 collapse = null, 63 activeCollapse, 64 activeElement, 65 showCustomEvent, 66 shownCustomEvent, 67 hideCustomEvent, 68 hiddenCustomEvent; 69 function openAction(collapseElement, toggle) { 70 dispatchCustomEvent.call(collapseElement, showCustomEvent); 71 if ( showCustomEvent.defaultPrevented ) { return; } 72 collapseElement.isAnimating = true; 73 collapseElement.classList.add('collapsing'); 74 collapseElement.classList.remove('collapse'); 75 collapseElement.style.height = (collapseElement.scrollHeight) + "px"; 76 emulateTransitionEnd(collapseElement, function () { 77 collapseElement.isAnimating = false; 78 collapseElement.setAttribute('aria-expanded','true'); 79 toggle.setAttribute('aria-expanded','true'); 80 collapseElement.classList.remove('collapsing'); 81 collapseElement.classList.add('collapse'); 82 collapseElement.classList.add('show'); 83 collapseElement.classList.add('opened'); 84 collapseElement.style.height = ''; 85 dispatchCustomEvent.call(collapseElement, shownCustomEvent); 86 }); 87 } 88 function closeAction(collapseElement, toggle) { 89 dispatchCustomEvent.call(collapseElement, hideCustomEvent); 90 if ( hideCustomEvent.defaultPrevented ) { return; } 91 collapseElement.isAnimating = true; 92 collapseElement.style.height = (collapseElement.scrollHeight) + "px"; 93 collapseElement.classList.remove('collapse'); 94 collapseElement.classList.remove('show'); 95 collapseElement.classList.add('collapsing'); 96 collapseElement.offsetWidth; 97 collapseElement.style.height = '0px'; 98 emulateTransitionEnd(collapseElement, function () { 99 collapseElement.isAnimating = false; 100 collapseElement.setAttribute('aria-expanded','false'); 101 toggle.setAttribute('aria-expanded','false'); 102 toggle.classList.add('collapsed'); 103 collapseElement.classList.remove('collapsing'); 104 collapseElement.classList.remove('opened'); 105 collapseElement.classList.add('collapse'); 106 collapseElement.style.height = ''; 107 dispatchCustomEvent.call(collapseElement, hiddenCustomEvent); 108 }); 109 } 110 self.toggle = function (e) { 111 if (e && e.target.tagName === 'A' || element.tagName === 'A') {e.preventDefault();} 112 if (element.contains(e.target) || e.target === element) { 113 if (!collapse.classList.contains('show')) { self.show(); } 114 else { self.hide(); } 115 } 116 }; 117 self.hide = function () { 118 if ( collapse.isAnimating ) { return; } 119 closeAction(collapse,element); 120 element.classList.add('collapsed'); 121 }; 122 self.show = function () { 123 if ( accordion ) { 124 activeCollapse = accordion.getElementsByClassName("collapse show")[0]; 125 activeElement = activeCollapse && (queryElement(("[data-target=\"#" + (activeCollapse.id) + "\"]"),accordion) 126 || queryElement(("[href=\"#" + (activeCollapse.id) + "\"]"),accordion) ); 127 } 128 if ( !collapse.isAnimating ) { 129 if ( activeElement && activeCollapse !== collapse ) { 130 closeAction(activeCollapse,activeElement); 131 activeElement.classList.add('collapsed'); 132 activeElement.classList.remove('opened'); 133 } 134 openAction(collapse,element); 135 element.classList.remove('collapsed'); 136 element.classList.remove('opened'); 137 } 138 };
139 self.dispose = function () { 140 element.removeEventListener('click',self.toggle,false); 141 delete element.Collapse; 142 }; 143 element = queryElement(element); 144 element.Collapse && element.Collapse.dispose(); 145 var accordionData = element.getAttribute('data-parent'); 146 showCustomEvent = bootstrapCustomEvent('show', 'collapse'); 147 shownCustomEvent = bootstrapCustomEvent('shown', 'collapse'); 148 hideCustomEvent = bootstrapCustomEvent('hide', 'collapse'); 149 hiddenCustomEvent = bootstrapCustomEvent('hidden', 'collapse'); 150 collapse = queryElement(options.target || element.getAttribute('data-target') || element.getAttribute('href')); 151 collapse.isAnimating = false; 152 accordion = element.closest(options.parent || accordionData); 153 if ( !element.Collapse ) { 154 element.addEventListener('click',self.toggle,false); 155 } 156 element.Collapse = self; 157 } 158 159 return Collapse; 160 161})));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.