1var LS = { 2 init: function () { 3 LS.navigation.init(); 4 LS.blogFeed.init(); 5 LS.original.init(); 6 } 7} 8jQuery(document).ready(function () { 9 LS.init(); 10}); 11/** 12 * Projects Feed Javascript Functions 13 * Updated on 2024-1-30 14 */// ! LS.blogFeed 15 LS.blogFeed = { 16 17 init: function() { 18 //Init each Projects feed. 19 jQuery('.blogs-feed .blogs__container').each(function(index, element) { 20 // Setup Pagination 21 $paginationContainer = jQuery(element).find('.feed__pagination'); 22 $paging = LS.blogFeed.generatePagination(parseInt($paginationContainer.attr('data-count')), parseInt(jQuery(element).attr('data-postsperpage')), parseInt(jQuery(element).attr('data-currentpage'))); 23 $paginationContainer.html($paging); 24 LS.blogFeed.enablePagination(jQuery(element)); 25 }); 26 }, 27 // ! getResults 28 //Loads and replaces the filter's result content. 29 getResults: function(projectContainer, page=1) { 30 //Get ajax url. 31 var ajaxUrl = projectContainer.attr('data-ajaxurl'); 32 if ((ajaxUrl == null) || (ajaxUrl == '')) { 33 return; 34 } 35 //Get posts per page. 36 var postsPerPage = projectContainer.attr('data-postsperpage'); 37 if (postsPerPage == null) { 38 return; 39 } 40 //Get application taxonomies 41 var categoryString = projectContainer.attr('data-categories'); 42 if (categoryString == null) { 43 return; 44 } 45 var categories = (categoryString !== '') ? categoryString.split(',') : []; 46 47 //Get orderby 48 var orderby = projectContainer.attr('data-orderby'); 49 if (orderby == null) { 50 return; 51 } 52 //Set loading indicator. 53 projectContainer.addClass('loading'); 54 55 //Get our data 56 var data = {}; 57 data.action = 'get_blog_feed'; 58 data.page = parseInt(page); 59 data.posts_per_page = postsPerPage; 60 data.categories = categories; 61 data.orderby = orderby; 62 63 jQuery.ajax({ 64 url: ajaxUrl, 65 method: 'post', 66 data: data, 67 success: function (response) { 68 //Replace the response 69 (projectContainer).html(response); 70 $resultsContainer = jQuery(projectContainer).find('.results-wrapper'); 71 $paging = LS.blogFeed.generatePagination(parseInt($resultsContainer.attr('data-count')), parseInt($resultsContainer.attr('data-postsperpage')), parseInt($resultsContainer.attr('data-currentpage'))); 72 jQuery(projectContainer).append($paging); 73 LS.blogFeed.enablePagination(projectContainer); 74 projectContainer.attr('data-currentpage', parseInt($resultsContainer.attr('data-currentpage'))); 75 projectContainer.attr('data-postsperpage', parseInt($resultsContainer.attr('data-postsperpage'))); 76 projectContainer.removeClass('loading'); 77 I72.image.init(); 78 }, 79 error: function () { 80 //Add event to the load more button. 81 LS.blogFeed.enablePagination(projectContainer); 82 projectContainer.removeClass('loading'); 83 } 84 }); 85 86 }, 87 enablePagination: function(projectContainer) { 88 buttons = projectContainer.find('.pagination__button'); 89 buttons.on('click', function(event) { 90 button = jQuery(event.currentTarget); 91 page = button.data('page'); 92 LS.blogFeed.getResults(projectContainer, page); 93 if (jQuery(window).width() < 1250) { 94 jQuery('html, body').animate({scrollTop: projectContainer.offset().top - 150}, 400); 95 } else { 96 jQuery('html, body').animate({scrollTop: projectContainer.offset().top - 260}, 400); 97 } 98 }); 99 }, 100 101 generatePagination: function (count, limit, page) { 102 var totalPages = Math.ceil(count/limit); 103 if (totalPages == 1) { 104 return ''; 105 } 106 var html = '<div class="feed__pagination" data-count="' + count +'">'; 107 //Prev Button 108 if (page>1) { 109 html += LS.blogFeed.getPaginationButtonHTML('<span class="prev"><svg xmlns="http://www.w3.org/2000/svg" width="12.48" height="7.71" viewB
109ox="0 0 12.48 7.71"><g transform="translate(12.48) rotate(90)"><path d="M1.47,0,0,1.47,4.77,6.24,0,11.011l1.47,1.47L7.71,6.24Z" transform="translate(0 0)" fill="#47627b"/></g></svg></span>', page-1); 110 } 111 //-1 Button 112 if (page>1) { 113 html += LS.blogFeed.getPaginationButtonHTML(page-1, page-1); 114 } 115 //Current Page 116 if (page) { 117 html += '<p class="pagination__current">' + page + '</p>' 118 } 119 //+1 Button 120 if (page<totalPages) { 121 html += LS.blogFeed.getPaginationButtonHTML(page+1, page+1); 122 } 123 //Next Button 124 if (page<totalPages) { 125 html += LS.blogFeed.getPaginationButtonHTML('<span class="next"><svg xmlns="http://www.w3.org/2000/svg" width="12.48" height="7.71" viewBox="0 0 12.48 7.71"><g transform="translate(12.48) rotate(90)"><path d="M1.47,0,0,1.47,4.77,6.24,0,11.011l1.47,1.47L7.71,6.24Z" transform="translate(0 0)" fill="#47627b"/></g></svg></span>', page+1); 126 } 127 128 html += '</div>'; 129 return html; 130 }, 131 getPaginationButtonHTML: function (title, page) { 132 var html = '<a class="pagination__button" aria-label="Go to page ' + page + '" data-page="' + page + '" href="javascript:;">'; 133 html += title; 134 html += '</a>'; 135 return html; 136 }, 137} 138/** 139 * Carousel Handler 140 * Updated on 2024-1-22 141 */ 142// ! I72.carousel 143I72.carousel = { 144 container: [], 145 init: function () { 146 //Check for the presence of this block. 147 I72.carousel.container = jQuery('.carousel'); 148 if (I72.carousel.container.length < 1) { 149 return false; 150 } 151 //Run through each and set them up. 152 I72.carousel.container.each(function (index, carousel) { 153 //Get this container, it's ID, and it's controls. 154 var container = jQuery(carousel), 155 innerContainer = container.find('.carousel__inner-container'), 156 controls = container.find('.carousel__controls'); 157 //Gather Intel 158 var slideCount = innerContainer.children().length, 159 slideWidth = innerContainer.children().outerWidth() + 4, 160 sliderUlWidth = slideCount * slideWidth + 2; 161 if (jQuery(window).width() >= 768) { 162 innerContainer.children().last().prependTo(innerContainer); 163 innerContainer.css({ width: sliderUlWidth, marginLeft: - (slideWidth + 4) }); 164 } 165 //Resize blocks when screen width changes 166 var resizeTimer; 167 jQuery(window).on('resize', function (e) { 168 clearTimeout(resizeTimer); 169 resizeTimer = setTimeout(function () { 170 slideWidth = innerContainer.children().outerWidth() + 4 171 sliderUlWidth = slideCount * slideWidth + 2; 172 if (jQuery(window).width() >= 768) { 173 innerContainer.css({ width: sliderUlWidth, marginLeft: - (slideWidth + 4) }); 174 } else { 175 innerContainer.css({ width: '100%', marginLeft: 0 }); 176 } 177 if (controls.length == 0) { 178 if (jQuery(window).width() < 768) { 179 //Set the carousel to progress on an interval 180 setInterval(function () { 181 return 182 }, 5000); 183 } 184 } 185 }, 250); 186 }); 187 //If controls are present, set them up. 188 if (controls.length > 0) { 189 //Add Previous Click event. 190 controls.find('.carousel__prev-btn').click(function () { 191 moveLeft(); 192 }); 193 //Add Next Click event. 194 controls.find('.carousel__next-btn').click(function () { 195 moveRight(); 196 }); 197 } else { 198 if (jQuery(window).width() >= 768) { 199 //Set the carousel to progress on an interval 200 setInterval(function () { 201 moveRight(); 202 }, 5000); 203 } 204 } 205 function moveLeft() { 206 innerContainer.animate({ 207 left: + slideWidth 208 }, 400, function () {
209 innerContainer.children().last().prependTo(innerContainer); 210 innerContainer.css('left', ''); 211 }); 212 } 213 function moveRight() { 214 innerContainer.animate({ 215 left: - slideWidth 216 }, 400, function () { 217 innerContainer.children().first().appendTo(innerContainer); 218 innerContainer.css('left', ''); 219 }); 220 } 221 }); 222 return true; 223 }, 224} 225/** 226 * Functions to navigation. 227 */// ! LS.navigation 228 LS.navigation = { 229 init: function () { 230 // skip navigation 231 jQuery('.skip-nav').click(LS.navigation.skipNav); 232 // adjust login link 233 if (jQuery('body').hasClass("logged-in")) { 234 jQuery('.menu-item > a:contains("Login"), .menu-item > a:contains("Log In")').text('My Account').attr("href", 235 "/my-account/"); 236 } 237 // toggle the mobile/tablet dropdown menu 238 jQuery('header .menu-toggle').on("click", LS.navigation.toggleMobileNav); 239 // Go back to top level nav on mobile 240 jQuery('.mobile-nav-back').click(LS.navigation.mobileBack); 241 // close search bar 242 jQuery('.search-bar-container > .close').click(LS.navigation.closeSearchBar); 243 // toggle the dropdown 244 jQuery('#menu-main-nav > .menu-item-has-children > a').on("click", LS.navigation.toggleDropdown); 245 // toggle third level 246 jQuery('#menu-main-nav .sub-menu-container > .sub-menu > .menu-item-has-children > a').on("click", LS.navigation.toggleThirdLevel); 247 jQuery('#menu-main-nav .menu-item-has-children > a').keydown(function(e) { 248 if (e.key === " ") { 249 e.preventDefault(); 250 LS.navigation.toggleSubNav(e); 251 } 252 }); 253 // for tablet/mobile, increase height of nav if sub nav is taller 254 jQuery('#menu-main-nav > .menu-item-has-children > a').on("click", LS.navigation.tabletHeight); 255 // for tablet/mobile, increase height of nav if third level sub nav is taller 256 jQuery('#menu-main-nav .sub-menu-container > .sub-menu > .menu-item-has-children > a').on("click", LS.navigation.tabletHeightThird); 257 var menu = jQuery('.main-nav'); 258 // close menu when clicking elsewhere on page 259 jQuery(document).on('click', function (event) { 260 if (!menu.is(event.target) && menu.has(event.target).length === 0) { 261 if (jQuery(window).width() >= 768) { 262 jQuery('#menu-main-nav > .menu-item-has-children .sub-menu > .menu-item-has-children > .sub-menu').removeClass('active'); 263 jQuery('#menu-main-nav .menu-item-has-children > a').removeClass('active'); 264 jQuery('#menu-main-nav > .menu-item-has-children > .sub-menu-container').removeClass('active'); 265 jQuery('.nav-container .main-nav #menu-main-nav li a').attr('aria-expanded', false); 266 } 267 } 268 }); 269 // allow escape key to close navigation for accessibility purposes 270 jQuery(document).on('keydown', function(event) { 271 if (event.key == "Escape") { 272 jQuery('#menu-main-nav > .menu-item-has-children .sub-menu > .menu-item-has-children > .sub-menu').removeClass('active'); 273 jQuery('#menu-main-nav .menu-item-has-children > a').removeClass('active'); 274 jQuery('#menu-main-nav > .menu-item-has-children > .sub-menu-container').removeClass('active'); 275 jQuery('.nav-container .main-nav #menu-main-nav li a').attr('aria-expanded', false); 276 jQuery('.nav-container').removeClass('active'); 277 jQuery('.nav-container .nav-inner-container .menu-toggle').attr('aria-expanded', false); 278 } 279 }); 280 }, 281 toggleMobileNav: function (event) { 282 // reset nav when closing mobile menu 283 jQuery('#menu-main-nav .sub-menu-container, #menu-main-nav .menu-item-has-children > a, #menu-top-nav-1 .sub-menu').removeClass('active'); 284 jQuery('#menu-main-nav').css('min-height', 'auto'); 285 setTimeout(function() { 286 if(jQuery('.nav-container').hasClass('active')) { 287 jQuery('.main-nav-image').css('max-height', jQuery('.main-nav').outerHeight(true)); 288 } else { 289 jQuery('.main-nav-image').css('max-height', 'none'); 290 } 291 }, 600); 292 }, 293 toggleDropdown: function (event) { 294 var toggleBtn = jQuery(event.currentTarget); 295 // add link text to back button 296 jQuery('.mobile-nav-back > span').text('Main'); 297 jQuery('#menu-main-nav > .menu-item-has-children > a').not(toggleBtn).removeClass('active'); 298 // close any open sub menu except for the one just triggered
299 jQuery('.sub-menu-container').not(toggleBtn.next('.sub-menu-container')).removeClass('active'); 300 jQuery('.sub-menu, #menu-main-nav .sub-menu-container > .sub-menu > .menu-item-has-children > a').removeClass('active'); 301 jQuery('#menu-main-nav .sub-menu-container > .sub-menu > .menu-item-has-children > a').attr('aria-expanded', false); 302 jQuery('#menu-main-nav > .menu-item-has-children > a').not(toggleBtn).attr('aria-expanded', false); 303 toggleBtn.toggleClass('active'); 304 toggleBtn.next('.sub-menu-container').toggleClass('active'); 305 306 }, 307 toggleThirdLevel: function (event) { 308 var toggleBtn = jQuery(event.currentTarget); 309 totalHeight = 0; 310 // add link text to back button 311 jQuery('.mobile-nav-back > span').html(jQuery('#menu-main-nav > .menu-item-has-children > a.active').text()); 312 jQuery('#menu-main-nav .sub-menu-container > .sub-menu > .menu-item-has-children > a').not(toggleBtn).removeClass('active'); 313 // close any open sub menu except for the one just triggered 314 jQuery('.sub-menu-container > .sub-menu').not(toggleBtn.next('.sub-menu')).removeClass('active'); 315 jQuery('#menu-main-nav .sub-menu-container > .sub-menu > .menu-item-has-children > a').not(toggleBtn).attr('aria-expanded', false); 316 toggleBtn.toggleClass('active'); 317 toggleBtn.next('.sub-menu').toggleClass('active'); 318 if(!toggleBtn.next('.sub-menu').hasClass('active')) { 319 jQuery('.sub-menu-container.active > .sub-menu').children().each(function(index, item) { 320 totalHeight = totalHeight + jQuery(item).outerHeight(true); 321 }); 322 if (jQuery(window).width() < 768) { 323 jQuery('#menu-main-nav').css('min-height', totalHeight + 50); 324 } else { 325 jQuery('#menu-main-nav').css('min-height', totalHeight); 326 } 327 } 328 }, 329 mobileBack: function (event) { 330 var backBtn = jQuery(event.currentTarget), 331 nextSub = backBtn.next('.sub-menu'), 332 totalHeight = 0; 333 if((nextSub).find('.sub-menu.active').length !== 0) { 334 jQuery('.mobile-nav-back > span').text('Main'); 335 336 jQuery('.sub-menu-container.active > .sub-menu').children().each(function(index, item) { 337 totalHeight = totalHeight + jQuery(item).outerHeight(true); 338 }); 339 if (jQuery(window).width() < 768) { 340 jQuery('#menu-main-nav').css('min-height', totalHeight + 50); 341 } else { 342 jQuery('#menu-main-nav').css('min-height', totalHeight); 343 } 344 jQuery('#menu-main-nav .sub-menu-container > .sub-menu > .menu-item-has-children > .sub-menu, #menu-main-nav .sub-menu-container > .sub-menu > .menu-item-has-children > a').removeClass('active'); 345 jQuery('#menu-main-nav .sub-menu-container > .sub-menu > .menu-item-has-children > a').attr('aria-expanded', false); 346 } else { 347 jQuery('.sub-menu-container, #menu-main-nav > .menu-item-has-children > a').removeClass('active'); 348 jQuery('#menu-main-nav > .menu-item-has-children > a').attr('aria-expanded', false); 349 jQuery('#menu-main-nav').css('min-height', 'auto'); 350 } 351 }, 352 skipNav: function() { 353 // finds first focusable element after navigation 354 jQuery('header').nextAll().find('button, a, input, select, textarea, [tabindex]:not([tabindex="-1"])').first().focus(); 355 }, 356 closeSearchBar: function() { 357 jQuery('.search-link, .search-bar-container').removeClass('active'); 358 }, 359 tabletHeight: function(event) { 360 var toggle = jQuery(event.currentTarget), 361 subNavContainer = toggle.next('.sub-menu-container'), 362 subNav = subNavContainer.find('.sub-menu').first(), 363 totalHeight = 0; 364 subNav.children().each(function(index, item) { 365 totalHeight = totalHeight + jQuery(item).outerHeight(true); 366 }); 367 // increase size of sub navigation if needed 368 if(subNavContainer.hasClass('active')) { 369 if ((jQuery(window).width() >= 768) && (jQuery(window).width() < 1251)) { 370 jQuery('#menu-main-nav').css('min-height', totalHeight); 371 } else if (jQuery(window).width() < 768) { 372 jQuery('#menu-main-nav').css('min-height', totalHeight + 50); 373 } 374 } else { 375 jQuery('#menu-main-nav').css('min-height', 'auto'); 376 } 377 }, 378 tabletHeightThird: function(event) { 379 var toggle = jQuery(event.currentTarget), 380 subNavContainer = toggle.next('.sub-menu'), 381 totalHeight = 0, 382 prevHeight = 0;
383 jQuery('.sub-menu-container.active > .sub-menu').children().each(function(index, item) { 384 prevHeight = prevHeight + jQuery(item).outerHeight(true); 385 }); 386 subNavContainer.children().each(function(index, item) { 387 totalHeight = totalHeight + jQuery(item).outerHeight(true); 388 }); 389 // increase size of sub navigation if needed 390 if(subNavContainer.hasClass('active')) { 391 if ((jQuery(window).width() >= 768) && (jQuery(window).width() < 1251) && (totalHeight > prevHeight)) { 392 jQuery('#menu-main-nav').css('min-height', totalHeight); 393 } else if ((jQuery(window).width() < 768) && (totalHeight > prevHeight)) { 394 jQuery('#menu-main-nav').css('min-height', totalHeight + 50); 395 } 396 } 397 } 398} 399/** 400 * Original LS JS 401 * Updated on 2023-12-14 402 * 403 */ 404// ! LS.original 405LS.original = { 406 init: function() { 407 jQuery('.mh-breadcrumb a').each(function() { 408 if( jQuery(this).attr('href').indexOf('/contest/') > -1 ) { 409 jQuery(this).attr('href', '/gallery-photo/'); 410 } 411 }); 412 413 if( jQuery('.mh-breadcrumb').text().indexOf('Contest Types') > -1 ) { 414 jQuery('.mh-breadcrumb').html('<a href="/" itemprop="url"><span itemprop="title">Home</span></a> <span class="mh-breadcrumb-delimiter"><i class="fa fa-angle-right"></i></span> Voting'); 415 } 416 417 418 /** 419 * externalLinks 420 * opens non-empty external urls, and PDFs, in a new browser tab 421 */ 422 function externalLinks(){ 423 /* External links and PDFs open in new window */ 424 var protocol = jQuery(location).attr('protocol'); 425 var siteurl = jQuery(location).attr('hostname'); 426 jQuery("a:not([href^='"+ protocol +'//'+ siteurl +"']):not([href^='javascript']):not([href^='/'])").attr('target', '_blank'); 427 jQuery('a[href$=".pdf"]').attr('target', '_blank'); 428 jQuery('a[href=""]').attr('target', ''); 429 } 430 externalLinks(); 431 432 433 /** 434 * doModal 435 */ 436 jQuery('a[data-toggle="modal"]').click(function(e){ 437 let data = jQuery(this).data(); 438 jQuery( data.target ).toggle(); 439 }); 440 441 442 443 444 // jQuery('[href*="wp-login.php"]').each(function() { 445 // jQuery(this).attr('href', (jQuery(this).attr('href')+'?redirect_to='+encodeURI(document.location)) ); 446 // }); 447 448 // jQuery('[action*="wp-login.php"]').each(function() { 449 // if( jQuery(this).attr('action').indexOf('wpe-login') === -1 ) { 450 // jQuery(this).attr('action', (jQuery(this).attr('action')+'?wpe-login=true') ); 451 // } 452 // }); 453 } 454};
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.