1/** 2 * Check if Cash has been replaced by jQuery. If it has not, set jQuery 3 * as a `window` element. 4 */ 5if (typeof jQuery === 'undefined') { 6 window.jQuery = cash = $; 7} else { 8 var $ = jQuery.noConflict(); 9} 10 11 12(function (mivaJS) {}(window.mivaJS || (window.mivaJS = {}))); 13 14/** 15 * Cash/jQuery Extensions 16 */ 17$.extend({ 18 debounced: function (fn, timeout, invokeAsap, ctx) { 19 /** 20 * Custom function to allow us to delay events until after the 21 * trigger has ended. 22 * 23 * Example: $(window).on('resize', $.debounced(function () {...DO SOMETHING...}, 100)); 24 */ 25 if (arguments.length === 3 && typeof invokeAsap !== 'boolean') { 26 ctx = invokeAsap; 27 invokeAsap = false; 28 } 29 var timer; 30 31 return function () { 32 var args = arguments; 33 34 ctx = ctx || this; 35 invokeAsap && !timer && fn.apply(ctx, args); 36 clearTimeout(timer); 37 timer = setTimeout(function () { 38 invokeAsap || fn.apply(ctx, args); 39 timer = null; 40 }, timeout); 41 }; 42 }, 43 hook: function (hookName) { 44 /** 45 * Custom function to allow us to unify event triggers/binding 46 * using `data-` elements. 47 * 48 * Usage: $.hook('HOOK NAME')... 49 * Example: $.hook('open-menu').on('click', function (e) {e.preventDefault(); ELEMENT.show();}); 50 */ 51 var selector; 52 53 if (!hookName || hookName === '*') { 54 // select all data-hooks 55 selector = '[data-hook]'; 56 } 57 else { 58 // select specific data-hook 59 selector = '[data-hook~="' + hookName + '"]'; 60 } 61 return $(selector); 62 }, 63 loadScript: function (url, callback) { 64 /** 65 * Loads a JavaScript file asynchronously with a callback, like 66 * jQuery's `$.getScript()` except without jQuery. 67 * 68 * Usage: 69 * $.loadScript(FILE_PATH, function () { 70 * DO SOMETHING... 71 * }); 72 */ 73 var head = document.getElementsByTagName('head')[0], 74 scriptCalled = document.createElement('script'); 75 76 scriptCalled.async = true; 77 scriptCalled.src = url; 78 scriptCalled.onload = scriptCalled.onreadystatechange = function () { 79 if (!scriptCalled.readyState || /loaded|complete/.test(scriptCalled.readyState)) { 80 scriptCalled.onload = scriptCalled.onreadystatechange = null; 81 82 if (head && scriptCalled.parentNode) { 83 head.removeChild(scriptCalled) 84 } 85 86 scriptCalled = undefined; 87 88 if (callback) { 89 callback(); 90 } 91 } 92 }; 93 //head.insertBefore(scriptCalled, head.firstChild); 94 head.appendChild(scriptCalled) 95 } 96}); 97 98 99/** 100 * HTML Class Name 101 * This function will check if JavaScript is enabled, detect touch and hover 102 * capabilities, and modify the class list as needed. 103 */ 104(function () { 105 'use strict'; 106 107 var html = document.documentElement; 108 109 html.classList.remove('no-js'); 110 html.classList.add('js'); 111 112 /** 113 * Detect if the user is utilizing a touch interface. 114 */ 115 window.addEventListener('touchstart', function onFirstTouch() { 116 html.classList.add('touch'); 117 html.setAttribute('data-touch', ''); 118 window.USER_IS_TOUCHING = true; 119 sessionStorage.setItem('USER_IS_TOUCHING', true); 120 window.removeEventListener('touchstart', onFirstTouch, false); 121 }, false); 122 123 /** 124 * Detect if the user can hover over elements. 125 */ 126 window.addEventListener('mouseover', function onFirstHover() { 127 window.USER_CAN_HOVER = true; 128 sessionStorage.setItem('USER_CAN_HOVER', true); 129 window.removeEventListener('mouseover', onFirstHover, false); 130 }, false); 131}()); 132 133 134/** 135 * CSS Feature Detect - Used in place of Modernizr 136 * Returns true or false depending on your browser. Let's hope it's true. 137 * NOTE: This may be removed in future versions of the framework as 138 * browser compatibility and support changes. 139 * 140 * Usage: detectCSSFeature('transition'); 141 */ 142function detectCSSFeature(featureName) { 143 'use strict'; 144 145 var feature = false, 146 domPrefixes = 'Moz ms Webkit'.split(' '), 147 elm = document.createElement('div'), 148 featureNameCapital = null; 149 150 featureName = featureName.toLowerCase(); 151 if (elm.style[featureName] !== undefined) { 152 feature = true; 153 } 154 if (feature === false) { 155 featureNameCapital = featureName.charAt(0).toUpperCase() + featureName.substr(1); 156 for (var i = 0; i < domPrefixes.length; i++) { 157 if (elm.style[domPrefixes[i] + featureNameCapital] !== undefined) { 158 feature = true; 159 break; 160 } 161 } 162 } 163 return feature; 164} 165 166 167/** 168 * A complete cookies reader/writer framework with full unicode support. 169 * 170 * Revision #1 - September 4, 2014 171 * https://developer.mozilla.org/en-US/docs/Web/API/document.cookie 172 * https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie/Simple_document.cookie_framework 173 * https://developer.mozilla.org/User:fusionchess 174 * https://github.com/madmurphy/cookies.js 175 * 176 * This framework is released under the GNU Public License, version 3 or later. 177 * http://www.gnu.org/licenses/gpl-3.0-standalone.html 178 * 179 * Syntax: 180 * docCookies.setItem(name, value[, end[, path[, domain[, secure]]]]); 181 * docCookies.getItem(name); 182 * docCookies.removeItem(name[, path[, domain]]); 183 * docCookies.hasItem(name); 184 * docCookies.keys(); 185 */ 186var docCookies = { 187 getItem: function (sKey) { 188 if (!sKey) { 189 return null; 190 } 191 return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null; 192 }, 193 setItem: function (sKey, sValue, vEnd, sPath, sDomain, bSecure) { 194 if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) { 195 return false;
196 } 197 var sExpires = ""; 198 if (vEnd) { 199 switch (vEnd.constructor) { 200 case Number: 201 sExpires = vEnd === Infinity ? "; expires=Fri, 31 Dec 9999 23:59:59 GMT" : "; max-age=" + vEnd; 202 break; 203 case String: 204 sExpires = "; expires=" + vEnd; 205 break; 206 case Date: 207 sExpires = "; expires=" + vEnd.toUTCString(); 208 break; 209 } 210 } 211 document.cookie = encodeURIComponent(sKey) + "=" + encodeURIComponent(sValue) + sExpires + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "") + (bSecure ? "; secure" : ""); 212 return true; 213 }, 214 removeItem: function (sKey, sPath, sDomain) { 215 if (!this.hasItem(sKey)) { 216 return false; 217 } 218 document.cookie = encodeURIComponent(sKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT" + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : ""); 219 return true; 220 }, 221 hasItem: function (sKey) { 222 if (!sKey) { 223 return false; 224 } 225 return (new RegExp("(?:^|;\\s*)" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(document.cookie); 226 }, 227 keys: function () { 228 var aKeys = document.cookie.replace(/((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g, "").split(/\s*(?:\=[^;]*)?;\s*/); 229 for (var nLen = aKeys.length, nIdx = 0; nIdx < nLen; nIdx++) { 230 aKeys[nIdx] = decodeURIComponent(aKeys[nIdx]); 231 } 232 return aKeys; 233 } 234}; 235 236 237var elementsUI = { 238 site: function () { 239 /** 240 * Load the `polyfills.js` file and initialise functions. 241 * NOTE: This may be removed in future versions of the framework as 242 * browser compatibility and support changes. 243 */ 244 if (!window.CSS || !window.CSS.supports('(--foo: red)')) { 245 $.loadScript((window.public_theme_path || window.theme_path) + 'core/js/polyfills.js', function () { 246 sessionStorage.setItem('outdated', true); 247 cssCapabilities.init(); 248 }); 249 } 250 251 252 /** 253 * Load the `mini-modal.js` file and initialize functions. 254 * This is the default set of modal/light box functionality supplied with the framework. 255 */ 256 var targets = document.querySelectorAll('[data-mini-modal]'); 257 if (targets.length) { 258 $('head').append('<link type="text/css" rel="stylesheet" href="' + (window.public_theme_path || window.theme_path) + 'core/css/components/mini-modal.css">'); 259 $.loadScript((window.public_theme_path || window.theme_path) + 'core/js/mini-modal.js', function () { 260 for (var i = 0; i < targets.length; i += 1) { 261 var modal = minimodal(targets[i], { 262 // If you would like a global onLoaded callback, add your function here 263 //onLoaded: function () {}, 264 // If you would like a global onClosed callback, add your function here 265 //onClosed: function () {}, 266 // If you are using, and have, a Google Maps API Key, enter it here. 267 googleMapsAPIKey: '' 268 }); 269 270 if (!targets[i].id) { 271 targets[i].id = 'miniModal_' + i; 272 } 273 modal.init(); 274 } 275 }); 276 } 277 278 279 if (window.NodeList && !NodeList.prototype.forEach) { 280 NodeList.prototype.forEach = function (callback, thisArg) { 281 thisArg = thisArg || window; 282 for (var i = 0; i < this.length; i++) { 283 callback.call(thisArg, this[i], i, this); 284 } 285 }; 286 } 287 288 289 }, 290 291 pages: { 292 /* ---------- 293 Common : 294 ---------- */ 295 common: function () { 296 /** 297 * Add `ID` and `CLASS` attributes to `INPUT` and `SELECT` elements 298 * dynamically created by Miva. 299 */ 300 var mvtInputWraps = document.querySelectorAll('[data-hook~="mvt-input"]'); 301 var mvtSelectWraps = document.querySelectorAll('[data-hook~="mvt-select"]'); 302 303 mvtInputWraps.forEach(function (element) { 304 var classes = element.getAttribute('data-classlist'); 305 var id = element.getAttribute('data-id'); 306 var mvtInputs = element.querySelectorAll('input'); 307 308 mvtInputs.forEach(function (mvtInput) { 309 if (mvtInput.getAttribute('type') !== 'hidden') { 310 mvtInput.setAttribute('class', classes); 311 mvtInput.setAttribute('id', id); 312 } 313 }); 314 }); 315 316 mvtSelectWraps.forEach(function (element) { 317 var classes = element.getAttribute('data-classlist'); 318 var id = element.getAttribute('data-id'); 319 var mvtSelects = element.querySelectorAll('select'); 320
321 mvtSelects.forEach(function (mvtSelect) { 322 mvtSelect.setAttribute('class', classes); 323 mvtSelect.setAttribute('id', id); 324 }); 325 }); 326 327 }, 328 329 jsSFNT: function () { 330 }, 331 332 jsCTGY: function () { 333 }, 334 335 jsPROD: function () { 336 }, 337 338 jsPATR: function () { 339 }, 340 341 jsBASK: function () { 342 /** 343 * Estimate Shipping 344 */ 345 mivaJS.estimateShipping = function (element) { 346 'use strict'; 347 348 var currentModal = document.querySelector('[data-hook="' + element + '"]'); 349 var formElement = currentModal.querySelector('[data-hook="shipping-estimate-form"]'); 350 var formButton = formElement.querySelector('[data-hook="calculate-shipping-estimate"]'); 351 352 function createCalculation () { 353 var processor = document.createElement('iframe'); 354 355 processor.id = 'calculate-shipping'; 356 processor.name = 'calculate-shipping'; 357 processor.style.display = 'none'; 358 formElement.before(processor); 359 processor.addEventListener('load', function () { 360 displayResults(processor); 361 }); 362 formElement.submit(); 363 } 364 365 function displayResults (source) { 366 var content = source.contentWindow.document.body.innerHTML; 367 368 formElement.querySelector('[data-hook="shipping-estimate-fields"]').classList.add('u-hidden'); 369 formElement.querySelector('[data-hook="shipping-estimate-results"]').innerHTML = content; 370 formElement.setAttribute('data-status', 'idle'); 371 372 formElement.querySelector('[data-hook="shipping-estimate-recalculate"]').addEventListener('click', function () { 373 formElement.querySelector('[data-hook="shipping-estimate-results"]').innerHTML = ''; 374 formElement.querySelector('[data-hook="shipping-estimate-fields"]').classList.remove('u-hidden'); 375 }); 376 377 setTimeout( 378 function () { 379 source.parentNode.removeChild(source); 380 }, 1 381 ); 382 } 383 384 formButton.addEventListener('click', function (event) { 385 event.preventDefault(); 386 createCalculation(); 387 }, false); 388 }; 389 390 }, 391 392 jsORDL: function () { 393 }, 394 395 jsOCST: function () { 396 //added hidden fields to hold this data. Populate them with the onchange events below. 397 //This is to fix the problem with the clientside toggledetails.js script. 398 399 function Country_Change(prefix) { 400 $("#" + prefix + "Country").on("change", function() { 401 var optns = ""; 402 var optnsel = ""; 403 if ( $("#" + prefix + "Country").val() == "US" ) { 404 $("label[for='l-" + prefix + "Zip']").text('Zip Code'); 405 optns = $("#US_StateSelect").html(); 406 } else { 407 $("label[for='l-" + prefix + "Zip']").text('Postal Code'); 408 if ( $("#" + prefix + "Country").val() == "CA" ) { 409 optns = $("#CA_StateSelect").html(); 410 } else { 411 $("#l-" + prefix + "State").val(""); 412 } 413 } 414 if ( prefix == "Ship" ){ 415 if ( js_ShipStateSelect != "" ){ 416 optnsel = js_ShipStateSelect; 417 } 418 js_ShipStateSelect = ""; 419 js_ShipState = ""; 420 } else if ( prefix == "Bill" ){ 421 if ( js_BillStateSelect != "" ){ 422 optnsel = js_BillStateSelect; 423 } 424 js_BillStateSelect = ""; 425 js_BillState = "" 426 } 427 428 if ( optns.length > 0 ) { 429 $("#l-" + prefix + "State").prop('required',false); 430 $("#l-" + prefix + "State").val(""); 431 $("#l-" + prefix + "State").parent().hide(); 432 var statesel = $("#" + prefix + "StateSelect"); 433 statesel.html(optns); 434 statesel.parent().parent().show(); 435 if ( optnsel != ""){ 436 statesel.val(optnsel); 437 } 438 if ( prefix == "Ship" ){ 439 statesel.prop('required',true); 440 } 441 } else { 442 $("#l-" + prefix + "State").prop('required',true); 443 $("#l-" + prefix + "State").parent().show(); 444 var statesel = $("#" + prefix + "StateSelect"); 445 statesel.val(""); 446 statesel.parent().parent().hide(); 447 statesel.prop('required',false); 448 } 449 var isChecked = $('#billing_to_show').prop('checked'); 450 if (isChecked) { 451 $("#l-BillState").prop('required',false); 452 } 453 }); 454 455 } 456 457 $('#billing_to_show').on('change', function(){ 458 var isChecked = $('#billing_to_show').prop('checked'); 459 460 if (!isChecked) { 461 $('.c-form-submit-top').hide(); 462 $('.c-form-submit-bottom').show(); 463 } else { 464 $('.c-form-submit-top').show(); 465 $('.c-form-submit-bottom').hide(); 466 $("#l-BillState").prop('required',false); 467 } 468 }); 469 470 $("#submit_top").on('click', function(){ 471 var isChecked = $('#billing_to_show').prop('checked'); 472 if ( isChecked ){ 473 //ensure options are the same so clientside ToggleDetails does not fail. 474 $("#BillStateSelect").html( $("#ShipStateSelect").html() ); 475 } 476 }); 477 478 Country_Change("Ship"); 479 Country_Change("Bill"); 480 481 $("#ShipCountry").trigger("change"); 482 $("#BillCountry").trigger("change"); 483 }, 484 485 jsOSEL: function () { 486 }, 487 488 jsOPAY: function () { 489 /** 490 * Credit Card Detection 491 */ 492 $.loadScript((window.public_theme_path || window.theme_path) + 'core/js/payment-method.js', function () { 493 $.hook('detect-card').on('input', function () { 494 var cardInput = this; 495 496 if (isNaN(this.value)) { 497 this.classList.add('has-error'); 498 } 499 paymentMethod(this, function (paymentDetected) { 500 if (paymentDetected) { 501 cardInput.classList.remove('has-error'); 502 $.hook('payment-method-display').text(paymentDetected.display); 503 $.hook('payment-method').val(supportedPaymentMethods.findPaymentMethod(paymentDetected.name)); 504 } 505 }); 506 }); 507 }); 508 509 /** 510 * Added functionality to help style the default Miva output payment 511 * fields. 512 */ 513 $.hook('mvt-input').each(function () { 514 var dataHook = $(this).attr('data-datahook'); 515
516 if (dataHook) { 517 $(this).find('input').attr('data-hook', dataHook); 518 } 519 520 Array.prototype.forEach.call($(this), function (el) { 521 el.innerHTML = el.innerHTML.replace(/ /gi, ''); 522 }); 523 }); 524 525 $.hook('detect-card').attr('type', 'tel'); 526 527 $('[data-id="cvv"]').find('input').attr('type', 'tel'); 528 529 $.hook('mvt-select').find('select').each(function () { 530 var wrapDiv = document.createElement('div'), 531 select = this; 532 533 wrapDiv.classList.add('c-form-select'); 534 select.parentNode.insertBefore(wrapDiv, select); 535 wrapDiv.appendChild(select); 536 }); 537 538 // Chagnes CVV field to numeric format in safari 539 // $('#cc_cvv').attr("pattern", "[0-9]*"); 540 // $('#cc_cvv').attr("inputmode", "numeric"); 541 542 }, 543 544 jsINVC: function () { 545 /** 546 * Launch Printer Dialog 547 */ 548 $.hook('print-invoice').on('click', function (element) { 549 element.preventDefault(); 550 window.print(); 551 }); 552 }, 553 554 jsORDS: function () { 555 /** 556 * Launch Printer Dialog 557 */ 558 $.hook('print-invoice').on('click', function (element) { 559 element.preventDefault(); 560 window.print(); 561 }); 562 }, 563 564 jsLOGN: function () { 565 }, 566 567 jsACAD: function () { 568 }, 569 570 jsACED: function () { 571 }, 572 573 jsCABK: function () { 574 }, 575 576 jsCADA: function () { 577 }, 578 579 jsCADE: function () { 580 }, 581 582 jsAFCL: function () { 583 }, 584 585 jsAFAD: function () { 586 }, 587 588 jsAFED: function () { 589 }, 590 591 jsORHL: function () { 592 }, 593 594 jsCTUS: function () { 595 } 596 }, 597 598 theme: function (pageID) { 599 /** 600 * Call in additional functions as developed for theme. 601 */ 602 $.loadScript((window.public_theme_path || window.theme_path) + 'ui/js/theme.js?v=' + window.mivaJS.ThemeJS_Version, function () { 603 //window.addEventListener('load', 604 // $.debounced(function () { 605 themeFunctionality.init(); 606 607 if (themeFunctionality[pageID]) { 608 themeFunctionality[pageID](); 609 } 610 //}, 300), 611 // false 612 //); 613 }); 614 } 615}; 616 617 618(function () { 619 String.prototype.toCamelCase = function (cap1st) { 620 'use strict'; 621 622 return ((cap1st ? '-' : '') + this).replace(/-+([^-])/g, function (a, b) { 623 return b.toUpperCase(); 624 }); 625 }; 626 var pageID = document.body.id.toCamelCase(); 627 628 /** 629 * Initialize Global Site Functions 630 */ 631 elementsUI.site(); 632 633 /** 634 * Initialize Common Page Functions 635 */ 636 elementsUI.pages.common(); 637 638 /** 639 * Initialize Page Specific Functions 640 */ 641 if (elementsUI.pages[pageID]) { 642 elementsUI.pages[pageID](); 643 } 644 645 /** 646 * Initialize Theme Specific Function 647 */ 648 elementsUI.theme(pageID); 649}());
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.