1/** 2 * This file is part of ILIAS, a powerful learning management system 3 * published by ILIAS open source e-Learning e.V. 4 * 5 * ILIAS is licensed with the GPL-3.0, 6 * see https://www.gnu.org/licenses/gpl-3.0.en.html 7 * You should have received a copy of said license along with the 8 * source code, too. 9 * 10 * If this is not the case or you just want to try ILIAS, you'll find 11 * us at: 12 * https://www.ilias.de 13 * https://github.com/ILIAS-eLearning 14 * 15 *********************************************************************/ 16 17var il = il || {}; 18il.UI = il.UI || {}; 19il.UI.toast = ((UI) => { 20 let vanishTime = 5000; 21 let delayTime = 500; 22 let queue = new WeakMap(); 23 24 const showToast = (element) => { 25 setTimeout(() => {appearToast(element);}, delayTime); 26 } 27 28 const closeToast = (element, forced = false) => { 29 element.querySelector('.il-toast').addEventListener('transitionend', () => { 30 if (forced && element.dataset.vanishurl !== '') { 31 let xhr = new XMLHttpRequest(); 32 xhr.open('GET', element.dataset.vanishurl); 33 xhr.send(); 34 } 35 element.remove(); 36 element.dispatchEvent(new Event('removeToast')); 37 }) 38 element.querySelector('.il-toast').classList.remove('active'); 39 }; 40 41 const appearToast = (element) => { 42 element.querySelector('.il-toast').classList.add('active'); 43 queueToast(element); 44 element.querySelector('.il-toast .close').addEventListener('click', () => closeToast(element, true)); 45 element.querySelector('.il-toast').addEventListener('mouseenter', () => stopToast(element)); 46 element.querySelector('.il-toast').addEventListener('focusin', () => stopToast(element)); 47 element.querySelector('.il-toast').addEventListener('mouseleave', () => queueToast(element)); 48 element.querySelector('.il-toast').addEventListener('focusout', () => queueToast(element)); 49 } 50 51 const stopToast = (element) => { 52 clearTimeout(queue.get(element)); 53 } 54 55 const queueToast = (element) => { 56 queue.set(element, setTimeout(() => closeToast(element), vanishTime)); 57 } 58 59 return { 60 showToast: showToast, 61 closeToast: closeToast, 62 appearToast: appearToast, 63 } 64})(il.UI)
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.