1(function ($) { 2 $(document).ready(function () { 3 4 /*************** 5 6 Please put all scripts in the scripts.js in the child theme. 7 8 ***************/ 9 10 11 /*************** Mobile sidebar nav ***************/ 12 $('.launch.button, .launch.close').click(function () { 13 $('.ui.sidebar').sidebar('toggle'); 14 }); 15 16 /*************** Dropdown ***************/ 17 $('.ui.dropdown').dropdown(); 18 19 /*************** Accordion ***************/ 20 $('.ui.accordion').accordion(); 21 22 /*************** Parallax ***************/ 23 $.fn.parallax = function (options) { 24 var windowHeight = $(window).height(); 25 // Establish default settings 26 var settings = $.extend({ 27 speed: 0.15 28 }, options); 29 // Iterate over each object in collection 30 return this.each(function () { 31 // Save a reference to the element 32 var $this = $(this); 33 // Set up Scroll Handler 34 $(document).scroll(function () { 35 var scrollTop = $(window).scrollTop(); 36 var offset = $this.offset().top; 37 var height = $this.outerHeight(); 38 // Check if above or below viewport 39 if (offset + height <= scrollTop || offset >= scrollTop + windowHeight) { 40 return; 41 } 42 var yBgPosition = Math.round((offset - scrollTop) * settings.speed);
43 // Apply the Y Background Position to Set the Parallax Effect 44 $this.css('background-position', 'center ' + yBgPosition + 'px'); 45 }); 46 }); 47 }; 48 49 $('.parallax').parallax({ 50 speed: 0.15 51 }); 52 53 54 /*************** Scrolling anchor tags ***************/ 55 56 // to use, simply add href="#anchor-tag" and it will scroll smoothly to that link 57 // Select all links with hashes 58$('a[href*="#"]') 59 // Remove links that don't actually link to anything 60 .not('[href="#"]') 61 .not('[href="#0"]') 62 .click(function(event) { 63 // On-page links 64 if ( 65 location.pathname.replace(/^\//, '') === this.pathname.replace(/^\//, '') && location.hostname === this.hostname 66 ) { 67 // Figure out element to scroll to 68 var target = $(this.hash); 69 target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); 70 // Does a scroll target exist? 71 if (target.length) { 72 // Only prevent default if animation is actually gonna happen 73 event.preventDefault(); 74 $('html, body').animate({ 75 scrollTop: target.offset().top 76 }, 1000, function() { 77 // Callback after animation 78 // Must change focus! 79 var $target = $(target); 80 $target.focus(); 81 if ($target.is(":focus")) { // Checking if the target was focused 82 return false; 83 } else { 84 $target.attr('tabindex','-1'); // Adding tabindex for elements not focusable 85 $target.focus(); // Set focus again 86 } 87 }); 88 } 89 } 90 }); 91 92 93 /*************** close jquery and document ready ***************/ 94 }); 95})(jQuery);
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.