1/* Nav Accordion Plugin v1.1.2 2************************************/ 3 4(function($){ 5 $.fn.navAccordion = function(options, callback){ 6 this.each(function(){ 7 8 //Options 9 var settings = $.extend({ 10 expandButtonText : "+", //Text inside of expand button 11 collapseButtonText: "-", //Text inside of collapse button 12 selectedExpand: "true", //Expand the selected channel 13 selectedClass: "selected", //Class that will be used to detect the currently selected channel - this will check the "parentElement" for this class (the parent <li> by default) 14 multipleLevels: "true", //Apply accordion to all levels - setting this to false will apply the accordion only to the first level 15 buttonWidth: "", //Width of accordion expand/collapse button as a percentage or pixels 16 buttonPosition: "right", //Position of button - 'right' is default - you can also choose 'left' 17 slideSpeed: "fast", //Speed of slide animation - "fast", "slow", or number in milliseconds such as 500 18 parentElement: "li", //Parent element type, class or ID - you don't need to change this if you're using a ul > li > ul pattern 19 childElement: ".childcontent", //Child element type, class or ID - you don't need to change this if you're using a ul > li > ul pattern 20 headersOnly: false, //False is default - setting to true will make any link with sub-nav behave as if it were set to header only, making the link inaccessible - this option is useful if you are using the plugin for a non-navigation area 21 headersOnlyCheck: false, // False is default - set to true to apply the accordion only to links that are set as "header only" (have no href) 22 delayLink: false, //Delay following the href of links until after the accordion the has expanded 23 delayAmount: null //Time in milliseconds to delay before following href - will use "slideSpeed" by default if nothing else is set 24 }, options); 25 26 var container = this, 27 //Multiple levels variable 28 multi = settings.multipleLevels ? '': ' > ' + settings.childElement + ' > '; 29 30 //Add class to container 31 $(container) 32 .addClass('accordion-nav'); 33 34 //Apply has-subnav class to lis with uls - also add accordion buttons with styles 35 $(multi + settings.parentElement, container).each(function(){ 36 if (( ($(this).contents().find( "ul" ).length) > 0 37 && settings.headersOnlyCheck == false) || (!($('> a', this).attr('href')) 38 && settings.headersOnlyCheck == true) ) 39 { 40 //Apply Class and styles to parent item 41 $(this).addClass('has-subnav') 42 .css('position', 'relative') 43 .find('>a') 44 .css('margin-' + settings.buttonPosition, settings.buttonWidth); 45 46 //Add expand button elements 47 $(' > ' + settings.childElement, this) 48 .before('<span class=" jux-custom-css accordion-btn-wrap"><span class="accordion-btn accordion-collapsed">' 49 + settings.expandButtonText + '</span><span class="accordion-btn accordion-expanded">' 50 + settings.collapseButtonText + '</span></span>'); 51 52 //Apply Styles to expand button 53 $('.accordion-btn-wrap', this) 54 .css({ 55 'width': settings.buttonWidth, 56 'position': 'absolute', 57 'top': 0, 58 'text-align': 'center', 59 'cursor': 'pointer', 60 'display': 'inline-block' 61 }) 62 .css(settings.buttonPosition, 0); 63 $('.accordion-btn ', this) 64 .css({ 65 'display': 'inline-block', 66 'width': '100%' 67 }); 68 $('.accordion-expanded', this) 69 .css('display', 'none'); 70 } 71 72 //Apply styles to <a> tags that are set to header only 73 if (!($('> a', this).attr('href')) || settings.headersOnly){ 74 $(this) 75 .addClass('accordion-header-only') 76 .find('.accordion-btn-wrap') 77 .css({ 78 'width': '100%', 79 'text-align': settings.buttonPosition 80 }) 81 .find('.accordion-btn ') 82 .css({ 83 'width': settings.buttonWidth, 84 'text-align': 'center' 85 }); 86 } 87 88 //Delay Link Mode
89 if (settings.delayLink && !settings.headersOnly) { 90 var currentThis = this, 91 speed = settings.delayAmount != null ? settings.delayAmount : settings.slideSpeed; 92 if (speed == "fast") { 93 speed = 200; 94 } else if (speed == "slow") { 95 speed = 1000; 96 } 97 $('> a', currentThis).on('click',function(e){ 98 if (!$('> .accordion-btn-wrap', currentThis).hasClass("accordion-active")) { 99 e.preventDefault(); 100 var href = $(this).attr('href'); 101 clickToggle($('> .accordion-btn-wrap', currentThis)); 102 //Go to link after delay 103 setTimeout(function(){ 104 window.location = href; 105 }, speed) 106 } 107 }) 108 } 109 110 }); 111 112 var selectedNavAccordion = $(settings.parentElement + '.' + settings.selectedClass + ' > .accordion-btn-wrap', container); 113 114 //Debounced Button height event listener 115 var buttonheightResize = debounce(function(){ 116 //Run button height 117 buttonheight(); 118 //Expand Selected Channel 119 expandSelected(); 120 }, 250); 121 //$(window).on('resize', buttonheightResize); 122 //Set button heights 123 buttonheight(); 124 125 //Expand Selected Channel 126 expandSelected(); 127 128 //On click function 129 $(container).on('click', '.accordion-btn-wrap', function(e) { 130 e.preventDefault(); 131 clickToggle(this); 132 }); 133 134 //Callback 135 if (typeof callback == "function") { 136 callback(); 137 } 138 139 140 /* Functions 141 *******************************/ 142 //Click Toggle function 143 function clickToggle(element) { 144 var nextChild = $(element).next(settings.childElement), 145 currentExpandBtn = $('.accordion-expanded', element), 146 currentCollapseBtn = $('.accordion-collapsed', element), 147 parentObj = $(element).closest(settings.parentElement); 148 if (nextChild.is(':visible')) { 149 nextChild 150 .slideUp(settings.slideSpeed); 151 $(element) 152 .removeClass('accordion-active'); 153 currentExpandBtn 154 .css('display', 'none'); 155 currentCollapseBtn 156 .css('display', 'inline-block'); 157 parentObj.add(parentObj.siblings('.active1')).add(parentObj.find('.active1')).removeClass('active1'); 158 } else { 159 $(element).closest('ul').find('.accordion-active') 160 .removeClass('accordion-active') 161 .next(settings.childElement) 162 .slideUp(settings.slideSpeed).prev() 163 .find('.accordion-expanded') 164 .css('display', 'none') 165 .parent().find('.accordion-collapsed') 166 .css('display', 'inline-block'); 167 168 parentObj.add(parentObj.siblings('.active1')).add(parentObj.find('.active1')).removeClass('active1'); 169 $(element) 170 .addClass('accordion-active'); 171 nextChild 172 .slideToggle(settings.slideSpeed); 173 currentExpandBtn 174 .css('display', 'inline-block'); 175 currentCollapseBtn 176 .css('display', 'none'); 177 parentObj.addClass('active1'); 178 } 179 } 180 181 //Expand Selected Channel Function 182 function expandSelected(){ 183 if(settings.selectedExpand){ 184 if(!settings.headersOnlyCheck){ 185 selectedNavAccordion.find('.accordion-expanded') 186 .css('display', 'inline-block'); 187 selectedNavAccordion.find('.accordion-collapsed') 188 .css('display', 'none'); 189 selectedNavAccordion.addClass('accordion-active') 190 .next(settings.childElement) 191 .css('display', 'block'); 192 selectedNavAccordion.closest(settings.parentElement) 193 .addClass('active1'); 194 } else { 195 $(settings.parentElement + '.' + settings.selectedClass + ' > ' + settings.childElement, container) 196 .css('display', 'block'); 197 $(settings.parentElement + '.' + settings.selectedClass).addClass('active1'); 198 } 199 } 200 } 201 202 //Accordion Button Height Function 203 function buttonheight(){ 204 $('.accordion-btn', container).each(function(){ 205 //Show uls so heights are calculated correctly 206 $(settings.parentElement + '.has-subnav > ' + settings.childElement, container) 207 .css('display', 'block'); 208 209 //Calculate and set heights 210 var parentItem = $(this).closest(settings.parentElement), 211 lineheight = $('> a', parentItem).innerHeight(); 212 $(this) 213 .css({'line-height': lineheight + 'px', 'height': lineheight}); 214 215 //Hide uls under lis and reset expand/collapse buttons 216 $(settings.parentElement + ((settings.headersOnlyCheck) ? ' ' : '.has-subnav > ') + settings.childElement, container) 217 .css('display', 'none'); 218 $('.accordion-expanded') 219 .css('display', 'none'); 220 $('.accordion-collapsed') 221 .css('display', 'inline-block'); 222 }) 223 } 224 225 //Debounce function 226 function debounce(func, wait, immediate) { 227 var timeout; 228 return function() { 229 var context = this, args = arguments; 230 var later = function() { 231 timeout = null;
232 if (!immediate) func.apply(context, args); 233 }; 234 var callNow = immediate && !timeout; 235 clearTimeout(timeout); 236 timeout = setTimeout(later, wait); 237 if (callNow) func.apply(context, args); 238 }; 239 }; 240 241 242 }); 243 } 244})(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.