1 // Global jQuery Config & Extensions
3 import jQuery from "jquery"
4 window.jQuery = window.$ = jQuery;
7 * Scroll the view to a specific element.
8 * @param {HTMLElement} element
10 window.scrollToElement = function(element) {
12 let offset = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
13 let top = element.getBoundingClientRect().top + offset;
14 $('html, body').animate({
15 scrollTop: top - 60 // Adjust to change final scroll position top margin
20 * Scroll and highlight an element.
21 * @param {HTMLElement} element
23 window.scrollAndHighlight = function(element) {
25 window.scrollToElement(element);
26 let color = document.getElementById('custom-styles').getAttribute('data-color-light');
27 let initColor = window.getComputedStyle(element).getPropertyValue('background-color');
28 element.style.backgroundColor = color;
30 element.classList.add('selectFade');
31 element.style.backgroundColor = initColor;
34 element.classList.remove('selectFade');
35 element.style.backgroundColor = '';
40 jQuery.fn.smoothScrollTo = function () {
41 if (this.length === 0) return;
42 window.scrollToElement(this[0]);
46 // Making contains text expression not worry about casing
47 jQuery.expr[":"].contains = $.expr.createPseudo(function (arg) {
48 return function (elem) {
49 return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
54 if(navigator.userAgent.indexOf('MSIE')!==-1
55 || navigator.appVersion.indexOf('Trident/') > 0
56 || navigator.userAgent.indexOf('Safari') !== -1){
57 document.body.classList.add('flexbox-support');