1jQuery(document).ready(function() { 2 jQuery(document).foundation(); 3}); 4 5function iframe_setup() { 6 // Adds Flex Video to YouTube and Vimeo Embeds 7 jQuery('iframe[src*="youtube.com"], iframe[src*="vimeo.com"]').each(function(){ 8 if(jQuery(this).innerWidth()/jQuery(this).innerHeight()>1.5){ 9 jQuery(this).wrap("<div class='widescreen responsive-embed'/>"); 10 } else { 11 jQuery(this).wrap("<div class='responsive-embed'/>"); 12 } 13 }); 14 15 // Remove empty P tags created by WP inside of Accordion and Orbit 16 jQuery('.accordion p:empty, .orbit p:empty').remove(); 17} 18 19jQuery(document).on('ready', iframe_setup); 20jQuery(window).on('statechangecomplete', iframe_setup); 21 22// Menu toggle 23var button_menu_toggle = function() { 24 var menu = document.getElementById('nav-main'); 25 var menu_button_main = document.getElementById('menu-button-main'); 26 var menu_button_mobile = document.getElementById('menu-button-mobile'); 27 28 if (menu.style.display !== 'none') { 29 menu.style.display = 'none'; 30 if(menu_button_main.classList.contains("active")) { 31 menu_button_main.classList.remove("active"); 32 } 33 if(menu_button_mobile.classList.contains("active")) { 34 menu_button_mobile.classList.remove("active"); 35 } 36 } else { 37 menu.style.display = 'block'; 38 menu_button_main.className += " active"; 39 menu_button_mobile.className += " active"; 40 window.scrollTo(0, 0); 41 } 42}; 43 44var menu_button_main = document.getElementById('menu-button-main'); 45var menu_button_mobile = document.getElementById('menu-button-mobile'); 46var menu_button_footer = document.getElementById('menu-button-footer'); 47menu_button_main.onclick = button_menu_toggle; 48menu_button_mobile.onclick = button_menu_toggle; 49menu_button_footer.onclick = button_menu_toggle; 50 51 52// Tabs 53var tabs_setup = function() { 54 var tab_buttons = document.querySelectorAll(".tabs-bar a"); 55 for(var i = 0; i < tab_buttons.length; i++) { 56 tab_buttons[i].onclick = tabs_click; 57 } 58}; 59 60var tabs_click = function() { 61 var tab_name = this.getAttribute('data-tabname'); 62 document.getElementById(tab_name).className += ' active'; 63 this.className += ' active'; 64 65 var tabs_other = document.querySelectorAll(".tab-content:not(#"+tab_name+")"); 66 for(var i = 0; i < tabs_other.length; i++) { 67 if(tabs_other[i].classList.contains("active")) { 68 tabs_other[i].classList.remove('active'); 69 } 70 } 71 72 var tab_buttons_other = document.querySelectorAll(".tabs-bar a:not(#button-"+tab_name+")"); 73 for(var i = 0; i < tab_buttons_other.length; i++) { 74 if(tab_buttons_other[i].classList.contains("active")) { 75 tab_buttons_other[i].classList.remove('active'); 76 } 77 } 78} 79 80jQuery(document).on('ready', tabs_setup); 81jQuery(window).on('statechangecomplete', tabs_setup); 82 83 84// Menu button - trigger live stream 85var button_listen_setup = function() { 86 var buttons = document.querySelectorAll("a.stream_play"); 87 for(var i = 0; i < buttons.length; i++) { 88 buttons[i].onclick = button_listen_click; 89 } 90}; 91 92var button_listen_click = function(event) { 93 // Event handler for Listen Live button in menu 94 95 event.preventDefault(event); 96 97 if(typeof metaradio.stations == 'undefined' || metaradio.stations.length == 0) { 98 console.log("Stations not loaded"); 99 return; 100 } 101 102 // Find a specific station 103 var parent = jQuery(event.target).parent('a'); 104 var station_id = parent.attr('data-stationid'); 105 106 if(typeof station_id != "undefined") { 107 // Find key from value 108 var station_key = Object.keys(metaradio.stations).find(key => metaradio.stations[key] === station_id); 109 110 if(typeof metaradio.stations[station_key] != "undefined") { 111 // Load specific station 112 player_stationload(metaradio.stations[station_key], metaradio.station_data[metaradio.stations[station_key]].station.name); 113 } else { 114 // Fallback to the 1st station 115 player_stationload(metaradio.stations[0], metaradio.station_data[metaradio.stations[0]].station.name); 116 } 117 118 } else { 119 // Fallback to the 1st station 120 player_stationload(metaradio.stations[0], metaradio.station_data[metaradio.stations[0]].station.name); 121 } 122 123 metaradio_radioplayer = { 124 'allow_pause': false, 125 'station_data': metaradio.station_data[metaradio.stations[0]].station, 126 }; 127 128 player_invoke(); 129 metaradio_player_start(); 130} 131 132jQuery(document).on('ready', button_listen_setup); 133 134 135// Menu button - search box 136var menu_button_search_show = function() { 137 var menu_form_search = document.getElementById('menu-form-search'); 138 menu_form_search.className += " active"; 139} 140 141var menu_button_search = document.getElementById('menu-button-search'); 142menu_button_search.onclick = menu_button_search_show; 143 144// Menu button - search box close icon 145var menu_button_search_close = function(event) { 146 event.preventDefault(); 147 var menu_form_search = document.getElementById('menu-form-search'); 148 menu_form_search.classList.remove("active"); 149 return false;
150} 151 152var menu_button_search_close_element = document.getElementById('menu-form-search-close'); 153menu_button_search_close_element.onclick = menu_button_search_close; 154 155 156// Menu - expand/collapse 157var menu_mobile_setup = function() { 158 var parents = document.querySelectorAll(".nav-main a.menu-item-has-children span.icon-expandcollapse"); 159 for(var i = 0; i < parents.length; i++) { 160 parents[i].onclick = menu_mobile_click; 161 } 162}; 163 164var menu_mobile_click = function(event) { 165 166 var id = this.parentElement.id.replace("menu-item-", ""); 167 var items = document.querySelectorAll(".nav-main a.parent-menu-id-"+id); 168 169 if(this.classList.contains("icon-plus")) { 170 // Expand 171 this.classList.remove("icon-plus"); 172 this.className += " icon-minus"; 173 174 for(var i = 0; i < items.length; i++) { 175 items[i].style.display = "block"; 176 } 177 178 } else { 179 // Collapse 180 this.classList.remove("icon-minus"); 181 this.className += " icon-plus"; 182 183 for(var i = 0; i < items.length; i++) { 184 items[i].style.display = "none"; 185 } 186 } 187 188 event.preventDefault(); 189} 190 191jQuery(document).on('ready', menu_mobile_setup); 192 193 194 195 196// Shopping Cart - add product to cart 197var shoppingcart_setup = function() { 198 jQuery("form.shoppingcart-add").submit(function(e) { 199 var form = jQuery(this); 200 var url = form.attr('action'); 201 e.preventDefault(); 202 203 jQuery.ajax({ 204 type: "POST", 205 url: url, 206 data: form.serialize(), 207 success: function(data) { 208 // Update the menu cart icon 209 data_html = jQuery.parseHTML(data); 210 jQuery(".header-main-right a.cart-button").replaceWith(jQuery(".header-main-right a.cart-button", data_html)); 211 212 // Get the shopping cart URL 213 var cart_url = jQuery(".header-main-right a.cart-button").attr('href'); 214 215 // Acknowledge the cart addition 216 jQuery('#modal .modal-content').html('<h2>This item has been added to your cart.</h2><p><a href="'+cart_url+'" class="button">Checkout</a> <button data-close class="button">Continue Shopping</button></p>'); 217 jQuery('#modal').foundation('open'); 218 } 219 }); 220 }); 221} 222 223jQuery(document).on('ready', shoppingcart_setup); 224 225 226// Shopping Cart - edit quantity on checkout page 227var shoppingcart_editquantity = function() { 228 jQuery("form li.gfield.product-listing input.ginput_quantity").on('change keypress', function(e) { 229 230 if(e.type == 'keypress' && e.which != 13) { 231 // If keypress, only process this event if the key was the enter key (13) 232 return; 233 } 234 235 var form = jQuery(this).closest('form'); 236 var li = jQuery(this).closest('li'); 237 var li_classes = li.attr("class").split(/\s+/); 238 var quantity = jQuery(this).val(); 239 var url = form.attr('action'); 240 e.preventDefault(); 241 242 var productId = null; 243 244 for(var i = 0; i <= li_classes.length; i++) { 245 if(typeof li_classes[i] == 'string' && li_classes[i].substring(0, 15) == "gfield_product_") { 246 // We have the product id 247 productId = li_classes[i].substring(16).split('_')[1]; 248 } 249 } 250 251 if(productId != null) { 252 jQuery.ajax({ 253 type: "POST", 254 url: url, 255 data: { 256 mrwp_update_product_id: productId, 257 mrwp_update_product_quantity: quantity, 258 }, 259 success: function(data) { 260 // Update the menu cart icon 261 data_html = jQuery.parseHTML(data); 262 jQuery(".header-main-right a.cart-button").replaceWith(jQuery(".header-main-right a.cart-button", data_html)); 263 264 if(quantity == 0) { 265 li.hide(); 266 267 setInterval(function() { 268 li.remove(); 269 }, 1000); 270 271 } 272 } 273 }); 274 } 275 }); 276} 277 278jQuery(document).on('ready', shoppingcart_editquantity); 279 280 281// Playlists 282var playlists_setup = function() { 283 var selectors = document.querySelectorAll("select[name=episode_list]"); 284 for(var i = 0; i < selectors.length; i++) { 285 selectors[i].onchange = playlist_selector_change; 286 playlist_selector_change({ 287 target: selectors[i] 288 }); 289 } 290} 291var playlist_selector_change = function(event) { 292 show_name = event.target.getAttribute('data-show'); 293 selected_element = event.target.options[event.target.selectedIndex]; 294 jQuery('div.playlists-' + show_name).hide(); 295 jQuery('div.' + selected_element.value).show(); 296} 297 298jQuery(document).on('ready', playlists_setup); 299jQuery(window).on('statechangecomplete', playlists_setup); 300 301 302// Playlists in On Demand blocks 303var ondemand_trackhistory_setup = function() { 304 var selectors = document.querySelectorAll(".playlistitem"); 305 for(var i = 0; i < selectors.length; i++) { 306 selectors[i].addEventListener("click", ondemand_trackhistory_click); 307 } 308} 309var ondemand_trackhistory_click = function(event) { 310 // Show the next .trackplaylist 311 var episode_id = event.target.getAttribute('data-playlistitem-id'); 312 313 if(jQuery('div.trackplaylist-episode-' + episode_id).css('display') == 'none') { 314 // Hide all existing expanded playlists 315 jQuery('.trackplaylist').hide(); 316 317 // Expand new playlist 318 jQuery('div.trackplaylist-episode-' + episode_id).show(); 319 } else { 320 // Hide all existing expanded playlists 321 jQuery('.trackplaylist').hide(); 322 } 323} 324 325jQuery(document).on('ready', ondemand_trackhistory_setup); 326jQuery(window).on('statechangecomplete', ondemand_trackhistory_setup); 327 328var logos_rotator_setup = function() { 329 jQuery('div.block-sponsors-logos.rotator').scrollbox({ 330 infiniteLoop: true, 331 direction: 'h', 332 speed: 20, 333 linear: false 334 }); 335} 336 337jQuery(document).on('ready', logos_rotator_setup); 338jQuery(window).on('statechangecomplete', logos_rotator_setup); 339 340// Social Wall Rotator 341var socialwall_rotator_setup = function() { 342 jQuery('div.social-wall.social-wall-row_scroll').scrollbox({ 343 infiniteLoop: true, 344 direction: 'h', 345 speed: 20, 346 linear: false 347 }); 348} 349 350jQuery(document).on('ready', socialwall_rotator_setup); 351jQuery(window).on('statechangecomplete', socialwall_rotator_setup); 352 353 354// Time helper function 355var time_format_friendly = function(time) { 356 // Based on https://stackoverflow.com/a/13899011 357 358 // Check correct time format and split into components 359 time = time.toString().match(/^([01]\d|2[0-3])(:)([0-5]\d)(:[0-5]\d)?$/) || [time]; 360 361 if (time.length > 1) { // If time format correct 362 time = time.slice(1); // Remove full string match value 363 364 if(time[2] == 59) { 365 time[0] = parseInt(time[0]) + 1; 366 time[2] = 0; 367 } 368 if(time[0] == 24) { 369 time[0] = 0; 370 } 371 372 time[2] = time[2].toString().padStart(2, "0"); 373 374 time[5] = +time[0] < 12 ? 'am' : 'pm'; // Set AM/PM 375 time[0] = +time[0] % 12 || 12; // Adjust hours 376 377 if(time[2] == 0) { 378 time[1] = ""; 379 time[2] = ""; 380 } 381 } 382 383 return time.join(''); // return adjusted time or original string 384} 385 386// Sortable Tables 387var table_sorting_setup = function() { 388 jQuery('figure.sorting-enabled table th').click(function(){ 389 // From https://stackoverflow.com/a/19947532/2888733 390 var table = jQuery(this).parents('table').eq(0); 391 var rows = table.find('tr:gt(0)').toArray().sort(table_sorting_comparer(jQuery(this).index())); 392 this.asc = !this.asc; 393 if (!this.asc){ 394 rows = rows.reverse(); 395 } 396 for (var i = 0; i < rows.length; i++){ 397 table.append(rows[i]); 398 } 399 400 // Add class to sorted header 401 jQuery(table).find('th').removeClass('sorted-column'); 402 jQuery(this).addClass('sorted-column'); 403 }); 404} 405var table_sorting_comparer = function(index) { 406 return function(a, b) { 407 var valA = table_sorting_getCellValue(a, index); 408 var valB = table_sorting_getCellValue(b, index); 409 return jQuery.isNumeric(valA) && jQuery.isNumeric(valB) ? valA - valB : valA.toString().localeCompare(valB); 410 } 411} 412var table_sorting_getCellValue = function(row, index){ 413 return jQuery(row).children('td').eq(index).text(); 414} 415 416jQuery(document).on('ready', table_sorting_setup); 417jQuery(window).on('statechangecomplete', table_sorting_setup); 418 419// If a user has ?utm_medium=email parameter, set a cookie with the current unix timestamp 420(function() { 421 function setCookie(name, value, hours) { 422 var s = name + '=' + encodeURIComponent(String(value)) + '; path=/'; 423 if (typeof hours === 'number' && hours > 0) { 424 var exp = new Date(); 425 exp.setTime(exp.getTime() + hours * 3600 * 1000); 426 s += '; expires=' + exp.toUTCString(); 427 } 428 document.cookie = s; 429 } 430 431 function getParameterByName(name, url) { 432 if (!url) url = window.location.href; 433 name = name.replace(/[\[\]]/g, '\\$&'); 434 var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), 435 results = regex.exec(url); 436 if (!results) return null; 437 if (!results[2]) return ''; 438 return decodeURIComponent(results[2].replace(/\+/g, ' ')); 439 } 440 441 var utm_medium = getParameterByName('utm_medium'); 442 if(utm_medium == 'email') { 443 // Set cookie for 30 days
444 setCookie('utm_medium_email_ts', Date.now(), 24 * 30); 445 } 446})(); 447 448function card_strip_expand_setup() { 449 var card_strips = document.querySelectorAll(".card-strip"); 450 for(var i = 0; i < card_strips.length; i++) { 451 card_strips[i].addEventListener("click", card_strip_expand_click); 452 } 453} 454function card_strip_expand_click(event) { 455 456 event.preventDefault(); 457 458 // Un-expand all other card strips 459 var card_strips = document.querySelectorAll(".card-strip"); 460 for(var i = 0; i < card_strips.length; i++) { 461 if(card_strips[i] != this && card_strips[i].classList.contains("expanded")) { 462 card_strips[i].classList.remove("expanded"); 463 } 464 } 465 466 // Toggle this card strip 467 if(this.classList.contains("expanded")) { 468 this.classList.remove("expanded"); 469 } else { 470 this.className += " expanded"; 471 } 472 473 return false; 474} 475 476jQuery(document).on('ready', card_strip_expand_setup); 477jQuery(window).on('statechangecomplete', card_strip_expand_setup);
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.