https://elgl.org/wp-content/plugins/wp-proud-core/modules/proud-menu/assets/js/proud-menu.js?ver=7.1
1(function($, Proud) { 2 3 $.fn.proudMenuSlider = (function() { 4 var self = this, 5 active = 1, 6 height = 0, 7 $slider = $(this); 8 9 self.init = function() { 10 // Set active 11 active = $slider.data('level-active'); 12 // Set height 13 self.alterHeight(active, false); 14 // Slight timeout ot make sure we get height right 15 setTimeout(function () { 16 self.alterHeight(active, false); 17 // make visible 18 $slider.css({ 'opacity': 1 }); 19 }, 500); 20 // Init clicks 21 // @TODO evaluate if the navigation forward is important 22 // $('[data-active-click]', $slider).on('click', self.sliderClick); 23 $('[data-back-click]', $slider).on('click', self.sliderClick); 24 // Set watch on resize 25 self.setWatch(); 26 } 27 28 self.sliderClick = function(event) { 29 event.preventDefault(); 30 var level = $(this).data('active-click') || $(this).data('back-click') || 1; 31 // Alter items 32 self.alterHeight(level, true); 33 self.alterClass(level); 34 // Save active 35 active = level; 36 37 // resetting tabindex on backclick so that users 38 // can still navigate through the rest of the menu 39 if ( $(this).data('back-click') ){ 40 var items = $slider.find('.inner div'); 41 var tindex = 1; 42 43 //reset tab index 44 items.each( function( index ){ 45 var links = $(this).find('a'); 46 47 links.each( function( index ) { 48 $(this).attr('tabindex', tindex ); 49 tindex = tindex + 1; 50 }); // each links 51 52 }); // each 53 54 // refocusing on the first item 55 $('[tabindex=1]').focus(); 56 57 } // if back-click 58 59 } // sliderClick 60 61 // migrates the menu visually to the desired location 62 self.alterHeight = function(levelTo, animate) { 63 // on bigger screens this is getting cut off, so add 2 64 var toHeight = $slider.find('.level-' + levelTo).height() + 2; 65 // @todo set all links to tabindex=-1 but skip the level-$levelTo item 66 if(!animate) { 67 $slider.height(toHeight); 68 } 69 else { 70 $slider.animate({ 71 height: toHeight 72 }, 250 ); 73 } 74 75 /** 76 * This messes with the tab index of slider menu items. A bunch of it is offscreen 77 * but it still gets a tabindex setting. Here we remove it for all but the 78 * active item. 79 */ 80 var items = $slider.find('.inner div'); 81 var activeClass = 'level-' + levelTo; 82 // loop through items removing tabindex 83 items.each( function( index ) { 84 85 var itemClass = $(this).attr('class'); 86 //console.log(itemClass); 87 88 // loops through items removing tabindex from those not visible 89 if ( itemClass != activeClass ){ 90 $(this).find('a').attr( 'tabindex', -1 ); 91 } 92 }); 93 94 height = toHeight; 95 } 96 97 self.alterClass = function(level) { 98 $slider.removeClass(function (index, css) { 99 return (css.match (/level-[0-9]+-active/g) || []).join(' '); 100 }).addClass('level-' + level + '-active'); 101 } 102 103 // Description: 104 // Executes a function a max of once every n milliseconds 105 self.throttle = function (func, delay) { 106 var timer = null; 107 108 return function () { 109 var context = this, args = arguments; 110 111 if (timer == null) { 112 timer = setTimeout(function () { 113 func.apply(context, args); 114 timer = null; 115 }, delay); 116 } 117 }; 118 } 119 120 self.setWatch = function() { 121 // Set watch 122 $(window).on('resize.proudMenu', self.throttle(function () { 123 self.alterHeight(active, false); 124 }, 50)); 125 } 126 127 return self.init(); 128 }); 129 130 // init menu sliders 131 $('.menu-slider').proudMenuSlider(); 132 133})(jQuery, Proud);
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.