1/* ------------------------------- 2 * Get query string and hash 3 * ------------------------------- */ 4var qd = {}; 5location.search 6 .substr(1) 7 .split("&") 8 .forEach(function(item) { 9 var k = item.split("=")[0], 10 v = decodeURIComponent(item.split("=")[1]); 11 (k in qd) ? qd[k].push(v) : qd[k] = [v] 12 }); 13var hash = decodeURIComponent(location.hash.substring(1)); 14 15function gform_format_option_label( fullLabel, fieldLabel, priceLabel, selectedPrice, price, formId, fieldId ) { 16 return fieldLabel; 17} 18(function($) { 19 $(document) 20 .on( 'mouseenter', '#masthead .menu-item-has-children', function() { 21 let toggler = $(this).children( '.dropdown-toggler' ); 22 if ( toggler.length && 'false' === toggler.attr( 'aria-expanded' ) ) { 23 toggler.click(); 24 } 25 }) 26 .on( 'mouseleave', '#masthead .menu-item-has-children', function() { 27 let toggler = $(this).children( '.dropdown-toggler' ); 28 if ( toggler.length && 'true' === toggler.attr( 'aria-expanded' ) ) { 29 toggler.click(); 30 } 31 }) 32 .on( 'click', '.dropdown-toggler', function() { 33 let toExpand = 'false' === $(this).attr( 'aria-expanded' ); 34 $(this).attr( 'aria-expanded', toExpand ); 35 }) 36 .on( 'click', function( e ) { 37 let target = $( e.target ); 38 $('.dropdown-toggler').each(function() { 39 let toggler = $(this); 40 let menuItem = toggler.closest( '.menu-item' ); 41 if ( ! target.is( toggler ) && ! menuItem.has( target ).length > 0 ) { 42 toggler.attr( 'aria-expanded', 'false' ); 43 } 44 }); 45 }) 46 ; 47 48 $(document).bind('gform_post_render', function() { 49 /* DISABLED 2021/01/07 50 // gift cards should have restricted shipping options when over $100 51 $('.form-gift-card').each(function() { 52 var form = $(this); 53 var shippingFields = form.find('.gfield_shipping input'); 54 55 var getSubTotal = function() { 56 var total = 0; 57 58 // grab the main product field, then find the matching quantity field to calculate subtotal 59 form.find('[class*="gfield_product_"]').each(function() { 60 var amountField = $(this).find('.ginput_amount'); 61 62 if( amountField.length ) { 63 var cost = parseInt( amountField.val().replace('$', '') ); 64 if ( cost ) { 65 cost = parseInt( cost ); 66 } 67 68 if ( cost ) { 69 total += cost; 70 } 71 } 72 }); 73 74 return total; 75 }; 76 var toggleShipping = function( subtotal ) { 77 shippingFields.each(function() { 78 // disable first class if the subtotal is over 100 79 if( $(this).val().indexOf('First Class') >= 0 ) { 80 if( subtotal >= 100 ) { 81 $(this).prop('disabled', true); 82 } else { 83 $(this).prop('disabled', false); 84 } 85 } 86 }); 87 // we'll need to change the selection if a shipping option is disabled 88 if( subtotal >= 100 ) { 89 if( shippingFields.filter(':checked').val().indexOf('First Class') >= 0 ) { 90 shippingFields.each(function() { 91 if( $(this).val().indexOf('First Class') < 0 ) { 92 $(this).prop('checked', true); 93 return false; 94 } 95 }); 96 } 97 } 98 }; 99 form.find('.gfield_price input').change(function() { 100 toggleShipping( getSubTotal() ); 101 }); 102 }); 103 */ 104 }); 105 106 107})( jQuery ); 108 109/* ------------------------------- 110 * Start jquery stuff 111 * ------------------------------- */ 112jQuery(document).ready(function ($) { 113 114/* Woocommerce */ 115 jQuery('.shop_table.cart select, .qty-wrapper select').customSelect({}); 116 117 /* Shop */ 118 // Disable clicking on out of stock items 119 jQuery('.shop-item.qty-0').on('click', function(e) { 120 e.preventDefault(); 121 }); 122 123 /* Product Single */ 124 // Gallery switching 125 jQuery('.product-detail .left .gallery img').on('click', function() { 126 if( !jQuery(this).hasClass('active') ) { 127 var item = jQuery(this).attr('data-item'); 128 129 jQuery('.product-detail .left img').removeClass('active'); 130 jQuery('.product-detail .left .primary img[data-item="' + item + '"]').addClass('active'); 131 jQuery(this).addClass('active'); 132 } 133 }); 134 135 // Manage selecting product variations 136 jQuery('.product-detail .attr').on('click', function() { 137 if( !jQuery(this).hasClass('active') && !jQuery(this).hasClass('sold-out') ) { 138 var type = jQuery(this).attr('data-attr-type'); 139 var value = jQuery(this).attr('data-value'); 140 var prodId = jQuery(this).attr('data-product-id'); 141 var price = jQuery(this).attr('data-price'); 142 143 jQuery('.attr[data-attr-type="' + type + '"]').removeClass('active'); 144 jQuery(this).addClass('active'); 145 jQuery('option[value="' + value + '"]').prop('selected', true); 146 jQuery('input[name="variation_id"]').val(prodId); 147 jQuery('.right .amount').html(price); 148 jQuery('.right input[type="submit"]').prop('disabled', false); 149 150 jQuery('.add-to-cart').addClass('active'); 151 } 152 }); 153 154 // Update price on variation switch 155 jQuery('.qty-wrapper select').on('change', function() { 156 var value = jQuery(this).val(); 157 158 jQuery('.product-detail .right input[type="number"]').val(value); 159 }); 160 161 /* Header */ 162 // Popup Banner 163 (function() { 164 // We need to add the popup sale banner in via JavaScript since WPE's page caching will interfere with getting 165 // the latest ACF settings. We perform an AJAX request to see if the sale is active, and if so reveal 166 // the banner and insert the user's cart and sale data. 167 168 var data = { 169 action: 'check_sale_status' 170 }; 171 172 jQuery.ajax({ 173 type: 'POST', 174 url: ajaxURL, 175 data: data, 176 success: function(response) { 177 if( response != 'inactive' ) { 178 var saleData = JSON.parse(response); 179 180 if( saleData.days == 1 ) { 181 saleData.days += ' Day'; 182 } else { 183 saleData.days += ' Days'; 184 } 185 186 jQuery('#popup-banner .sale-name').html(saleData.sale_name); 187 jQuery('#popup-banner .cart-count').html(saleData.cart_count); 188 jQuery('#popup-banner .days').html(saleData.days); 189 jQuery('#popup-banner .hours').html(saleData.hours); 190 jQuery('#popup-banner .minutes').html(saleData.minutes); 191 jQuery('#popup-banner .seconds').html(saleData.seconds); 192 jQuery('#popup-banner').attr('data-total', saleData.total); 193 194 jQuery('body').addClass('popup-sale'); 195 196 xroadsTimerID = setInterval(decrementTimer, 1000); 197 198 if( typeof( itemAdded ) != 'undefined' ) { 199 jQuery('#popup-banner p .cart').addClass('open'); 200 jQuery('#popup-banner .mini-cart').fadeIn(); 201 } 202 } 203 } 204 }); 205 }()); 206 207 function decrementTimer() { 208 var remainder = jQuery('#popup-banner').attr('data-total'); 209 210 remainder = remainder - 1000; 211 212 jQuery('#popup-banner').attr('data-total', remainder); 213 214 var remainingDate = new Date(remainder); 215 216 var days = remainingDate.getUTCDate(); 217 var hours = remainingDate.getUTCHours(); 218 var minutes = remainingDate.getUTCMinutes(); 219 var seconds = remainingDate.getUTCSeconds(); 220 221 if( hours > 12 ) { 222 hours = hours - 12; 223 } 224 if( hours < 10 ) { 225 hours = '0' + hours; 226 } 227 if( minutes < 10 ) { 228 minutes = '0' + minutes; 229 } 230 if( seconds < 10 ) { 231 seconds = '0' + seconds; 232 } 233 234 days--; 235 236 if( days == '1' ) { 237 days = days + ' Day'; 238 } else { 239 days = days + ' Days'; 240 } 241 242 if( remainder <= 0 ) { 243 remainder = 0; 244 days = '0 Days'; 245 hours = '00'; 246 clearInterval(xroadsTimerID); 247 } 248 249 jQuery('#popup-banner .days').html( days ); 250 jQuery('#popup-banner .hours').html( hours ); 251 jQuery('#popup-banner .minutes').html( minutes ); 252 jQuery('#popup-banner .seconds').html( seconds ); 253 } 254 255 // Mini-cart 256 jQuery('#popup-banner p .cart').on('click', function() { 257 if( jQuery(this).hasClass('open') ) { 258 jQuery(this).removeClass('open'); 259 jQuery('#popup-banner .mini-cart').fadeOut(); 260 } else { 261 jQuery(this).addClass('open'); 262 jQuery('#popup-banner .mini-cart').fadeIn(); 263 } 264 }); 265 266 267 268/* 269 * Pause all tutorial videos when another video is focused 270 * REQUIREMENTS: 271 * 1. <script src="http://www.youtube.com/iframe_api"></script> 272 * 2. "?enablejsapi=1" must be appended in the src of the video embed's iframe src parameter 273 * e.g. <iframe width="510" height="287" src="https://www.youtube.com/embed/VIDEO_ID?enablejsapi=1" frameborder="0" allowfullscreen></iframe> 274 * ------------------------------------------- */ 275 276 $(function(){ 277 278 $('#ui-id-3').on('click', function(ev) { 279 $("#what-to-bring")[0].src += "&autoplay=1"; 280 ev.preventDefault(); 281 }); 282 $('#ui-id-4').on('click', function(ev) { 283 $("#how-to-sell")[0].src += "&autoplay=1"; 284 ev.preventDefault(); 285 }); 286 $('#ui-id-5').on('click', function(ev) { 287 $("#tips-for-shopping")[0].src += "&autoplay=1"; 288 ev.preventDefault(); 289 }); 290 $('#ui-id-6').on('click', function(ev) { 291 $("#bloggers-love-crossroads")[0].src += "&autoplay=1"; 292 ev.preventDefault(); 293 }); 294 295 }); 296 297 $('.video-tutorial ul li a').on('click',function(){ 298 $(".yt_player_iframe").each(function() { 299 $(this)[0].contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*') 300 }); 301 302 }); 303 304 305 /* 306 * Send select box selections to appropriate places 307 * ------------------------------------------- */ 308 $('.select select').on('change',function(){ 309 if ( $(this).val() != '' ) { location.href = $(this).val(); } 310 }); 311 312 313 /* 314 * Add Sell-By-Mail Link on Locations page 315 * ------------------------------------------- */ 316 //dumpConsole('crossroads.js $(.locations-grid ul.vc_grid-filter)',$('.locations-grid ul.vc_grid-filter')); 317 $('.locations-grid ul.vc_grid-filter').append('<li class="vc_grid-filter-item sell-by-mail-menu-item"><span data-vc-grid-filter-value=".vc_grid-term-14">Sell By Mail</span></li>'); 318 319 320 /* 321 * Grid ACF Link 322 * ------------------------------------------- */ 323 $('.grid-container-about-us').on('load','grid-acf-link',function(){ 324 var link = $(this).html(); 325 $(this).html('<a href="' + link + ' target="_blank">Read Article</a>'); 326 }); 327 328 $( document ).ajaxComplete(function() { 329 //console.log( "Triggered ajaxComplete handler." ); 330 331 if ( $('.in-the-news-grid .grid-acf-link').length > 0 ) { 332 $('.in-the-news-grid .grid-acf-link').each(function(){ 333 var link = $(this).html(); 334 $(this).html('<a href="' + link + '" target="_blank">Read Full Article</a>'); 335 336 }); 337 } 338 339 if ( $('.style-council-actual-link').length > 0 ) { 340 $('.grid-style-council-link').each(function(){ 341 var blogName = $(this).parent().find('.grid-style-council-link').html(); 342 var link = $(this).parent().find('.style-council-actual-link').html(); 343 $(this).html('<a href="' + link + '" target="_blank">' + blogName + '</a>'); 344 }); 345 } 346 if ( $('.locations-grid ul.vc_grid-filter').length > 0 ) { 347 348 /* 349 * Add Sell-By-Mail Link on Locations page 350 * ------------------------------------------- */ 351 //$('.locations-grid ul.vc_grid-filter').append('<li class="vc_grid-filter-item sell-by-mail-menu-item"><span data-vc-grid-filter-value=".vc_grid-term-14">Sell By Mail</span></li>'); 352 353 354 /* 355 * Trigger region on the locations page 356 * ------------------------------------------- */ 357 if ( qd.region != 'undefined' ) { 358 var region = urldecode(qd.region[0]).toLowerCase(); 359 360 $('.locations-grid ul.vc_grid-filter li.vc_grid-filter-item').each(function(){ 361 var regionText = $(this).find('span').text().toLowerCase(); 362 var regionQ = region.toLowerCase(); 363 if ( regionQ == regionText ) { 364 $(this).click(); 365 return; 366 } 367 }); 368 369 $regionSpan = $("span[data-vc-grid-filter-value='" + region + "']"); 370 $regionEl = $regionSpan.parent(); 371 $regionEl.click(); 372 } 373 374 } 375 376 377 /* 378 * Scroll to a div 379 * ------------------------------------------- */ 380 if( hash.length ) { 381 target = $('.' + hash); 382 if (target.length) { 383 $('html,body').animate({ 384 scrollTop: target.offset().top - 100 385 }, 1000); 386 return false;
387 } 388 } 389 }); 390 391 392 393 394 /* 395 * Zip code lookup code 396 * ------------------------------------------- */ 397 $( "#ziplookup" ).autocomplete({ 398 source: "/wp-content/themes/shopkeeper-child/process/ziplookup.process.php?distance=50", 399 minLength: 5, 400 messages: { // Turn off autocomplete's showing status outside of the menu 401 noResults : '', 402 results: function() {} 403 }, 404 response: function(e,ui) { 405 // console.log('crossroads.js ui',ui); 406 // console.log('crossroads.js this',this); 407 var items = ui.content; 408 409 buildZipList($(this),items); 410 return; 411 }, 412 change: function(e,ui) { 413 // $(this).siblings('ul').remove(); 414 return; 415 }, 416 create: function(e,ui) { 417 // console.log('crossroads.js autocomplete created'); 418 }, 419 select: function(e,ui) { 420 window.location.href = ui.item.link; 421 $('#ziplookup').val(ui.item.address); 422 }, 423 focus: function(e,ui) { // Turn off autocomplete's showing item text outside of item box on hover 424 if ( e.keyCode === undefined ) { 425 return false; 426 } 427 return false; 428 // console.log('crossroads.js focusing'); 429 }, 430 search: function(e,ui) { 431 // console.log('crossroads.js searching'); 432 if ( $(this).siblings('ul').length > 0 ) { $(this).siblings('ul').remove(); } 433 $(this).parent().append('<ul class="ui-menu"></ul>'); 434 $(this).siblings('ul').append('<li class="ui-menu-msg">Searching...</li>'); 435 } 436 }); 437 438 $('#ziplookup').blur(function(){ 439 $(this).siblings('ul').fadeOut(); 440 }); 441 442 443 $( "#ziplookup-mobile" ).autocomplete({ 444 source: "/wp-content/themes/shopkeeper-child/process/ziplookup.process.php?distance=50", 445 minLength: 5, 446 messages: { // Turn off autocomplete's showing status outside of the menu 447 noResults : '', 448 results: function() {} 449 }, 450 response: function(e,ui) { 451 // console.log('crossroads.js ui',ui); 452 // console.log('crossroads.js this',this); 453 var items = ui.content; 454 455 buildZipList($(this),items); 456 return; 457 }, 458 change: function(e,ui) { 459 // $(this).siblings('ul').remove(); 460 return; 461 }, 462 create: function(e,ui) { 463 // console.log('crossroads.js autocomplete created'); 464 }, 465 select: function(e,ui) { 466 window.location.href = ui.item.link; 467 $('#ziplookup-mobile').val(ui.item.address); 468 }, 469 focus: function(e,ui) { // Turn off autocomplete's showing item text outside of item box on hover 470 if ( e.keyCode === undefined ) { 471 return false; 472 } 473 return false; 474 // console.log('crossroads.js focusing'); 475 }, 476 search: function(e,ui) { 477 // console.log('crossroads.js searching'); 478 if ( $(this).siblings('ul').length > 0 ) { $(this).siblings('ul').remove(); } 479 $(this).parent().append('<ul class="ui-menu"></ul>'); 480 $(this).siblings('ul').append('<li class="ui-menu-msg">Searching...</li>'); 481 } 482 }); 483 484 $('#ziplookup-mobile').blur(function(){ 485 $(this).siblings('ul').fadeOut(); 486 }); 487 488 function buildZipList($el,items) { 489 var total = ( !(items === undefined) ) ? items.length : 0; 490 491 if ( $el.siblings('ul').length > 0 ) { $el.siblings('ul').remove(); } 492 $el.parent().append('<ul class="ui-menu"></ul>'); 493 if ( total > 0 ) { 494 for ( i=0 ; i<total ; i++ ) { 495 496 $el.siblings('ul').append('<li class="ui-menu-item"><a href="' + items[i].link + '">' + items[i].address + '</a></li>'); 497 498 } 499 } else { 500 $el.siblings('ul').append('<li class="ui-menu-msg">No locations found for this zip code.</li>'); 501 } 502 } 503 504}); 505 506 507/* 508 * Log selected variables to the console, except when the console is not available. 509 * ------------------------------------------- */ 510function dumpConsole(theName,theValue) { 511 512 /* 513 * Expose defaults to allow users to define them independently 514 * ------------------------------------------- */ 515 var msg = theName; 516 theValue = ( theValue != undefined ) ? theValue : ''; 517 518 /* 519 * Does the browser have console capabilities 520 * ------------------------------------------- */ 521 if ( console != 'undefined' ) { 522 523 /* 524 * Objects have to be comma-delimited when printing to console 525 * ------------------------------------------- */ 526 if ( typeof theValue=='object' ) { 527 console.log(msg,":",theValue); 528 529 /* 530 * Anything that doesn't have a typeof='object' can be concatenated into a single str
530ing 531 * ------------------------------------------- */ 532 } else { 533 msg = ( theValue != '' ) ? msg + '=' + theValue : msg; 534 console.log(msg); 535 } 536 return true; 537 } 538 return false; 539} 540 541function urldecode(str) { 542 return decodeURIComponent((str+'').replace(/\+/g, '%20')); 543}
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.