1var pagesForSearch = new Array(); 2var typeaheadLinks = {}; 3var isApp = false; 4var isAndroid = false; 5var MAX_POLS = 75; 6var isMobileMenuOpen = false; 7 8$(document).ready(function () { 9 10 //Determine which version of IE to show .svg vs .png 11 if (+(/MSIE\s(\d+)/.exec(navigator.userAgent) || 0)[1] < 9) { 12 // IE8 or less 13 $('#logoImg').html('<img src="../../../images/siteMenuLogoWhite.png" alt="" border="0" />'); 14 $('#custSvcImg').html('<img src="../../../images/customerSvc.png" alt="" border="0" width="56" height="68" />'); 15 } 16 17 $('body').on("click", 'a[href="#"]', function (e) { 18 // javascript:void(0); no longer allowed in Content-Security-Policy. Use # instead and block page from jumping. 19 e.preventDefault ? e.preventDefault() : e.returnValue = false; 20 }); 21 22 $(".scrollTop").on('click', function (e) { 23 scrollTo(0, 0); 24 }); 25 26 // ===== SEARCH BAR ===== // 27 $.ajax({ 28 url: "/Search/Links", 29 type: "GET", 30 cache: false 31 }).done(function (dataReturned) { 32 $('#searchContainer .typeahead').autocomplete({ 33 lookup: dataReturned, 34 onSelect: function (suggestion) { 35 window.location = suggestion.data; 36 } 37 }); 38 }); 39 40 // ===== POLICY SELECTORS ===== // 41 var currPolNum; 42 43 //policy selector code 44 if ($("#changePol").length > 0) { 45 46 currPolNum = $('[name="policy_num"]').val().trim(); 47 $('#polSel').val(currPolNum); 48 49 $("#changePol").on("click", function () { 50 // Policy Select listener that refreshes the page with new policy number selected 51 var ref = $("#polSel option:selected").attr("data-ref"); 52 window.location = window.location.href.split("?")[0] + "?p=" + ref; 53 }); 54 } 55 56 //NEW policy selector code 57 if ($(".policyContainer").length > 0) { 58 currPolNum = $('[name="policy_num"]').val().trim(); 59 $('.policyBox[data-pol="' + currPolNum + '"]').addClass("activeBox").prepend('<div class="checkmark"></div>'); 60 61 $('.policyBox').on("click", function () { 62 window.location.href = $(this).attr("data-page") + "/" + $(this).attr("data-pol"); 63 }); 64 } 65 66 // If NEW policy selector is a drop-down due to too many policies 67 if ($('select[name="policySelector"]').length > 0) { 68 currPolNum = $('[name="policy_num"]').val().trim(); 69 $('select[name="policySelector"]').val(currPolNum); 70 71 $('select[name="policySelector"]').on('change', function () { 72 window.location.href = $(this).attr("data-page") + "/" + $(this).find(':selected').val(); 73 $(this).after('<div class="processing"><img src="/Content/Images/loadspin.gif" width="24" height="24" alt="Loading GIF"> Loading information...</div>'); 74 }); 75 } 76 77 78 // ===== NAVIGATION SUBMENUS ===== // 79 80 $(".dropdown-submenu ul").css("border-top", "1px solid #3C3E3E"); 81 82 // required to allow dropdowns to work properly on touch screens 83 $('.dropdown-menu').on('touchstart.dropdown.data-api', function (e) { e.stopPropagation(); }); 84 if ('ontouchstart' in window || navigator.MaxTouchPoints > 0 || navigator.msMaxTouchPoints > 0) { 85 // navigation dropdown menus for touchscreens 86 87 //Remove all existing bootstrap menu function to avoid interference. 88 $(".openOnHover a").attr("data-toggle", ""); 89 90 $('.openOnHover').on('mouseenter', function (e) { 91 $('.openOnHover').not(this).each(function () { 92 $(this).removeClass("open"); 93 }); 94 $(this).toggleClass("open"); 95 96 //If touch screen - add back the class Open 97 $('.openOnHover').on('touchstart', function () { 98 $('.openOnHover').not(this).each(function () { 99 $(this).removeClass("open"); 100 }); 101 $(this).toggleClass("open"); 102 }); 103 }); 104 105 $('.touchScreenOnly').css("display", "list-item"); 106 107 } 108 else { 109 110 // navigation dropdown menus for non-touchscreens 111 $(".openOnHover").on('mouseenter', function () { 112 $(".openOnHover").removeClass("open"); 113 $(this).addClass("open"); 114 }).on('mouseleave', function () { 115 var mainDropdownElem = this; 116 setTimeout(function () { 117 $(mainDropdownElem).removeClass("open"); 118 $(mainDropdownElem).removeClass("bg-grey"); 119 }, 100); 120 }); 121 122 $(".dropdown-menu").on('mouseover', function (event) { 123 $("#navBtn_" + $(this).attr("data-parent")).addClass("bg-orange"); 124 }).on('mouseleave', function (event) { 125 $("#navBtn_" + $(this).attr("data-parent")).removeClass("bg-orange"); 126 }); 127 } 128 129 $('#siteMobileMenu li a').on('click', function () { 130 if ($(this).siblings('.submenuDropdown').hasClass('collapse')) { 131 //Clear all existing opened slots 132 $(this).parent().siblings().children('.submenuDropdown').addClass('collapse').css('padding-bottom', '0px');
133 $(this).parent().siblings().removeClass('highlightBackground'); 134 //Add classes to chosen slot 135 $(this).siblings('.submenuDropdown').removeClass('collapse').css('padding-bottom', '10px'); 136 $(this).parent().addClass('highlightBackground'); 137 } 138 else { 139 //Collapse and remove orange highlight 140 $(this).siblings('.submenuDropdown').addClass('collapse').css('padding-bottom', '0px'); 141 $(this).parent().removeClass('highlightBackground'); 142 } 143 }); 144 145 146 // ===== NAVIGATION BAR ===== // 147 148 if ($('[name="query_app"]').val() === "1") { 149 isMobileApp(); 150 } 151 152 /*Mobile menu click listeners */ 153 $('#menuBtn').on('click', function () { 154 mobileMenu(); 155 }); 156 157 $('#closeX').on('click', function () { 158 mobileMenu(); 159 }); 160 161 // If window is resized, change navbar positioning back and forth 162 $(window).on('resize', function () { 163 if (isMobileSize()) { 164 if (isMobileMenuOpen) { 165 $("#myNavBar").css({ "top": "0", "position": "fixed" }); 166 $.scrollLock(true); 167 168 if ($("#appBanner").is("visible")) { 169 $(".containerContentMobile").css("top", "10px"); 170 } 171 } else { 172 if ($("#appBanner").is(":visible")) { 173 if ($(window).scrollTop() > $("#appBanner").outerHeight(true)) { 174 $(".navbar").css({ "top": "0", "position": "fixed" }); 175 } else { 176 $(".navbar").css({ "top": "", "position": "relative" }); 177 $(".containerContentMobile").css("top", "10px"); 178 } 179 } else { 180 $(".navbar").css({ "top": "", "position": "fixed" }); 181 $(".containerContentMobile").css("top", "95px"); 182 } 183 } 184 } else { 185 $(".navbar").css({ "top": "", "position": "" }); 186 $.scrollLock(false); 187 } 188 }); 189 190 /*Mobile menu side slider */ 191 /* Set the width of the side navigation to 250px */ 192 function mobileMenu() { 193 if ($('#siteMobileMenu').hasClass("removeWidth")) { 194 //Open Mobile Menu 195 $('#siteMobileMenu').addClass("expandWidth"); 196 $('#siteMobileMenu').removeClass("removeWidth"); 197 $('body').append('<div class="overlay"></div>'); 198 $('#menuBtnFrame').addClass("hide"); 199 $('#closeX').removeClass("hide"); 200 // Locks the page 201 $.scrollLock(true); 202 isMobileMenuOpen = true; 203 $("#myNavBar").css("position", "fixed"); 204 } else { 205 //Close Mobile Menu 206 $('#siteMobileMenu').addClass("removeWidth"); 207 $('#siteMobileMenu').removeClass("expandWidth"); 208 $('.overlay').remove(); 209 $('#closeX').addClass("hide"); 210 $('#menuBtnFrame').removeClass("hide"); 211 // unlocks the page 212 $.scrollLock(false); 213 isMobileMenuOpen = false; 214 215 // If mobile app promo banner is shown 216 if ($("#appBanner").is(":visible")) { 217 // If the user has scrolled past the banner 218 if ($(window).scrollTop() >= $("#appBanner").outerHeight(true)) { 219 $("#myNavBar").css("position", "fixed"); 220 } 221 // If the banner is still seen in the browser window 222 else { 223 $("#myNavBar").animate({ 224 top: $("#appBanner").outerHeight(true) - $(window).scrollTop() 225 }, 100, function () { 226 $("#myNavBar").css({ "position": "relative", "top": "" }); 227 }); 228 } 229 } 230 } 231 } 232 233 234 // ===== FOOTER ===== // 235 236 //Determine which page the footer is on to determine height 237 var footerHeight = "248px"; //Default for inside lobby 238 239 if (window.location.pathname.toLowerCase().indexOf("outsidelobby") !== -1) { 240 footerHeight = "200px"; 241 } 242 else if (window.location.pathname.toLowerCase().indexOf("login") !== -1 || (window.location.pathname.toLowerCase().indexOf("optout") !== -1)) { 243 footerHeight = "157px"; 244 } 245 else if (window.location.pathname.toLowerCase().indexOf("register") !== -1 || window.location.pathname.toLowerCase().indexOf("forgot") !== -1) { 246 footerHeight = "200px"; 247 } 248 249 // Footer mobile menu click listeners 250 $('#footerMobileBtn').on('click', function () { 251 mobileMenuFooter(); 252 }); 253 254 /* Mobile Menu footer dropwdown */ 255 function mobileMenuFooter() { 256 if ($('#footerMenuArrowRight').css("display") === "block") { 257 $('#footerMenuArrowRight').css("display", "none"); 258 $('#footerMenuArrowDown').css("display", "block"); 259 $('#footerMenuContent').css("height", footerHeight); 260 } else { 261 $('#footerMenuArrowRight').css("display", "block"); 262 $('#footerMenuArrowDown').css("display", "none"); 263 $('#footerMenuContent').css("height", "0px"); 264 } 265 } 266 267 268 // ===== MODALS ===== // 269 270 // Accessibility for modals. Keep tabbing within modal windows.
271 var parentPageElements = $('header, div#desktopHeader, .navbar, .nav, footer, div#footer, .skipToMain, [data-toggle="modal"], #pageContent'); 272 273 $(".modal").on("shown.bs.modal", function (e) { 274 parentPageElements.attr("aria-hidden", "true"); 275 $(this).find(".modal-body").trigger('focus'); 276 277 var elements = $(this).find("button, [href]"); 278 var firstElement = elements.first(); 279 var lastElement = elements.last(); 280 281 //redirect last tab to first tabbable item 282 lastElement.on('keydown', function (e) { 283 if (e.which === 9 && !e.shiftKey) { 284 e.preventDefault(); 285 firstElement.trigger('focus'); 286 } 287 }); 288 289 //redirect first shift+tab to last tabbable item 290 firstElement.on('keydown', function (e) { 291 if (e.which === 9 && e.shiftKey) { 292 e.preventDefault(); 293 lastElement.trigger('focus'); 294 } 295 }); 296 }); 297 298 $(".modal").on("hidden.bs.modal", function (e) { 299 parentPageElements.removeAttr("aria-hidden"); 300 }); 301 302 // ====== Password Strength ====== // 303 304 $('#newPassword').on("keyup", function () { 305 (passwordStrength($('#newPassword').val())) ? hidePasswordReqs() : showPasswordReqs(); 306 }); 307 308}); //End doc ready 309 310function trapFocusForModal(modalSelector) { 311 let modal = document.querySelector(modalSelector); 312 if (!modal) { 313 console.warn("Modal not found for selector"); 314 return; 315 } 316 317 let focusableSelectors = [ 318 'a[href]', 'button:not([disabled])', 'textarea:not([disabled])', 319 'input:not([disabled])', 'select:not([disabled])', '[tabindex]:not([tabindex="-1"])' 320 ]; 321 322 let focusableElements = []; 323 let firstFocusable, lastFocusable; 324 325 function updateFocusableElements() { 326 let allFocusable = Array.prototype.slice.call( 327 modal.querySelectorAll(focusableSelectors.join(',')) 328 ); 329 // Only visible elements 330 focusableElements = allFocusable.filter(function (el) { 331 return el.offsetParent !== null && 332 window.getComputedStyle(el).visibility !== 'hidden' && 333 window.getComputedStyle(el).display !== 'none'; 334 }); 335 firstFocusable = focusableElements[0]; 336 lastFocusable = focusableElements[focusableElements.length - 1]; 337 } 338 339 function handleTab(e) { 340 updateFocusableElements(); // Always use current visible elements 341 if (focusableElements.length === 0) return; 342 if (e.key === 'Tab') { 343 if (e.shiftKey) { 344 if (document.activeElement === firstFocusable) { 345 e.preventDefault(); 346 lastFocusable.focus(); 347 } 348 } else if (document.activeElement === lastFocusable) { 349 e.preventDefault(); 350 firstFocusable.focus(); 351 } 352 } 353 } 354 355 modal.addEventListener('keydown', handleTab); 356 357 // Initial focus 358 updateFocusableElements(); 359 if (firstFocusable) firstFocusable.focus(); 360 361 // Remove event listener when modal closes 362 modal.addEventListener('hidden', function () { 363 modal.removeEventListener('keydown', handleTab); 364 }); 365 366 // Expose update function for carousel events 367 modal._updateTrapFocus = updateFocusableElements; 368} 369 370function authedAjaxRequest(requestObject, callbackFunction, failbackFunction = null) { 371 372 if (typeof requestObject.complete === 'undefined') { 373 requestObject.complete = function (xhr, textStatus) { 374 if (xhr.responseText === "") { 375 checkIfStillLoggedIn(); 376 } 377 }; 378 } 379 380 if (failbackFunction !== null) { 381 $.ajax(requestObject).done(function (responseObject) { 382 callbackFunction(responseObject); 383 }).fail(function (jqXHR, textStatus) { 384 failbackFunction(jqXHR, textStatus); 385 }); 386 } 387 else { 388 $.ajax(requestObject).done(function (responseObject) { 389 callbackFunction(responseObject); 390 }); 391 } 392} 393 394function isMobileApp() { 395 isApp = true; 396 $("body").css("background-color", "#E15525"); 397 $("body").html('<div id="outdated-app-banner"><img src="/Content/Images/OutdatedAppBanner.png" /><span>New Updated App Available</span><p>Please be informed that this app is now unavailable. Visit the App Store or Google Play Store to download the new NYCM Insurance Mobile App.</p><p>After successfully installing the new NYCM Insurance Mobile App, you can delete this one from your device.</p><p>Thank you for your understanding.</p><p>NYCM Insurance</p></div>'); 398 document.cookie = "isMobileApp=Y"; 399} 400 401function isMobileAppAndroid() { 402 isMobileApp(); 403 isAndroid = true; 404 setTimeout(function () { return Android.showView(); }, 1000); 405} 406 407function isMobileSize() { 408 return viewport().width < 979; 409} 410 411function getDeviceType() { 412 let ua = navigator.userAgent || window.opera; 413 414 if (/android/i.test(ua)) { 415 return "Android"; 416 } 417 if (/iPad|iPhone|iPod/.test(ua) && !window.MSStream) { 418 return "iOS"; 419 } 420 return "Desktop"; 421} 422 423function closeView() { 424 if (isAndroid) { 425 return Android.closeView(); 426 } 427 else { 428 window.location = "#closeview"; 429 } 430} 431 432function getCookie(cname) { 433 var name = cname + "="; 434 var decodedCookie = decodeURIComponent(document.cookie); 435 var ca = decodedCookie.split(';'); 436 for (var i of ca) { 437 var c = i; 438 while (c.charAt(0) === ' ') { 439 c = c.substring(1); 440 } 441 if (c.indexOf(name) === 0) { 442 return c.substring(name.length, c.length); 443 } 444 } 445 return ""; 446} 447 448function getNYCMAFTValue() { 449 return $('input[name="__RequestVerificationToken"]').val(); 450} 451 452function getFormattedDate(passedDate) { 453 passedDate = passedDate.replace(/-/g, '/'); 454 var date = new Date(passedDate); 455 456 var year = date.getFullYear(); 457
458 var month = (1 + date.getMonth()).toString(); 459 month = month.length > 1 ? month : '0' + month; 460 461 var day = date.getDate().toString(); 462 day = day.length > 1 ? day : '0' + day; 463 464 return month + '/' + day + '/' + year; 465} 466 467function getParameterByName(name, url) { 468 if (!url) url = window.location.href; 469 name = name.replace(/[\[\]]/g, "\\$&"); 470 var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), 471 results = regex.exec(url); 472 if (!results) return null; 473 if (!results[2]) return ''; 474 return decodeURIComponent(results[2].replace(/\+/g, " ")); 475} 476 477function stripSpaces(value) { 478 if (value === null || value === undefined) return ""; 479 480 return String(value).replace(/\s+/g, ""); 481} 482 483function popovers() { 484 485 // Popover options 486 var options = { 487 container: 'body', 488 placement: function (context, source) { 489 490 var windowSize = viewport().width; 491 var positionLeft = $(source).offset().left - $(window).scrollLeft(); 492 var positionRight = windowSize - positionLeft + $(source).width(); 493 494 if (positionRight < 147) { 495 return "left"; 496 } else if (positionLeft < 147) { 497 return "right"; 498 } else { 499 return "bottom"; 500 } 501 }, 502 trigger: "manual", 503 html: true 504 }; 505 506 // Show popovers when mouse is hovered over icon 507 $('[rel="popover"]').popover(options).on("mouseenter", function (e) { 508 $('[rel="popover"]').each(function () { 509 if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) { 510 $(this).popover('hide'); 511 } 512 }); 513 $(this).popover("show"); 514 }).on("mouseout", function (e) { 515 $(this).popover('hide'); 516 }); 517 518 // Hide popovers when outside of popover is clicked. Applied to form due to iPhones. 519 $("body").on("click", function (e) { 520 $('[data-toggle="popover"]').each(function () { 521 if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) { 522 $(this).popover('hide'); 523 } 524 }); 525 }); 526 527 // Hide popovers when browser is resized. 528 $(window).on('resize', function () { 529 $('[rel="popover"]').popover("hide"); 530 }); 531} 532 533function viewport() { 534 var e = window, a = 'inner'; 535 if (!('innerWidth' in window)) { 536 a = 'client'; 537 e = document.documentElement || document.body; 538 } 539 return { width: e[a + 'Width'], height: e[a + 'Height'] }; 540} 541 542function checkIfStillLoggedIn() { 543 $.ajax({ 544 url: "/Home/IsAuthenticated", 545 cache: false 546 }).done(function (dataReturned) { 547 if (dataReturned === "false") { 548 window.location = "/Login/Index"; 549 } 550 }); 551} 552 553function aValueExists(value) { 554 if (value === null || value === undefined || value === "") return false; 555 556 if (typeof value === "string") { 557 if (value.trim() === "") return false; 558 } 559 560 return true; 561} 562 563function showPasswordReqs() { 564 $("#passwordStrength").css("display", "inline-block"); 565} 566 567function hidePasswordReqs() { 568 $("#passwordStrength").css("display", "none"); 569} 570 571function passwordStrength(password) { 572 573 (password == "") ? hidePasswordReqs() : showPasswordReqs(); 574 575 (password.match(nycmRegExps.pwLength)) ? $('#ruleLength').addClass('metReq') : $('#ruleLength').removeClass('metReq'); 576 577 (password.match(nycmRegExps.alphaUpper)) ? $('#ruleUpper').addClass('metReq') : $('#ruleUpper').removeClass('metReq'); 578 579 (password.match(nycmRegExps.alphaLower)) ? $('#ruleLower').addClass('metReq') : $('#ruleLower').removeClass('metReq'); 580 581 (password.match(nycmRegExps.numeric)) ? $('#ruleNumeric').addClass('metReq') : $('#ruleNumeric').removeClass('metReq'); 582 583 (password.match(nycmRegExps.specialChar)) ? $('#ruleSpecial').addClass('metReq') : $('#ruleSpecial').removeClass('metReq'); 584 585 var result = (password.match(nycmRegExps.pwLength) && password.match(nycmRegExps.alphaUpper) && password.match(nycmRegExps.alphaLower) && password.match(nycmRegExps.numeric) && password.match(nycmRegExps.specialChar)) ? true : false; 586 587 return (result); 588} 589 590function isAssignedRisk(policy) { 591 if (!aValueExists(policy)) return false; 592 return policy.trim().substring(0, 1).toUpperCase() == "T" || policy.trim().substring(0, 1).toUpperCase() == "S"; 593} 594 595 596// CLICK TRACKING 597 598function trackButtonClick(eventId, location) { 599 $.ajax({ 600 url: "/EventTracking/TrackClick", 601 type: "POST", 602 data: { 603 eventId: eventId, // unique identifier for Button (e.g. "Manage Policy") 604 location: location // page location (e.g. "Homepage") 605 }, 606 cache: false 607 }).done(function (dataReturned) {
608 // Do nothing 609 }); 610} 611 612 613// FREQUENTLY USED REGULAR EXPRESSIONS 614var nycmRegExps = new Object(); 615nycmRegExps.policy = /^(([39][0-9]{5})|([467LlTtSsVvZz][0-9]{6})|([148][0-9]{7}))$/; 616nycmRegExps.zip = /^((\d{5}-?\d{4})|(\d{5})|([A-Za-z]\d[A-Za-z]\s?\d[A-Za-z]\d))$/; 617nycmRegExps.email = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,10}$/; 618nycmRegExps.phone = /^(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}$/; 619nycmRegExps.last4 = /^[0-9]{4}$/; 620nycmRegExps.username = /^[a-zA-Z0-9.@]{6,36}$/; 621nycmRegExps.fpusername = /^[A-Za-z0-9!@@$&*)_:.? -]{4,36}$/; 622nycmRegExps.password = /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[\!@#$%^&*()_\-+={[}\]\|\\:;,\.\?/~`]).{8,64}$/; 623nycmRegExps.space = /^.*(\w+)(\s+)(\w+).*$/; 624nycmRegExps.policyholder = /^[a-zA-Z0-9\.\'\-\s\&]+$/; 625nycmRegExps.greetingname = /^[A-Za-z0-9\.\'\-\s]{2,50}$/; 626nycmRegExps.specialChar = /([\!@#$%^&*()_\-+={[}\]\|\\:;,\.\?/~`])/; 627nycmRegExps.numeric = /([0-9])/; 628nycmRegExps.alphaUpper = /[A-Z]/; 629nycmRegExps.alphaLower = /[a-z]/; 630nycmRegExps.pwLength = /^.{8,64}$/; 631nycmRegExps.alphanumeric = /^[a-zA-Z0-9]*$/ 632nycmRegExps.alphanumericWithSpecials = /^[a-zA-Z0-9!@#$^*_\-+:;',.?&()\" ]*$/;
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.