1function trackGaEvent(category, action, label, eventValue) { 2 if (ga) { 3 console.log("event", category + " : " + action + " : " + label + " : " + eventValue); 4 try { 5 ga("send", "event", category, action, label, eventValue); 6 } catch (e) { 7 // ignore 8 } 9 } 10} 11var phoneUtilesjsPath = "/Scripts/Utils.js"; 12var LogJS = function () { 13 var debugFlag = true; 14 15 function logAjaxError(xhr, textStatus, errorThrown) { 16 if (debugFlag) { 17 console.log("xhr.responseText", xhr.responseText, "textStatus", textStatus, "errorThrown", errorThrown); 18 } 19 } 20 21 return { 22 LogAjaxError: logAjaxError 23 } 24}(); 25 26var LoginModalMainJs = function () { 27 var $loginModal; 28 var loginContentUrl; 29 var contentIsSet = false; 30 var preloadAfterInit = false; 31 var loginRetries = 0; 32 33 var init = function (loginModalContentUrl) { 34 loginContentUrl = loginModalContentUrl; 35 $loginModal = $("#loginModal"); 36 37 if (preloadAfterInit) { 38 preload(); 39 } 40 }; // init 41 42 // preload on the pages that most likely will use it 43 function preload(fromInfo) { 44 // in case preload runs before init 45 if (!loginContentUrl) { 46 preloadAfterInit = true; 47 return; 48 } 49 50 trackGaEvent("LoginModal", "Preload", fromInfo); 51 getLoginModalContent(null, false, false); 52 }; // preload 53 54 55 function showLogin(fromInfo, onLoadSuccessFunction, reloginFlag) { 56 if (fromInfo) { 57 trackGaEvent("LoginModal", "Show", fromInfo); 58 } 59 60 if (contentIsSet) { 61 refreshTokenShowLoginModal(onLoadSuccessFunction, reloginFlag); 62 return; 63 }; 64 65 getLoginModalContent(onLoadSuccessFunction, reloginFlag, true); 66 }; // showLogin 67 68 function showRelogin(fromInfo, onLoadSuccessFunction) { 69 trackGaEvent("LoginModal", "Relogin", fromInfo); 70 showLogin(null, onLoadSuccessFunction, true); 71 }; //showRelogin 72 73 function getLoginModalContent(onLoadSuccessFunction, reloginFlag, showFlag) { 74 if (contentIsSet) { 75 return; 76 } 77 var $loginBody = $loginModal.find(".modal-body"); 78 if (showFlag) { 79 // show login with a a spinner during $get 80 $loginBody.html(renderSpinner()); 81 $loginModal.modal("show"); 82 } 83 84 $.get(loginContentUrl, 85 function (html) { 86 $loginModal.find(".modal-dialog").html(html); 87 contentIsSet = true; 88 initLoginModal(true, onLoadSuccessFunction, reloginFlag); 89 }) 90 .fail(function (xhr, textStatus, errorThrown) { 91 LogJS.LogAjaxError(xhr, textStatus, errorThrown); 92 removeSpinner(); 93 $loginBody.html("Unexpected Error"); 94 }); 95 96 } // getLoginModal 97 98 function refreshTokenShowLoginModal(onLoadSuccessFunction, reloginFlag, doNotClearFields) { 99 var refreshTokenUrl = $("#RefreshTokenUrl").val(); 100 $.get(refreshTokenUrl, 101 function (html) { 102 var token = $(html).val(); 103 $("#loginModalForm").find("input[name=__RequestVerificationToken]").val(token); 104 105 $("#loginModal").modal("show"); 106 initLoginModal(false, onLoadSuccessFunction, reloginFlag, doNotClearFields); 107 108 }); 109 }; // refreshTokenShowLoginModal 110 111 function initLoginModal(fistLoad, onLoadSuccessFunction, reloginFlag, doNotClearFields) { 112 if (fistLoad) { 113 initLoginSubmitEvent(); 114 } 115 else if (!doNotClearFields) { 116 clearModalFields(); 117 } 118 119 if (reloginFlag) { 120 showReloginMessage(); 121 } 122 123 if (onLoadSuccessFunction) { 124 onLoadSuccessFunction(); 125 } 126 }; // initLoginModal 127 128 function showReloginMessage() { 129 if ($("#reloginMessage").find(".hidden") != undefined) { 130 $("#reloginMessage").removeClass("hidden"); 131 } 132 }; // showReloginMessage 133 134 135 function initLoginSubmitEvent() { 136 $("#loginModalForm").on("submit", 137 function (e) { 138 e.preventDefault(); 139 e.stopImmediatePropagation(); 140 $("#loginModalSubmitBtn").attr("disabled", ""); 141 var origLoginLabel = $("#loginModalSubmitBtn").val(); 142 $("#loginModalSubmitBtn").val("Logging in..."); 143 $("#responseContainer").html(""); 144 145 $.ajax({
146 url: "/ToastmastersAccount/LoginModal", 147 type: "POST", 148 data: $("#loginModalForm").serialize(), 149 success: function (data) { 150 // debugger; 151 $("#loginModalSubmitBtn").removeAttr("disabled").val(origLoginLabel); 152 if (data.success) { 153 changeHeaderAfterLogin(data.FirstName); 154 loadConsentsModal(); 155 $(document).trigger("loginEvent"); 156 return; 157 } 158 159 if (data.resultCode === "AntiForgery" && loginRetries <= 2) { 160 //retry 161 loginRetries += 1; 162 console.log("retry", loginRetries); 163 var submitLogin = function () { $("#loginModalForm").submit() }; 164 refreshTokenShowLoginModal(submitLogin, false, true); 165 } 166 167 $("#responseContainer").html(data.message); 168 }, 169 error: function (xhr, textStatus, errorThrown) { 170 $("#loginModalSubmitBtn").removeAttr("disabled").val(origLoginLabel); 171 $("#responseContainer").html("Unexpected Error"); 172 LogJS.LogAjaxError(xhr, textStatus, errorThrown); 173 } 174 }); 175 }); 176 177 }; // initLoginSubmitEvent 178 179 function loadConsentsModal() { 180 $.ajax({
181 url: "/api/sitecore/PrivacyConsent/GetModal", 182 type: "GET", 183 success: function (data) { 184 $("#PrivacyConsentContainer").html(data); 185 } 186 }); 187 } 188 189 return { 190 Init: init, 191 Preload: preload, 192 Show: showLogin, 193 ShowRelogin: showRelogin 194 } 195}(); //LoginModalMainJs 196 197function validateNonLatinCharacters() { 198 $("input[type='text'], input[type='email'], input[type='search'], textarea").each(function (index, element) { 199 var id = element.getAttribute("id"); 200 var val = $('#' + id).val(); 201 var regex = /[!@.#\$%\^&\*\(\)_|}{~`">':<\?/\]\[\\=\+\-;\w\s,]*/g; 202 var finalString = regex.exec(val); 203 if (val != undefined && val != "" && val != null) { 204 if (finalString == val) { 205 $('#' + id).parent().removeClass('has-error'); 206 $('#' + id).parent().removeClass('has-danger'); 207 $('#' + id).parent().find(".help-block").html(''); 208 } 209 else { 210 $('#' + id).parent().addClass('has-error'); 211 $('#' + id).parent().addClass('has-danger'); 212 $('#' + id).parent().find(".help-block").html('<ul class="list-unstyled"><li>Please remove non latin characters.</li></ul>'); 213 } 214 } 215 }); 216} 217 218$(document).on("click", function () { 219 $("input[type='text'], input[type='email'], input[type='search'], textarea").on('keyup keydown change click input', function (event) { 220 //Validate only keyboard keys 221 var backspaceKey = 8; 222 var tabKey = 9; 223 var enterKey = 13; 224 var shiftKey = 16; 225 var capsLockKey = 20; 226 var spaceKey = 32; 227 var tildKey = 126; 228 var hyphenKey = 173; 229 var semiColonKey = 186; 230 var graveAccentKey = 192; 231 var openBracketKey = 219; 232 var singleQuoteKey = 222; 233 234 if (event.keyCode == backspaceKey || event.keyCode == tabKey || event.keyCode == enterKey || event.keyCode == hyphenKey || (event.keyCode >= shiftKey && event.keyCode <= capsLockKey) || (event.keyCode >= spaceKey && event.keyCode <= tildKey) || (event.keyCode >= semiColonKey && event.keyCode <= graveAccentKey) || (event.keyCode >= openBracketKey && event.keyCode <= singleQuoteKey) || event.type == "click" || event.type == "change" || event.type == "input") { 235 var $target = $(event.target); 236 var value = $target.val(); 237 var regex = /[!@.#\$%\^&\*\(\)_|}{~`">':<\?/\]\[\\=\+\-;\w\s,]*/g; 238 var finalString = regex.exec(value); 239 $target.val(finalString); 240 } 241 else { 242 event.preventDefault(); 243 } 244 }); 245}); 246 247$(document).ready(function () { 248 249 $(".modal").on("show.bs.modal", function () { 250 $("html").css("overflow", "hidden"); 251 $(".modal-backdrop").removeClass("hide"); 252 253 }); 254 255 $(".modal").on("hide.bs.modal", function () { 256 $("html").attr("style", ""); 257 $(".modal-backdrop").addClass("hide"); 258 }); 259
260 if ($("#Description .more").children().length <= 0) { 261 $("#Description .body").addClass("solo"); 262 } 263 264 $("#added-to-cart-close").on("click", function () { 265 $("#added-to-cart").addClass("hidden"); 266 }); 267 268 $("#added-to-cart-close-button").on("click", function () { 269 $("#added-to-cart").addClass("hidden"); 270 }); 271 272 $("#id-continue-shopping").on("click", function () { 273 $("#added-to-cart").addClass("hidden"); 274 }); 275 276 $("#id-continue-shopping-view-cart").on("click", function () { 277 $("#added-to-cart").addClass("hidden"); 278 }); 279 280 281 // for membeship dialog 282 $("#cart-question-membership-link").on("click", function () { 283 $("#cart-question-membership-message").removeClass("hidden"); 284 }); 285 286 // for memberhsip dialog 287 $("#cart-question-membership-message-close").on("click", function () { 288 $("#cart-question-membership-message").addClass("hidden"); 289 }); 290 291 292 $("#btn-add-to-cart-2").on("click", function () { 293 $("#added-to-cart").removeClass("hidden"); 294 }); 295 296 297 $("#body").on("click", ".compare-items.bttn", function () { 298 $("#compare-modal").removeClass("hidden"); 299 }); 300 301 $(".bioItem").each(function () { 302 $(this).on("click", ".editable.bioImage", function (e) { 303 e.preventDefault(); 304 $("#EditPhoto").show(); 305 }); 306 $(this).on("click", ".close", function (e) { 307 e.preventDefault(); 308 $("#EditPhoto").hide(); 309 }); 310 }); 311 312 /* Adding in 3rd party chat buttons */ 313 314 $(".boldChat").each(function () { 315 !function (t, e, o, c, n, a) { var s = window.nanorep = window.nanorep || {}; s = s[e] = s[e] || {}, s.apiHost = a, s.host = n, s.path = c, s.account = t, s.protocol = "https:", s.on = s.on || function () { s._calls = s._calls || [], s._calls.push([].slice.call(arguments)) }; var p = s.protocol + "//" + n + c + o + "?account=" + t, l = document.createElement("script"); l.async = l.defer = !0, l.setAttribute("src", p), document.getElementsByTagName("head")[0].appendChild(l) }("toastmasters-cv19", "floatingWidget", "floating-widget.js", "/web/", "toastmasters-cv19.nanorep.co"); 316 317 nanorep.floatingWidget.on({ 318 init: function () { 319 this.setConfigId('2217073981'); 320 } 321 }); 322 }); 323 324 /*----------- NAVIGATION FUNCTIONALITY -----------*/ 325 326 var $mainNav = $(".mainHeader").find(".mainNav .mainMenu").clone(); 327 328 $(".menuWrap .mainNav").append($mainNav); 329 330 $(".mainHeader").on("click", ".navbar-toggle", function (e) { 331 e.preventDefault(); 332 333 $("body").hasClass("menu-active") ? $("body").off("click", menuToggleHandler) : $("body").on("click", menuToggleHandler); 334 $("body").toggleClass("menu-active"); 335 }); 336 337 if (getViewportW() >= 768) { 338 var header = $(".mainHeader"); 339 var secondarymenu = $(".secondary-menu-header"); 340 header.addClass("affix-top"); 341 secondarymenu.addClass("affix-top"); 342 343 $(window).on("scroll", function () { 344 if (window.pageYOffset > 0) { 345 header.removeClass("affix-top"); 346 header.addClass("affix"); 347 secondarymenu.removeClass("affix-top"); 348 secondarymenu.addClass("affix"); 349 } else { 350 header.addClass("affix-top"); 351 header.removeClass("affix"); 352 secondarymenu.addClass("affix-top"); 353 secondarymenu.removeClass("affix"); 354 } 355 }); 356 } 357 358 var menu = $(".mainNav .mainMenu, .secondaryNav .mainMenu"), 359 menuContainer = menu.closest(".mainNav"); 360 361 menu.find("a").each(function () { 362 if ($(this).siblings(".subMenu").length > 0) { 363 $(this).addClass("hasSub"); 364 } 365 }); 366 367 menu.each(function () { 368 $(this).on("click", "a", function (e) { 369 var currAnchor = $(this), 370 parentLi = currAnchor.closest("li"), 371 siblingUl = currAnchor.siblings(".subMenu, ul"),
372 isMainTier = currAnchor.siblings().hasClass("subMenu"); 373 374 if (siblingUl.length > 0) { 375 // Prevent other handlers 376 e.preventDefault(); 377 378 if (isMainTier) { 379 $("body").off("click", menuHandler); 380 381 // Toggle close when clicking and open link 382 if (parentLi.hasClass("clicked")) { 383 parentLi.removeClass("clicked").find(".subMenu").slideUp(); 384 } else { 385 // Otherwise Open submenu and attach body click handler 386 // Close any other open menus 387 menu.find(".subMenu").slideUp().closest(".clicked").removeClass("clicked"); 388 389 // Open this menu 390 parentLi.addClass("clicked").find(".subMenu").slideDown(); 391 392 $("body").on("click", menuHandler); 393 } 394 } else { 395 if (parentLi.hasClass("clicked")) { 396 parentLi.removeClass("clicked").find("ul").slideUp(); 397 } else { 398 parentLi.siblings().removeClass("clicked").find("ul").slideUp(); 399 parentLi.addClass("clicked").find("ul").slideDown(); 400 } 401 } 402 } 403 }); 404 405 }); 406 407 $(".topHeader").on("click", ".search-toggle", function (e) { 408 e.preventDefault(); 409 var $this = $(this); 410 411 $this.hasClass("active") ? $("body").off("click", searchToggleHandler) : $("body").on("click", searchToggleHandler); 412 $this.toggleClass("active").parents(".topHeader").find(".siteSearch").slideToggle(); 413 }); 414 415 function searchToggleHandler(e) { 416 if ($(e.target).parents(".siteSearch, .search-toggle").length <= 0 && !$(e.target).hasClass("siteSearch") && !$(e.target).hasClass("search-toggle") && e.originalEvent) { 417 $(".search-toggle").trigger("click"); 418 $("body").off("click", searchToggleHandler); 419 } 420 } 421 422 function menuToggleHandler(e) { 423 if ($(e.target).parents(".menuWrap").length <= 0 && !$(e.target).hasClass("menuWrap") && !$(e.target).hasClass("navbar-toggle") && e.originalEvent) { 424 $(".navbar-toggle").trigger("click"); 425 $("body").off("click", menuToggleHandler); 426 } 427 } 428 429 function menuHandler(e) { 430 if ($(e.target).parents(".mainNav").length <= 0 && $(e.target).parents(".secondaryNav").length <= 0 && e.originalEvent) { 431 menu.find(".subMenu").slideUp().closest(".clicked").removeClass("clicked"); 432 433 $("body").off("click", menuHandler); 434 } 435 } 436 437 /*----------- HERO BANNER FUNCTIONALITY -----------*/ 438 439 if (getViewportW() >= 768) { 440 var x = 1; 441 $(".heroBanners").addClass("isMasonry"); 442 $(".heroBanners .masonry .item").each(function (index, val) { 443 var $item = $(val); 444 445 setTimeout(function () { 446 lazyLoadImage($item); 447 }, (x * 200)); 448 x++; 449 450 if ($item.hasClass("interactive")) { 451 $item.hoverIntent({ 452 over: function (e) { 453 if ($item.find(".hoverlay img").length <= 0) { 454 var src = $item.find("img").data("hover-src"); 455 $item.find(".hoverlay").append("<img src=" + src + " alt='overlay'/>"); 456 } 457 $item.find(".hoverlay").stop(true, true).fadeIn(); 458 }, 459 out: function (e) { 460 if ($item.find(".hoverlay").length > 0) { 461 $item.find(".hoverlay").stop(true, true).fadeOut(); 462 } 463 }, 464 timeout: 200 465 }); 466 } 467 }); 468 } else { 469 lazyLoadImage($(".heroBanners .slide")); 470 } 471 472 /*------------ TIMELINE SLIDER FUNCTIONALITY ------------*/ 473 474 $(".timelineCallouts").each(function () { 475 var $panels = $(this).find(".panels"), 476 $tabs = $(this).find(".tabs"), 477 $indicator = $tabs.find(".indicator"); 478 479 $tabs.on("click", "a", function (e) { 480 e.preventDefault(); 481 var index = $(this).index(), 482 tabMove = (index * 33) + "%", 483 panelMove = "-" + (index * 100) + "%"; 484 485 $panels.find(".active").removeClass("active"); 486 $panels.children().eq(index).addClass("active"); 487 $panels.css("left", panelMove); 488 489 $indicator.css("left", tabMove).text((index + 1)); 490 491 if (index > 0) { 492 $indicator.addClass("hasPrev hasNext"); 493 if (index >= $panels.find(".panel").length - 1) { 494 $indicator.removeClass("hasNext"); 495 } 496 } else { 497 $indicator.removeClass("hasPrev").addClass("hasNext"); 498 } 499 500 }); 501 });
502 503 /*------------ TIMELINE SLIDER FUNCTIONALITY ------------*/ 504 505 $(".toolCallouts").each(function () { 506 var $container = $(this), 507 $panels = $container.find(".panels"), 508 $tabs = $container.find(".tabs"), 509 $transitionBG; 510 511 $tabs.on("click", "a", function (e) { 512 if (getViewportW() >= 768) { 513 e.preventDefault(); 514 var index = $(this).parents().index(), 515 background = $(this).data("bg"); 516 517 $tabs.find("a").removeClass("active"); 518 $(this).addClass("active"); 519 520 if (background) { 521 if ($transitionBG) { 522 $transitionBG.stop(true, true); 523 $transitionBG.fadeOut(function () { 524 $transitionBG.css("background-image", "url(" + background + ")").fadeIn(function () { 525 $container.css("background-image", "url(" + background + ")"); 526 }); 527 }); 528 } else { 529 $transitionBG = $("<div class='bg'/>"); 530 $transitionBG.css("background-image", "url(" + background + ")").fadeIn(function () { 531 $container.css("background-image", "url(" + background + ")"); 532 }); 533 $container.prepend($transitionBG); 534 } 535 } 536 $panels.children().removeClass("active"); 537 $panels.children().eq(index).addClass("active"); 538 } 539 }); 540 }); 541 542 /*------------ 90th Anniversary ------------*/ 543 544 $(".AnniversaryCallouts").each(function () { 545 var $container = $(this), 546 $panels = $container.find(".panels"), 547 $tabs = $container.find(".tabs"), 548 $infoPanelsBG = $container.find(".AnniversaryInfoPanels"); 549 550 $tabs.on("click", "a", function (e) { 551 if (getViewportW() >= 768) { 552 e.preventDefault(); 553 var index = $(this).parents().index(), 554 background = $(this).data("bg"); 555 $tabs.find("a").removeClass("active"); 556 $(this).addClass("active"); 557 558 if (background) { 559 if ($infoPanelsBG) { 560 $infoPanelsBG.stop(true, true); 561 $infoPanelsBG.fadeOut(0, function () { 562 $infoPanelsBG.css("background-image", "url(" + background + ")"); 563 $infoPanelsBG.fadeIn(1000); 564 }); 565 } 566 } 567 $panels.children().removeClass("active"); 568 $panels.children().eq(index).addClass("active"); 569 } 570 }); 571 }); 572 573 /*------------ GENERAL CALLOUT FUNCTIONALITY ------------*/ 574 575 $(".callouts .modHead").on("click", ".title", function (e) { 576 var $this = $(this); 577 578 if (getViewportW() < 768 && $this.children("a").length <= 0) { 579 e.preventDefault(); 580 581 if ($this.hasClass("active")) { 582 $this.removeClass("active"); 583 $this.parents(".modHead").siblings(".modContent").slideUp(); 584 } else { 585 $this.addClass("active"); 586 $this.parents(".modHead").siblings(".modContent").slideDown(); 587 } 588 } 589 }); 590 591 $(".callouts .modContent .row").each(function () { 592 $(this).find(".callout").matchHeights(); 593 }); 594 595 $(".itemListing .row").each(function () { 596 $(this).find(".item").matchHeights(); 597 }); 598 599 /*------------ FIND A CLUB FUNCTIONALITY ------------*/ 600 601 var itemListHidden = false; 602 603 $(".findList .nav-tabs").on("click", "a", function (e) { 604 e.preventDefault(); 605 $(".findList .tab-pane").removeClass("hide"); 606 $(this).tab("show"); 607 }); 608 609 $(".findList .itemList").on("click", "a", function (e) { 610 e.preventDefault(); 611 //PROGRAMMING MAY NEED TO DO SOMETHING LIKE HAVE AN API CALL INSTEAD BUT NEED TO INCLUDE V
611IEW MAP ASPECT 612 if (getViewportW() < 768) { 613 $(".findList").find(".nav-tabs .active").removeClass("active"); 614 $(".findList").find(".tab-pane.active").removeClass("in").addClass("hide"); 615 itemListHidden = true; 616 } 617 618 }); 619 620 $(window).resize(function () { 621 if (itemListHidden) { 622 $(".findList").find(".nav li:first-child a").tab("show"); 623 itemListHidden = false; 624 } 625 }); 626 627 /*------------ MEMBER SPOTLIGHT FUNCTIONALITY ------------*/ 628 $(".spotlightList .modHead, .filterList .modHead, .navList .modHead").on("click", ".expander", function (e) { 629 e.preventDefault(); 630 631 if (getViewportW() < 1200) { 632 if (getViewportW() > 1170) { 633 $("html").addClass("overflow"); 634 } 635 $(this).closest(".rail").toggleClass("active").find(".modContent").slideToggle(); 636 $("html").removeClass("overflow"); 637 } 638 639 }); 640 641 /*----------- List Expander ------------*/ 642 $(".expanderList").on("click", ".expander", function (e) { 643 e.preventDefault(); 644 645 var expandable = $(this).siblings(".expandable"); 646 647 if ($(this).hasClass("open")) { 648 $(this).removeClass("open"); 649 expandable.slideUp(); 650 } else { 651 $(this).addClass("open"); 652 expandable.slideDown(); 653 654 if ($(this).attr("data-transcript").length) { 655 var certificateId = $(this).attr("data-transcript"); 656 var link = $(this); 657 $.ajax({
658 url: "/My-Toastmasters/Profile/Award-Transcript", 659 type: "GET", 660 data: { "certificateId": certificateId }, 661 success: function (data) { 662 if (data != null) { 663 link.attr("data-transcript", ""); 664 var content = $(data).find("#mainContent").html(); 665 expandable.find(".row#" + certificateId).html(content); 666 } 667 } 668 }); 669 } 670 } 671 }); 672 673 // This is for handling ajax call without authorized access 674 $(document).ajaxError(function (event, jqXHR, ajaxSettings, thrownError) { 675 if (jqXHR.status === 401) { 676 LoginModalMainJs.ShowRelogin("ajaxError"); 677 return; 678 } 679 680 LogJS.LogAjaxError(jqXHR, ajaxSettings, thrownError); 681 }); 682}); 683/* WINDOW LOAD - MOSTLY STYLING ADJUSTMENTS */ 684 685$(window).load(function () { 686 if ($(".siteWrap.home").length > 0) { 687 document.getElementById("logoLink").focus(); 688 } 689 690 $(".callouts .modContent .row").each(function () { 691 $(this).find(".callout").matchHeights(); 692 }); 693 694 $(".itemListing .row").each(function () { 695 $(this).find(".item").matchHeights(); 696 }); 697 698 var recalcHeights = debounce(function () { 699 700 $(".callouts .modContent .row").each(function () { 701 $(this).find(".callout").css("minHeight", 0); 702 $(this).find(".callout").matchHeights(); 703 }); 704 705 $(".itemListing .row").each(function () { 706 $(this).find(".item").css("minHeight", 0); 707 $(this).find(".item").matchHeights(); 708 }); 709 }); 710 711 $(window).resize(recalcHeights); 712}); 713 714/*----------- LAZY LOADER FOR HERO BANNERS, ETC. -----------*/ 715 716function lazyLoadImage($container) { 717 var $image = $container.find("img"), 718 src = $image.data("src"); 719 720 $image.attr("src", src).on("load error", function () { 721 $(this).fadeIn(function () { 722 $container.addClass("loaded"); 723 }); 724 }); 725 726 if ($image.complete || typeof $image.complete === "undefined") { 727 $image.fadeIn(function () { 728 $container.addClass("loaded"); 729 }); 730 } 731} 732 733/*----------- DEBOUNCER -----------*/ 734 735// Returns a function, that, as long as it continues to be invoked, will not 736// be triggered. The function will be called after it stops being called for 737// N milliseconds. If `immediate` is passed, trigger the function on the 738// leading edge, instead of the trailing. 739 740function debounce(func, wait, immediate) { 741 var timeout; 742 return function () { 743 var context = this, args = arguments; 744 clearTimeout(timeout); 745 timeout = setTimeout(function () { 746 timeout = null; 747 if (!immediate) func.apply(context, args); 748 }, wait); 749 if (immediate && !timeout) func.apply(context, args); 750 }; 751};
752 753/*----------- GET VIEWPORT -----------*/ 754 755var getViewportW = function () { 756 var win = typeof window != "undefined" && window, 757 doc = typeof document != "undefined" && document, 758 docElem = doc && doc.documentElement; 759 760 var a = docElem["clientWidth"], b = win["innerWidth"]; 761 return a < b ? b : a; 762}; 763 764/*----------- Helper Functions -----------*/ 765 766function changeHeaderAfterLogin(firstName) { 767 var memberLink = $("<a></a>"); 768 memberLink.text("Welcome, " + firstName); 769 memberLink.attr("href", "/My-Toastmasters/Profile"); 770 memberLink.attr("class", "welcomeInfo"); 771 var oldMemberLink = $("#memberNav").find(".welcomeInfo"); 772 if (oldMemberLink != undefined) { 773 oldMemberLink.remove(); 774 } 775 $("#memberNav").prepend(memberLink); 776 777 $("#cartLink").attr("href", "/My-Toastmasters/Profile/View-Cart"); 778 779 $("#navItem_0").attr("href", "/Logout"); 780 $("#navItem_0").text("Logout"); 781} 782 783function clearModalFields() { 784 $("#responseContainer").html(""); 785 $("#UserName").val(""); 786 $("#Password").val(""); 787} 788
789function renderSpinner() { 790 return "<i id='spinner' class='fa fa-spinner fa-pulse fa-3x fa-fw centerSpinner' aria-hidden='true'></i>"; 791} 792 793function removeSpinner() { 794 $("#spinner").remove(); 795} 796 797$(document).on("submit", 798 ".siteSearchForm", 799 function () { 800 var form = $(this); 801 var term = form.find("input").val(); 802 var url = "/search#q=" + encodeURIComponent(term) + "&t=contentTab"; 803 form.prop("action", url); 804 }); 805 806$(document).on("click", "#acBtnSiteSearch", function () { searchAC(this); }); 807 808$(document).on("keyup", "#acTxtSiteSearch", 809 function (e) { 810 if (e.which === 13 || e.keyCode === 13) { 811 searchAC(this); 812 } 813 }); 814 815function searchAC(element) { 816 var term = $(element).closest(".siteSearch").find("input").val(); 817 var url = "/search#q=" + encodeURIComponent(term) + "&t=contentTab"; 818 819 window.location.href = url; 820} 821 822AddAntiForgeryToken = function (data) { 823 data.__RequestVerificationToken = $("input[name=__RequestVerificationToken]").val(); 824 return data; 825}; 826 827// Checks for number key press event 828function isNumberKey(evt) { 829 var charCode = (evt.which) ? evt.which : event.keyCode; 830 if (charCode > 31 && (charCode < 48 || charCode > 57)) 831 return false; 832 return true; 833} 834 835(function (TI, $, undefined) { 836 TI.GetTranslation = function (key, fallback, callback) { 837 if (fallback === undefined) { 838 fallback = ""; 839 } 840 841 if (key === undefined) { 842 return fallback; 843 } 844 845 try { 846 if (callback !== undefined) { 847 var url = "/api/translate/" + encodeURI(key); 848 $.ajax(url).done(function (data) { 849 callback(data); 850 }); 851 } 852 } 853 catch (error) { 854 return fallback; 855 } 856 } 857})(window.TI = window.TI || {}, jQuery); 858 859function tiExtend(ns, nsString, definition) { 860 // https://addyosmani.com/blog/essential-js-namespacing/ 861 var parts = nsString.split("."), 862 parent = ns, i; 863 864 if (parts[0] === "TI") { 865 parts = parts.slice(1); 866 } 867 868 var pl = parts.length; 869 for (i = 0; i < pl; i++) { 870 //create a property if it doesnt exist 871 if (typeof parent[parts[i]] == "undefined") { 872 parent[parts[i]] = {}; 873 } 874 875 parent = parent[parts[i]]; 876 } 877 878 if (jQuery.isEmptyObject(parent)) { 879 // Don't re-define 880 definition(parent, jQuery); 881 } 882} 883 884function trackClickEvent(category, label, element) { 885 if (element === undefined || element === null) { 886 return; 887 } 888 889 try { 890 element.on("click", function () { 891 ga("send", "event", category, "click", label); 892 return true; 893 }); 894 } 895 catch (exception) { 896 // 897 } 898 899 return; 900} 901 902// --- Google Analytics --- // 903const GA_CATEGORIES = { 904 PWA: "Progressive Web App" 905} 906 907function trackEvent(category, action, label, value) { 908 /// <summary>Track event with Google Analytics</summary> 909 /// <param name="category" type="String">Category</param> 910 /// <param name="action" type="String">Action</param> 911 /// <param name="label" type="String">Label (optional)</param> 912 /// <param name="value" type="Integer">Value (optional)</param> 913 914 if (!category || !action) return; 915 916 if (typeof (ga) != 'undefined') { 917 if (value) { 918 ga('send', 'event', category, action, label, value); 919 } else if (label) { 920 ga('send', 'event', category, action, label); 921 } else if (action) { 922 ga('send', 'event', category, action); 923 } 924 } 925} 926 927function initPhoneControl(doneCallBack, autoPlaceholdervalue, formatOnDisplayvalue) { 928 var phoneOptions = 929 { 930 initialCountry: "auto", 931 geoIpLookup: function (callback, doneCallBack) { 932 $.get('https://api.ipstack.com/check?access_key=9762c38e9b1d7ecfadbee3f776ef7d82&output=json&legacy=1', function () { }, "jsonp") 933 .always(function (resp) { 934 var countryCode = (resp && resp.country_code) ? resp.country_code : ""; 935 callback(countryCode); 936 }) 937 .done(function (resp) { 938 if (doneCallBack) { 939 doneCallBack(resp); 940 941 } else { 942 defaultDone(resp); 943 } 944 }) 945 .fail(function () { 946 console.log("ipinfo failed"); 947 }); 948 }, 949 formatOnDisplay: formatOnDisplayvalue, 950 autoPlaceholder: autoPlaceholdervalue, 951 allowExtensions: true, 952 utilsScript: phoneUtilesjsPath 953 }; 954 955 return phoneOptions; 956} 957 958function defaultDone(resp) { 959 if (resp && resp.country_code) { 960 _countryCode = resp.country_code.toLowerCase(); 961 if ($(".phone-iso")) { 962 initIntlPhoneIso();
963 } else { 964 initIntlPhoneIso1(); 965 } 966 967 } 968} 969 970function initIntlPhoneIso() { 971 if (_countryCode) { 972 $(".phone-iso").each(function () { 973 if ($(this).val() === "") 974 $(this).val(_countryCode); 975 }); 976 } 977} 978 979function initIntlPhoneIso1() { 980 if (_countryCode) { 981 if ($("#PhoneIso2").val() === "") { 982 $("#PhoneIso2").val(_countryCode); 983 } 984 } 985} 986 987function RedirectB2CLogin() { 988 if ($("#CurrentActionName").length > 0) { 989 var CurrentActionName = $("#CurrentActionName").val().toLowerCase(); 990 var CurrentControllerName = $("#CurrentControllerName").val().toLowerCase(); 991 var CurrentpostingLink = $("#CurrentpostingLink").val().toLowerCase(); 992 var locationRedirect = B2CLoginRedirect + "?returnUrl=" + window.location.pathname + "&CurrentActionName=" + CurrentActionName + "&CurrentControllerName=" + CurrentControllerName + "&CurrentpostingLink=" + CurrentpostingLink; 993 location.href = locationRedirect; 994 } 995 else { 996 var locationRedirect = B2CLoginRedirect + "?returnUrl=" + window.location.pathname; 997 location.href = locationRedirect; 998 } 999}
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.