1/** 2 * 3 * TODO: Remove this line after 03/19/2025 4 * 5 * Create Brand US/CA namespace objects 6 * 7 * @author dvo2 8 * @since 03/18/2021 9 */ 10gmfx$.createNameSpace('gmfx'); 11gmfx$.createNameSpace('gmfx.cms'); 12gmfx$.createNameSpace('gmfx.cms.www'); 13gmfx$.createNameSpace('gmfx.cms.www.configs'); 14gmfx$.createNameSpace('gmfx.cms.www.constants'); 15gmfx$.createNameSpace('gmfx.cms.www.utils'); 16gmfx$.createNameSpace('gmfx.cms.www.models'); 17gmfx$.createNameSpace('gmfx.cms.www.services'); 18gmfx$.createNameSpace('gmfx.cms.www.components'); 19gmfx$.createNameSpace('gmfx.cms.www.templates'); 20 21/** 22 * Initialize global Brand namespace objects 23 * 24 * @author dvo2 25 * @since 03/18/2021 26 */ 27var gmfxWww = gmfx.cms.www, 28 gmfxWwwConfigs = gmfxWww.configs, 29 gmfxWwwConstants = gmfxWww.constants, 30 gmfxWwwTemplateConstants = gmfxWwwConstants.template, 31 gmfxWwwUtils = gmfxWww.utils, 32 gmfxWwwComponents = gmfxWww.components, 33 gmfxWwwModels = gmfxWww.models, 34 gmfxWwwServices = gmfxWww.services, 35 gmfxWwwTemplates = gmfxWww.templates; 36 37/** 38 * FinalInstallmentForm object designed to inherit BaseForm methods and validate form fields 39 * 40 * USAGE: var finalInstallmentForm = new FinalInstallmentForm() 41 * 42 * @author mmustaine 43 * @since 7/6/2021 44 */ 45gmfxWwwServices.FinalInstallmentForm = function() { 46 'use strict'; 47 48 // ************************************************************************ 49 // CREATE FinalInstallmentForm OBJECT 50 // ************************************************************************ 51 /** 52 * Create a FinalInstallmentForm constructor w/ the provided custom configurations 53 * 54 * @constructor 55 */ 56 var FinalInstallmentForm = function(config) { 57 // Configure this specific form instance and its fields 58 var fieldCurrentBalance = {}, 59 fieldLastPaymentReceived = {}, 60 fieldNextDueDate = {}, 61 fieldMaturityDate = {}, 62 fieldApr = {}, 63 fieldMonthlyPayment = {}, 64 formPrefix = "finalInstallment-", 65 formPrefixIdSelector = "#" + formPrefix, 66 formData = {}; 67 68 formData.$currentForm = gmfx$(formPrefixIdSelector + "form", config); 69 formData.$header = gmfx$(formPrefixIdSelector + "header", config); 70 formData.$submitButton = gmfx$(formPrefixIdSelector + "submit", formData.$currentForm); 71 72 formData.$validateFields = []; 73 fieldCurrentBalance[gmfxMomentumFormConstants.FIELD_NAME] = "currentBalance"; 74 fieldCurrentBalance[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "currentBalance"), formData.$currentForm); 75 fieldCurrentBalance[gmfxMomentumFormConstants.FIELD_EVENT] = (gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP + " " + gmfxMomentumCoreConstants.EVENT_LABEL_CHANGE); 76 formData.$validateFields.push(fieldCurrentBalance); 77 78 fieldLastPaymentReceived[gmfxMomentumFormConstants.FIELD_NAME] = "lastPaymentReceived"; 79 fieldLastPaymentReceived[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "lastPaymentReceived"), formData.$currentForm); 80 fieldLastPaymentReceived[gmfxMomentumFormConstants.FIELD_EVENT] = (gmfxMomentumCoreConstants.EVENT_LABEL_FOCUS_IN + " " + gmfxMomentumCoreConstants.EVENT_LABEL_CHANGE); 81 formData.$validateFields.push(fieldLastPaymentReceived); 82 83 fieldNextDueDate[gmfxMomentumFormConstants.FIELD_NAME] = "nextDueDate"; 84 fieldNextDueDate[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "nextDueDate"), formData.$currentForm); 85 fieldNextDueDate[gmfxMomentumFormConstants.FIELD_EVENT] = (gmfxMomentumCoreConstants.EVENT_LABEL_FOCUS_IN + " " + gmfxMomentumCoreConstants.EVENT_LABEL_CHANGE); 86 formData.$validateFields.push(fieldNextDueDate); 87 88 fieldMaturityDate[gmfxMomentumFormConstants.FIELD_NAME] = "maturityDate"; 89 fieldMaturityDate[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "maturityDate"), formData.$currentForm); 90 fieldMaturityDate[gmfxMomentumFormConstants.FIELD_EVENT] = (gmfxMomentumCoreConstants.EVENT_LABEL_FOCUS_IN + " " + gmfxMomentumCoreConstants.EVENT_LABEL_CHANGE); 91 formData.$validateFields.push(fieldMaturityDate); 92 93 fieldApr[gmfxMomentumFormConstants.FIELD_NAME] = "apr"; 94 fieldApr[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "apr"), formData.$currentForm); 95 fieldApr[gmfxMomentumFormConstants.FIELD_EVENT] = (gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP + " " + gmfxMomentumCoreConstants.EVENT_LABEL_CHANGE); 96 formData.$validateFields.push(fieldApr); 97 98 fieldMonthlyPayment[gmfxMomentumFormConstants.FIELD_NAME] = "monthlyPayment"; 99 fieldMonthlyPayment[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "monthlyPayment"), formData.$currentForm); 100 fieldMonthlyPayment[gmfxMomentumFormConstants.FIELD_EVENT] = (gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP + " " + gmfxMomentumCoreConstants.EVENT_LABEL_CHANGE); 101 formData.$validateFields.push(fieldMonthlyPayment); 102 103 // Instantiate this form w specific custom configs 104 config[gmfxMomentumCoreConstants.COMPONENT] = config; 105 config[gmfxMomentumFormConstants.FORM_DATA] = formData; 106 107 // Initialize BaseForm w these custom configs 108 gmfxMomentumServices.BaseForm.apply(this, arguments); 109 }; 110 111 // ************************************************************************ 112 // SETUP INHERITANCE RELATIONSHIP FROM BASE 113 // ************************************************************************ 114 FinalInstallmentForm.prototype = new gmfxMomentumServices.BaseForm(); 115 116 // ************************************************************************ 117 // >>>>>>>>>>>>>>>>>>> PUBLIC PROPERTIES/METHODS/OBJECTS <<<<<<<<<<<<<<<<<< 118 // ************************************************************************ 119 return FinalInstallmentForm; 120}(); 121 122/** 123 * ArticleContactForm object designed to inherit BaseForm methods and validate form fields 124 * 125 * USAGE: var articleContactForm = new ArticleContactForm() 126 * 127 * @author dvo2, mmustaine 128 * @since 04/14/2021 129 */ 130gmfxWwwServices.ArticleContactForm = function() { 131 'use strict'; 132 133 // ************************************************************************ 134 // CREATE ArticleContactForm OBJECT 135 // ************************************************************************ 136 /** 137 * Create a ArticleContactForm constructor w/ the provided custom configurations 138 * 139 * @constructor 140 */ 141 var ArticleContactForm = function(config) { 142 // Configure this specific form instance and its fields 143 var fieldFullName = {}, 144 fieldEmail = {}, 145 fieldDealershipName = {}, 146 fieldDealershipRole = {}, 147 fieldDealershipBac = {}, 148 formPrefix = "articleContact-", 149 formPrefixIdSelector = "#" + formPrefix, 150 formData = {}, 151 $component = config; 152 153 formData.$currentForm = gmfx$(formPrefixIdSelector + "form", $component); 154 formData.$header = gmfx$(formPrefixIdSelector + "header", $component); 155 formData.$alert = gmfx$(formPrefixIdSelector + "alert", $component); 156 formData.$submitButton = gmfx$(formPrefixIdSelector + "submit", formData.$currentForm); 157 158 formData.$validateFields = []; 159 fieldFullName[gmfxMomentumFormConstants.FIELD_NAME] = "fullName"; 160 fieldFullName[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "fullName"), formData.$currentForm); 161 fieldFullName[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 162 formData.$validateFields.push(fieldFullName); 163 164 fieldEmail[gmfxMomentumFormConstants.FIELD_NAME] = "emailAddress"; 165 fieldEmail[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "emailAddress"), formData.$currentForm); 166 fieldEmail[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 167 formData.$validateFields.push(fieldEmail); 168 169 fieldDealershipName[gmfxMomentumFormConstants.FIELD_NAME] = "dealershipName"; 170 fieldDealershipName[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "dealershipName"), formData.$currentForm); 171 fieldDealershipName[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 172 formData.$validateFields.push(fieldDealershipName); 173 174 fieldDealershipRole[gmfxMomentumFormConstants.FIELD_NAME] = "dealershipRole"; 175 fieldDealershipRole[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "dealershipRole"), formData.$currentForm); 176 fieldDealershipRole[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 177 formData.$validateFields.push(fieldDealershipRole); 178 179 fieldDealershipBac[gmfxMomentumFormConstants.FIELD_NAME] = "dealershipBac"; 180 fieldDealershipBac[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "dealershipBac"), formData.$currentForm); 181 fieldDealershipBac[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 182 formData.$validateFields.push(fieldDealershipBac); 183 184 // Instantiate this form w specific custom configs 185 config[gmfxMomentumCoreConstants.COMPONENT] = config; 186 config[gmfxMomentumFormConstants.FORM_DATA] = formData; 187 188 // Initialize BaseForm w these custom configs 189 gmfxMomentumServices.BaseForm.apply(this, arguments); 190 }; 191 192 // ************************************************************************ 193 // SETUP INHERITANCE RELATIONSHIP FROM BASE 194 // ************************************************************************ 195 ArticleContactForm.prototype = new gmfxMomentumServices.BaseForm(); 196 197 // ************************************************************************ 198 // >>>>>>>>>>>>>>>>>>> PUBLIC PROPERTIES/METHODS/OBJECTS <<<<<<<<<<<<<<<<<< 199 // ************************************************************************ 200 return ArticleContactForm; 201}(); 202 203/** 204 * EmailRequestForm object designed to inherit BaseForm methods and validate form fields 205 *
206 * USAGE: var emailRequestForm = new EmailRequestForm() 207 * 208 * @author mmustaine 209 * @since 9/27/2021 210 */ 211gmfxWwwServices.EmailRequestForm = function() { 212 'use strict'; 213 214 // ************************************************************************ 215 // CREATE EmailRequestForm OBJECT 216 // ************************************************************************ 217 /** 218 * Create a EmailRequestForm constructor w/ the provided custom configurations 219 * 220 * @constructor 221 */ 222 var EmailRequestForm = function(config) { 223 // Configure this specific form instance and its fields 224 var fieldFirstName = {}, 225 fieldLastName = {}, 226 fieldTitle = {}, 227 fieldOrganization = {}, 228 fieldAddressOne = {}, 229 fieldAddressTwo = {}, 230 fieldCity = {}, 231 fieldState = {}, 232 fieldZipCode = {}, 233 fieldPhone = {}, 234 fieldFax = {}, 235 fieldEmail = {}, 236 fieldComments = {}, 237 formPrefix = "emailRequest-", 238 formPrefixIdSelector = "#" + formPrefix, 239 formData = {}, 240 $component = config; 241 242 formData.$currentForm = gmfx$(formPrefixIdSelector + "form", $component); 243 formData.$alert = gmfx$(formPrefixIdSelector + "alert", $component); 244 formData.$submitButton = gmfx$(formPrefixIdSelector + "submit", formData.$currentForm); 245 246 formData.$validateFields = []; 247 fieldFirstName[gmfxMomentumFormConstants.FIELD_NAME] = "firstName"; 248 fieldFirstName[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "firstName"), formData.$currentForm); 249 fieldFirstName[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 250 formData.$validateFields.push(fieldFirstName); 251 252 fieldLastName[gmfxMomentumFormConstants.FIELD_NAME] = "lastName"; 253 fieldLastName[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "lastName"), formData.$currentForm); 254 fieldLastName[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 255 formData.$validateFields.push(fieldLastName); 256 257 fieldTitle[gmfxMomentumFormConstants.FIELD_NAME] = "title"; 258 fieldTitle[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "title"), formData.$currentForm); 259 fieldTitle[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 260 formData.$validateFields.push(fieldTitle); 261 262 fieldOrganization[gmfxMomentumFormConstants.FIELD_NAME] = "organization"; 263 fieldOrganization[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "organization"), formData.$currentForm); 264 fieldOrganization[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 265 formData.$validateFields.push(fieldOrganization); 266 267 fieldAddressOne[gmfxMomentumFormConstants.FIELD_NAME] = "addressOne"; 268 fieldAddressOne[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "addressOne"), formData.$currentForm); 269 fieldAddressOne[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 270 formData.$validateFields.push(fieldAddressOne); 271 272 fieldAddressTwo[gmfxMomentumFormConstants.FIELD_NAME] = "addressTwo"; 273 fieldAddressTwo[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "addressTwo"), formData.$currentForm); 274 fieldAddressTwo[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 275 formData.$validateFields.push(fieldAddressTwo); 276 277 fieldCity[gmfxMomentumFormConstants.FIELD_NAME] = "city"; 278 fieldCity[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "city"), formData.$currentForm); 279 fieldCity[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 280 formData.$validateFields.push(fieldCity); 281 282 fieldState[gmfxMomentumFormConstants.FIELD_NAME] = "state"; 283 fieldState[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "state"), formData.$currentForm); 284 fieldState[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 285 formData.$validateFields.push(fieldState); 286 287 fieldZipCode[gmfxMomentumFormConstants.FIELD_NAME] = "zipCode"; 288 fieldZipCode[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "zipCode"), formData.$currentForm); 289 fieldZipCode[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 290 formData.$validateFields.push(fieldZipCode); 291 292 fieldPhone[gmfxMomentumFormConstants.FIELD_NAME] = "phone"; 293 fieldPhone[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "phone"), formData.$currentForm); 294 fieldPhone[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 295 formData.$validateFields.push(fieldPhone); 296 297 fieldFax[gmfxMomentumFormConstants.FIELD_NAME] = "fax"; 298 fieldFax[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "fax"), formData.$currentForm); 299 fieldFax[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP;
300 formData.$validateFields.push(fieldFax); 301 302 fieldEmail[gmfxMomentumFormConstants.FIELD_NAME] = "emailAddress"; 303 fieldEmail[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "emailAddress"), formData.$currentForm); 304 fieldEmail[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 305 formData.$validateFields.push(fieldEmail); 306 307 fieldComments[gmfxMomentumFormConstants.FIELD_NAME] = "comments"; 308 fieldComments[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "comments"), formData.$currentForm); 309 fieldComments[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 310 formData.$validateFields.push(fieldComments); 311 312 // Instantiate this form w specific custom configs 313 config[gmfxMomentumCoreConstants.COMPONENT] = config; 314 config[gmfxMomentumFormConstants.FORM_DATA] = formData; 315 316 // Initialize BaseForm w these custom configs 317 gmfxMomentumServices.BaseForm.apply(this, arguments); 318 }; 319 320 // ************************************************************************ 321 // SETUP INHERITANCE RELATIONSHIP FROM BASE 322 // ************************************************************************ 323 EmailRequestForm.prototype = new gmfxMomentumServices.BaseForm(); 324 325 // ************************************************************************ 326 // >>>>>>>>>>>>>>>>>>> PUBLIC PROPERTIES/METHODS/OBJECTS <<<<<<<<<<<<<<<<<< 327 // ************************************************************************ 328 return EmailRequestForm; 329}(); 330 331/** 332 * SendExpertForm object designed to inherit BaseForm methods and validate form fields 333 * 334 * USAGE: var sendExpertForm = new SendExpertForm() 335 * 336 * @author mmustaine 337 * @since 11/8/2021 338 */ 339gmfxWwwServices.SendExpertForm = function() { 340 'use strict'; 341 342 // ************************************************************************ 343 // CREATE SendExpertForm OBJECT 344 // ************************************************************************ 345 /** 346 * Create a SendExpertForm constructor w/ the provided custom configurations 347 * 348 * @constructor 349 */ 350 var SendExpertForm = function(config) { 351 // Configure this specific form instance and its fields 352 var fieldFirstName = {}, 353 fieldLastName = {}, 354 fieldEmail = {}, 355 fieldPhone = {}, 356 fieldPhoneExt = {}, 357 fieldBusiness = {}, 358 fieldZipCode = {}, 359 fieldContactMethod = {}, 360 fieldHelpWith = {}, 361 fieldVehicleType = {}, 362 fieldVehicleTimeFrame = {}, 363 fieldBusinessTimeFrame = {}, 364 fieldReferral = {}, 365 fieldInformation = {}, 366 fieldDisclosureCheckbox = {}, 367 formPrefix = "sendExpert-", 368 formPrefixIdSelector = "#" + formPrefix, 369 formData = {}, 370 $component = config; 371 372 formData.$currentForm = gmfx$(formPrefixIdSelector + "form", $component); 373 formData.$alert = gmfx$(formPrefixIdSelector + "alert", $component); 374 formData.$successContent = gmfx$(formPrefixIdSelector + "successContent", $component); 375 formData.$submitButton = gmfx$(formPrefixIdSelector + "submit", formData.$currentForm); 376 377 formData.$validateFields = []; 378 fieldFirstName[gmfxMomentumFormConstants.FIELD_NAME] = "firstName"; 379 fieldFirstName[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "firstName"), formData.$currentForm); 380 fieldFirstName[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 381 formData.$validateFields.push(fieldFirstName); 382 383 fieldLastName[gmfxMomentumFormConstants.FIELD_NAME] = "lastName"; 384 fieldLastName[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "lastName"), formData.$currentForm); 385 fieldLastName[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 386 formData.$validateFields.push(fieldLastName); 387 388 fieldEmail[gmfxMomentumFormConstants.FIELD_NAME] = "emailAddress"; 389 fieldEmail[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "emailAddress"), formData.$currentForm); 390 fieldEmail[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 391 formData.$validateFields.push(fieldEmail); 392 393 fieldPhone[gmfxMomentumFormConstants.FIELD_NAME] = "phone"; 394 fieldPhone[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "phone"), formData.$currentForm); 395 fieldPhone[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 396 formData.$validateFields.push(fieldPhone); 397 398 fieldPhoneExt[gmfxMomentumFormConstants.FIELD_NAME] = "phone
398Ext"; 399 fieldPhoneExt[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "phoneExt"), formData.$currentForm); 400 fieldPhoneExt[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 401 formData.$validateFields.push(fieldPhoneExt); 402 403 fieldBusiness[gmfxMomentumFormConstants.FIELD_NAME] = "business"; 404 fieldBusiness[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "business"), formData.$currentForm); 405 fieldBusiness[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 406 formData.$validateFields.push(fieldBusiness); 407 408 fieldZipCode[gmfxMomentumFormConstants.FIELD_NAME] = "zipCode"; 409 fieldZipCode[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "zipCode"), formData.$currentForm); 410 fieldZipCode[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 411 formData.$validateFields.push(fieldZipCode); 412 413 fieldContactMethod[gmfxMomentumFormConstants.FIELD_NAME] = "contactMethod"; 414 fieldContactMethod[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "contactMethod"), formData.$currentForm); 415 fieldContactMethod[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 416 formData.$validateFields.push(fieldContactMethod); 417 418 fieldHelpWith[gmfxMomentumFormConstants.FIELD_NAME] = "helpWith"; 419 fieldHelpWith[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "helpWith"), formData.$currentForm); 420 fieldHelpWith[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 421 formData.$validateFields.push(fieldHelpWith); 422 423 fieldVehicleType[gmfxMomentumFormConstants.FIELD_NAME] = "vehicleType"; 424 fieldVehicleType[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "vehicleType"), formData.$currentForm); 425 fieldVehicleType[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 426 formData.$validateFields.push(fieldVehicleType); 427 428 fieldVehicleTimeFrame[gmfxMomentumFormConstants.FIELD_NAME] = "vehicleTimeFrame"; 429 fieldVehicleTimeFrame[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "vehicleTimeFrame"), formData.$currentForm); 430 fieldVehicleTimeFrame[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 431 formData.$validateFields.push(fieldVehicleTimeFrame); 432 433 fieldBusinessTimeFrame[gmfxMomentumFormConstants.FIELD_NAME] = "businessTimeFrame"; 434 fieldBusinessTimeFrame[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "businessTimeFrame"), formData.$currentForm); 435 fieldBusinessTimeFrame[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 436 formData.$validateFields.push(fieldBusinessTimeFrame); 437 438 fieldReferral[gmfxMomentumFormConstants.FIELD_NAME] = "referral"; 439 fieldReferral[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "referral"), formData.$currentForm); 440 fieldReferral[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 441 formData.$validateFields.push(fieldReferral); 442 443 fieldInformation[gmfxMomentumFormConstants.FIELD_NAME] = "information"; 444 fieldInformation[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "information"), formData.$currentForm); 445 fieldInformation[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 446 formData.$validateFields.push(fieldInformation); 447 448 fieldDisclosureCheckbox[gmfxMomentumFormConstants.FIELD_NAME] = "disclosureCheckbox"; 449 fieldDisclosureCheckbox[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "disclosureCheckbox"), formData.$currentForm); 450 fieldDisclosureCheckbox[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_CHANGE; 451 formData.$validateFields.push(fieldDisclosureCheckbox); 452 453 // Instantiate this form w specific custom configs 454 config[gmfxMomentumCoreConstants.COMPONENT] = config; 455 config[gmfxMomentumFormConstants.FORM_DATA] = formData; 456 457 // Initialize BaseForm w these custom configs 458 gmfxMomentumServices.BaseForm.apply(this, arguments); 459 }; 460 461 // ************************************************************************ 462 // SETUP INHERITANCE RELATIONSHIP FROM BASE 463 // ************************************************************************ 464 SendExpertForm.prototype = new gmfxMomentumServices.BaseForm(); 465 466 // ************************************************************************ 467 // >>>>>>>>>>>>>>>>>>> PUBLIC PROPERTIES/METHODS/OBJECTS <<<<<<<<<<<<<<<<<< 468 // ************************************************************************ 469 return SendExpertForm; 470}(); 471 472/** 473 * SendFleetExpertForm object designed to inherit BaseForm methods and validate form fields 474 * 475 * USAGE: var sendFleetExpertForm = new SendFleetExpertForm() 476 * 477 * @author grajas 478 */ 479gmfxWwwServices.SendFleetExpertForm = function() { 480 'use strict'; 481 482 // ************************************************************************ 483 // CREATE SendFleetExpertForm OBJECT 484 // ************************************************************************ 485 /** 486 * Create a SendFleetExpertForm constructor w/ the provided custom configurations 487 * 488 * @constructor 489 */ 490 var SendFleetExpertForm = function(config) { 491 // Configure this specific form instance and its fields 492 var fieldFirstName = {}, 493 fieldLastName = {}, 494 fieldEmail = {}, 495 fieldPhone = {}, 496 fieldBusiness = {}, 497 fieldZipCode = {}, 498 fieldDisclosureCheckbox = {}, 499 fieldMarketingCheckbox = {}, 500 formPrefix = "sendFleetExpert-", 501 formPrefixIdSelector = "#" + formPrefix, 502 formData = {}, 503 $component = config; 504 505 formData.$currentForm = gmfx$(formPrefixIdSelector + "form", $component); 506 formData.$alert = gmfx$(formPrefixIdSelector + "alert", $component); 507 formData.$successContent = gmfx$(formPrefixIdSelector + "successContent", $component); 508 formData.$submitButton = gmfx$(formPrefixIdSelector + "submit", formData.$currentForm); 509 510 formData.$validateFields = []; 511 fieldFirstName[gmfxMomentumFormConstants.FIELD_NAME] = "firstName"; 512 fieldFirstName[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "firstName"), formData.$currentForm); 513 fieldFirstName[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 514 formData.$validateFields.push(fieldFirstName); 515 516 fieldLastName[gmfxMomentumFormConstants.FIELD_NAME] = "lastName"; 517 fieldLastName[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "lastName"), formData.$currentForm); 518 fieldLastName[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 519 formData.$validateFields.push(fieldLastName); 520 521 fieldEmail[gmfxMomentumFormConstants.FIELD_NAME] = "emailAddress"; 522 fieldEmail[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "emailAddress"), formData.$currentForm); 523 fieldEmail[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 524 formData.$validateFields.push(fieldEmail); 525 526 fieldPhone[gmfxMomentumFormConstants.FIELD_NAME] = "phone"; 527 fieldPhone[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "phone"), formData.$currentForm); 528 fieldPhone[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 529 formData.$validateFields.push(fieldPhone); 530 531 fieldBusiness[gmfxMomentumFormConstants.FIELD_NAME] = "business"; 532 fieldBusiness[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "business"), formData.$currentForm); 533 fieldBusiness[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 534 formData.$validateFields.push(fieldBusiness); 535 536 fieldZipCode[gmfxMomentumFormConstants.FIELD_NAME] = "zipCode"; 537 fieldZipCode[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "zipCode"), formData.$currentForm); 538 fieldZipCode[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_KEY_UP; 539 formData.$validateFields.push(fieldZipCode); 540 541 fieldDisclosureCheckbox[gmfxMomentumFormConstants.FIELD_NAME] = "disclosureCheckbox"; 542 fieldDisclosureCheckbox[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "disclosureCheckbox"), formData.$currentForm); 543 fieldDisclosureCheckbox[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_CHANGE; 544 formData.$validateFields.push(fieldDisclosureCheckbox); 545 546 fieldMarketingCheckbox[gmfxMomentumFormConstants.FIELD_NAME] = "marketingCheckbox"; 547 fieldMarketingCheckbox[gmfxMomentumFormConstants.FIELD_ELEMENT] = gmfx$((formPrefixIdSelector + "marketingCheckbox"), formData.$currentForm); 548 fieldMarketingCheckbox[gmfxMomentumFormConstants.FIELD_EVENT] = gmfxMomentumCoreConstants.EVENT_LABEL_CHANGE; 549 formData.$validateFields.push(fieldMarketingCheckbox); 550 551 // Instantiate this form w specific custom configs 552 config[gmfxMomentumCoreConstants.COMPONENT] = config; 553 config[gmfxMomentumFormConstants.FORM_DATA] = formData; 554 555 // Initialize BaseForm w these custom configs 556 gmfxMomentumServices.BaseForm.apply(this, arguments); 557 }; 558 559 // ************************************************************************ 560 // SETUP INHERITANCE RELATIONSHIP FROM BASE 561 // ************************************************************************ 562 SendFleetExpertForm.prototype = new gmfxMomentumServices.BaseForm(); 563 564 // ************************************************************************ 565 // >>>>>>>>>>>>>>>>>>> PUBLIC PROPERTIES/METHODS/OBJECTS <<<<<<<<<<<<<<<<<< 566 // ************************************************************************ 567 return SendFleetExpertForm; 568}(); 569 570/** 571 * HTMLGlobalGMF2ColPage 572 * 573 * @author subha 574 * @since 10/27/2021 575 */ 576gmfxWwwComponents.HTMLGlobalGMF2ColPage = function(component) { 577 'use strict'; 578 579 var $component = gmfx$(component), 580 isCookie = gmfxMomentumServices.Cookie.get("eol_service"); 581 582 if(isCookie != null && isCookie != "") { 583 gmfx$('#eol-error-message').fadeIn().delay(10000).fadeOut(); 584 } 585}; 586//Initialize the component 587gmfxMomentumUtils.component.init(".htmlglobalgmf2colpage", gmfxWwwComponents.HTMLGlobalGMF2ColPage); 588 589/** 590 * HTMLGMF2ColPage - generate script only on fr-CA/es-US 591 * 592 * @author subha 593 * @since 10/26/2021 594 */ 595gmfxWwwComponents.HTMLGMF2ColPage = function(component) { 596 'use strict'; 597 var $component = gmfx$(component), 598 isCookie = gmfxMomentumServices.Cookie.get("eol_service"); 599 600 if(isCookie != null && isCookie != "") { 601 gmfx$('#eol-error-message').fadeIn().delay(10000).fadeOut(); 602 } 603 604 // EOL Past Due Handling 605 var isEOLCookie = gmfxMomentumServices.Cookie.get("eol_uid"); 606 if(isEOLCookie != null && isEOLCookie != "") { 607 isEOLCookie = Base64.decode(isEOLCookie); 608 var jsonData = JSON.parse(isEOLCookie); 609 var leaseTerm = jsonData["eolData"]["gmfAccountDetail"]["leaseaccount"]["daysUntilLeaseEnds"]; 610 if(leaseTerm <= 0 && leaseTerm >= -60) { 611 var warningCont = gmfx$('#eol-warning-message').html(); 612 gmfx$('.lease-intro').last().after("<div class=appendText></div>"); 613 gmfx$('.appendText').html(warningCont); 614 gmfx$('.lEndDate').parent().css('color', '#A81700'); 615 // Replace Lease Type Text 616 if(leaseTerm < 0) { 617 gmfx$('.box-header h4').text((leaseTerm * (-1)) + ' ' + gmfx$('#lease-type').text()); 618 } else { 619 gmfx$('.box-header h4').text(leaseTerm + ' ' + gmfx$('#lease-type').text()); 620 } 621 } 622 } 623}; 624//Initialize the component 625gmfxMomentumUtils.component.init(".htmlgmf2colpage", gmfxWwwComponents.HTMLGMF2ColPage); 626 627/** 628 * GMF2ColPage 629 * 630 * @author subha 631 * @since 10/13/2021 632 */ 633gmfxWwwComponents.GMF2ColPage = function(component) { 634 'use strict'; 635 636 var $component = gmfx$(component), 637 isCookie = gmfxMomentumServices.Cookie.get("eol_service"); 638 639 if(isCookie != null && isCookie != "") { 640 gmfx$('#eol-error-message').fadeIn().delay(10000).fadeOut(); 641 } 642 643 // EOL Past Due Handling 644 var isEOLCookie = gmfxMomentumServices.Cookie.get("eol_uid"); 645 if(isEOLCookie != null && isEOLCookie != "") { 646 isEOLCookie = Base64.decode(isEOLCookie); 647 var jsonData = JSON.parse(isEOLCookie); 648 var leaseTerm = jsonData["eolData"]["gmfAccountDetail"]["leaseaccount"]["daysUntilLeaseEnds"]; 649 if(leaseTerm <= 0 && leaseTerm >= -60) { 650 var warningCont = gmfx$('#eol-warning-message').html(); 651 gmfx$('.lease-intro').last().after("<div class=appendText></div>"); 652 gmfx$('.appendText').html(warningCont); 653 gmfx$('.lEndDate').parent().css('color', '#A81700'); 654 // Replace Lease Type Text 655 if(leaseTerm < 0) { 656 gmfx$('.box-header h4').text((leaseTerm * (-1)) + ' ' + gmfx$('#lease-type').text()); 657 } else { 658 gmfx$('.box-header h4').text(leaseTerm + ' ' + gmfx$('#lease-type').text()); 659 } 660 } 661 } 662}; 663//Initialize the component 664gmfxMomentumUtils.component.init(".gmf2colpagejs", gmfxWwwComponents.GMF2ColPage); 665 666/** 667 * SubNavigation 668 * 669 * @author subha 670 * @since 10/14/2021 671 */ 672gmfxWwwComponents.SubNavigation = function(component) { 673 'use strict'; 674 675 var $component = gmfx$(component), 676 $menu = gmfx$(".subnav .subnav-links"); 677 678 gmfx$("#subnav-mobmenu").click(function(e) { 679 e.preventDefault(); 680 if(gmfx$(".subnav .subnav-links").hasClass("subnav-links-active")) {
681 gmfx$(".subnav .subnav-links").slideUp("fast"); 682 gmfx$(".subnav .subnav-links").removeClass("subnav-links-active"); 683 } else { 684 gmfx$(".subnav .subnav-links").slideDown("fast"); 685 gmfx$(".subnav .subnav-links").addClass("subnav-links-active"); 686 } 687 }); 688 689 gmfx$("html").on("click", function(e) { 690 if(!$menu.is(e.target) && $menu.closest(".subnav").find(e.target).length === 0 && gmfx$(window).width() < 1024) { 691 gmfx$(".subnav .subnav-links").slideUp("fast"); 692 gmfx$(".subnav .subnav-links").removeClass("subnav-links-active"); 693 } 694 }); 695 696 gmfx$(".subnav .subnav-links ul li.active a").click(function(e) { 697 e.preventDefault(); 698 }); 699 700 gmfx$(window).resize(function() { 701 if(gmfx$(window).width() > 1023 && !gmfx$(".subnav .subnav-links").hasClass("subnav-links-active")) { 702 gmfx$(".subnav .subnav-links").removeAttr("style"); 703 } 704 }); 705}; 706//Initialize the component 707gmfxMomentumUtils.component.init(".subnav", gmfxWwwComponents.SubNavigation); 708 709/*! 710 * smartbanner.js v1.10.1 <https://github.com/ain/smartbanner.js> 711 * Copyright © 2018 Ain Tohvri, contributors. Licensed under GPL-3.0. 712 */ 713(function e(t, n, r) { 714 function s(o, u) { 715 if(!n[o]) { 716 if(!t[o]) { 717 var a = typeof require == "function" && require; 718 if(!u && a) return a(o, !0); 719 if(i) return i(o, !0); 720 var f = new Error("Cannot find module '" + o + "'"); 721 throw f.code = "MODULE_NOT_FOUND", f 722 } 723 var l = n[o] = { 724 exports: {} 725 }; 726 t[o][0].call(l.exports, function(e) { 727 var n = t[o][1][e]; 728 return s(n ? n : e) 729 }, l, l.exports, e, t, n, r) 730 } 731 return n[o].exports 732 } 733 var i = typeof require == "function" && require; 734 for(var o = 0; o < r.length; o++) s(r[o]); 735 return s 736})({ 737 1: [function(require, module, exports) { 738 "use strict"; 739 740 Object.defineProperty(exports, "__esModule", { 741 value: true 742 }); 743 exports.default = void 0; 744 745 function _classCallCheck(instance, Constructor) { 746 if(!(instance instanceof Constructor)) { 747 throw new TypeError("Cannot call a class as a function"); 748 } 749 } 750 751 function _defineProperties(target, props) { 752 for(var i = 0; i < props.length; i++) { 753 var descriptor = props[i]; 754 descriptor.enumerable = descriptor.enumerable || false; 755 descriptor.configurable = true; 756 if("value" in descriptor) descriptor.writable = true; 757 Object.defineProperty(target, descriptor.key, descriptor); 758 } 759 } 760 761 function _createClass(Constructor, protoProps, staticProps) { 762 if(protoProps) _defineProperties(Constructor.prototype, protoProps); 763 if(staticProps) _defineProperties(Constructor, staticProps); 764 return Constructor; 765 } 766 767 var Bakery = 768 /*#__PURE__*/ 769 function() { 770 function Bakery() { 771 _classCallCheck(this, Bakery); 772 } 773 774 _createClass(Bakery, null, [{ 775 key: "getCookieExpiresString", 776 value: function getCookieExpiresString(hideTtl) { 777 var now = new Date(); 778 var expireTime = new Date(now.getTime() + hideTtl); 779 return "expires=".concat(expireTime.toGMTString(), ";"); 780 } 781 }, { 782 key: "bake", 783 value: function bake(hideTtl, hidePath) { 784 document.cookie = "smartbanner_exited=1; ".concat(hideTtl ? Bakery.getCookieExpiresString(hideTtl) : '', " path=").concat(hidePath) + ";Secure; SameSite=Strict;"; 785 } 786 }, { 787 key: "unbake", 788 value: function unbake() { 789 document.cookie = 'smartbanner_exited=; expires=Thu, 01 Jan 1970 00:00:01 GMT;Secure; SameSite=Strict;'; 790 } 791 }, { 792 key: "baked", 793 get: function get() { 794 var value = document.cookie.replace(/(?:(?
794:^|.*;\s*)smartbanner_exited\s*=\s*([^;]*).*$)|^.*$/, '$1'); 795 return value === '1'; 796 } 797 }]); 798 799 return Bakery; 800 }(); 801 802 exports.default = Bakery; 803 804 }, {}], 805 2: [function(require, module, exports) { 806 (function(global) { 807 "use strict"; 808 809 Object.defineProperty(exports, "__esModule", { 810 value: true 811 }); 812 exports.default = void 0; 813 814 function _classCallCheck(instance, Constructor) { 815 if(!(instance instanceof Constructor)) { 816 throw new TypeError("Cannot call a class as a function"); 817 } 818 } 819 820 function _defineProperties(target, props) { 821 for(var i = 0; i < props.length; i++) { 822 var descriptor = props[i]; 823 descriptor.enumerable = descriptor.enumerable || false; 824 descriptor.configurable = true; 825 if("value" in descriptor) descriptor.writable = true; 826 Object.defineProperty(target, descriptor.key, descriptor); 827 } 828 } 829 830 function _createClass(Constructor, protoProps, staticProps) { 831 if(protoProps) _defineProperties(Constructor.prototype, protoProps); 832 if(staticProps) _defineProperties(Constructor, staticProps); 833 return Constructor; 834 } 835 836 var Detector = 837 /*#__PURE__*/ 838 function() { 839 function Detector() { 840 _classCallCheck(this, Detector); 841 } 842 843 _createClass(Detector, null, [{ 844 key: "platform", 845 value: function platform() { 846 if(/iPhone|iPad|iPod/i.test(window.navigator.userAgent)) { 847 return 'ios'; 848 } else if(/Android/i.test(window.navigator.userAgent)) { 849 return 'android'; 850 } 851 } 852 }, { 853 key: "userAgentMatchesRegex", 854 value: function userAgentMatchesRegex(regexString) { 855 return new RegExp(regexString).test(window.navigator.userAgent); 856 } 857 }, { 858 key: "jQueryMobilePage", 859 value: function jQueryMobilePage() { 860 return typeof global.$ !== 'undefined' && global.$.mobile !== 'undefined' && document.querySelector('.ui-page') !== null; 861 } 862 }, { 863 key: "wrapperElement", 864 value: function wrapperElement() { 865 var selector = Detector.jQueryMobilePage() ? '.ui-page' : 'html'; 866 return document.querySelectorAll(selector); 867 } 868 }]); 869 870 return Detector; 871 }(); 872 873 exports.default = Detector; 874 875 }).call(this, typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 876 }, {}], 877 3: [function(require, module, exports) { 878 "use strict"; 879 880 var _smartbanner = _interopRequireDefault(require("./smartbanner.js")); 881 882 function _interopRequireDefault(obj) { 883 return obj && obj.__esModule ? obj : { 884 default: obj 885 }; 886 } 887 888 var smartbanner; 889 window.addEventListener('load', function() { 890 smartbanner = new _smartbanner.default(); 891 smartbanner.publish(); 892 }); 893 894 }, { 895 "./smartbanner.js": 5 896 }], 897 4: [function(require, module, exports) { 898 "use strict"; 899 900 Object.defineProperty(exports, "__esModule", { 901 value: true 902 }); 903 exports.default = void 0; 904 905 function _classCallCheck(instance, Constructor) { 906 if(!(instance instanceof Constructor)) { 907 throw new TypeError("Cannot call a class as a function"); 908 } 909 } 910 911 function _defineProperties(target, props) { 912 for(var i = 0; i < props.length; i++) { 913 var descriptor = props[i]; 914 descriptor.enumerable = descriptor.enumerable || false; 915 descriptor.configurable = true; 916 if("value" in descriptor) descriptor.writable = true; 917 Object.defineProperty(target, descriptor.key, descriptor); 918 } 919 } 920 921 function _createClass(Constructor, protoProps, staticProps) { 922 if(protoProps) _defineProperties(Constructor.prototype, protoProps); 923 if(staticProps) _defineProperties(Constructor, staticProps); 924 return Constructor; 925 } 926 927 function valid(name) { 928 // TODO: validate against options dictionary 929 return name.indexOf('smartbanner:') !== -1 && name.split(':')[1].length > 0; 930 } 931 932 function convertToCamelCase(name) { 933 var parts = name.split('-'); 934 parts.map(function(part, index) { 935 if(index > 0) { 936 parts[index] = part.charAt(0).toUpperCase() + part.substring(1); 937 } 938 }); 939 return parts.join(''); 940 } 941 942 var OptionParser = 943 /*#__PURE__*/ 944 function() { 945 function OptionParser() { 946 _classCallCheck(this, OptionParser); 947 } 948 949 _createClass(OptionParser, [{ 950 key: "parse", 951 value: function parse() { 952 var metas = document.getElementsByTagName('meta'); 953 var options = {}; 954 var optionName = null;
955 Array.from(metas).forEach(function(meta) { 956 var name = meta.getAttribute('name'); 957 var content = meta.getAttribute('content'); 958 959 if(name && content && valid(name) && content.length > 0) { 960 optionName = name.split(':')[1]; 961 962 if(optionName.indexOf('-') !== -1) { 963 optionName = convertToCamelCase(optionName); 964 } 965 966 options[optionName] = content; 967 } 968 }); 969 return options; 970 } 971 }]); 972 973 return OptionParser; 974 }(); 975 976 exports.default = OptionParser; 977 978 }, {}], 979 5: [function(require, module, exports) { 980 "use strict"; 981 982 Object.defineProperty(exports, "__esModule", { 983 value: true 984 }); 985 exports.default = void 0; 986 987 var _optionparser = _interopRequireDefault(require("./optionparser.js")); 988 989 var _detector = _interopRequireDefault(require("./detector.js")); 990 991 var _bakery = _interopRequireDefault(require("./bakery.js")); 992 993 function _interopRequireDefault(obj) { 994 return obj && obj.__esModule ? obj : { 995 default: obj 996 }; 997 } 998 999 function _classCallCheck(instance, Constructor) { 1000 if(!(instance instanceof Constructor)) { 1001 throw new TypeError("Cannot call a class as a function"); 1002 } 1003 } 1004 1005 function _defineProperties(target, props) { 1006 for(var i = 0; i < props.length; i++) { 1007 var descriptor = props[i]; 1008 descriptor.enumerable = descriptor.enumerable || false; 1009 descriptor.configurable = true; 1010 if("value" in descriptor) descriptor.writable = true; 1011 Object.defineProperty(target, descriptor.key, descriptor); 1012 } 1013 } 1014 1015 function _createClass(Constructor, protoProps, staticProps) { 1016 if(protoProps) _defineProperties(Constructor.prototype, protoProps); 1017 if(staticProps) _defineProperties(Constructor, staticProps); 1018 return Constructor; 1019 } 1020 1021 var DEFAULT_PLATFORMS = 'android,ios'; 1022 var datas = { 1023 originalTop: 'data-smartbanner-original-top', 1024 originalMarginTop: 'data-smartbanner-original-margin-top' 1025 }; 1026 1027 function handleExitClick(event, self) { 1028 self.exit(); 1029 event.preventDefault(); 1030 } 1031 1032 function handleJQueryMobilePageLoad(event) { 1033 if(!this.positioningDisabled) { 1034 setContentPosition(event.data.height); 1035 } 1036 } 1037 1038 function addEventListeners(self) { 1039 var closeIcon = document.querySelector('.js_smartbanner__exit'); 1040 closeIcon.addEventListener('click', function(event) { 1041 return handleExitClick(event, self); 1042 }); 1043 1044 if(_detector.default.jQueryMobilePage()) { 1045 $(document).on('pagebeforeshow', self, handleJQueryMobilePageLoad); 1046 } 1047 } 1048 1049 function removeEventListeners() { 1050 if(_detector.default.jQueryMobilePage()) { 1051 $(document).off('pagebeforeshow', handleJQueryMobilePageLoad); 1052 } 1053 } 1054 1055 function setContentPosition(value) { 1056 var wrappers = _detector.default.wrapperElement(); 1057 1058 for(var i = 0, l = wrappers.length, wrapper; i < l; i++) { 1059 wrapper = wrappers[i]; 1060 1061 if(_detector.default.jQueryMobilePage()) { 1062 if(wrapper.getAttribute(datas.originalTop)) { 1063 continue; 1064 } 1065 1066 var top = parseFloat(getComputedStyle(wrapper).top); 1067 wrapper.setAttribute(datas.originalTop, isNaN(top) ? 0 : top); 1068 wrapper.style.top = value + 'px'; 1069 } else { 1070 if(wrapper.getAttribute(datas.originalMarginTop)) { 1071 continue; 1072 } 1073 1074 var margin = parseFloat(getComputedStyle(wrapper).marginTop); 1075 wrapper.setAttribute(datas.originalMarginTop, isNaN(margin) ? 0 : margin); 1076 wrapper.style.marginTop = value + 'px'; 1077 } 1078 } 1079 } 1080 1081 function restoreContentPosition() { 1082 var wrappers = _detector.default.wrapperElement(); 1083 1084 for(var i = 0, l = wrappers.length, wrapper; i < l; i++) { 1085 wrapper = wrappers[i]; 1086 1087 if(_detector.default.jQueryMobilePage() && wrapper.getAttribute(datas.originalTop)) { 1088 wrapper.style.top = wrapper.getAttribute(datas.originalTop) + 'px'; 1089 } else if(wrapper.getAttribute(datas.originalMarginTop)) { 1090 wrapper.style.marginTop = wrapper.getAttribute(datas.originalMarginTop) + 'px'; 1091 } 1092 } 1093 } 1094 1095 var SmartBanner = 1096 /*#__PURE__*/ 1097 function() { 1098 function SmartBanner() { 1099 _classCallCheck(this, SmartBanner); 1100 1101 var parser = new _optionparser.default(); 1102 this.options = parser.parse(); 1103 this.platform = _detector.default.platform(); 1104 } // DEPRECATED. Will be removed. 1105 1106 1107 _createClass(SmartBanner, [{ 1108 key: "publish", 1109 value: function publish() { 1110 if(Object.keys(this.options).length === 0) { 1111 throw new Error('No options detected. Please consult documentation.'); 1112 } 1113 1114 if(_bakery.default.baked) { 1115 return false;
1116 } // User Agent was explicetely excluded by defined excludeUserAgentRegex 1117 1118 1119 if(this.userAgentExcluded) { 1120 return false; 1121 } // User agent was neither included by platformEnabled, 1122 // nor by defined includeUserAgentRegex 1123 1124 1125 if(!(this.platformEnabled || this.userAgentIncluded)) { 1126 return false; 1127 } 1128 1129 var bannerDiv = document.createElement('div'); 1130 document.querySelector('body').appendChild(bannerDiv); 1131 bannerDiv.outerHTML = this.html; 1132 1133 if(!this.positioningDisabled) { 1134 setContentPosition(this.height); 1135 } 1136 1137 addEventListeners(this); 1138 } 1139 }, { 1140 key: "exit", 1141 value: function exit() { 1142 removeEventListeners(); 1143 1144 if(!this.positioningDisabled) { 1145 restoreContentPosition(); 1146 } 1147 1148 var banner = document.querySelector('.js_smartbanner'); 1149 document.querySelector('body').removeChild(banner); 1150 1151 _bakery.default.bake(this.hideTtl, this.hidePath); 1152 } 1153 }, { 1154 key: "originalTop", 1155 get: function get() { 1156 var wrapper = _detector.default.wrapperElement()[0]; 1157 1158 return parseFloat(wrapper.getAttribute(datas.originalTop)); 1159 } // DEPRECATED. Will be removed. 1160 1161 }, { 1162 key: "originalTopMargin", 1163 get: function get() { 1164 var wrapper = _detector.default.wrapperElement()[0]; 1165 1166 return parseFloat(wrapper.getAttribute(datas.originalMarginTop)); 1167 } 1168 }, { 1169 key: "priceSuffix", 1170 get: function get() { 1171 if(this.platform === 'ios') { 1172 return this.options.priceSuffixApple; 1173 } else if(this.platform === 'android') { 1174 return this.options.priceSuffixGoogle; 1175 } 1176 1177 return ''; 1178 } 1179 }, { 1180 key: "icon", 1181 get: function get() { 1182 if(this.platform === 'android') { 1183 return this.options.iconGoogle; 1184 } else { 1185 return this.options.iconApple; 1186 } 1187 } 1188 }, { 1189 key: "buttonUrl", 1190 get: function get() { 1191 if(this.platform === 'android') { 1192 return this.options.buttonUrlGoogle; 1193 } else if(this.platform === 'ios') { 1194 return this.options.buttonUrlApple; 1195 } 1196 1197 return '#'; 1198 } 1199 }, { 1200 key: "html", 1201 get: function get() { 1202 var modifier = !this.options.customDesignModifier ? this.platform : this.options.customDesignModifier; 1203 return "<div class=\"smartbanner smartbanner--".concat(modifier, " js_smartbanner\">\n <a href=\"javascript:void();\" class=\"smartbanner__exit js_smartbanner__exit\"></a>\n <div class=\"smartbanner__icon\" style=\"background-image: url(").concat(this.icon, ");\"></div>\n <div class=\"smartbanner__info\">\n <div>\n <div class=\"smartbanner__info__title\">").concat(this.options.title, "</div>\n <div class=\"smartbanner__info__author\">").concat(this.options.author, "</div>\n <div class=\"smartbanner__info__price\">").concat(this.options.price).concat(this.priceSuffix, "</div>\n </div>\n </div>\n <a href=\"").concat(this.buttonUrl, "\" target=\"_blank\" class=\"smartbanner__button\"><span class=\"smartbanner__button__label\">").concat(this.options.button, "</span></a>\n </div>"); 1204 } 1205 }, { 1206 key: "height", 1207 get: function get() { 1208 var height = document.querySelector('.js_smartbanner').offsetHeight; 1209 return height !== undefined ? height : 0; 1210 } 1211 }, { 1212 key: "platformEnabled", 1213 get: function get() { 1214 var enabledPlatforms = this.options.enabledPlatforms || DEFAULT_PLATFORMS; 1215 return enabledPlatforms && enabledPlatforms.replace(/\s+/g, '').split(',').indexOf(this.platform) !== -1; 1216 } 1217 }, { 1218 key: "positioningDisabled", 1219 get: function get() { 1220 return this.options.disablePositioning === 'true'; 1221 } 1222 }, { 1223 key: "userAgentExcluded", 1224 get: function get() { 1225 if(!this.options.excludeUserAgentRegex) { 1226 return false;
1227 } 1228 1229 return _detector.default.userAgentMatchesRegex(this.options.excludeUserAgentRegex); 1230 } 1231 }, { 1232 key: "userAgentIncluded", 1233 get: function get() { 1234 if(!this.options.includeUserAgentRegex) { 1235 return false; 1236 } 1237 1238 return _detector.default.userAgentMatchesRegex(this.options.includeUserAgentRegex); 1239 } 1240 }, { 1241 key: "hideTtl", 1242 get: function get() { 1243 return this.options.hideTtl ? parseInt(this.options.hideTtl) : false; 1244 } 1245 }, { 1246 key: "hidePath", 1247 get: function get() { 1248 return this.options.hidePath ? this.options.hidePath : '/'; 1249 } 1250 }]); 1251 1252 return SmartBanner; 1253 }(); 1254 1255 exports.default = SmartBanner; 1256 1257 }, { 1258 "./bakery.js": 1, 1259 "./detector.js": 2, 1260 "./optionparser.js": 4 1261 }] 1262}, {}, [3]); 1263 1264gmfxWwwComponents.ExternalLinkPopup = function(component) { 1265 'use strict'; 1266 1267 // Define external domains to trigger interstitial popup 1268 var externalDomains = ["gmfinancial.everfi-next.net"] 1269 1270 var continueBtn = document.getElementById("external-link-continue"); 1271 1272 // Function to check if passed url is a defined external url 1273 function isExternal(url) { 1274 if(!url) return false; 1275 return externalDomains.some(function(domain) { 1276 return url.includes(domain); 1277 }); 1278 } 1279 1280 // Query all links and determine if external - if so, add event listener 1281 document.querySelectorAll('a').forEach(function(link) { 1282 var href = link.getAttribute('href'); 1283 1284 // Check if link is external 1285 if(isExternal(href)) { 1286 link.addEventListener('click', function(event) { 1287 // Prevent default anchor click 1288 event.preventDefault(); 1289 event.stopPropagation(); 1290 event.stopImmediatePropagation(); 1291 1292 // Set continue button to redirect to external link 1293 continueBtn.addEventListener('click', function() { 1294 window.location.href = href 1295 }) 1296 // Show modal 1297 $("#external-link-modal").modal("show"); 1298 }) 1299 } 1300 1301 }) 1302 1303} 1304 1305//Initialize the component 1306gmfxMomentumUtils.component.init(".external-link-modal", gmfxWwwComponents.ExternalLinkPopup); 1307 1308/** 1309 * Analytics 1310 * 1311 * @author subha 1312 * @since 11/09/2021 1313 */ 1314gmfxWwwComponents.Analytics = function(component) { 1315 'use strict'; 1316 1317 var $component = gmfx$(component), 1318 url = window.location.href, 1319 isEOLCookie = gmfxMomentumServices.Cookie.get("eol_uid"), 1320 vehicleCookie = gmfxMomentumServices.Cookie.get("GMF_vehicle"); 1321 1322 1323 // EOL Analytics Data 1324 var uid = gmfxMomentumServices.Analytics.getURL("uid",url); 1325 if (((url.indexOf("lease-end")!= -1) || uid!=null) && isEOLCookie != null && isEOLCookie != "") { 1326 digitaldata.event = { 1327 "action" : "EOL-purl-id|pageload", 1328 "name" : "EOL-purl-id", 1329 "type" : "pageload" 1330 }; 1331 digitaldata.page.language = gmfx$(".analyticsLanguage").text(); 1332 gmfxMomentumServices.Analytics.getEOL(isEOLCookie,vehicleCookie); 1333 }else if( uid!=null){ 1334 digitaldata.event = { 1335 "action" : "EOL|pageload", 1336 "name" : "EOL", 1337 "type" : "pageload" 1338 }; 1339 digitaldata.page.language = gmfx$(".analyticsLanguage").text(); 1340 } 1341 1342 if (gmfx$("form.searchResults").length > 0) { 1343 digitaldata.event = { 1344 "action" : "internal-search|pageload", 1345 "name" : "internal-search", 1346 "type" : "pageload" 1347 }; 1348 digitaldata.page.attributes = { 1349 "internalSearch": { 1350 "term" : gmfx$('.searchKeyword').val(), 1351 "results" : gmfx$('.searchTotalResults').html()?gmfx$('.searchTotalResults').html():0 1352 } 1353 }; 1354 var contentRegion = gmfx$(".analyticsContentRegion").text(); 1355 digitaldata.page.pageinfo = { 1356 "contentRegion": contentRegion 1357 }; 1358 if (isEOLCookie != null && isEOLCookie != "") { 1359 gmfxMomentumServices.Analytics.getEOL(isEOLCookie,vehicleCookie); 1360 } 1361 } 1362 1363 1364 1365 gmfx$(document).on( "click", "a", function() { 1366 var isSearchResultLink = gmfx$(this).closest(".search-result h3").length > 0; 1367 if(isSearchResultLink){ 1368 gmfxMomentumServices.Analytics.getClick(this,"internal search"); 1369 digitaldata.page.attributes = { 1370 "internalSearch": { 1371 "term" : gmfx$('.searchKeyword').val(), 1372 "results" : gmfx$('.searchTotalResults').html()?gmfx$('.searchTotalResults').html():0, 1373 "pageNumber" : gmfx$('.searchPagination li.active a').text(), 1374 "position" : gmfx$(this).closest(".search-result").index()+1 1375 } 1376 }; 1377 _satellite.track("internal search"); 1378 }else if (!gmfx$(this).attr("data-make") && !gmfx$(this).attr("data-year") ) { 1379 gmfxMomentumServices.Analytics.getClick(this,"link"); 1380 if(digitaldata.event.name == "download"){ 1381 _satellite.track("file download"); 1382 }else{ 1383 _satellite.track("global onclick"); 1384 } 1385 } 1386 }); 1387 1388 /** Responsible for populating offer ids in data layer */ 1389 gmfx$(window).on('load', function () { 1390 gmfxMomentumServices.Analytics.setOfferIds(); 1391 }); 1392 1393 1394}; 1395//Initialize the component 1396gmfxMomentumUtils.component.init(".site-analytics", gmfxWwwComponents.Analytics); 1397/** 1398 * Video Analytics 1399 * 1400 * @author subha 1401 * @since 11/09/2021 1402 */ 1403gmfxWwwComponents.VideoAnalytics = function(component) { 1404 'use strict'; 1405 1406 document.addEventListener('DOMContentLoaded', init, false) 1407 1408 var $component = gmfx$(component), 1409 videoId = gmfx$("#brightcove-frame"); 1410 1411 function init () { 1412 gmfx$.each(videoId, function(key,val){ 1413 val.addEventListener('ended', videoEnd, false) 1414 val.addEventListener('timeupdate', videoTimeUpdate, false) 1415 val.addEventListener('play', videoPlay, false) 1416 val.addEventListener('pause', videoPause, false) 1417 }) 1418
1419 } 1420 1421 function setKeyFrames (duration) { 1422 var quarter = (duration / 4).toFixed(1) 1423 sessionStorage.setItem('one', (quarter * 1).toFixed(0)) 1424 sessionStorage.setItem('two', (quarter * 2).toFixed(0)) 1425 sessionStorage.setItem('three', (quarter * 3).toFixed(0)) 1426 1427 } 1428 1429 function videoTimeUpdate () { 1430 var curTime = this.currentTime.toFixed(0) 1431 switch (curTime) { 1432 case sessionStorage.getItem('one'): 1433 sessionStorage.setItem('one', null) 1434 setVideoDigitalData(this,"video-milestone","25"); 1435 break; 1436 case sessionStorage.getItem('two'): 1437 sessionStorage.setItem('two', null) 1438 setVideoDigitalData(this,"video-milestone","50"); 1439 break; 1440 case sessionStorage.getItem('three'): 1441 sessionStorage.setItem('three', null) 1442 setVideoDigitalData(this,"video-milestone","75"); 1443 break; 1444 } 1445 } 1446 1447 function videoEnd () { 1448 setVideoDigitalData(this,"video-complete",null); 1449 } 1450 1451 function videoPlay () { 1452 setKeyFrames(this.duration); 1453 setVideoDigitalData(this,"video-start",null); 1454 } 1455 1456 function videoPause () { 1457 if(this.currentTime < this.duration) 1458 setVideoDigitalData(this,"video-stop",null); 1459 } 1460 1461 function setVideoDigitalData(ele,actionName,mileStone){ 1462 var videoTitle = gmfx$(ele).attr("data-title") ? gmfx$(ele).attr("data-title") : ""; 1463 var vLink = gmfx$(ele).attr('src'); 1464 var linkName = gmfx$(".analyticsLinkPath").text(); 1465 linkName = linkName ? linkName+"|"+actionName:actionName; 1466 digitaldata.video = { 1467 "videoName" : videoTitle 1468 }; 1469 if(mileStone){ 1470 digitaldata.video.milestone = mileStone; 1471 } 1472 digitaldata.onclick = { 1473 "LinkName" : linkName, 1474 "LinkText" : videoTitle, 1475 "LinkURL" : vLink 1476 }; 1477 digitaldata.event = { 1478 "action" : actionName + "|onclick", 1479 "name" : actionName, 1480 "type" : "onclick" 1481 }; 1482 _satellite.track(actionName); 1483 } 1484}; 1485//Initialize the component 1486gmfxMomentumUtils.component.init("#brightcove-frame", gmfxWwwComponents.VideoAnalytics); 1487/** 1488 * Accessibility - generate accessibility script only on en-ca 1489 * 1490 * @author subha 1491 * @since 10/8/2021 1492 */ 1493gmfxWwwComponents.Accessibility = function(component) { 1494 'use strict'; 1495 var $component = gmfx$(component); 1496 1497 if(gmfx$("html").is(":lang(en-CA)")) { 1498 var accessibilityScript = gmfx$("<script src='https://cdn.levelaccess.net/accessjs/YW1wMTA2NjE/access.js'></script>"); 1499 gmfx$("head").append(accessibilityScript); 1500 } 1501}; 1502//Initialize the component 1503gmfxMomentumUtils.component.init("html", gmfxWwwComponents.Accessibility); 1504 1505/** 1506 * Personalization 1507 * 1508 * @author subha 1509 * @since 10/8/2021 1510 */ 1511gmfxWwwComponents.Personalization = function(component) { 1512 'use strict'; 1513 1514 var $component = gmfx$(component), 1515 referrerUrl = document.referrer; 1516 1517 var defaultImage = gmfx$(".default-hero-image").attr("data-attr-default"); 1518 if(referrerUrl && isDisabledMode()) { 1519 var buickReferrerUrl = gmfx$("#buickReferrerUrl").html(); 1520 var cadillacReferrerUrl = gmfx$("#cadillacReferrerUrl").html(); 1521 var chevroletReferrerUrl = gmfx$("#chevroletReferrerUrl").html(); 1522 var gmcReferrerUrl = gmfx$("#gmcReferrerUrl").html(); 1523 var buickImage = gmfx$(".default-hero-image").attr("data-attr-buick"); 1524 var cadillacImage = gmfx$(".default-hero-image").attr("data-attr-cadillac"); 1525 var chevroletImage = gmfx$(".default-hero-image").attr("data-attr-chevrolet"); 1526 var gmcImage = gmfx$(".default-hero-image").attr("data-attr-gmc"); 1527 1528 if(referrerUrl.indexOf(buickReferrerUrl) != -1 && buickImage) { 1529 gmfx$(".default-hero-image").attr("src", buickImage); 1530 gmfx$(".buick-hero").show(); 1531 gmfx$(".default-hero, .cadillac-hero, .chevrolet-hero, .gmc-hero").remove(); 1532 } else if(referrerUrl.indexOf(cadillacReferrerUrl) != -1 && cadillacImage) { 1533 gmfx$(".default-hero-image").attr("src", cadillacImage); 1534 gmfx$(".cadillac-hero").show(); 1535 gmfx$(".default-hero, .buick-hero, .chevrolet-hero, .gmc-hero").remove(); 1536 } else if(referrerUrl.indexOf(chevroletReferrerUrl) != -1 && chevroletImage) { 1537 gmfx$(".default-hero-image").attr("src", chevroletImage); 1538 gmfx$(".chevrolet-hero").show(); 1539 gmfx$(".default-hero, .buick-hero, .cadillac-hero, .gmc-hero").remove(); 1540 } else if(referrerUrl.indexOf(gmcReferrerUrl) != -1 && gmcImage) { 1541 gmfx$(".default-hero-image").attr("src", gmcImage); 1542 gmfx$(".gmc-hero").show(); 1543 gmfx$(".default-hero, .buick-hero, .cadillac-hero, .chevrolet-hero").remove(); 1544 } else { 1545 gmfx$(".default-hero-image").attr("src", defaultImage); 1546 gmfx$(".default-hero").show(); 1547 gmfx$(".buick-hero, .cadillac-hero, .chevrolet-hero, .gmc-hero").remove(); 1548 } 1549 } else { 1550 gmfx$(".default-hero-image").attr("src", defaultImage); 1551 gmfx$(".default-hero").show(); 1552 gmfx$(".buick-hero, .cadillac-hero, .chevrolet-hero, .gmc-hero").remove(); 1553 } 1554}; 1555//Initialize the component 1556gmfxMomentumUtils.component.init(".default-hero-image", gmfxWwwComponents.Personalization); 1557 1558gmfxWwwComponents.eolWizard = function(component) { 1559 var gmBrand = ''; 1560 var exteriorValuesArray, interiorValuesArray, answerFeeArray = []; 1561 var exteriorView, interiorView = 0; 1562 /*Lease end Guide path*/ 1563 var chevyGuideUrl = "/content/dam/gmf/eol/pdf/2021_Lease%20End%20Guides_Chevrolet.pdf"; 1564 var buickGuideUrl = "/content/dam/gmf/eol/pdf/2021_Lease%20End%20Guides_Buick.pdf"; 1565 var gmcGuideUrl = "/content/dam/gmf/eol/pdf/2021_%20Lease%20End%20Guides_GMC.pdf"; 1566 var cadillacGuideUrl = "/content/dam/gmf/eol/pdf/2021_Lease%20End%20Guides_Cadillac.pdf"; 1567 1568 /* Global external and internal options selection*/ 1569 var optionNameHeadlight = "Cracked Headlights", 1570 optionNamePunctures = "Hail Damage or Punctures", 1571 optionNameDings = "Dings", 1572 optionNameScratches = "Scratches", 1573 optionNameDents = "Dents", 1574 optionNameGlass = "Cracked Glass", 1575 optionNameDamageWheel = "Damaged Wheels", 1576 optionNameTires = "Tire Treads Under 4/32", 1577 optionNameExteriorNoneSelected = "extnone"; 1578 1579 var optionNamePanel = "Instrument Panel Warnings", 1580 optionNameEquipment = "Missing Equipment", 1581 optionNameDefects = "Mechanical Defects", 1582 optionNameStains = "Stains", 1583 optionNameHoles = "Upholstery Holes", 1584 optionNameTears = "Tears", 1585 optionNameInteriorNoneSelected = "intnone"; 1586 1587 /*Global scripts */ 1588 var $component = gmfx$(component),
1589 breadcrumbContainer = gmfx$(".gmf-wizard--breadcrumb-container", $component), 1590 btnDefaultClick = gmfx$(".btn, .btn-brand", $component), 1591 btnBrandClick = gmfx$(".btn-brand", $component), 1592 btnPrintClick = gmfx$(".btn-print", $component), 1593 btnExteriorInfo = gmfx$('.btn[data-go-to="exterior-info"]', $component), 1594 btnInteriorInfo = gmfx$('.btn[data-go-to="interior-info"]', $component), 1595 initExteriorEvaluation = gmfx$('.btn[data-go-to="exterior-evaluation"]', $component), 1596 initInteriorEvaluation = gmfx$('.btn[data-go-to="interior-evaluation"]', $component), 1597 inputRadioDefault = gmfx$('input[type=radio][name="radio"]', $component), 1598 selectionExteriorForm = gmfx$('.btn[data-go-to="exterior-selections"]', $component), 1599 forwardExteriorSectionView = gmfx$('.btn[data-view="ext-view"]', $component), 1600 forwardInteriorSectionView = gmfx$('.btn[data-view="int-view"]', $component), 1601 backExteriorSectionView = gmfx$('.btn[data-view="ext-back"]', $component), 1602 backInteriorSectionView = gmfx$('.btn[data-view="int-back"]', $component), 1603 backExteriorSectionGoTo = gmfx$('.btn[data-go-to="exterior-back"]', $component), 1604 backInteriorSectionGoTo = gmfx$('.btn[data-go-to="interior-back"]', $component), 1605 fillAnswers = gmfx$('.btn[data-go-to="review-disposition-fee"]', $component), 1606 reviewSelectionClick = gmfx$('.btn[data-go-to="review-selections"]', $component), 1607 mobileTabOpen = gmfx$('.panel-heading a[aria-expanded="false"]', $component), 1608 mobileTabClose = gmfx$('.panel-heading a.collapsed', $component), 1609 checkboxSelectedExterior = gmfx$('#ext-eval input', $component), 1610 checkboxSelectedExteriorNone = gmfx$('#ext-eval-none input', $component), 1611 checkboxSelectedInterior = gmfx$('#int-eval input', $component), 1612 checkboxSelectedInteriorNone = gmfx$('#int-eval-none input', $component),
1613 keyEnterAnchorClick = gmfx$(".gmf-wizard a", $component), 1614 keyEnterInputClick = gmfx$(".gmf-wizard label", $component); 1615 1616 /*Btn most used - Start*/ 1617 var btnOemClosure = '.exterior-oem .btn[data-go-to="exterior-closure"]', 1618 btnOemTire = '.exterior-oem .btn[data-go-to="exterior-tire"]', 1619 btnOemUnsureClosure = '.exterior-oem-unsure .btn[data-go-to="exterior-closure"]', 1620 btnOemUnsureTire = '.exterior-oem-unsure .btn[data-go-to="exterior-tire"]', 1621 btnOriginalWheelYes = '.exterior-original-yes .btn[data-go-to="exterior-wheels-damage"]', 1622 btnOriginalWheelNo = '.exterior-original-no .btn[data-go-to="exterior-wheels-damage"]', 1623 btnOriginalOemYes = '.exterior-original-yes .btn[data-go-to="exterior-oem"]', 1624 btnOriginalOemNo = '.exterior-original-no .btn[data-go-to="exterior-oem"]'; 1625 /*Btn most used - End*/ 1626 1627 /* Accessibility - Start*/ 1628 gmfx$(document).on("keypress", ".gmf-wizard a", function(e) { 1629 var key = e.which; 1630 if(key == 13) // the enter key code 1631 { 1632 gmfx$(this).click(); 1633 gmfx$(".gmf-wizard").focus(); 1634 } 1635 }); 1636 gmfx$(document).on("keypress", ".gmf-wizard label", function(e) { 1637 var key = e.which; 1638 if(key == 13) // the enter key code 1639 { 1640 gmfx$(this).find("input").click(); 1641 } 1642 }); 1643 /* Accessibility - Ends*/ 1644 1645 1646 gmfx$(btnDefaultClick, $component).on("click", function() { 1647 var goToPageToDisplay = gmfx$(this).data("go-to"); //page to display 1648 var step = gmfx$(this).data("step"); //breadcrumb step on the wizard 1649 var answer = gmfx$(this).data("answer"); //answer selected 1650 if(goToPageToDisplay) { 1651 gmfx$(".gmf-wizard").focus(); 1652 gmfx$(".gmf-wizard-screen").removeClass('show').addClass('hide'); 1653 switch (step) { 1654 case 1: 1655 gmfx$(breadcrumbContainer, $component).removeClass("hide"); 1656 gmfx$("#step-2, #step-3, #step-4").addClass('hide'); 1657 gmfx$("#step-1").addClass('show').removeClass('hide'); 1658 gmfx$(".basic-screen").removeClass('hide').addClass('show'); 1659 break; 1660 case 2: 1661 gmfx$(breadcrumbContainer, $component).removeClass("hide"); 1662 gmfx$("#step-1,#step-3,#step-4").addClass('hide').removeClass("show"); 1663 gmfx$("#step-2").removeClass('hide'); 1664 gmfx$(".exterior-screen").removeClass('hide').addClass('show'); 1665 gmfx$(".middle-bar").first().removeClass('inactive-step').addClass("active-step"); 1666 break; 1667 case 3: 1668 gmfx$(breadcrumbContainer, $component).removeClass("hide"); 1669 gmfx$("#step-1,#step-2,#step-4").addClass('hide'); 1670 gmfx$("#step-3").removeClass('hide'); 1671 gmfx$(".interior-screen").removeClass('hide').addClass('show'); 1672 gmfx$(".middle-bar").removeClass('inactive-step').addClass("active-step"); 1673 break; 1674 case 4: 1675 gmfx$(breadcrumbContainer, $component).removeClass("hide"); 1676 gmfx$("#step-1, #step-2, #step-3").addClass('hide'); 1677 gmfx$("#step-4").removeClass('hide'); 1678 gmfx$(".review-screen").removeClass('hide').addClass('show'); 1679 gmfx$(".inactive-step").removeClass('inactive-step').addClass("active-step"); 1680 break; 1681 default: 1682 gmfx$(".cover-screen").removeClass('hide').addClass('show'); 1683 break; 1684 } 1685 switch (goToPageToDisplay) { 1686 case "exterior-title": 1687 gmfx$("#step-one").removeClass("show").addClass("hide"); 1688 gmfx$("#step-two").removeClass("hide").addClass("show"); 1689 break; 1690 case "interior-title": 1691 gmfx$("#step-two").removeClass("show").addClass("hide"); 1692 gmfx$("#step-three").removeClass("hide").addClass("show"); 1693 break; 1694 case "review": 1695 gmfx$("#step-three").removeClass("show").addClass("hide"); 1696 gmfx$("#step-four").removeClass("hide").addClass("show"); 1697 break; 1698 case "basic-disc": 1699 gmfx$(breadcrumbContainer, $component).addClass("hide"); 1700 break; 1701 case "basic-explain": 1702 case "cover-screen": 1703 gmfx$("#step-two, #step-three, #step-four").removeClass("show").addClass("hide"); 1704 gmfx$("#step-one").removeClass("hide"); 1705 gmfx$("#step-2, #step-3, #step-4").addClass('hide'); 1706 gmfx$("#step-1").removeClass('hide'); 1707 gmfx$(breadcrumbContainer, $component).addClass("hide"); 1708 gmfx$(".bar").removeClass('active-step').addClass("inactive-step"); 1709 gmfx$(".left-bar").addClass("active-step").removeClass("inactive-step"); 1710 gmfx$("ul.exterior-items, ul.interior-items").html(""); 1711 break; 1712 } 1713 gmfx$(this).closest('.show').removeClass('show').addClass('hide'); 1714 goToPageToDisplay === 'basic-explain' ? gmfx$('#eol-wizard .gmf-wizard--breadcrumb-container').removeClass('hide')
1714: ''; 1715 if(goToPageToDisplay != "interior-info") { 1716 gmfx$("section[data-gmfw-step='" + goToPageToDisplay + "'").removeClass('hide').addClass('show'); 1717 } 1718 optionsSelected(answer); 1719 } 1720 }); 1721 gmfx$(btnBrandClick, $component).on("click", function() { 1722 var brandSelected = gmfx$(this).data("brand"); 1723 gmBrand = brandSelected; 1724 gmfx$('.brand-selection').text(brandSelected); 1725 optionsSelected(gmBrand); 1726 }); 1727 1728 /* Click to go to Exterior information page CTA Section 2*/ 1729 gmfx$(document).on("click", '.btn[data-go-to="exterior-info"]', function() { 1730 var goToPageToDisplay = ""; 1731 var exteriorArrayValue = []; 1732 var exteriorArrayLength = gmfx$("#ext-eval input:checkbox:checked").length; 1733 var exteriorOptionsChecked = gmfx$("#ext-eval input:checkbox:checked").map(function() { 1734 optionsSelected(gmfx$(this).val()); 1735 return gmfx$(this).val(); 1736 }).get(); 1737 var exteriorSelectedLabel = gmfx$("#ext-eval input:checkbox:checked").map(function() { 1738 return gmfx$(this).data("label"); 1739 }).get(); 1740 if(exteriorOptionsChecked == 0) { 1741 exteriorOptionsChecked = [optionNameExteriorNoneSelected]; 1742 } 1743 exteriorValuesArray = exteriorOptionsChecked; 1744 exteriorArrayValue = JSON.stringify(exteriorValuesArray); 1745 setCookie("wizardExt", exteriorArrayValue); 1746 sessionStorage.setItem("extAnswer", exteriorArrayValue); 1747 gmfx$(btnOriginalWheelYes).addClass("hide"); 1748 gmfx$(btnOriginalWheelNo).addClass("hide"); 1749 gmfx$(btnOriginalOemYes).removeClass("hide"); 1750 gmfx$(btnOriginalOemNo).removeClass("hide"); 1751 gmfx$(btnOemClosure).removeClass("hide"); 1752 gmfx$(btnOemTire).addClass("hide"); 1753 gmfx$(btnOemUnsureClosure).removeClass("hide"); 1754 gmfx$(btnOemUnsureTire).addClass("hide"); 1755 if(exteriorArrayLength > 0) { 1756 if(exteriorArrayLength == 1 && (exteriorValuesArray[0] == optionNamePunctures || exteriorValuesArray[0] == optionNameHeadlight || exteriorValuesArray[0] == optionNameExteriorNoneSelected)) { 1757 goToPageToDisplay = "exterior-original-wheels"; 1758 gmfx$("section[data-gmfw-step='exterior-info'").removeClass('show').addClass('hide'); 1759 gmfx$("section[data-gmfw-step='" + goToPageToDisplay + "'").removeClass('hide').addClass('show'); 1760 } else if(exteriorArrayLength == 2 && exteriorValuesArray[0] == optionNamePunctures && exteriorValuesArray[1] == optionNameHeadlight) { 1761 goToPageToDisplay = "exterior-original-wheels"; 1762 gmfx$("section[data-gmfw-step='exterior-info'").removeClass('show').addClass('hide'); 1763 gmfx$("section[data-gmfw-step='" + goToPageToDisplay + "'").removeClass('hide').addClass('show'); 1764 } else { 1765 var exteriorHtmlCode = function() { 1766 var exteriorHtmlCopy = ""; 1767 exteriorValuesArray.forEach(function(element, index) { //add list to need more info Section 2 1768 if(element != optionNamePunctures && element != optionNameHeadlight) { 1769 exteriorHtmlCopy = exteriorHtmlCopy + '<li class="selectedvalues"><h5>' + exteriorSelectedLabel[index] + '</h5></li>'; 1770 } 1771 if(element == optionNameDamageWheel) { 1772 gmfx$(btnOriginalWheelYes).removeClass("hide"); 1773 gmfx$(btnOriginalWheelNo).removeClass("hide"); 1774 gmfx$(btnOriginalOemYes).addClass("hide"); 1775 gmfx$(btnOriginalOemNo).addClass("hide"); 1776 1777 } 1778 if(element == optionNameTires) { //check if tires option was selected to show or hide the ctas needed 1779 gmfx$(btnOemClosure).addClass("hide"); 1780 gmfx$(btnOemTire).removeClass("hide"); 1781 gmfx$(btnOemUnsureClosure).addClass("hide"); 1782 gmfx$(btnOemUnsureTire).removeClass("hide"); 1783 } 1784 }); 1785 return exteriorHtmlCopy; 1786 } 1787 gmfx$(".exterior-list").html(exteriorHtmlCode); //add html code to display in the exterior list on step 2 1788 } 1789 } else { 1790 goToPageToDisplay = "exterior-original-wheels"; 1791 gmfx$("section[data-gmfw-step='exterior-info'").removeClass('show').addClass('hide'); 1792 gmfx$("section[data-gmfw-step='" + goToPageToDisplay + "'").removeClass('hide').addClass('show'); 1793 } 1794 1795 }); 1796 gmfx$(btnInteriorInfo, $component).on("click", function() { 1797 var goToPageToDisplay = ""; 1798 var InteriorArrayValue = [];
1799 var interiorArrayLength = gmfx$("#int-eval input:checkbox:checked").length; 1800 var interiorOptionsChecked = gmfx$("#int-eval input:checkbox:checked").map(function() { 1801 optionsSelected(gmfx$(this).val()); 1802 return gmfx$(this).val(); 1803 }).get(); 1804 var intName = gmfx$("#int-eval input:checkbox:checked").map(function() { 1805 return gmfx$(this).data("label"); 1806 }).get(); 1807 if(interiorOptionsChecked == 0) { 1808 interiorOptionsChecked = [optionNameInteriorNoneSelected]; 1809 } 1810 interiorValuesArray = interiorOptionsChecked; 1811 InteriorArrayValue = JSON.stringify(interiorValuesArray); 1812 setCookie("wizardInt", InteriorArrayValue); 1813 sessionStorage.setItem("intAnswer", InteriorArrayValue); 1814 if(interiorArrayLength > 0) { 1815 if(interiorArrayLength == 1 && interiorValuesArray[0] == optionNameEquipment || interiorValuesArray[0] == optionNamePanel || interiorValuesArray[0] == optionNameInteriorNoneSelected) { 1816 goToPageToDisplay = "interior-recall"; 1817 gmfx$("section[data-gmfw-step='interior-info'").removeClass('show').addClass('hide'); 1818 gmfx$("section[data-gmfw-step='" + goToPageToDisplay + "'").removeClass('hide').addClass('show'); 1819 } else if(interiorArrayLength == 2 && interiorValuesArray[0] == optionNameEquipment && interiorValuesArray[1] == optionNamePanel) { 1820 goToPageToDisplay = "interior-recall"; 1821 gmfx$("section[data-gmfw-step='interior-info'").removeClass('show').addClass('hide'); 1822 gmfx$("section[data-gmfw-step='" + goToPageToDisplay + "'").removeClass('hide').addClass('show'); 1823 } else { 1824 var inthtml = function() { 1825 var interiorHtmlCopy = ""; 1826 interiorValuesArray.forEach(function(element, index, array) { 1827 if(element != optionNamePanel && element != optionNameEquipment) { 1828 interiorHtmlCopy = interiorHtmlCopy + '<li class="selectedvalues"><h5>' + intName[index] + '</h5></li>'; 1829 } 1830 }); 1831 return interiorHtmlCopy; 1832 } 1833 gmfx$(".interior-list").html(inthtml); 1834 gmfx$("section[data-gmfw-step='interior-info'").removeClass('hide').addClass('show'); 1835 } 1836 } else { 1837 goToPageToDisplay = "interior-recall"; 1838 gmfx$("section[data-gmfw-step='interior-info'").removeClass('show').addClass('hide'); 1839 gmfx$("section[data-gmfw-step='" + goToPageToDisplay + "'").removeClass('hide').addClass('show'); 1840 } 1841 }); 1842 gmfx$(inputRadioDefault, $component).on("click", function() { 1843 gmfx$(".check-box label").removeClass("active"); 1844 gmfx$(this).parents(".check-box").find("label").addClass("active"); 1845 }); 1846 gmfx$(selectionExteriorForm, $component).on("click", function() { 1847 var exteriorArrayLength = gmfx$(exteriorValuesArray).length; 1848 var goToPageToDisplay; 1849 if(exteriorView < exteriorArrayLength) { 1850 goToPageToDisplay = exteriorInformation(exteriorView); 1851 } else { 1852 goToPageToDisplay = "exterior-original-wheels"; 1853 } 1854 if(goToPageToDisplay == "exterior-glass") { 1855 exteriorView++; 1856 } 1857 gmfx$("section[data-gmfw-step='" + goToPageToDisplay + "'").removeClass('hide').addClass('show'); 1858 }); 1859 gmfx$(forwardExteriorSectionView, $component).on("click", function() { 1860 exteriorView++; 1861 }); 1862 gmfx$(backExteriorSectionView, $component).on("click", function() { 1863 exteriorView--; 1864 }); 1865 gmfx$(forwardInteriorSectionView, $component).on("click", function() { 1866 interiorView++; 1867 }); 1868 gmfx$(backInteriorSectionView, $component).on("click", function() { 1869 interiorView--; 1870 }); 1871 gmfx$(backExteriorSectionGoTo, $component).on("click", function() { 1872 var exteriorGoBack = sessionStorage.getItem("extAnswer"); 1873 exteriorGoBack = JSON.parse(exteriorGoBack); 1874 var exteriorBackArrayLength = gmfx$(exteriorGoBack).length - 1; 1875 if(exteriorGoBack[exteriorBackArrayLength] != optionNameDings && exteriorGoBack[exteriorBackArrayLength] != optionNameScratches && exteriorGoBack[exteriorBackArrayLength] != optionNamePunctures && exteriorGoBack[exteriorBackArrayLength] != optionNameHeadlight && exteriorGoBack[exteriorBackArrayLength] != optionNameDents && exteriorGoBack[exteriorBackArrayLength] != optionNameGlass && exteriorGoBack[exteriorBackArrayLength] != optionNameDamageWheel && exteriorGoBack[exteriorBackArrayLength] != optionNameTires) { 1876 answerExteriorArray.pop(); 1877 sessionStorage.setItem("extAnswer", JSON.stringify(answerExteriorArray)); 1878 } 1879 switch (exteriorGoBack[exteriorBackArrayLength]) { 1880 case optionNamePunctures: 1881 case optionNameHeadlight: 1882 if(gmfx$(exteriorGoBack).length == 1) { 1883 goToPageToDisplay = "exterior-evaluation"; 1884 } else if(gmfx$(exteriorGoBack).length == 2 && exteriorGoBack[0] == optionNamePunctures && exteriorGoBack[1] == optionNameHeadlight) { 1885 goToPageToDisplay = "exterior-evaluation"; 1886 } else { 1887 goToPageToDisplay = "exterior-info"; 1888 } 1889 break; 1890 case optionNameDings: 1891 case optionNameScratches: 1892 case optionNameDents: 1893 case optionNameGlass: 1894 case optionNameDamageWheel: 1895 case optionNameTires: 1896 exteriorView = 0; 1897 goToPageToDisplay = "exterior-info"; 1898 break; 1899 case "dings-yes": 1900 case "dings-no": 1901 goToPageToDisplay = "exterior-dings"; 1902 break; 1903 case "dings-count-yes": 1904 case "dings-count-no": 1905 goToPageToDisplay = "exterior-dings-count"; 1906 break; 1907 case "dings-unsure": 1908 goToPageToDisplay = "exterior-dings-unsure"; 1909 break; 1910 case "scratches-yes": 1911 case "scratches-no": 1912 goToPageToDisplay = "exterior-scratches"; 1913 break; 1914 case "scratches-count-yes": 1915 case "scratches-count-no": 1916 goToPageToDisplay = "exterior-scratches-count"; 1917 break; 1918 case "scratches-unsure": 1919 goToPageToDisplay = "exterior-scratches-unsure"; 1920 break; 1921 case "dents-yes": 1922 case "dents-no": 1923 goToPageToDisplay = "exterior-dents"; 1924 break; 1925 case "dents-count-yes": 1926 case "dents-count-no": 1927 goToPageToDisplay = "exterior-dents-count"; 1928 break; 1929 case "dents-unsure": 1930 goToPageToDisplay = "exterior-dents-unsure"; 1931 break; 1932 case "glass-yes": 1933 case "glass-no": 1934 goToPageToDisplay = "exterior-glass"; 1935 break; 1936 case "glass-unsure": 1937 goToPageToDisplay = "exterior-glass-unsure"; 1938 break; 1939 case "original-wheel-yes": 1940 goToPageToDisplay = "exterior-original-yes"; 1941 break; 1942 case "original-wheel-no": 1943 goToPageToDisplay = "exterior-original-wheels"; 1944 break; 1945 case "original-quality-yes": 1946 case "original-quality-no": 1947 goToPageToDisplay = "exterior-original-no"; 1948 break; 1949 case "wheels-damage-yes": 1950 case "wheels-damage-no": 1951 goToPageToDisplay = "exterior-wheels-damage"; 1952 break; 1953 case "wheels-damage-unsure": 1954 goToPageToDisplay = "exterior-wheels-unsure"; 1955 break; 1956 case "oem-yes": 1957 case "oem-no": 1958 goToPageToDisplay = "exterior-oem"; 1959 break; 1960 case "oem-unsure": 1961 goToPageToDisplay = "exterior-oem-unsure"; 1962 break; 1963 case "tires-yes": 1964 case "tires-no": 1965 goToPageToDisplay = "exterior-tire"; 1966 break; 1967 case "tires-unsure": 1968 goToPageToDisplay = "exterior-tire-unsure"; 1969 break; 1970 case optionNameExteriorNoneSelected: 1971 goToPageToDisplay = "exterior-evaluation"; 1972 gmfx$(btnOriginalWheelYes).addClass("hide"); 1973 gmfx$(btnOriginalWheelNo).addClass("hide"); 1974 gmfx$(btnOriginalOemYes).removeClass("hide"); 1975 gmfx$(btnOriginalOemNo).removeClass("hide"); 1976 break; 1977 } 1978 gmfx$("section[data-gmfw-step='" + goToPageToDisplay + "'").removeClass('hide').addClass('show'); 1979 1980 }); 1981 gmfx$(backInteriorSectionGoTo, $component).on("click", function() { 1982 var interiorGoBack = sessionStorage.getItem("intAnswer"); 1983 interiorGoBack = JSON.parse(interiorGoBack); 1984 var interiorBackArrayLength = gmfx$(interiorGoBack).length - 1; 1985 if(interiorGoBack[interiorBackArrayLength] != optionNameDefects && interiorGoBack[interiorBackArrayLength] != optionNameEquipment && interiorGoBack[interiorBackArrayLength] != optionNamePanel && interiorGoBack[interiorBackArrayLength] != optionNameStains && interiorGoBack[interiorBackArrayLength] != optionNameHoles && interiorGoBack[interiorBackArrayLength] != optionNameTears) { 1986 answerInteriorArray.pop(); 1987 sessionStorage.setItem("intAnswer", JSON.stringify(answerInteriorArray)); 1988 } 1989 switch (interiorGoBack[interiorBackArrayLength]) { 1990 case optionNamePanel: 1991 case optionNameEquipment: 1992 interiorView = 0; 1993 if(gmfx$(interiorGoBack).length == 1) { 1994 goToPageToDisplay = "interior-evaluation"; 1995 } else if(gmfx$(interiorGoBack).length == 2 && interiorGoBack[0] == optionNameEquipment && interiorGoBack[1] == optionNamePanel) { 1996 goToPageToDisplay = "interior-evaluation"; 1997 } else { 1998 goToPageToDisplay = "interior-info"; 1999 } 2000 break; 2001 case optionNameDefects: 2002 case optionNameStains: 2003 case optionNameHoles: 2004 case optionNameTears: 2005 interiorView = 0; 2006 goToPageToDisplay = "interior-info"; 2007 break; 2008 case "mechanical-yes": 2009 case "mechanical-no": 2010 goToPageToDisplay = "interior-mechanical"; 2011 break; 2012 case "stains-yes": 2013 case "stains-no": 2014 goToPageToDisplay = "interior-stains"; 2015 break; 2016 case "stains-unsure": 2017 goToPageToDisplay = "interior-stains-unsure"; 2018 break; 2019 case "holes-yes": 2020 case "holes-no": 2021 goToPageToDisplay = "interior-holes"; 2022 break; 2023 case "holes-unsure": 2024 goToPageToDisplay = "interior-holes-unsure"; 2025 break; 2026 case "tears-yes": 2027 case "tears-no": 2028 goToPageToDisplay = "interior-tears"; 2029 break; 2030 case "tears-unsure": 2031 goToPageToDisplay = "interior-tears-unsure"; 2032 break; 2033 case "recall-yes": 2034 goToPageToDisplay = "interior-recall"; 2035 break; 2036 case optionNameInteriorNoneSelected: 2037 goToPageToDisplay = "interior-evaluation"; 2038 break; 2039 } 2040 gmfx$("section[data-gmfw-step='" + goToPageToDisplay + "'").removeClass('hide').addClass('show'); 2041 }); 2042 gmfx$(document).on("click", '.btn[data-go-to="interior-selections"]', function() {
2043 var interiorArrayLength = gmfx$(interiorValuesArray).length; 2044 var goToPageToDisplay; 2045 if(interiorView < interiorArrayLength) { 2046 goToPageToDisplay = internalInfo(interiorView); 2047 } else { 2048 goToPageToDisplay = "interior-recall"; 2049 } 2050 gmfx$("section[data-gmfw-step='" + goToPageToDisplay + "'").removeClass('hide').addClass('show'); 2051 }); 2052 /* section 4 */ 2053 gmfx$(fillAnswers, $component).on("click", function() { 2054 printSelectedAnswer(); //add all answers into result boxes 2055 }); 2056 gmfx$(fillAnswers, $component).on("click", function() { 2057 var exteriorFilledAnswers = sessionStorage.getItem("extAnswer"); 2058 var interiorFilledAnswers = sessionStorage.getItem("intAnswer"); 2059 var exteriorFilledAnswerNone = exteriorFilledAnswers[0]; 2060 var interiorFilledAnswerNone = interiorFilledAnswers[0]; 2061 if(exteriorFilledAnswerNone == optionNameExteriorNoneSelected && interiorFilledAnswerNone == optionNameInteriorNoneSelected) { //Display Brand in section 1 2062 gmfx$("section[data-gmfw-step='review-disposition-fee'] span.subtitle").html("We're Sorry <br/> Your disposition fee of " + brand + " won't be waived."); 2063 } 2064 }); 2065 gmfx$(reviewSelectionClick, $component).on("click", function() { 2066 var verify = gmfx$(this).data("verify"); 2067 var exteriorSelectedAnswers = sessionStorage.getItem("extAnswer"); 2068 var interiorSelectedAnswers = sessionStorage.getItem("intAnswer"); 2069 var count = 0; 2070 exteriorSelectedAnswers = JSON.parse(exteriorSelectedAnswers); 2071 interiorSelectedAnswers = JSON.parse(interiorSelectedAnswers); 2072 var goToPageToDisplay; 2073 if(verify == "oem") { 2074 exteriorSelectedAnswers.forEach(function(element) { 2075 if(element == "oem-no") { 2076 goToPageToDisplay = "review-tires"; 2077 count++; 2078 } else if(element == "oem-yes") { 2079 exteriorSelectedAnswers.forEach(function(element) { 2080 if(element == "original-wheel-no") { 2081 goToPageToDisplay = "original-wheels"; 2082 count++; 2083 } else if(element == "original-wheel-yes") { 2084 interiorSelectedAnswers.forEach(function(element) { 2085 if(element == "mechanical-yes") { 2086 goToPageToDisplay = "review-mechanical-defects"; 2087 count++; 2088 } 2089 }); 2090 } 2091 }); 2092 } 2093 }); 2094 } 2095 if(verify == "tires") { 2096 exteriorSelectedAnswers.forEach(function(element) { 2097 if(element == "original-wheel-no") { 2098 goToPageToDisplay = "original-wheels"; 2099 count++; 2100 } else if(element == "original-wheel-yes") { 2101 interiorSelectedAnswers.forEach(function(element) { 2102 if(element == "mechanical-yes") { 2103 goToPageToDisplay = "review-mechanical-defects"; 2104 count++; 2105 } 2106 }) 2107 } 2108 }) 2109 } 2110 if(verify == "wheels") { 2111 interiorSelectedAnswers.forEach(function(element) { 2112 if(element == "mechanical-yes") { 2113 goToPageToDisplay = "review-mechanical-defects"; 2114 count++; 2115 } 2116 }); 2117 } 2118 if(count == 0) { 2119 goToPageToDisplay = "what-next"; 2120 } 2121 gmfx$("section[data-gmfw-step='" + goToPageToDisplay + "'").removeClass('hide').addClass('show'); 2122 }); 2123 gmfx$(mobileTabOpen, $component).on("click", function() { //tab collapse in 2124 gmfx$(this).addClass("collapsed").attr("aria-expanded", "true"); 2125 gmfx$(this).parents('.panel').find('.collapse').removeClass("collapse").addClass("collapsing").attr("aria-expanded", "true"); 2126 gmfx$(this).parents('.panel').find('.collapsing').queue(function(next) { 2127 gmfx$(this).removeClass("collapsing").addClass("collapse").addClass("in").attr("style", ""); 2128 next(); 2129 }); 2130 }); 2131 gmfx$(mobileTabClose, $component).on("click", function() { 2132 gmfx$(this).removeClass("collapsed").attr("aria-expanded", "false"); 2133 gmfx$(this).parents('.panel').find('.collapse').addClass("collapsing").removeClass("in").attr("aria-expanded", "false").attr("style", "height:0px"); 2134 gmfx$(this).parents('.panel').find('.collapse').removeClass("collapsing"); 2135 }); 2136 gmfx$(btnPrintClick, $component).on("click", function() { 2137 window.print(); 2138 }); 2139 /* initialize exterior and interior forms */
2140 gmfx$(initExteriorEvaluation, $component).on("click", function() { 2141 exteriorView = 0; 2142 }); 2143 gmfx$(initInteriorEvaluation, $component).on("click", function() { 2144 interiorView = 0; 2145 }); 2146 2147 /* Checkbox input*/ 2148 gmfx$(checkboxSelectedExterior, $component).on("click", function() { 2149 gmfx$('#ext-eval-none input[type=checkbox]').prop('checked', false); 2150 }); 2151 gmfx$(checkboxSelectedExteriorNone, $component).on("click", function() { 2152 gmfx$('#ext-eval input[type=checkbox]').prop('checked', false); 2153 exteriorView = 0; 2154 exteriorValuesArray = {}; 2155 }); 2156 gmfx$(checkboxSelectedInterior, $component).on("click", function() { 2157 gmfx$('#int-eval-none input[type=checkbox]').prop('checked', false); 2158 }); 2159 gmfx$(checkboxSelectedInteriorNone, $component).on("click", function() { 2160 gmfx$('#int-eval input[type=checkbox]').prop('checked', false); 2161 interiorView = 0; 2162 interiorValuesArray = {}; 2163 }); 2164 /*Functions - Start */ 2165 /*External section display depends of form selection*/ 2166 function exteriorInformation(externalView) { 2167 var exteriorPage = exteriorValuesArray[externalView]; 2168 var goToPageToDisplay; 2169 exteriorView = externalView; 2170 switch (exteriorPage) { 2171 case optionNamePunctures: 2172 externalView++; 2173 goToPageToDisplay = exteriorInformation(externalView); 2174 break; 2175 case optionNameHeadlight: 2176 externalView++; 2177 goToPageToDisplay = exteriorInformation(externalView); 2178 break; 2179 case optionNameDings: 2180 goToPageToDisplay = "exterior-dings"; 2181 break; 2182 case optionNameScratches: 2183 goToPageToDisplay = "exterior-scratches"; 2184 break; 2185 case optionNameDents: 2186 goToPageToDisplay = "exterior-dents"; 2187 break; 2188 case optionNameGlass: 2189 goToPageToDisplay = "exterior-glass"; 2190 break; 2191 case optionNameDamageWheel: 2192 goToPageToDisplay = "exterior-original-wheels"; 2193 gmfx$(btnOriginalWheelYes).removeClass("hide"); 2194 gmfx$(btnOriginalWheelNo).removeClass("hide"); 2195 gmfx$(btnOriginalOemYes).addClass("hide"); 2196 gmfx$(btnOriginalOemNo).addClass("hide"); 2197 break; 2198 case optionNameTires: 2199 goToPageToDisplay = "exterior-original-wheels"; 2200 gmfx$(btnOemClosure).addClass("hide"); 2201 gmfx$(btnOemClosure).addClass("hide"); 2202 gmfx$(btnOemTire).removeClass("hide"); 2203 gmfx$(btnOemTire).removeClass("hide"); 2204 gmfx$(btnOemUnsureClosure).attr("data-go-to", "exterior-tire"); 2205 break; 2206 default: 2207 goToPageToDisplay = "exterior-original-wheels"; 2208 break; 2209 } 2210 return goToPageToDisplay; 2211 } 2212 2213 /*Internal section display depends of form selection*/ 2214 function internalInfo(internalView) { 2215 var interiorPage = interiorValuesArray[internalView]; 2216 var goToPageToDisplay; 2217 interiorView = internalView; 2218 switch (interiorPage) { 2219 case optionNameDefects: 2220 goToPageToDisplay = "interior-mechanical"; 2221 break; 2222 case optionNameEquipment: 2223 internalView++; 2224 goToPageToDisplay = internalInfo(internalView); 2225 break; 2226 case optionNamePanel: 2227 internalView++; 2228 goToPageToDisplay = internalInfo(internalView); 2229 break; 2230 case optionNameStains: 2231 goToPageToDisplay = "interior-stains"; 2232 break; 2233 case optionNameHoles: 2234 goToPageToDisplay = "interior-holes"; 2235 break; 2236 case optionNameTears: 2237 goToPageToDisplay = "interior-tears"; 2238 break; 2239 default: 2240 goToPageToDisplay = "interior-recall"; 2241 break; 2242 } 2243 return goToPageToDisplay; 2244 } 2245 2246 function optionsSelected(answer) { 2247 var splitSelectedAnswerSection, splitSelectedAnswer = answer; 2248 try { //split none unique answers data 2249 splitSelectedAnswer = answer.split("-ans-"); 2250 splitSelectedAnswerSection = splitSelectedAnswer[0]; //get if the answer is for exterior or interior option 2251 splitSelectedAnswer = splitSelectedAnswer[1]; 2252 } catch (e) {} 2253 switch (answer) { // unique named data options selected 2254 case "Chevy": 2255 case "Buick": 2256 case "GMC": 2257 case "Cadillac": 2258 var guideUrl = ""; 2259 answerFeeArray = []; 2260 answerFeeArray.push(answer); 2261 sessionStorage.setItem("step1Answer", JSON.stringify(answerFeeArray)); 2262 switch (answer) { 2263 case "Chevy": 2264 guideUrl = chevyGuideUrl; 2265 break; 2266 case "Buick": 2267 guideUrl = buickGuideUrl; 2268 break; 2269 case "GMC": 2270 guideUrl = gmcGuideUrl; 2271 break; 2272 case "Cadillac": 2273 guideUrl = cadillacGuideUrl; 2274 break; 2275 } 2276 gmfx$("a.leaseEndGuide").attr("href", guideUrl); 2277 break; 2278 case "exterior-form": //initialize exterior form 2279 answerExteriorArray = []; 2280 break; 2281 case "interior-form": //initialize interior form 2282 answerInteriorArray = []; 2283 break; 2284 case optionNamePunctures: 2285 case optionNameHeadlight: 2286 answerExteriorArray.push(answer); 2287 sessionStorage.setItem("extAnswer", JSON.stringify(answerExteriorArray)); 2288 break; 2289 case optionNameEquipment: 2290 case optionNamePanel: 2291 answerInteriorArray.push(answer); 2292 sessionStorage.setItem("intAnswer", JSON.stringify(answerInteriorArray)); 2293 break; 2294 } 2295 switch (splitSelectedAnswerSection) { // none unique name data options selected 2296 case "staying": 2297 for(var i = 1; answerFeeArray.length > i; i++) { 2298 answerFeeArray.pop(); 2299 } 2300 answerFeeArray.push(splitSelectedAnswer); 2301 sessionStorage.setItem("step1Answer", JSON.stringify(answerFeeArray)); 2302 break; 2303 case "ext": 2304 answerExteriorArray = exteriorValuesArray; 2305 answerExteriorArray.push(splitSelectedAnswer); 2306 sessionStorage.setItem("extAnswer", JSON.stringify(answerExteriorArray)); 2307 break; 2308 case "int": 2309 answerInteriorArray = interiorValuesArray; 2310 answerInteriorArray.push(splitSelectedAnswer); 2311 sessionStorage.setItem("intAnswer", JSON.stringify(answerInteriorArray)); 2312 break; 2313 } 2314 } 2315 2316 /* section 4 fill selected answers */ 2317 function printSelectedAnswer() { 2318 var firstStepAnswers = sessionStorage.getItem("step1Answer"); 2319 var exteriorAnswers = sessionStorage.getItem("extAnswer"); 2320 var interiorAnswers = sessionStorage.getItem("intAnswer"); 2321 firstStepAnswers = JSON.parse(firstStepAnswers); 2322 exteriorAnswers = JSON.parse(exteriorAnswers); 2323 interiorAnswers = JSON.parse(interiorAnswers); 2324 var helpCount = 0; 2325 var helpString = ""; 2326 var exteriorAnswerNone = exteriorAnswers[0]; 2327 var interiorAnswerNone = interiorAnswers[0]; 2328 var wheelYes = exteriorAnswers[1]; 2329 var oemYes = exteriorAnswers[2]; 2330 gmfx$("ul.exterior-items, ul.interior-items").html(""); 2331 if(interiorAnswerNone == optionNameInteriorNoneSelected) { 2332 gmfx$(".interior-results .subtitle").html("It looks like youâve treated y
2332our vehicle well and you may not be subject to excess wear charges."); 2333 } else { 2334 gmfx$(".interior-results .subtitle").html("Your vehicle may be considered to have normal or excess wear and use based on the following answers:"); 2335 } 2336 if(exteriorAnswerNone == optionNameExteriorNoneSelected && interiorAnswerNone == optionNameInteriorNoneSelected && wheelYes == "original-wheel-yes" && oemYes == "oem-yes") { 2337 gmfx$("section[data-gmfw-step='review-wear-use'] p.lead").html("It looks like youâve treated your vehicle well and you may not be subject to excess wear charges."); 2338 } else { 2339 gmfx$("section[data-gmfw-step='review-wear-use'] p.lead").html("Based on your answers, it's likely you may be subject to excess wear charges on your lease-end liability invoice. It's recommended to schedule a complimentary inspection to have an expert examine your vehicle. After taking advantage of your inspection, we recommend talking with your nearest dealer about making possible repairs prior to turning in."); 2340 } 2341 firstStepAnswers.forEach(function(element, index, array) { 2342 switch (helpCount) { 2343 case 0: 2344 gmfx$(".items .answer-brand .answerSection p").text(element); 2345 break; 2346 case 1: 2347 var getAnswer = element; 2348 var copyTextAnswer; 2349 var brand = array[index - 1].toLowerCase().replace(/\b[a-z]/g, function(letter) { 2350 return letter.toUpperCase(); 2351 }); 2352 if(brand == "Gmc") { 2353 brand = "GMC"; 2354 } 2355 getAnswer = element.split("family-"); 2356 if(getAnswer[1] == "yes") { 2357 copyTextAnswer = "By staying loyal, you may have your disposition fee waived. Youâll also be eligible for a partial waiver on excess wear."; 2358 gmfx$("section[data-gmfw-step='review-disposition-fee'] p.lead").html("Congrats! The disposition fee of your " + brand + " will be waived."); 2359 } else { 2360 copyTextAnswer = "If you stay in the GM family, you may have your disposition fee waived and be eligible for a partial waiver on excess wear."; 2361 gmfx$("section[data-gmfw-step='review-disposition-fee'] p.lead").html("Weâre Sorry <br/> Your disposition fee of " + brand + " wonât be waived."); 2362 } 2363 gmfx$(".items .answer-fee .answerSection p").text(getAnswer[1]); 2364 gmfx$(".items .answer-eligible .answerSection p").text(copyTextAnswer); 2365 break; 2366 } 2367 helpCount++; 2368 }); 2369 exteriorAnswers.forEach(function(element, index, array) { 2370 var exteriorSplitAnswer = element.split("-"); 2371 var exteriorDisplayQuestion, exteriorDisplayAnswer; 2372 var originalWheel = 0; 2373 if(exteriorSplitAnswer[0] == "oem") { 2374 exteriorDisplayQuestion = "Tires"; 2375 exteriorDisplayAnswer = printReviewSectionAnswer(exteriorSplitAnswer[0], exteriorSplitAnswer[1], array[index + 1]); 2376 } else if(exteriorSplitAnswer[1] == "wheel") { 2377 if(exteriorAnswers[index + 1] == "original-wheel-yes" || exteriorAnswers[index + 1] == "original-wheel-no") { 2378 originalWheel = 1; 2379 } else { 2380 originalWheel = 0; 2381 exteriorDisplayQuestion = "Wheels"; 2382 exteriorDisplayAnswer = printReviewSectionAnswer(exteriorSplitAnswer[0], exteriorSplitAnswer[2], array[index + 1]); 2383 } 2384 } else if(exteriorSplitAnswer[1] == "damage") { 2385 exteriorDisplayQuestion = exteriorSplitAnswer[0]; 2386 exteriorDisplayAnswer = printReviewSectionAnswer(exteriorSplitAnswer[0], exteriorSplitAnswer[2], array[index + 1]); 2387 } else { 2388 exteriorDisplayQuestion = exteriorSplitAnswer[0]; 2389 exteriorDisplayAnswer = printReviewSectionAnswer(exteriorSplitAnswer[0], exteriorSplitAnswer[1], array[index + 1]); 2390 } 2391 if(originalWheel == 0 && exteriorSplitAnswer[1] != "count" && element != optionNameDings && element != optionNameScratches && element != optionNameDents && element != optionNameTires && element != optionNameGlass && element != optionNameDamageWheel && exteriorSplitAnswer[0] != "wheels" && exteriorSplitAnswer[0] != "tires" && exteriorSplitAnswer[1] != "quality" && element != optionNameExteriorNoneSelected) { 2392 helpString = '<li class="items"><div class="infoWrap ' + exteriorSplitAnswer[0] + '"><div class="questionSection"><h4>' + exteriorDisplayQuestion + '</h4></div><div class="answerSection">' + exteriorDisplayAnswer + '</div></div></li>' 2393 gmfx$("ul.exterior-items").append(helpString); 2394 } 2395 });
2396 interiorAnswers.forEach(function(element, index, array) { 2397 var InteriorSplitAnswer = element.split("-"); 2398 var interiorDisplayQuestion, interiorDisplayAnswer; 2399 if(InteriorSplitAnswer[0] == "holes") { 2400 interiorDisplayQuestion = optionNameHoles; 2401 interiorDisplayAnswer = printReviewSectionAnswer(InteriorSplitAnswer[0], InteriorSplitAnswer[1], array[index + 1]); 2402 } else if(InteriorSplitAnswer[0] == "mechanical") { 2403 interiorDisplayQuestion = optionNameDefects; 2404 interiorDisplayAnswer = printReviewSectionAnswer(InteriorSplitAnswer[0], InteriorSplitAnswer[1], array[index + 1]); 2405 } else { 2406 interiorDisplayQuestion = InteriorSplitAnswer[0]; 2407 interiorDisplayAnswer = printReviewSectionAnswer(InteriorSplitAnswer[0], InteriorSplitAnswer[1], array[index + 1]); 2408 } 2409 if(InteriorSplitAnswer[0] != "recall" && element != optionNameInteriorNoneSelected && element != "mechanical-yes" && element != "mechanical-no" && element != optionNameStains && element != optionNameHoles && element != optionNameTears) { 2410 helpString = '<li class="items"><div class="infoWrap ' + InteriorSplitAnswer[0] + '"><div class="questionSection"><h4>' + interiorDisplayQuestion + '</h4></div><div class="answerSection">' + interiorDisplayAnswer + '</div></div></li>' 2411 gmfx$("ul.interior-items").append(helpString); 2412 } 2413 }); 2414 } 2415 2416 function printReviewSectionAnswer(question, answer, next) { 2417 var printQuestion = question; 2418 var printAnswer = answer; 2419 var nextAnswer = next; 2420 var nextCount = nextAnswer; 2421 var answerSelected = "<span>Excess</span>"; 2422 var nextAnswerSelected = "<span>Excess</span>"; 2423 var decision = "<p><span class='atitle'>Decision:</span> " + answerSelected + "</p>"; 2424 var answerType = "<p><span class='atitle'>" + printQuestion + ":</span> " + answerSelected + "</p>"; 2425 var addHtmlCode, answerDamageLength, answerDamageCount = ""; 2426 var exteriorHaveDamageLength, exteriorHaveDamage, exteriorHaveOriginalWheel; //count if the user have or do not have length size longer than x, damage wheel and if they have their original wheels 2427 try { 2428 nextCount = nextAnswer.split("-count-") 2429 nextCount = nextCount[1]; 2430 if(nextCount == "yes") { 2431 nextAnswerSelected = "<span>Excess</span>"; 2432 } else { 2433 nextAnswerSelected = "<span>Normal</span>"; 2434 } 2435 } catch (e) {} 2436 if(printAnswer == "yes") { 2437 answerSelected = "<span>Excess</span>"; 2438 decision = "<p><span class='atitle'>Decision:</span> " + answerSelected + "</p>"; 2439 } else if(printAnswer == "no") { 2440 answerSelected = "<span>Normal</span>"; 2441 if(nextCount == "yes") { 2442 decision = "<p><span class='atitle'>Decision:</span> <span>Excess</span></p>"; 2443 } else { 2444 decision = "<p><span class='atitle'>Decision:</span> " + answerSelected + "</p>"; 2445 } 2446 } else if(printAnswer == "unsure") { 2447 answerSelected = "<span>Excess</span>"; 2448 } else { 2449 answerSelected = "<span>Normal</span>"; 2450 } 2451 answerType = "<p><span class='atitle'>" + printQuestion + ":</span> " + answerSelected + "</p>"; 2452 switch (printQuestion) { 2453 case optionNamePunctures: 2454 answerSelected = "<span>Excess</span>"; 2455 decision = "<p><span class='atitle'>Decision:</span> " + answerSelected + "</p>"; 2456 addHtmlCode = decision; 2457 break; 2458 case optionNameHeadlight: 2459 answerSelected = "<span>Excess</span>"; 2460 decision = "<p><span class='atitle'>Decision:</span> " + answerSelected + "</p>"; 2461 addHtmlCode = decision; 2462 break; 2463 case optionNameDings.toLowerCase(): 2464 if(nextCount == "yes") { 2465 answerDamageLength = "<p><span class='atitle'>Length:</span> <span>Over</span></p>"; 2466 } else if(nextCount == "no") { 2467 answerDamageLength = "<p><span class='atitle'>Length:</span> <span>Under</span></p>"; 2468 } 2469 if(answerSelected == "<span>Excess</span>") { 2470 answerDamageCount = "<p><span class='atitle'>Count:</span> <span>More</span></p>" 2471 } else { 2472 answerDamageCount = "<p><span class='atitle'>Count:</span> <span>Less</span></p>" 2473 } 2474 addHtmlCode = decision + answerDamageLength + answerDamageCount; 2475 break; 2476 case optionNameScratches.toLowerCase(): 2477 if(nextCount == "yes") { 2478 answerDamageLength = "<p><span class='atitle'>Length:</span> <span>Over</span></p>"; 2479 } else if(nextCount == "no") { 2480 answerDamageLength = "<p><span class='atitle'>Length:</span> <span>Under</span></p>"; 2481 } 2482 if(answerSelected == "<span>Excess</span>") { 2483 answerDamageCount = "<p><span class='atitle'>Count:</span> <span>More</span></p>" 2484 } else { 2485 answerDamageCount = "<p><span class='atitle'>Count:</span> <span>Less</span></p>" 2486 } 2487 addHtmlCode = decision + answerDamageLength + answerDamageCount; 2488 break; 2489 case optionNameDents.toLowerCase(): 2490 if(nextCount == "yes") { 2491 answerDamageLength = "<p><span class='atitle'>Length:</span> <span>Over</span></p>"; 2492 } else if(nextCount == "no") { 2493 answerDamageLength = "<p><span class='atitle'>Length:</span> <span>Under</span></p>"; 2494 } 2495 if(answerSelected == "<span>Excess</span>") { 2496 answerDamageCount = "<p><span class='atitle'>Count:</span> <span>More</span></p>" 2497 } else { 2498 answerDamageCount = "<p><span class='atitle'>Count:</span> <span>Less</span></p>" 2499 } 2500 addHtmlCode = decision + answerDamageLength + answerDamageCount; 2501 break; 2502 case "glass": 2503 if(answerSelected == "<span>Excess</span>") { 2504 answerDamageLength = "<p><span class='atitle'>Length:</span> <span>Over</span></p>"; 2505 } else { 2506 answerDamageLength = "<p><span class='atitle'>Length:</span> <span>Under</span></p>"; 2507 } 2508 addHtmlCode = decision + answerDamageLength; 2509 break; 2510 case "original": 2511 exteriorAnswers = sessionStorage.getItem("extAnswer"); 2512 exteriorAnswers = JSON.parse(exteriorAnswers); 2513 answerDamageCount, exteriorHaveOriginalWheel, exteriorHaveDamageLength, exteriorHaveDamage = "";
2514 exteriorAnswers.forEach(function(element, index, array) { 2515 if(element == "original-quality-yes") { //aftermarket wheels 2516 exteriorHaveDamage = 0; 2517 } else if(element == "original-quality-no" || exteriorHaveDamage != 0) { 2518 exteriorHaveDamage = 1; 2519 } 2520 if(element == "wheels-damage-yes") { //Length 2521 answerDamageCount = "<p><span class='atitle'>Length:</span> <span>Over</span></p>"; 2522 exteriorHaveDamageLength = 0; 2523 } else if(element == "wheels-damage-no") { 2524 answerDamageCount = "<p><span class='atitle'>Length:</span> <span>Under</span></p>"; 2525 exteriorHaveDamageLength = 1; 2526 } else if(exteriorHaveDamageLength != 0) { 2527 exteriorHaveDamageLength = 1; 2528 } 2529 if(element == "original-wheel-yes") { 2530 answerType = "<p><span class='atitle'>Originals:</span> <span>Yes</span></p>"; 2531 exteriorHaveOriginalWheel = 0; 2532 } else if(element == "original-wheel-no") { 2533 answerType = "<p><span class='atitle'>Originals:</span> <span>No</span></p>"; 2534 exteriorHaveOriginalWheel = 1; 2535 } 2536 }) 2537 if((exteriorHaveOriginalWheel == 0 || exteriorHaveDamage == 0) && exteriorHaveDamageLength == 1) { 2538 decision = "<p><span class='atitle'>Decision:</span> <span>Normal</span></p>"; 2539 } else { 2540 decision = "<p><span class='atitle'>Decision:</span> <span>Excess</span></p>"; 2541 } 2542 //addHtmlCode = decision + answerType + answerDamageLength + answerDamageCount; 2543 addHtmlCode = decision + answerType + answerDamageCount; 2544 break; 2545 case "oem": 2546 exteriorAnswers = sessionStorage.getItem("extAnswer"); 2547 exteriorAnswers = JSON.parse(exteriorAnswers); 2548 answerDamageCount, exteriorHaveDamage, exteriorHaveDamageLength = ""; 2549 exteriorAnswers.forEach(function(element, index, array) { 2550 if(element == "tires-yes") { 2551 answerDamageCount = "<p><span class='atitle'>Length:</span> <span>Under</span></p>"; 2552 exteriorHaveDamageLength = 0; 2553 } else if(element == "tires-no" || element == "tires-unsure") { 2554 answerDamageCount = "<p><span class='atitle'>Length:</span> <span>Over</span></p>"; 2555 exteriorHaveDamageLength = 1; 2556 } 2557 if(element == "oem-yes") { 2558 answerType = "<p><span class='atitle'>Recommended Tires:</span> <span>Yes</span></p>"; 2559 exteriorHaveDamage = 0; 2560 } else if(element == "oem-no" || element == "oem-unsure") { 2561 answerType = "<p><span class='atitle'>Recommended Tires:</span> <span>No</span></p>"; 2562 exteriorHaveDamage = 1; 2563 } 2564 }); 2565 2566 if((exteriorHaveDamage == 0 && exteriorHaveDamageLength == 0) || (exteriorHaveDamage == 0 && exteriorHaveDamageLength == "")) { 2567 decision = "<p><span class='atitle'>Decision:</span> <span>Normal</span></p>"; 2568 } else { 2569 decision = "<p><span class='atitle'>Decision:</span> <span>Excess</span></p>"; 2570 } 2571 //addHtmlCode = decision + answerType + answerDamageLength + answerDamageCount; 2572 addHtmlCode = decision + answerType + answerDamageCount; 2573 break; 2574 case optionNameEquipment: 2575 addHtmlCode = decision; 2576 break; 2577 case optionNamePanel: 2578 answerSelected = "<span>Excess</span>"; 2579 addHtmlCode = decision; 2580 break; 2581 case optionNameDefects: 2582 interiorAnswers = sessionStorage.getItem("intAnswer"); 2583 interiorAnswers = JSON.parse(interiorAnswers);
2584 interiorAnswers.forEach(function(element, index, array) { 2585 if(element == "mechanical-yes") { 2586 decision = "<p><span class='atitle'>Decision:</span> <span>Excess</span></p>"; 2587 answerType = "<p><span class='atitle'>Defects:</span> <span>Excess</span></p>"; 2588 } else if(element == "mechanical-no") { 2589 decision = "<p><span class='atitle'>Decision:</span> <span>Normal</span></p>"; 2590 answerType = "<p><span class='atitle'>Defects:</span> <span>Normal</span></p>"; 2591 } 2592 }) 2593 addHtmlCode = decision + answerType; 2594 break; 2595 case optionNameStains.toLowerCase(): 2596 interiorAnswers = sessionStorage.getItem("intAnswer"); 2597 interiorAnswers = JSON.parse(interiorAnswers); 2598 interiorAnswers.forEach(function(element, index, array) { 2599 if(element == "stains-yes" || element == "stains-unsure") { 2600 decision = "<p><span class='atitle'>Decision:</span> <span>Excess</span></p>"; 2601 answerDamageLength = "<p><span class='atitle'>Permanence:</span> <span>Over</span></p>"; 2602 } else if(element == "stains-no") { 2603 decision = "<p><span class='atitle'>Decision:</span> <span>Normal</span></p>"; 2604 answerDamageLength = "<p><span class='atitle'>Permanence:</span> <span>Under</span></p>"; 2605 } 2606 }) 2607 addHtmlCode = decision + answerDamageLength; 2608 break; 2609 case "holes": 2610 interiorAnswers = sessionStorage.getItem("intAnswer"); 2611 interiorAnswers = JSON.parse(interiorAnswers); 2612 interiorAnswers.forEach(function(element, index, array) { 2613 if(element == "holes-yes" || element == "holes-unsure") { 2614 decision = "<p><span class='atitle'>Decision:</span> <span>Excess</span></p>"; 2615 answerDamageLength = "<p><span class='atitle'>Length:</span> <span>Over</span></p>"; 2616 } else if(element == "holes-no") { 2617 decision = "<p><span class='atitle'>Decision:</span> <span>Normal</span></p>"; 2618 answerDamageLength = "<p><span class='atitle'>Length:</span> <span>Under</span></p>"; 2619 } 2620 }); 2621 addHtmlCode = decision + answerDamageLength; 2622 break; 2623 case optionNameTears.toLowerCase(): 2624 interiorAnswers = sessionStorage.getItem("intAnswer"); 2625 interiorAnswers = JSON.parse(interiorAnswers); 2626 interiorAnswers.forEach(function(element, index, array) { 2627 if(element == "tears-yes" || element == "tears-unsure") { 2628 decision = "<p><span class='atitle'>Decision:</span> <span>Excess</span></p>"; 2629 answerDamageLength = "<p><span class='atitle'>Length:</span> <span>Over</span></p>"; 2630 } else if(element == "tears-no") { 2631 decision = "<p><span class='atitle'>Decision:</span> <span>Normal</span></p>"; 2632 answerDamageLength = "<p><span class='atitle'>Length:</span> <span>Under</span></p>"; 2633 } 2634 }); 2635 addHtmlCode = decision + answerDamageLength; 2636 break; 2637 } 2638 return addHtmlCode; 2639 } 2640 2641 /* Cookie saved options fill in forms*/ 2642 function formInfoSaved(form, checkboxSelected) { 2643 if(checkboxSelected == optionNameExteriorNoneSelected || checkboxSelected == optionNameInteriorNoneSelected) { 2644 if(form == "ext") { 2645 gmfx$("#ext-eval-none input").prop('checked', true); 2646 } 2647 if(form == "int") { 2648 gmfx$("#int-eval-none input").prop('checked', true); 2649 } 2650 } else { 2651 gmfx$("input[value='" + checkboxSelected + "'").prop('checked', true); 2652 } 2653 } 2654 /* Set, get and check cookies */ 2655 function setCookie(name, value) { 2656 var expire = new Date(); 2657 //expire.setHours(7, 24, 60, 60, 0); 2658 expire.setTime(expire.getTime() + (7 * 24 * 60 * 60 * 1000)); 2659 expire = expire.toUTCString(); 2660 document.cookie = name + "=" + value + "; expires=" + expire + "; path=/; Secure; SameSite=Strict"; 2661 } 2662 2663 function getCookie(cookieName) { 2664 var name = cookieName + "="; 2665 var decodedCookie = decodeURIComponent(document.cookie); 2666 var cookieSplit = decodedCookie.split(';'); 2667 for(var i = 0; i < cookieSplit.length; i++) { 2668 var cookie = cookieSplit[i]; 2669 while(cookie.charAt(0) == ' ') { 2670 cookie = cookie.substring(1); 2671 } 2672 if(cookie.indexOf(name) == 0) { 2673 return cookie.substring(name.length, cookie.length); 2674 } 2675 } 2676 return ""; 2677 } 2678 2679 function checkCookies() { 2680 var cookieExteriorSelection = getCookie("wizardExt"); 2681 var cookieInteriorSelection = getCookie("wizardInt"); 2682 if(cookieExteriorSelection) { 2683 storeCookie('wizardExt', 'ext', optionNameExteriorNoneSelected) 2684 } 2685 if(cookieInteriorSelection) { 2686 storeCookie('wizardInt', 'int', optionNameInteriorNoneSelected) 2687 } 2688 } 2689 2690 function storeCookie(cookieName, type, selectNone) { 2691 var storedCookie = JSON.parse(getCookie(cookieName)); 2692 if(storedCookie == "" || storedCookie[0] == selectNone) { 2693 formInfoSaved(type, storedCookie[0]); 2694 } else { 2695 storedCookie.forEach(function(element) { 2696 formInfoSaved(type, element); 2697 }); 2698 } 2699 } 2700 2701 /*init*/ 2702 checkCookies(); 2703}
2704gmfxMomentumUtils.component.init(".gmf-wizard", gmfxWwwComponents.eolWizard); 2705 2706 2707/** 2708 * VideoTile 2709 * 2710 * @author subha 2711 * @since 8/16/2021 2712 */ 2713gmfxWwwComponents.VideoTile = function(component) { 2714 'use strict'; 2715 2716 var $component = gmfx$(component); 2717 2718 // close video for embed (non brightcove) selection 2719 gmfx$(".embed-video-close, .modal", $component).on("click hidden.bs.modal", function() { 2720 gmfx$(".embed-video-player").each(function() { 2721 var videoSrc = gmfx$(this).attr("src"); 2722 gmfx$(this).attr("src", videoSrc); 2723 }); 2724 }); 2725 2726 //Check if PURL Page 2727 var isCookie = gmfxMomentumServices.Cookie.get("eol_uid"); 2728 if(isCookie != null && isCookie != "") { 2729 isCookie = Base64.decode(isCookie); 2730 var jsonObject = JSON.parse(isCookie); 2731 2732 // Getting Vehicle info from EOL Service 2733 var vehicleBrand = getFirstWord(jsonObject["eolData"]["gmfAccountDetail"]["vehicle"]["vehicleMake"].toLowerCase()); 2734 if(vehicleBrand == "buick") { 2735 gmfx$('.timeline .default, .timeline .cadillac, .timeline .chevy, .timeline .gmc').remove(); 2736 gmfx$(".timeline .buick").removeClass("hide"); 2737 gmfx$(".timeline2 .buick").removeClass("hide"); 2738 } else if(vehicleBrand == "cadillac") { 2739 gmfx$('.timeline .buick, .timeline .default, .timeline .chevy, .timeline .gmc').remove(); 2740 gmfx$(".timeline .cadillac").removeClass("hide"); 2741 gmfx$(".timeline2 .cadillac").removeClass("hide"); 2742 } else if(vehicleBrand == "chevrolet") { 2743 gmfx$('.timeline .buick, .timeline .cadillac, .timeline .default, .timeline .gmc').remove(); 2744 gmfx$(".timeline .chevy").removeClass("hide"); 2745 gmfx$(".timeline2 .chevy").removeClass("hide"); 2746 } else if(vehicleBrand == "gmc") { 2747 gmfx$('.timeline .buick, .timeline .cadillac, .timeline .chevy, .timeline .default').remove(); 2748 gmfx$(".timeline .gmc").removeClass("hide"); 2749 gmfx$(".timeline2 .gmc").removeClass("hide"); 2750 } 2751 } else { 2752 gmfx$('.timeline .buick, .timeline .cadillac, .timeline .chevy, .timeline .gmc').remove(); 2753 gmfx$(".timeline .default").removeClass("hide"); 2754 gmfx$(".timeline2 .default").removeClass("hide"); 2755 2756 } 2757 gmfx$('.timeline').each(function() { 2758 var vidid = gmfx$(this).data('unique-vidid'); 2759 var popup = gmfx$(this).data('video-checkbox'); 2760 var trial = "#"; 2761 var trial2 = trial + vidid; 2762 var videoimg = gmfx$(this).data('video-img'); 2763 2764 if(popup && !videoimg) { 2765 gmfx$(this).find('.vjs-poster').length === 0 ? gmfx$(this).find('iframe').after('<div class="timeline-video-overlay-layer" data-target="' + trial2 + '" data-toggle="modal" type="button"></div>') : gmfx$(this).find('.vjs-poster').after('<div class="timeline-video-overlay-layer" data-target="' + trial2 + '" data-toggle="modal" type="button"></div>'); 2766 } 2767 2768 var popupVideoContainer = gmfx$('#' + vidid + ' .timeline2 > div')[0]; 2769 gmfx$('#' + vidid).on('shown.bs.modal', function() { 2770 if(videojs.getPlayer(popupVideoContainer)) { 2771 videojs.getPlayer(popupVideoContainer).ready(function() { 2772 var secPlayer = this; 2773 secPlayer.play(); 2774 }); 2775 } 2776 }); 2777 gmfx$('#' + vidid).on('hidden.bs.modal', function() { 2778 if(videojs.getPlayer(popupVideoContainer)) { 2779 videojs.getPlayer(popupVideoContainer).ready(function() { 2780 var ThirdPlayer = this; 2781 ThirdPlayer.pause(); 2782 ThirdPlayer.currentTime(0); 2783 }); 2784 } 2785 }); 2786 2787 }); 2788}; 2789 2790//Initialize the component 2791gmfxMomentumUtils.component.init(".video-tile-component", gmfxWwwComponents.VideoTile); 2792 2793/** 2794 * Terms and Condition Component - accept and check if TNC has been accepted on ABS page 2795 * 2796 * @author subha 2797 * @since 8/16/2021 2798 */ 2799gmfxWwwComponents.TermsAndCondition = function(component) { 2800 'use strict'; 2801 2802 var $component = gmfx$(component); 2803 2804 // Reset Checkbox on page load 2805 gmfx$('input:checkbox:not(.login-section__form #rememberMe)').prop('checked', false); 2806 2807 if (gmfx$.fn.validator) { 2808 gmfx$(".termsform").validator(); 2809 } 2810 2811 gmfx$('.tc-btns button[type="submit"]').on('click touchstart', function(e) { 2812 gmfx$.each(gmfx$(".termsform").elements, function() { 2813 if(!gmfx$(this).val() && gmfx$(this).prop('required')) { 2814 gmfx$('.tc-btns button[type="submit"]').addClass("disabled"); 2815 return; 2816 } 2817 }); 2818 2819 if(gmfx$(this).hasClass("disabled")) { 2820 gmfx$('.with-errors').show(); 2821 return; 2822 } else { 2823 gmfx$('#term-condition-content').remove(); 2824 gmfx$('#original-content').show().removeClass('hide'); 2825 gmfx$('nav.secondary span').removeClass('nav-secondary-hide'); 2826 if(gmfx$('.hide-in-nav > a.active').length > 1) { 2827 if(gmfx$('#secondary > li > span > a.active').attr('href')) { 2828 gmfx$('#secondary > li > span > a.active').removeClass('active'); 2829 } 2830 } 2831 document.cookie = "GMF_ABS_Terms=" + Base64.encode('true') + "; mtracker=0; path=/; Secure; SameSite=Strict"; 2832 return false;
2833 } 2834 }); 2835 2836 gmfx$(".tc-btns .btn-secondary").click(function() { 2837 location.href = gmfx$('.tc-cancel-content').text(); 2838 }); 2839 2840 function checkCookie() { 2841 var isCookie = gmfxMomentumServices.Cookie.get("GMF_ABS_Terms"); 2842 if(isCookie != null && isCookie != "") { 2843 gmfx$('#term-condition-content').remove(); 2844 gmfx$('#original-content').show().removeClass('hide'); 2845 gmfx$('nav.secondary span').removeClass('nav-secondary-hide'); 2846 if(gmfx$('.hide-in-nav > a.active').length > 1) { 2847 if(gmfx$('#secondary > li > span > a.active').attr('href')) { 2848 gmfx$('#secondary > li > span > a.active').removeClass('active'); 2849 } 2850 } 2851 } else { 2852 gmfx$('#term-condition-content').show().removeClass('hide'); 2853 } 2854 } 2855 2856 // If checkbox enabled, check for cookie else show actual content 2857 if(gmfx$('.term-condition-enable').length > 0 && gmfx$('.term-condition-enable').text() == 'true') { 2858 checkCookie(); 2859 } else { 2860 gmfx$('#original-content').show().removeClass('hide'); 2861 } 2862 2863}; 2864 2865//Initialize the component 2866gmfxMomentumUtils.component.init("#original-content", gmfxWwwComponents.TermsAndCondition); 2867 2868/** 2869 * Table add table-revision ID when revision date is inputted 2870 * 2871 * @author mmustaine 2872 * @since 6/8/2021 2873 */ 2874 2875gmfxWwwComponents.Table = function(component) { 2876 'use strict'; 2877 2878 var $component = gmfx$(component); 2879 2880 if(gmfx$('.privacy-table') != null && gmfx$('.privacy-facts') != null && gmfx$('#table-revision').html() != null) { 2881 gmfx$('<div class="revision-date tiny">' + gmfx$('#table-revision').html() + '</div>').insertBefore(gmfx$('.privacy-table >.privacy-facts')); 2882 } 2883}; 2884 2885// Initialize the component 2886gmfxMomentumUtils.component.init(".privacy-table", gmfxWwwComponents.Table); 2887 2888/** 2889 * StaticOffers - displays static offer 2890 * 2891 * @author subha 2892 * @since 9/22/2021 2893 */ 2894gmfxWwwComponents.StaticOffers = function(component) { 2895 'use strict'; 2896 2897 var $component = gmfx$(component), 2898 staticOffersBrands; 2899 2900 gmfx$('.staticOffersForm').validator(); 2901 var isCookie = gmfxMomentumServices.Cookie.get("eol_uid"); 2902 if(isCookie != null && isCookie != "") { 2903 isCookie = b64DecodeUnicode(isCookie); 2904 var jsonObject = JSON.parse(isCookie); 2905 gmfx$('.staticoffersnonpurl').remove(); 2906 var staticOfferBrand; 2907 var vehicleInfo = jsonObject["vehicleData"]; 2908 if(vehicleInfo != null && vehicleInfo != "") { 2909 staticOfferBrand = getFirstWord(vehicleInfo["makeName"].toLowerCase()); 2910 } else { 2911 staticOfferBrand = getFirstWord(jsonObject["eolData"]["gmfAccountDetail"]["vehicle"]["vehicleMake"].toLowerCase()); 2912 } 2913 2914 var staticofferspurlDesc = gmfx$('.staticofferspurlDesc').html(); 2915 if(staticofferspurlDesc != null && staticofferspurlDesc != "" && staticofferspurlDesc != undefined) { 2916 staticofferspurlDesc = staticofferspurlDesc.replace('{0}', capitalize(staticOfferBrand)); 2917 gmfx$('.staticofferspurlDesc').html(staticofferspurlDesc); 2918 populateImageAndLink(true, staticOfferBrand); 2919 } 2920 var brandMake = getBrandMake(staticOfferBrand); 2921 gmfx$('.static-offer-brand').html(brandMake); 2922 gmfx$('#static-offers-make input').prop('value', brandMake); 2923 gmfx$('#static-offers-make input').attr('value', brandMake); 2924 gmfx$('#see-offers-btn').removeClass('disabled'); 2925 } else { 2926 gmfx$('.staticofferspurl').remove(); 2927 } 2928 2929 function populateImageAndLink(isPurl, staticOfferBrand) { 2930 var staticOffersBrandsJson = []; 2931 staticOffersBrands = gmfx$('.staticBrandTypes').html(); 2932 staticOffersBrandsJson = JSON.parse(staticOffersBrands); 2933 if(staticOffersBrandsJson.length > 0) { 2934 for(var x = 0; x < staticOffersBrandsJson.length; x++) { 2935 if(staticOfferBrand == staticOffersBrandsJson[x].title.toLowerCase()) { 2936 if(isPurl) { 2937 gmfx$('.staticofferspurlImg').attr('src', staticOffersBrandsJson[x].iconPath).attr('title', staticOfferBrand).attr('alt', staticOfferBrand); 2938 } 2939 gmfx$('#see-offers-btn').attr('href', staticOffersBrandsJson[x].url + ".html?vehiclemake=" + staticOfferBrand); 2940 break; 2941 } 2942 } 2943 } 2944 } 2945 gmfx$("#see-offers-btn").on('click', function() {
2946 var valCheck = gmfx$('.static-offer-brand').text(); 2947 var errText = gmfx$('#static-offers-make input').attr('data-error'); 2948 if(valCheck == "Select Brand") { 2949 gmfx$('#static-offers-make .help-block.with-errors').show(); 2950 gmfx$('#static-offers-make').addClass('has-error'); 2951 gmfx$('#static-offers-make .with-errors').html(errText); 2952 } 2953 gmfx$('#static-offers-make').on('click', '.dropdown-menu li a', function() { 2954 gmfx$('#static-offers-make').removeClass('has-error'); 2955 gmfx$('#static-offers-make .help-block.with-errors').hide(); 2956 }); 2957 }); 2958 2959 gmfx$('.dropdown-toggle').on('blur', function() { 2960 if(gmfx$('.offers-make-input').val() != '') { 2961 gmfx$('#see-offers-btn').removeClass('disabled'); 2962 } 2963 }); 2964 2965 gmfx$('#static-offers-make').on('click', '.dropdown-menu li a', function() { 2966 var div = document.createElement('div'); 2967 div.innerHTML = this.innerHTML; 2968 var brandOptValue = div.firstChild.nodeValue; 2969 gmfx$('#static-offers-make .dropdown-toggle .option').text(brandOptValue); 2970 gmfx$('#static-offers-make input').attr('value', brandOptValue.toLowerCase()); 2971 gmfx$('#static-offers-make input').prop('value', brandOptValue.toLowerCase()); 2972 gmfx$('#see-offers-btn').removeClass('disabled'); 2973 populateImageAndLink(false, brandOptValue.toLowerCase()); 2974 }); 2975}; 2976 2977//Initialize the component 2978gmfxMomentumUtils.component.init(".static-offers-component", gmfxWwwComponents.StaticOffers); 2979 2980/** 2981 * SecFilling - Open pop up and navigate to external link when accept is clicked 2982 * 2983 * Created by subhaK on 07/23/2021. 2984 */ 2985gmfxWwwComponents.InteractiveMap = function(component) { 2986 'use strict'; 2987 2988 var $component = gmfx$(component), 2989 listinfo = [], 2990 wholeshabam; 2991 2992 gmfx$.fn.ignore = function(sel) { 2993 return this.clone().find(sel || ">*").remove().end(); 2994 }; 2995 2996 gmfx$(".map-careers li a").each(function() { 2997 listinfo.push({ 2998 title: gmfx$(this).ignore(".map-information").html(), 2999 icon: gmfx$(this).attr("map-icon"), 3000 position: gmfx$(this).attr("map-position"), 3001 x: gmfx$(this).attr("map-x"), 3002 y: gmfx$(this).attr("map-y"), 3003 z: gmfx$(this).attr("map-z"), 3004 mapinfo: gmfx$(this).find(".map-information").html(), 3005 }); 3006 3007 gmfx$(this).removeAttr("map-info"); 3008 gmfx$(this).removeAttr("map-icon"); 3009 gmfx$(this).removeAttr("map-position"); 3010 gmfx$(this).removeAttr("map-y"); 3011 gmfx$(this).removeAttr("map-x"); 3012 gmfx$(this).removeAttr("map-z"); 3013 gmfx$(this).find(".map-information").remove(); 3014 if(!gmfx$(this).attr("href")) { 3015 gmfx$(this).contents().unwrap(); 3016 } 3017 }); 3018 3019 for(var i = 0; i < listinfo.length; i++) { 3020 var careermapicon = ""; 3021 var zeeindex = ""; 3022 if(listinfo[i].icon == "star") { 3023 careermapicon = "/etc.clientlibs/gmf/clientlibs/core-script/resources/images/icons/star-blue.svg"; 3024 } else { 3025 careermapicon = "/etc.clientlibs/gmf/clientlibs/core-script/resources/images/icons/map-spot.svg"; 3026 } 3027 if(listinfo[i].z) { 3028 zeeindex = "z-index:" + listinfo[i].z + ";"; 3029 } 3030 if(listinfo[i].icon != "na") { 3031 wholeshabam += '<div class="map-spot" style="' + zeeindex + ' top:' + listinfo[i].y + '%; left:' + listinfo[i].x + '%;"><a href="#" data-toggle="tooltip" data-placement="' + listinfo[i].position + '" title="<span>' + listinfo[i].title + '</span><br>' + listinfo[i].mapinfo + '" data-html="true"><img class="map-spot-icon" src="' + careermapicon + '"></a></div>'; 3032 } 3033 } 3034 if(gmfx$(".da-map").length > 0) { 3035 gmfx$(".da-map").prepend(wholeshabam.replace("undefined", "")); 3036 } 3037 gmfx$('[data-toggle="tooltip"]').tooltip({ 3038 trigger: "hover" 3039 }); 3040 gmfx$(".da-map a").attr("href", "javascript:void(0)"); 3041}; 3042 3043//Initialize the component 3044gmfxMomentumUtils.component.init(".map-container", gmfxWwwComponents.InteractiveMap); 3045 3046/** 3047 * SecFilling - loads all filings and allows filtering, pagination 3048 * 3049 * Created by subhaK on 07/23/2021. 3050 */ 3051gmfxWwwComponents.SecFiling = function(component) { 3052 'use strict'; 3053 3054 var $component = gmfx$(component), 3055 secFilJson, secFilTotalPgs, secFilResultsPerPg, docListResultsPerPg, docListModalId, secFilterType, container; 3056 3057 gmfx$('.wsTheme .secDropdown .dropdown-toggle .option').text("All Filings"); 3058 gmfx$('.wsTheme .secDropdown input.fillingInput').attr('value', "All Filings"); 3059 gmfx$('.wsTheme .secDropdown input.fillingInput').prop('value', "All Filings"); 3060 3061 if(gmfx$('.sec-filling.cpTheme').length > 0) { 3062 if(gmfx$('.cpTheme').parents('div.tab-pane').length > 0) { 3063 var tabElements = gmfx$('.cpTheme').parents('div.tab-pane'); 3064 for(var i = 0; i < tabElements.length; i++) { 3065 var tabId = tabElements.eq(i).attr("id"); 3066 docListModalId = gmfx$('#' + tabId + ' .cpTheme .docListModalId').html(); 3067 populateDocumentList(docListModalId); 3068 } 3069 } else { 3070 docListModalId = gmfx$('.cpTheme .docListModalId').html(); 3071 populateDocumentList(docListModalId); 3072 } 3073 } 3074 3075 $('.dropdown-toggle').dropdown(); 3076 //on click of drop down 3077 gmfx$('#filling-dropdown').on('click', function() { 3078 gmfx$('.dropdown-option').attr('tabindex', '-1'); 3079 if(gmfx$('[option-selected="selectedOption"]').length == 0) { 3080 gmfx$(gmfx$('.dropdown-option')[0]).attr('tabindex', '0').focus(); 3081 } else { 3082 gmfx$('[option-selected="selectedOption"]').attr('tabindex', '0').focus(); 3083 } 3084 }); 3085 3086 //on choosing value in drop down 3087 gmfx$('#selectFillingList li').on({ 3088 'keydown': function(e) { 3089 var listItems = gmfx$('li[tabindex]'); 3090 // down key 3091 if(e.which == 40 && gmfx$(this).attr('tabindex') !== gmfx$(listItems[listItems.length - 1]).attr('tabindex')) { 3092 e.preventDefault(); 3093 gmfx$(this).attr('tabindex', '-1').next('li').attr('tabindex', '0').focus(); 3094 } 3095 // up key 3096 if(e.which == 38 && gmfx$(this).attr('tabindex') !== gmfx$(listItems[0]).attr('tabindex')) { 3097 e.preventDefault(); 3098 gmfx$(this).attr('tabindex', '-1').prev('li').attr('tabindex', '0').focus(); 3099 } 3100 // esc key 3101 if(e.which == 27) { 3102 e.preventDefault(); 3103 gmfx$('#filling-dropdown').click().focus(); 3104 } 3105 // enter & spacebar key 3106 if(e.which == 13 || e.which == 32) { 3107 e.preventDefault(); 3108 // if card has been previously selected, remove selected alt text 3109 if(gmfx$('[option-selected="selectedOption"]').length !== 0) { 3110 gmfx$('[option-selected="selectedOption"]').attr('option-selected', '').find('.screenReaderTextWCAG').html(''); 3111 } 3112 gmfx$(this).attr('option-selected', 'selectedOption'); 3113 var optionId = gmfx$(this).attr('id'); 3114 gmfx$(this).closest('.btn-group').find('[aria-activedescendant]').attr('aria-activedescendant', optionId); 3115 var altText = gmfx$(this).find('.screenReaderTextWCAG'); 3116 // add selected alt text to option 3117 altText.html(altText.html() + 'selected'); 3118 var optionHtml = gmfx$(this).html() 3119 var selectedValue = gmfx$(optionHtml).attr('data-make'); 3120 var option = '<span class="option filling-Input">' + selectedValue + '</span><span class="hide firstSECVal">All Filings</span> <div class="caret-container"><span class="caret"></span></div>'; 3121 gmfx$('.wsTheme .secDropdown input.fillingInput').attr('value', selectedValue); 3122 gmfx$('.wsTheme .secDropdown input.fillingInput').prop('value', selectedValue); 3123 gmfx$('#filling-dropdown') 3124 .html(option) 3125 .attr('aria-label', gmfx$(this).text()) 3126 .click() 3127 .focus(); 3128 } 3129 }, 3130 'click': function() { 3131 gmfx$(this).trigger({ 3132 type: 'keydown', 3133 which: 13 3134 }); 3135 gmfx$('#selectFillingList li[tabindex="0"]').attr('tabindex', '-1'); 3136 gmfx$(this).attr('tabindex', '0'); 3137 } 3138 }); 3139 3140 if(gmfx$('.sec-filling.wsTheme').length > 0) { 3141 gmfx$('.wsTheme .errorSECFilings').hide(); 3142 secFilResultsPerPg = gmfx$('.wsTheme .secFilResultsPerPg').html(); 3143 3144 // on clicking dropdown 3145 gmfx$('.wsTheme .secDropdown').on('click touchstart', '.dropdown-menu li a', function() { 3146 var div = document.createElement('div'); 3147 div.innerHTML = this.innerHTML; 3148 var secOptionValue = div.firstChild.nodeValue; 3149 gmfx$('.wsTheme .secDropdown .dropdown-toggle .option').text(secOptionValue); 3150 gmfx$('.wsTheme .secDropdown input.fillingInput').attr('value', secOptionValue); 3151 gmfx$('.wsTheme .secDropdown input.fillingInput').prop('value', secOptionValue); 3152 gmfx$('.wsTheme .secDropdown .dropdown-toggle').prop('disabled', false); 3153 }); 3154 3155 //getSecFilings("", "", false); 3156 3157 gmfx$.ajax({ 3158 type: 'GET', 3159 beforeSend: function() { 3160 gmfx$('.sec-filling.wsTheme .secFillingTable').append("<span class='spinner img-responsive'></span>"); 3161 }, 3162 url: '/gmfdyn/secfilings', 3163 data: 'size=' + gmfx$('.wsTheme .secFilResultsPerPg').html(), 3164 success: function(response) { 3165 gmfx$('.sec-filling.wsTheme .secFillingTable').find(".spinner").remove(); 3166 if(gmfx$.trim(response).length > 0) { 3167 gmfx$('.wsTheme .errorSECFilings').hide(); 3168 gmfx$('.wsTheme .secFillingTable').show(); 3169 gmfx$('.wsTheme .secpagination').show(); 3170 secFilJson = JSON.parse(response); 3171 secFilTotalPgs = parseInt(secFilJson.totalResults); 3172 secFilingsResults(secFilJson.secFilingsList, secFilTotalPgs); 3173 } else { 3174 gmfx$('.wsTheme .errorSECFilings').show(); 3175 gmfx$('.wsTheme .secFillingTable').hide(); 3176 gmfx$('.wsTheme .secpagination').hide(); 3177 } 3178 }, 3179 error: function(data, errorThrown) { 3180 gmfx$('.sec-filling.wsTheme .secFillingTable').find(".spinner").remove(); 3181 gmfx$('.wsTheme .errorSECFilings').show(); 3182 gmfx$('.wsTheme .secFillingTable').hide(); 3183 gmfx$('.wsTheme .secpagination').hide(); 3184 } 3185 }); 3186 } 3187 3188 3189 function getSecFilings(page, formGroups, isConstruct) { 3190 var dataFill; 3191 3192 if(page.length != 0 && formGroups.length != 0) { 3193 dataFill = '&size=8&page=' + page + '&formGroups=' + formGroups; 3194 } else if(page.length === 0 && formGroups.length != 0) { 3195 dataFill = '&size=8&formGroups=' + formGroups; 3196 } else if(page.length != 0 && formGroups.length === 0) { 3197 dataFill = '&size=8&page=' + page; 3198 } else { 3199 dataFill = '&size=8'; 3200 } 3201 gmfx$.ajax({ 3202 type: 'GET', 3203 beforeSend: function() { 3204 gmfx$('.sec-filling.wsTheme .secFillingTable').append("<span class='spinner img-responsive'></span>"); 3205 }, 3206 url: '/gmfdyn/secfilings', 3207 data: dataFill, 3208 success: function(response) { 3209 gmfx$('.sec-filling.wsTheme .secFillingTable').find(".spinner").remove(); 3210 if(gmfx$.trim(response).length > 0) { 3211 gmfx$('.wsTheme .errorSECFilings').hide(); 3212 gmfx$('.wsTheme .secFillingTable').show(); 3213 gmfx$('.wsTheme .secpagination').show(); 3214 secFilJson = JSON.parse(response); 3215 if(isConstruct) { 3216 //constructSECFilingsData 3217 constructTheResponse(secFilJson.secFilingsList); 3218 } else { 3219 secFilTotalPgs = parseInt(secFilJson.totalResults); 3220 secFilingsResults(secFilJson.secFilingsList, secFilTotalPgs); 3221 } 3222 3223 3224 3225 } else { 3226 gmfx$('.wsTheme .errorSECFilings').show(); 3227 gmfx$('.wsTheme .secFillingTable').hide(); 3228 gmfx$('.wsTheme .secpagination').hide(); 3229 } 3230 }, 3231 error: function(data, errorThrown) { 3232 gmfx$('.sec-filling.wsTheme .secFillingTable').find(".spinner").remove(); 3233 gmfx$('.wsTheme .errorSECFilings').show(); 3234 gmfx$('.wsTheme .secFillingTable').hide(); 3235 gmfx$('.wsTheme .secpagination').hide(); 3236 } 3237 }); 3238 } 3239 3240 function populateDocumentList(docListModalId) { 3241 gmfx$('.cpTheme #' + docListModalId + '.errorCPTheme').hide(); 3242 docListResultsPerPg = gmfx$('.cpTheme #' + docListModalId + '.cpFilResultsPerPg').html(); 3243 var docListJson = gmfx$('.cpTheme #' + docListModalId + '.docListJson').html(); 3244 if(docListJson && typeof docListJson !== 'undefined' && docListJson !== null) { 3245 docListResult = JSON.parse(docListJson); 3246 docListTotalPgs = Math.ceil(parseInt(gmfx$('.cpTheme #' + docListModalId + '.totalDocuments').html()) / parseInt(docListResultsPerPg)); 3247 docListResults(docListResult, docListTotalPgs, docListModalId); 3248 } else { 3249 gmfx$('.cpTheme #' + docListModalId + '.errorCPTheme').show(); 3250 gmfx$('.cpTheme #' + docListModalId + '.cptable').hide(); 3251 gmfx$('.cpTheme #' + docListModalId + '.cppagination').hide(); 3252 } 3253 } 3254 3255 //Onclick of view results 3256 gmfx$('.wsTheme .view-results .btn-secondary').on('click touchstart', function(e) { 3257 var size = gmfx$('.wsTheme .secFilResultsPerPg').html(); 3258 var formGroups = gmfx$('.wsTheme .fillingInput').val(); 3259 if(formGroups == "All Filings") { 3260 formGroups = ""; 3261 } 3262 3263 //getSecFilings("", formGroups, false); 3264 gmfx$.ajax({ 3265 type: 'GET', 3266 beforeSend: function() { 3267 gmfx$('.sec-filling.wsTheme .secFillingTable').append("<span class='spinner img-responsive'></span>"); 3268 }, 3269 url: '/gmfdyn/secfilings', 3270 data: { 3271 size: size, 3272 formGroups: formGroups 3273 }, 3274 success: function(response) { 3275 gmfx$('.sec-filling.wsTheme .secFillingTable').find(".spinner").remove(); 3276 if(gmfx$.trim(response).length > 0) { 3277 gmfx$('.wsTheme .errorSECFilings').hide(); 3278 gmfx$('.wsTheme .secFillingTable').show(); 3279 gmfx$('.wsTheme .secpagination').show(); 3280 secFilJson = JSON.parse(response); 3281 secFilTotalPgs = parseInt(secFilJson.totalResults); 3282 secFilingsResults(secFilJson.secFilingsList, secFilTotalPgs); 3283 } else { 3284 gmfx$('.wsTheme .errorSECFilings').show(); 3285 gmfx$('.wsTheme .secFillingTable').hide(); 3286 gmfx$('.wsTheme .secpagination').hide(); 3287 } 3288 }, 3289 error: function(data, errorThrown) { 3290 gmfx$('.sec-filling.wsTheme .secFillingTable').find(".spinner").remove(); 3291 gmfx$('.wsTheme .errorSECFilings').show(); 3292 gmfx$('.wsTheme .secFillingTable').hide(); 3293 gmfx$('.wsTheme .secpagination').hide(); 3294 } 3295 }); 3296 }); 3297 3298 function secFilingsResults(secResponse, secFilTotalPgs) { 3299 gmfx$('.wsTheme .secpagination').twbsPagination('destroy'); 3300 gmfx$('.wsTheme .secpagination').empty(); 3301 gmfx$('.wsTheme .table-striped').empty(); 3302 if(typeof secFilTotalPgs !== 'undefined' && secFilTotalPgs !== null && secFilTotalPgs > 0) { 3303 gmfx$('.wsTheme .secpagination').twbsPagination
3303({ 3304 totalPages: secFilTotalPgs, 3305 visiblePages: parseInt(gmfx$('.wsTheme .secVisiblePages').html()), 3306 first: gmfx$('.wsTheme .secfirstlabel').html(), 3307 prev: gmfx$('.wsTheme .secprevlabel').html(), 3308 next: gmfx$('.wsTheme .secnextlabel').html(), 3309 last: gmfx$('.wsTheme .seclastlabel').html(), 3310 onPageClick: function(event, page) { 3311 constructSECFilingsData(secResponse, page); 3312 gmfx$('.wsTheme .page-link').on('click', function(e) { 3313 gmfxMomentumUtils.element.scrollTopAnimate(gmfx$(".sec-filling.wsTheme"), 0, 200); 3314 }); 3315 } 3316 }); 3317 } else { 3318 gmfx$('.wsTheme .errorSECFilings').show(); 3319 gmfx$('.wsTheme .secFillingTable').hide(); 3320 gmfx$('.wsTheme .secpagination').hide(); 3321 } 3322 } 3323 3324 function constructSECFilingsData(response, page) { 3325 var formGroups = gmfx$('.wsTheme .fillingInput').val(); 3326 if(formGroups == "All Filings") { 3327 formGroups = ""; 3328 } 3329 if(page != 1) { 3330 gmfx$('.wsTheme .table-striped').empty(); 3331 //getSecFilings(page, formGroups, true); 3332 3333 gmfx$.ajax({ 3334 type: 'GET', 3335 beforeSend: function() { 3336 gmfx$('.sec-filling.wsTheme .secFillingTable').append("<span class='spinner img-responsive'></span>"); 3337 }, 3338 url: '/gmfdyn/secfilings', 3339 data: 'page=' + page + '&size=' + gmfx$('.wsTheme .secFilResultsPerPg').html() + '&formGroups=' + formGroups, 3340 success: function(serviceResponse) { 3341 if(gmfx$.trim(response).length > 0) { 3342 gmfx$('.wsTheme .errorSECFilings').hide(); 3343 gmfx$('.wsTheme .secFillingTable').show(); 3344 gmfx$('.wsTheme .secpagination').show(); 3345 secFilJson = JSON.parse(serviceResponse); 3346 constructTheResponse(secFilJson.secFilingsList); 3347 } else { 3348 gmfx$('.wsTheme .errorSECFilings').show(); 3349 gmfx$('.wsTheme .secFillingTable').hide(); 3350 gmfx$('.wsTheme .secpagination').hide(); 3351 } 3352 gmfx$('.sec-filling.wsTheme .secFillingTable').find(".spinner").remove(); 3353 }, 3354 error: function(data, errorThrown) { 3355 gmfx$('.sec-filling.wsTheme .secFillingTable').find(".spinner").remove(); 3356 gmfx$('.wsTheme .errorSECFilings').show(); 3357 gmfx$('.wsTheme .secFillingTable').hide(); 3358 gmfx$('.wsTheme .secpagination').hide(); 3359 } 3360 }); 3361 } else { 3362 constructTheResponse(response); 3363 } 3364 3365 } 3366 3367 function constructTheResponse(response) { 3368 container = gmfx$('.wsTheme .table-striped'); 3369 gmfx$('.wsTheme .table-striped').empty(); 3370 var startIndex = 0; 3371 var endIndex = parseInt(secFilResultsPerPg); 3372 var secnewwindowxbrl = gmfx$('.wsTheme .secnewwindowxbrl').html(), 3373 secnewwindowpdf = gmfx$('.wsTheme .secnewwindowpdf').html(), 3374 secnewwindowexcel = gmfx$('.wsTheme .secnewwindowexcel').html(), 3375 secnewwindowdoc = gmfx$('.wsTheme .secnewwindowdoc').html(), 3376 tHeadItem = gmfx$('<thead>'), 3377 trItem = gmfx$('<tr>'), 3378 thFilDtItem = gmfx$('<th>').addClass('text-center'), 3379 thFormItem = gmfx$('<th>').addClass('text-center'), 3380 thFilGpItem = gmfx$('<th>').addClass('text-center'), 3381 thDownloadItem = gmfx$('<th>').addClass('text-left'), 3382 tBodyItem = gmfx$('<tbody>'); 3383 3384 thFilDtItem.text(gmfx$('.wsTheme .secfilingdate').html()); 3385 thFormItem.text(gmfx$('.wsTheme .secformlabel').html()); 3386 thFilGpItem.text(gmfx$('.wsTheme .secfilinggroup').html()); 3387 thDownloadItem.text(gmfx$('.wsTheme .secdownloadlabel').html()); 3388 trItem.append(thFilDtItem, thFormItem, thFilGpItem, thDownloadItem); 3389 trItem.appendTo(tHeadItem); 3390 for(var i = startIndex; i < endIndex; i++) { 3391 if(response[i]) { 3392 var trBodyItem = gmfx$('<tr>'), 3393 tdFilDtItem = gmfx$('<td>').addClass('text-left'), 3394 tdFormItem = gmfx$('<td>').addClass('text-left'), 3395 tdFilGpItem = gmfx$('<td>').addClass('text-center'), 3396 tdDownloadItem = gmfx$('<td>').addClass('text-left'), 3397 spanPdfItem = gmfx$('<span>').addClass('icon-pdf mr10 icon-medium'), 3398 spanDocItem = gmfx$('<span>').addClass('icon-doc mr10 icon-medium'), 3399 spanExcelItem = gmfx$('<span>').addClass('icon-excel mr10 icon-medium'), 3400 spanXbrlItem = gmfx$('<span>').addClass('icon-xbrl mr10 icon-medium'), 3401 aPdfItem = gmfx$('<a>').attr('target', secnewwindowpdf), 3402 aDocItem = gmfx$('<a>').attr('target', secnewwindowdoc), 3403 aExcelItem = gmfx$('<a>').attr('target', secnewwindowexcel), 3404 aXbrlItem = gmfx$('<a>').attr('target', secnewwindowxbrl); 3405 if(response[i].dateFiled) { 3406 tdFilDtItem.text(response[i].dateFiled); 3407 } 3408 if(response[i].form) { 3409 tdFormItem.text(response[i].form); 3410 } 3411 if(response[i].formGroup) { 3412 tdFilGpItem.text(response[i].formGroup); 3413 } 3414 if(response[i].pdfLink.length > 2) { 3415 aPdfItem.attr('href', response[i].pdfLink); 3416 spanPdfItem.appendTo(aPdfItem); 3417 aPdfItem.appendTo(tdDownloadItem); 3418 } 3419 if(response[i].docLink.length > 2) { 3420 aDocItem.attr('href', response[i].docLink); 3421 spanDocItem.appendTo(aDocItem); 3422 aDocItem.appendTo(tdDownloadItem); 3423 } 3424 if(response[i].xlsLink.length > 2) { 3425 aExcelItem.attr('href', response[i].xlsLink); 3426 spanExcelItem.appendTo(aExcelItem); 3427 aExcelItem.appendTo(tdDownloadItem); 3428 } 3429 if(response[i].xbrlLink.length > 2) { 3430 aXbrlItem.attr('href', response[i].xbrlLink); 3431 spanXbrlItem.appendTo(aXbrlItem); 3432 aXbrlItem.appendTo(tdDownloadItem); 3433 } 3434 trBodyItem.append(tdFilDtItem, tdFormItem, tdFilGpItem, tdDownloadItem); 3435 trBodyItem.appendTo(tBodyItem); 3436 } 3437 } 3438 container.append(tHeadItem, tBodyItem); 3439 } 3440 3441 function docListResults(docListResult, docListTotalPgs, docListModalId) { 3442 gmfx$('.cpTheme #' + docListModalId + '.cppagination').twbsPagination('destroy'); 3443 gmfx$('.cpTheme #' + docListModalId + '.cppagination').empty(); 3444 gmfx$('.cpTheme #' + docListModalId + '.table-striped').empty(); 3445 if(typeof docListTotalPgs !== 'undefined' && docListTotalPgs !== null && docListTotalPgs > 0) { 3446 gmfx$('.cpTheme #' + docListModalId + '.cppagination').twbsPagination({ 3447 totalPages: docListTotalPgs, 3448 visiblePages: parseInt(gmfx$('.cpTheme #' + docListModalId + '.cpVisiblePages').html()), 3449 first: gmfx$('.cpTheme #' + docListModalId + '.cpfirstlabel').html(), 3450 prev: gmfx$('.cpTheme #' + docListModalId + '.cpprevlabel').html(), 3451 next: gmfx$('.cpTheme #' + docListModalId + '.cpnextlabel').html(), 3452 last: gmfx$('.cpTheme #' + docListModalId + '.cplastlabel').html(), 3453 onPageClick: function(event, page) { 3454 constructDocListData(docListResult, page, docListModalId); 3455 gmfx$('.cpTheme .page-link').on('click', function(e) { 3456 gmfxMomentumUtils.element.scrollTopAnimate(gmfx$(".sec-filling.cpTheme"), 0, 2000); 3457 }); 3458 } 3459 }); 3460 } else { 3461 gmfx$('.cpTheme #' + docListModalId + '.errorCPTheme').show(); 3462 gmfx$('.cpTheme #' + docListModalId + '.cptable').hide(); 3463 gmfx$('.cpTheme #' + docListModalId + '.cppagination').hide(); 3464 } 3465 } 3466 3467 function constructDocListData(response, page, docListModalId) { 3468 container = gmfx$('.cpTheme #' + docListModalId + ' .table-striped'); 3469 gmfx$('.cpTheme #' + docListModalId + ' .table-striped').empty(); 3470 var startIndex = (parseInt(page) - 1) * parseInt(docListResultsPerPg); 3471 var endIndex = parseInt(startIndex) + parseInt(docListResultsPerPg); 3472 var tHeadItem = gmfx$('<thead>'), 3473 trItem = gmfx$('<tr>'), 3474 thDocItem = gmfx$('<th>').addClass('text-left'), 3475 thDownldItem = gmfx$('<th>').addClass('text-left'), 3476 tBodyItem = gmfx$('<tbody>'); 3477 thDocItem.text(gmfx$('.cpTheme #' + docListModalId + '.documentlabel').html()); 3478 thDownldItem.text(gmfx$('.cpTheme #' + docListModalId + '.cpdownloadlabel').html()); 3479 trItem.append(thDocItem, thDownldItem); 3480 trItem.appendTo(tHeadItem); 3481 3482 for(var i = startIndex; i < endIndex; i++) { 3483 if(response[i]) { 3484 var trBodyItem = gmfx$('<tr>'), 3485 tdDocItem = gmfx$('<td>').addClass('text-left'), 3486 tdDownldItem = gmfx$('<td>').addClass('text-left'), 3487 spanItem = gmfx$('<span>').addClass('mr10 icon-medium'), 3488 aDwnLdItem = gmfx$('<a>').attr('target', response[i].newWindow).attr('href', response[i].url), 3489 aItem = gmfx$('<a>').attr('target', response[i].newWindow).attr('href', response[i].url); 3490 3491 if(response[i].title) { 3492 aItem.text(response[i].title); 3493 aItem.appendTo(tdDocItem); 3494 } 3495 if(response[i].iconPath) { 3496 spanItem.addClass(response[i].iconPath); 3497 spanItem.appendTo(aDwnLdItem); 3498 aDwnLdItem.appendTo(tdDownldItem); 3499 } 3500 trBodyItem.append(tdDocItem, tdDownldItem); 3501 trBodyItem.appendTo(tBodyItem); 3502 } 3503 } 3504 container.append(tHeadItem, tBodyItem); 3505 } 3506 3507}; 3508 3509//Initialize the component 3510gmfxMomentumUtils.component.init(".sec-filing", gmfxWwwComponents.SecFiling); 3511 3512/** 3513 * Search - Auto complete search term and populate in search input box 3514 * Submit the term for search and navigate to search results page 3515 * 3516 * @author subha 3517 * @since 9/29/2021 3518 */ 3519gmfxWwwComponents.Search404 = function (component) { 3520 'use strict'; 3521 3522 var $component = gmfx$(component), 3523 searchResPath = '/content/gmf/en/search-results.html'; 3524 3525 gmfx$('#notfound-search-button').click(function () { 3526 var val = gmfx$('#notfound-search-box').val(); 3527 if (val && val.trim().length > 0) { 3528 sessionStorage.setItem('searchTerm', val.trim()); 3529 window.location.replace(searchResPath); 3530 } 3531 }); 3532 3533 gmfx$('#notfound-search-box').on('keypress', function (e) { 3534 if (e.which === 13) { 3535 var val = gmfx$('#notfound-search-box').val(); 3536 if (val && val.trim().length > 0) { 3537 sessionStorage.setItem('searchTerm', val.trim()); 3538 window.location.replace(searchResPath); 3539 } 3540 } 3541 }); 3542 3543 $('#notfound-search-box').on('blur', function () { 3544 var myInput = document.querySelector('#notfound-search-box'); 3545 if (myInput.value !== '') { 3546 $('.notfound-search-container .search-input .input-group label').addClass('hasValue'); 3547 } else { 3548 $('.notfound-search-container .search-input .input-group label').removeClass('hasValue'); 3549 } 3550 }); 3551}; 3552 3553//Initialize the component 3554gmfxMomentumUtils.component.init('#notfound-search-button', gmfxWwwComponents.Search404); 3555 3556/** 3557 * Schedule Insoection - display Public and PURL copy based on cookie availability 3558 * 3559 * @author subha 3560 * @since 8/20/2021 3561 */ 3562gmfxWwwComponents.ScheduleInspection = function(component) { 3563 'use strict'; 3564 3565 var gmfx$component = gmfx$(component), 3566 isCookie = gmfxMomentumServices.Cookie.get("eol_uid"); 3567 if(isCookie != null && isCookie != "") { 3568 isCookie = b64DecodeUnicode(isCookie); 3569 var jsonObject = JSON.parse(isCookie);
3570 var validUserAccount = jsonObject["eolData"]["gmfAccountDetail"]["leaseaccount"]; 3571 if(validUserAccount != null && validUserAccount != "") { 3572 gmfx$('#schedule_inspection_public').remove(); 3573 } else { 3574 gmfx$('#schedule_inspection_purl').remove(); 3575 } 3576 } else { 3577 gmfx$('#schedule_inspection_purl').remove(); 3578 } 3579}; 3580 3581//Initialize the component 3582gmfxMomentumUtils.component.init(".schedule-vid", gmfxWwwComponents.ScheduleInspection); 3583 3584/** 3585 * Redirection PopUp - Open pop up and navigate to external link when accept is clicked 3586 * 3587 * Created by subhaK on 07/23/2021. 3588 */ 3589gmfxWwwComponents.RedirectionPopUp = function(component) { 3590 'use strict'; 3591 3592 var $component = gmfx$(component), 3593 redirectionPopupFragmentPath = gmfx$("#redirectionPopupFragmentPath").text(); 3594 3595 if(redirectionPopupFragmentPath) { 3596 gmfx$("a").each(function() { 3597 if(location.hostname === this.hostname || !this.hostname.length) { 3598 gmfx$(this).addClass("int-link"); 3599 } else { 3600 gmfx$(this).addClass("ext-link"); 3601 if(!gmfx$(this).closest("ul").hasClass("nav") && gmfx$(this).closest(".container-fluid").has("footer").length == 0) { 3602 var extLinkText = gmfx$(this).text(); 3603 var extLinkImg = '<svg width="10px" height="10px" viewBox="0 0 10 10" version="1.1" xmlns=""><g id="Buy-or-Lease" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="v2.BuyOrLease_Hub" transform="translate(-1064.000000, -2659.000000)" stroke="#005DAB" stroke-width="2"><g id="Group-6-Copy" transform="translate(295.000000, 2345.000000)"><g id="CSR"><g id="Group-14-Copy-2" transform="translate(663.000000, 309.000000)"><g id="Group" transform="translate(107.000000, 6.000000)"><path d="M8,0 L0,8" id="Shape"></path><polyline id="Shape" points="0 0 8 0 8 8"></polyline></g></g></g></g></g></g></svg>'; 3604 gmfx$(this).html(extLinkText + extLinkImg); 3605 var theColorIs = gmfx$(this).css("color"); 3606 gmfx$(this).find("svg path").css('stroke', theColorIs); 3607 gmfx$(this).find("svg g").css('stroke', theColorIs); 3608 } 3609 } 3610 }); 3611 } 3612 3613 gmfx$(".ext-link").click(function(e) { 3614 e.preventDefault(); 3615 gmfx$("#aboutPop").modal("show"); 3616 var redirectLink = gmfx$(this).attr("href"), 3617 redirectTarget = gmfx$(this).attr("target"); 3618 gmfx$("#aboutPop").find("a.popup-accept").attr("href", redirectLink).attr("target", redirectTarget); 3619 }); 3620 3621 gmfx$("a.popup-accept").click(function() { 3622 gmfx$("#aboutPop").modal("hide"); 3623 }); 3624 3625}; 3626 3627//Initialize the component 3628gmfxMomentumUtils.component.init(".redirect-popup", gmfxWwwComponents.RedirectionPopUp); 3629 3630/** 3631 * Promo Standard Image Scroll Focus Firefox Fix 3632 * 3633 * @author mmustaine 3634 * @since 6/4/2021 3635 */ 3636 3637gmfxWwwComponents.PromoStandardImage = function(component) { 3638 'use strict'; 3639 3640 var $component = gmfx$(component); 3641 3642 // scroll focus for left tile image 3643 gmfx$(".tile-theme-link", $component).on("focus", function() { 3644 // run only on firefox
3645 if(navigator.userAgent.search("Firefox") >= 0) { 3646 gmfxMomentumUtils.element.scrollTopAnimate("#tile-theme-link-4", 85, 100); 3647 } 3648 }); 3649 3650 // promo video stop video 3651 gmfx$('.promo-standard-image-modal').on('hide.bs.modal', function(e) { 3652 var $if = gmfx$(e.delegateTarget).find('iframe'); 3653 var src = $if.attr("src"); 3654 $if.attr("src", '/empty.html'); 3655 $if.attr("src", src); 3656 }); 3657}; 3658 3659// Initialize the component 3660gmfxMomentumUtils.component.init(".promostandardimage", gmfxWwwComponents.PromoStandardImage); 3661 3662/** 3663 * PromoStandard 3664 * 3665 * @author subha 3666 * @since 9/30/2021 3667 */ 3668gmfxWwwComponents.PromoStandard = function(component) { 3669 'use strict'; 3670 3671 var $component = gmfx$(component), 3672 promoLocator = gmfx$('.promo-selector').val(); 3673 if(promoLocator) { 3674 // determine scroll padding based off window width 3675 var $promoScrollPadding = gmfxMomentumUtils.element.scrollTopResponsivePadding(110, 120, 100); 3676 3677 // scroll function 3678 gmfxMomentumUtils.element.scrollTopAnimate(('#' + promoLocator), $promoScrollPadding, gmfxMomentumCoreConstants.PAGE_SCROLL_SPEED); 3679 } 3680}; 3681 3682//Initialize the component 3683gmfxMomentumUtils.component.init(".promo-selector", gmfxWwwComponents.PromoStandard); 3684 3685 3686/** 3687 * NewsReleases - 3688 * loads news date, title and PDF 3689 * filters based on year 3690 * 3691 */ 3692gmfxWwwComponents.NewsReleases = function(component) { 3693 'use strict'; 3694 3695 var $component = gmfx$(component); 3696 3697 $('#year-dropdown', $component).on('click', '.dropdown-menu li a', function() { 3698 gmfx$('#year-dropdown .dropdown-toggle .option').text(this.innerHTML); 3699 gmfx$('#year-dropdown input#fillingInput').attr('value', this.innerHTML); 3700 gmfx$('button#view-btn').prop('disabled', false); 3701 3702 }); 3703 3704 gmfx$('button#view-btn', $component).click(function() { 3705 //Get year selected 3706 var year = gmfx$('input#fillingInput').attr('value'); 3707 showNewsReleases(year); 3708 }); 3709 3710 function showNewsReleases(year) { 3711 //Make all tbodies hidden 3712 gmfx$('table.news-release-table tbody').css('display', 'none'); 3713 3714 //Check if top table is hidden 3715 if(gmfx$('.news-release-table').is(':hidden')) { 3716 gmfx$('.news-release-table').toggle(); 3717 } 3718 3719 //Toggle table body 3720 gmfx$('table.news-release-table tbody.' + year).toggle(); 3721 } 3722 3723 if(gmfx$("#news-releases-row").length) { 3724 getNewsReleases(); 3725 } 3726 3727 3728 function getNewsReleases() { 3729 var yearsLimit = gmfx$("#news-releases").attr("data-years-limit"); 3730 gmfx$.ajax({ 3731 url: '/gmfdyn/newsreleases', 3732 type: 'POST', 3733 beforeSend: function() { 3734 gmfx$('.alert').append("<span class='spinner img-responsive'></span>"); 3735 }, 3736 data: { 3737 yearsLimit: yearsLimit 3738 }, 3739 dataType: 'json', 3740 success: function(response) { 3741 constructNewsReleases(response); 3742 gmfx$('.alert').find(".spinner").remove(); 3743 gmfx$('#news-releases-row').show(); 3744 } 3745 }); 3746 } 3747 3748 function constructNewsReleases(response) { 3749 var year = ''; 3750 gmfx$.each(response, function(key, value) { 3751 year = key; 3752 //construct years dropdown 3753 gmfx$("#years-drop-down").append("<li><a data-year='" + key + "'>" + key + "</a></li>"); 3754 //construct news releases for each year dropdown 3755 gmfx$("#news-releases-table").append("<tbody id='" + key + "' class='" + key + "' style='display: none'></tbody>"); 3756 gmfx$.each(value, function(i, item) { 3757 if(isItHTMLType(item)) { 3758 var currentPageUrl = gmfx$("#news-releases").attr("data-currentpage"); 3759 gmfx$("#" + key).append("<tr><td>" + item.releaseDate.date + "</td><td><a class='file-download' target='_blank' href='" + currentPageUrl + ".news.html?reqid=" + item.id + "' >" + item.title + "</a></td> </tr>"); 3760 } else { 3761 gmfx$("#" + key).append("<tr><td>" + item.releaseDate.date + "</td><td><a class='file-download' target='_blank' href='" + item.body[0].link.url + "'>" + item.title + "</a></td> </tr>"); 3762 } 3763 }); 3764 }); 3765 3766 var ul = gmfx$('#years-drop-down'); 3767 ul.children().each(function(i, li) { 3768 ul.prepend(li) 3769 }) 3770 3771 // prefill year dropdown with current year and show the news releases for the same. 3772 gmfx$('#year-dropdown .dropdown-toggle .option').text(year); 3773 gmfx$('#year-dropdown input#fillingInput').attr('value', year); 3774 gmfx$('button#view-btn').prop('disabled', false); 3775 showNewsReleases(year); 3776 } 3777 3778 3779 function isItHTMLType(item) { 3780 if(item != undefined) { 3781 if(item.body != undefined && item.body.length > 0) { 3782 if(item.body[0].type != undefined) { 3783 var type = item.body[0].type; 3784 if(type == 'html') { 3785 return true; 3786 } 3787 } 3788 } 3789 } else { 3790 return false;
3791 } 3792 } 3793 3794}; 3795 3796//Initialize the component 3797gmfxMomentumUtils.component.init(".news-releases", gmfxWwwComponents.NewsReleases); 3798 3799/** 3800 * LeaseSummary - displays lease summary 3801 * 3802 * @author subha 3803 * @since 9/17/2021 3804 */ 3805gmfxWwwComponents.LeaseSummary = function(component) { 3806 'use strict'; 3807 3808 var $component = gmfx$(component), 3809 isCookie = gmfxMomentumServices.Cookie.get("eol_uid"); 3810 3811 if(isCookie != null && isCookie != "") { 3812 isCookie = Base64.decode(isCookie); 3813 var jsonObject = JSON.parse(isCookie); 3814 3815 if(gmfx$('.lease-summary-public').length > 0) { 3816 gmfx$('.lease-summary-public').remove(); 3817 } 3818 3819 var purlId = jsonObject["eolData"]["purlId"]; 3820 if(purlId != null && purlId != "") { 3821 var isVehicleCookie = gmfxMomentumServices.Cookie.get("GMF_vehicle"); 3822 if(isVehicleCookie == null || isVehicleCookie == "") { 3823 var param = "uid=" + purlId; 3824 gmfx$.ajax({ 3825 url: '/gmfdyn/adsDetails', 3826 type: 'GET', 3827 beforeSend: function() { 3828 gmfx$('.lease-summary-purl').hide(); 3829 gmfx$('.summary-spinner').append("<span class='spinner img-responsive mb30 mt30'></span>"); 3830 }, 3831 data: param, 3832 success: function(data) { 3833 // Ajax Success save the data the cookie 3834 document.cookie = "GMF_vehicle=" + data + "; mtracker=0; path=/; Secure; SameSite=Strict"; 3835 // Getting vehicle info from Vehicle Cookie 3836 var isVehicleCookie = gmfxMomentumServices.Cookie.get("GMF_vehicle"); 3837 if(!populateVehicleInfo(isVehicleCookie)) { 3838 populateVehicleInfoFromEOL(jsonObject); 3839 } 3840 }, 3841 error: function(response) { 3842 // Showing vehicle Info from EOL in case of Chrome Service Failure 3843 populateVehicleInfoFromEOL(jsonObject); 3844 } 3845 }); 3846 } else { 3847 gmfx$('.lease-summary-purl').hide(); 3848 gmfx$('.summary-spinner').append("<span class='spinner img-responsive'></span>"); 3849 if(!populateVehicleInfo(isVehicleCookie)) { 3850 populateVehicleInfoFromEOL(jsonObject); 3851 } 3852 } 3853 } else { 3854 //No Purl ID available in cookie, setting the fall back from EOL 3855 populateVehicleInfoFromEOL(jsonObject); 3856 } 3857 3858 // Getting user information from EOL Service 3859 var validUserAccount = jsonObject["eolData"]["gmfAccountDetail"]["leaseaccount"]; 3860 if(validUserAccount) { 3861 var daysUntilLeaseEnd = validUserAccount["daysUntilLeaseEnds"]; 3862 gmfx$('.box-header h4 span').text(daysUntilLeaseEnd ? daysUntilLeaseEnd : ""); 3863 var leaseStartDate = validUserAccount["leaseStartDate"]; 3864 gmfx$('.lStartDate').text(leaseStartDate ? formatEOLDate(leaseStartDate) : ""); 3865 var leaseEndDate = validUserAccount["leaseEndDate"]; 3866 gmfx$('.lEndDate').text(leaseEndDate ? formatEOLDate(leaseEndDate) : ""); 3867 var leaseTerm = validUserAccount["leaserTerm"]; 3868 gmfx$('.leaseTerm').text(leaseTerm ? leaseTerm : ""); 3869 var mileageLimit = validUserAccount["mileageLimit"]; 3870 gmfx$('.mileageLimit').text(mileageLimit ? mileageLimit.toLocaleString() : ""); 3871 } 3872 3873 } else { 3874 // No cookie present, show the public view 3875 if(gmfx$('.lease-summary-purl').length > 0) { 3876 gmfx$('.lease-summary-purl').remove(); 3877 } 3878 } 3879 3880 // Formatting date to MM/DD/YYYY format from YYYY-MM-DD(EOL Service Response) 3881 function formatEOLDate(str) { 3882 var date = str.split('-'); 3883 var swap = function(theArray, indexA, indexB, indexC) { 3884 var temp = theArray[indexA]; 3885 theArray[indexA] = theArray[indexB]; 3886 theArray[indexB] = theArray[indexC]; 3887 theArray[indexC] = temp; 3888 }; 3889 swap(date, 0, 1, 2); 3890 return date.join('/'); 3891 } 3892 3893 // Populate VehicleInfo 3894 function populateVehicleInfo(data) { 3895 decodedData = Base64.decode(data); 3896 decodedData = JSON.parse(decodedData); 3897 var vehicleInfo = decodedData['vehicleData']; 3898 if(!jQuery.isEmptyObject(vehicleInfo)) { 3899 var trimName = ""; 3900 if(vehicleInfo["trimName"]) { 3901 trimName = vehicleInfo["trimName"]; 3902 } else if(vehicleInfo["styleName"]) { 3903 trimName = vehicleInfo["styleName"] 3904 } 3905 gmfx$('.box-body h5 span').html(vehicleInfo["modelYear"] + " " + vehicleInfo["makeName"] + "<br>" + vehicleInfo["modelName"] + " " + trimName); 3906 gmfx$('.box-body img').attr('src', vehicleInfo["imageUrl"]); 3907 } else { 3908 return false;
3909 } 3910 gmfx$('.summary-spinner').find(".spinner").remove(); 3911 gmfx$('.lease-summary-purl').show(); 3912 return true; 3913 } 3914 3915 function populateVehicleInfoFromEOL(jsonObject) { 3916 var vehicleInfo = jsonObject["eolData"]["gmfAccountDetail"]["vehicle"]; 3917 var vehicleBrand = getFirstWord(vehicleInfo["vehicleMake"].toLowerCase()); 3918 gmfx$('.box-body h5 span').html(vehicleInfo["vehicleYear"] + " " + vehicleInfo["vehicleMake"] + "<br>" + vehicleInfo["vehicleModel"]); 3919 gmfx$('.box-body img').attr('src', showFallbackImage(vehicleBrand)); 3920 gmfx$('.summary-spinner').find(".spinner").remove(); 3921 gmfx$('.lease-summary-purl').show(); 3922 } 3923 3924 // Show Fallback Image in case of AJAX/Chrome Service Failure 3925 function showFallbackImage(vehicleBrand) { 3926 var imageUrl = ""; 3927 if(vehicleBrand == "buick") { 3928 imageUrl = gmfx$("#fallback-summary-image-buick").html(); 3929 } else if(vehicleBrand == "cadillac") { 3930 imageUrl = gmfx$("#fallback-summary-image-cadillac").html(); 3931 } else if(vehicleBrand == "chevrolet") { 3932 imageUrl = gmfx$("#fallback-summary-image-chevrolet").html(); 3933 } else if(vehicleBrand == "gmc") { 3934 imageUrl = gmfx$("#fallback-summary-image-gmc").html(); 3935 } 3936 return imageUrl; 3937 } 3938}; 3939 3940//Initialize the component 3941gmfxMomentumUtils.component.init(".summary-spinner", gmfxWwwComponents.LeaseSummary); 3942 3943/** 3944 * LeaseMileageCalculator - Calculate Milage 3945 * 3946 * @author subha 3947 * @since 9/9/2021 3948 */ 3949gmfxWwwComponents.LeaseMileageCalculator = function(component) { 3950 'use strict'; 3951 3952 var $component = gmfx$(component); 3953 3954 //Clear datepicker 3955 gmfx$('.myModal').on('hidden.bs.modal', function() { 3956 if(gmfx$('.input-group.date').length > 0) { 3957 gmfx$('.input-group.date').datepicker('update', new Date()); 3958 gmfx$('.input-group.date').datepicker('clearDates'); 3959 } 3960 }); 3961 3962 gmfx$('.myModal .modal-dialog .modal-content .modal-header button.close').click(function() { 3963 if(gmfx$('.input-group.date').length > 0) { 3964 gmfx$('.input-group.date').datepicker('update', new Date()); 3965 gmfx$('.input-group.date').datepicker('clearDates'); 3966 } 3967 }); 3968 // input field validation 3969 gmfx$('.mileage-date').keyup(isDate).keypress(isDate); 3970 gmfx$('.numCheck').keypress(onlyNumber); 3971 3972 var date_input = gmfx$('input[name="date"]'); //our date input has the name "date" 3973 var container = gmfx$('.bootstrap-iso form').length > 0 ? gmfx$('.bootstrap-iso form').parent() : "body"; 3974 var options = { 3975 format: 'mm/dd/yyyy', 3976 container: "body", 3977 todayHighlight: true, 3978 autoclose: true 3979 }; 3980 gmfx$('.input-group.date').datepicker(options); 3981 3982 //change dropdown label on click 3983 gmfx$('.mileage-term-length').on('click', '.dropdown-menu li a', function() { 3984 gmfx$('.mileage-term-length .dropdown-toggle .option').text(this.innerHTML); 3985 gmfx$('.mileage-term-length input').prop('value', this.innerHTML); 3986 gmfx$('.mileage-calculator-form div.lease_mileage_term').removeClass("has-error has-danger"); 3987 }); 3988 3989 //Current Mileage - Update min value 3990 gmfx$('#mileage-inception-purl').on('change', function() { 3991 document.getElementById('mileage-current-purl').min = this.value; 3992 }); 3993 3994 gmfx$('#mileage-inception').on('change', function() { 3995 document.getElementById('mileage-current').min = this.value; 3996 }); 3997 3998 var validUserAccount = ''; 3999 4000 var isCookie = gmfxMomentumServices.Cookie.get("eol_uid"); 4001 if(isCookie != null && isCookie != "") { 4002 isCookie = b64DecodeUnicode(isCookie); 4003 //var jsonString = JSON.parse(isCookie); 4004 var jsonObject = JSON.parse(isCookie); 4005 validUserAccount = jsonObject["eolData"]["gmfAccountDetail"]["leaseaccount"]; 4006 if(validUserAccount != null && validUserAccount != "") { 4007 4008 gmfx$('.mileage_calc_public').remove(); 4009 } else { 4010 gmfx$('.mileage_calc_purl').remove(); 4011 } 4012 } else { 4013 gmfx$('.mileage_calc_purl').remove(); 4014 } 4015
4016 // onclick validate 4017 gmfx$('.mileage-calculator-form').validator().on('submit', function(e) { 4018 if(e.isDefaultPrevented()) { 4019 4020 } else { 4021 e.preventDefault(); 4022 4023 if(isCookie != null && isCookie != "") { 4024 //isCookie = b64DecodeUnicode(isCookie); 4025 //var jsonString = JSON.parse(isCookie); 4026 var jsonObject = JSON.parse(isCookie); 4027 var validAccount = jsonObject["eolData"]["gmfAccountDetail"]["leaseaccount"]; 4028 if(validAccount != null && validAccount != "") { 4029 calculateMileagePurl(validAccount); 4030 } else { 4031 calculateMileagePublic(); 4032 } 4033 } else { 4034 calculateMileagePublic(); 4035 } 4036 } 4037 }); 4038 4039 function calculateMileagePublic() { 4040 4041 var oneDay = 24 * 60 * 60 * 1000; // hours*minutes*seconds*milliseconds 4042 var oneMonth = (365 / 12) * 24 * 60 * 60 * 1000; 4043 4044 var currentDate = new Date(); //system date 4045 4046 var leaseTerm = gmfx$('.modal.in .mileage-term-length-input').val(); // EOL or User Input 4047 4048 var leaseEndDate = new Date(gmfx$(".modal.in .mileage-date").val()); // EOL or user input 4049 4050 //numbe rof months remaning on lease 4051 var remainingLeaseMonth = Math.round(Math.abs((leaseEndDate.getTime() - currentDate.getTime()) / (oneMonth))); 4052 4053 //number of days remaining on lease 4054 var remainingLeaseDays = Math.round(Math.abs((leaseEndDate.getTime() - currentDate.getTime()) / (oneDay))); 4055 4056 //mileage at inception 4057 var inceptionMileage = gmfx$('.modal.in .mileage-inception').val(); // userinput 4058 4059 //current mileage 4060 var currentMileage = gmfx$('.modal.in .mileage-current').val(); // userinput 4061 4062 //annual mileage allowance 4063 var annualMileageAllowance = gmfx$('.modal.in .mileage-annual').val(); // userinput or EOL (in case of EOL ) 4064 4065 //miles used 4066 var milesUsed = currentMileage - inceptionMileage; // currentMileage - inceptionMileage 4067 4068 //total Mileage allowance 4069 var totalMileageAllowance = ((annualMileageAllowance * leaseTerm) / 12); //((annualMileageAllowance * leaseTerm)/12) 4070 4071 //remaining Miles 4072 var remainingMiles = Math.round(totalMileageAllowance - milesUsed); 4073 4074 //months driven 4075 var monthsDriven = leaseTerm - remainingLeaseMonth; 4076 4077 //current Monthly Usage 4078 var currentMonthlyUsage = Math.round(milesUsed / monthsDriven); 4079 4080 //current Daily Usage 4081 var currentDailyUsage = milesUsed / (monthsDriven * 30); 4082 4083 //predicated Miles in remaining months 4084 var predicatedMiles = currentMonthlyUsage * remainingLeaseMonth; 4085 4086 //final Miles user will drive at lease end 4087 var finalMiles = predicatedMiles + milesUsed; 4088 4089 //extra miles 4090 var extraMiles = Math.round(totalMileageAllowance - finalMiles); 4091 4092 displayResult(remainingMiles, extraMiles, currentMonthlyUsage, currentDailyUsage, remainingLeaseDays); 4093 } 4094 4095 function calculateMileagePurl(validAccount) { 4096 4097 var currentDate = new Date(); //system date 4098 4099 var leaseTerm = validAccount["leaserTerm"]; // EOL input 4100 4101 var mileageLimit = validAccount["mileageLimit"]; // EOL input 4102 4103 //number of days remaining on lease 4104 var remainingLeaseDays = validAccount["daysUntilLeaseEnds"]; //EOL input 4105 4106 //numbe rof months remaning on lease 4107 var remainingLeaseMonth = remainingLeaseDays / (365 / 12); 4108 4109 //mileage at inception 4110 var inceptionMileage = gmfx$('.modal.in .mileage-inception-purl').val(); // userinput 4111 4112 //current mileage 4113 var currentMileage = gmfx$('.modal.in .mileage-current-purl').val(); // userinput 4114 4115 //annual mileage allowance 4116 var annualMileageAllowance = mileageLimit / (leaseTerm / 12); // Fetching from EOL 4117 4118 //miles used 4119 var milesUsed = currentMileage - inceptionMileage; // currentMileage - inceptionMileage 4120 4121 //total Mileage allowance 4122 var totalMileageAllowance = ((annualMileageAllowance * leaseTerm) / 12); //((annualMileageAllowance * leaseTerm)/12) 4123 4124 //remaining Miles 4125 var remainingMiles = Math.round(totalMileageAllowance - milesUsed); 4126 4127 //months driven 4128 var monthsDriven = leaseTerm - remainingLeaseMonth; 4129 4130 //current Monthly Usage 4131 var currentMonthlyUsage = Math.round(milesUsed / monthsDriven); 4132 4133 //current Daily Usage 4134 var currentDailyUsage = milesUsed / (monthsDriven * 30); 4135 4136 //predicated Miles in remaining months 4137 var predicatedMiles = currentMonthlyUsage * remainingLeaseMonth; 4138 4139 //final Miles user will drive at lease end 4140 var finalMiles = predicatedMiles + milesUsed; 4141 4142 //extra miles 4143 var extraMiles = Math.round(totalMileageAllowance - finalMiles); 4144 4145 displayResult(remainingMiles, extraMiles, currentMonthlyUsage, currentDailyUsage, remainingLeaseDays); 4146 } 4147 4148 function displayResult(remainingMiles, extraMiles, currentMonthlyUsage, currentDailyUsage, remainingLeaseDays) { 4149 4150 //Get current Date 4151 var today = new Date(); 4152 gmfx$('.input-group.date').datepicker('update', today); 4153 4154 var finalHtml = ''; 4155 //display message based on miles 4156 if(remainingMiles > 0) { 4157 if(extraMiles > 0) { 4158 gmfx$('.mileage-alert').attr('class', 'mileage-alert alert'); 4159 gmfx$('.mileage-tips').html(''); 4160 gmfx$('.mileage-alert').addClass('alert-success'); 4161 4162 // changes html of alert message 4163 finalHtml = gmfx$('.unused-mileage-description').html().replace('{0}
4163', remainingMiles.toLocaleString()); 4164 finalHtml = finalHtml.replace('{1}', currentMonthlyUsage.toFixed(1).replace(/\.0+$/, '')); 4165 finalHtml = finalHtml.replace('{2}', extraMiles.toLocaleString()); 4166 gmfx$('.mileage-alert').html(finalHtml); 4167 4168 } else { 4169 gmfx$('.mileage-alert').attr('class', 'mileage-alert alert'); 4170 gmfx$('.mileage-tips').html(''); 4171 gmfx$('.mileage-alert').addClass('alert-warning'); 4172 4173 if(extraMiles < 0) { 4174 extraMiles = extraMiles * (-1); 4175 } 4176 4177 //per day Mileage Limit 4178 var perDayMileageLimit = Math.round(extraMiles / remainingLeaseDays); 4179 4180 //weekday Mileage Limit 4181 var weekDayMileageLimit = Math.round(extraMiles / (remainingLeaseDays * (5 / 7))); 4182 4183 //weekends Mileage Limit 4184 var weekendMileageLimit = Math.round(extraMiles / (remainingLeaseDays * (2 / 7))); 4185 4186 // changes html of alert message 4187 finalHtml = gmfx$('.warning-mileage-description').html().replace('{0}', remainingMiles.toLocaleString()); 4188 finalHtml = finalHtml.replace('{1}', currentDailyUsage.toFixed(1).replace(/\.0+$/, '')); 4189 finalHtml = finalHtml.replace('{2}', extraMiles.toLocaleString()); 4190 gmfx$('.mileage-alert').html(finalHtml); 4191 gmfx$(".calc-display .alert-warning > p:nth-child(2)").prepend('<span class="icon-alert-warning icon-medium"></span>'); 4192 var tips = gmfx$('.mileage-tips-desc').html().replace('{0}', perDayMileageLimit.toFixed(1).replace(/\.0+$/, '')); 4193 tips = tips.replace('{1}', weekDayMileageLimit.toFixed(1).replace(/\.0+$/, '')); 4194 tips = tips.replace('{2}', weekendMileageLimit.toFixed(1).replace(/\.0+$/, '')); 4195 tips = tips.replace('{3}', gmfx$('.contact-number-dealer').html()); 4196 gmfx$('.mileage-tips').html(tips); 4197 } 4198 } else { 4199 gmfx$('.mileage-alert').attr('class', 'mileage-alert alert'); 4200 gmfx$('.mileage-tips').html(''); 4201 gmfx$('.mileage-alert').addClass('alert-danger'); 4202 4203 remainingMiles = remainingMiles * (-1); 4204 extraMiles = extraMiles * (-1); 4205 4206 // changes html of alert message 4207 finalHtml = gmfx$('.exceeded-mileage-description').html().replace('{0}', remainingMiles.toLocaleString()); 4208 finalHtml = finalHtml.replace('{1}', currentDailyUsage.toFixed(1).replace(/\.0+$/, '')); 4209 finalHtml = finalHtml.replace('{2}', extraMiles.toLocaleString()); 4210 finalHtml = finalHtml.replace('{3}', gmfx$('.contact-number-dealer').html()); 4211 gmfx$('.mileage-alert').html(finalHtml); 4212 gmfx$(".calc-display .alert-danger > p:nth-child(2)").prepend('<span class="icon-alert-error icon-medium"></span>'); 4213 } 4214
4215 //adds extra zeroes before # 4216 function pad(str, max) { 4217 str = str.toString(); 4218 return str.length < max ? pad("0" + str, max) : str; 4219 } 4220 4221 //displaying result 4222 var x = "" + Math.round(remainingMiles); 4223 4224 var x = pad(x, 6); 4225 var array = x.split(""); // contains all the digits of result 4226 4227 var tempHtml = ""; 4228 for(i = 0; i < array.length; i++) { 4229 tempHtml += "<span class='display_mile'>" + array[i] + "</span>"; 4230 } 4231 4232 if(gmfx$('.mileage-calculator-form').find('.mileage-section-1').css('display') == 'none') { 4233 gmfx$(".calc-output").hide(); 4234 gmfx$('.mileage-calculator-form .dropdown-toggle .option').text("Select"); 4235 gmfx$('.mileage-term-length-input').removeAttr('value'); 4236 gmfx$('.modal.in .mileage-calculator-form')[0].reset(); 4237 gmfx$(".mileage-section-1").show(); 4238 //gmfx$(".calculate-mileage-calculator").text(gmfx$('.mileage-cta-1').html()); 4239 gmfx$('.calculate-btn').show(); 4240 gmfx$('.re-calculate-btn').hide(); 4241 } else { 4242 gmfx$(".disp_remaining_mileage").html(tempHtml); 4243 gmfx$(".calc-output").show(); 4244 gmfx$(".mileage-section-1").hide(); 4245 //gmfx$(".calculate-mileage-calculator").text(gmfx$('.mileage-cta-2').html()); 4246 gmfx$('.calculate-btn').hide(); 4247 gmfx$('.re-calculate-btn').show(); 4248 } 4249 } 4250 4251 gmfx$('.buttonoverlay').click(function() { 4252 gmfx$('.mileage-section-1.mileage-calculator.myModalContent').show(); 4253 //gmfx$(".calculate-mileage-calculator").text(gmfx$('.mileage-cta-1').html()); 4254 gmfx$('.calculate-btn').show(); 4255 gmfx$('.re-calculate-btn').hide(); 4256 }); 4257 4258 gmfx$('.mileage_calculator_popup').click(function() { 4259 gmfx$('.mileage-section-1.mileage-calculator.myModalContent').show(); 4260 //gmfx$(".calculate-mileage-calculator").text(gmfx$('.mileage-cta-1').html()); 4261 gmfx$('.calculate-btn').show(); 4262 gmfx$('.re-calculate-btn').hide(); 4263 }); 4264}; 4265 4266//Initialize the component 4267gmfxMomentumUtils.component.init(".mileage-calculator-form", gmfxWwwComponents.LeaseMileageCalculator); 4268 4269/** 4270 * LeaseInfoFragment - displays dealers info 4271 * 4272 * @author subha 4273 * @since 9/9/2021 4274 */ 4275gmfxWwwComponents.LeaseInfoFragment = function(component) { 4276 'use strict'; 4277 4278 var $component = gmfx$(component), 4279 isCookie = gmfxMomentumServices.Cookie.get("eol_uid"); 4280 4281 if(isCookie != null && isCookie != "") { 4282 4283 isCookie = Base64.decode(isCookie); 4284 var jsonObject = JSON.parse(isCookie); 4285 4286 var validVehicle = jsonObject["eolData"]["gmfAccountDetail"]["vehicle"]; 4287 4288 if(gmfx$('.display_make').length > 0) { 4289 gmfx$('.display_make').text(validVehicle["vehicleMake"]); 4290 } 4291 4292 if(gmfx$('.display_make_model_year').length > 0) { 4293 gmfx$('.display_make_model_year').text(validVehicle["vehicleYear"] + " " + validVehicle["vehicleMake"] + " " + validVehicle["vehicleModel"]); 4294 } 4295 4296 } else { 4297 if(gmfx$('.display_make').length > 0) { 4298 gmfx$('.display_make').text(''); 4299 } 4300 4301 if(gmfx$('.display_make_model_year').length > 0) { 4302 gmfx$('.display_make_model_year').text(''); 4303 } 4304 4305 if(gmfx$('.add_empty_space').length > 0) { 4306 gmfx$('.add_empty_space').text(''); 4307 } 4308 } 4309 4310 var dragging = false; 4311 4312 gmfx$('body').on('touchmove', function(e) { 4313 dragging = true; 4314 }); 4315 4316 gmfx$('.nav-tabs a').on('click touchend', function(e) { 4317 if(!dragging) { 4318 gmfx$(this).tab('show'); 4319 } 4320 }); 4321 4322 gmfx$('body').on('touchend', function(e) { 4323 setTimeout(function() { 4324 dragging = false; 4325 }, 200) 4326 }); 4327 4328 /*California Privacy Opt Out*/ 4329 var calpath = window.location.href; 4330 calpath = calpath.split("privacy-and-security/"); 4331 calpath = calpath[1].split(".html"); 4332 var $activeContainerRadio = $(".form__container", $activeContainerTab), 4333 $dependantsRadio, 4334 $eHiddenRadio, 4335 dependantsR = "", 4336 hiddenList = "", 4337 dependantsList = ""; 4338 4339 $("#formHideYes").change(function() { 4340 if(calpath[0] == "california-privacy-rights" && calpath[1] == "?optout") { 4341 setTimeout(function() { 4342 if($("#form_input_checkbox_requesttype_opt_out").prop("required")) { 4343 $("#form_input_checkbox_requesttype_opt_out").trigger("click"); 4344 } 4345 }, 1000); 4346 } 4347 }); 4348 4349 $("#form_group_authorizedagent input").on("click", function() { 4350 hideInputsFields(); 4351 }) 4352 4353 $("#form_input_checkbox_newdeal1_norequired, #form_input_checkbox_newdeal2_norequired, #form_input_checkbox_newdeal3_norequired").on("click", function() { 4354 if($(this).prop("checked") == false) { 4355 isChecked(); 4356 } 4357 }); 4358 4359 $("#form_input_checkbox_requiredaddress_norequired, #form_input_checkbox_requiredemail_norequired").on("click", function() { 4360 setTimeout(function() { 4361 $("#form_input_checkbox_requiredaddress_norequired, #form_input_checkbox_requiredemail_norequired, #form_input_text_addressforauthorizedagent, #form_input_text_cityforauthorizedagent, #form_input_dropdown_stateforauthorizedagent").prop("required", false); 4362 $("#form_group_requiredaddress .with-errors").hide(); 4363 }, 1000); 4364 }); 4365 4366 $("#form_group_whoami input, #form_group_hrcontext input").on("click", function() { 4367 $("#form_input_dropdown_contactmethod option:eq(0), #form_input_dropdown_contactmethodforagent option:eq(0)").prop("selected", true); 4368 hideInputsFields(); 4369 if($("#form_input_checkbox_newdeal1_norequired").prop("checked")) { 4370 $("#form_input_checkbox_newdeal1_norequired").trigger("click"); 4371 } 4372 if(document.getElementById('form_input_checkbox_requiredaddress_norequired').checked) { 4373 $("#form_input_checkbox_requiredaddress_norequired").trigger("click"); 4374 } 4375 }); 4376 4377 $('#form_input_dropdown_contactmethodforagent').change(function() { 4378 var leaseOptionSelected = ""; 4379 var leaseInputChecked = ""; 4380 cleanHiddenErrorFields(); 4381 $("#form_input_dropdown_contactmethodforagent option:selected").each(function() { 4382 leaseOptionSelected = $(this).val(); 4383 if(leaseOptionSelected == "email") { 4384 $("#form_group_whoami input:checked").each(function() { 4385 leaseInputChecked = $(this).val().toLowerCase(); 4386 $("#form_input_checkbox_requiredemailagent_norequired").prop("required", false); 4387 switch (leaseInputChecked) { 4388 case "hr_contact": 4389 case "hr contact": 4390 $("#form_group_emailforauthorizedagent").hide(); 4391 break; 4392 default: 4393 displayEmailOrMail("form_input_checkbox_requiredemailagent_norequired", "#form_input_checkbox_requiredemailagent_norequired", "#form_group_requiredemailagent"); 4394 break; 4395 } 4396 }); 4397 } 4398 }); 4399 }); 4400 4401 $('#form_input_dropdown_contactmethod').change(function() { 4402 var leaseOptionSelected = ""; 4403 var leaseInputChecked = ""; 4404 $("#form_input_dropdown_contactmethod option:selected").each(function() { 4405 leaseOptionSelected = $(this).val(); 4406 if(leaseOptionSelected == "mail") { 4407 $("#form_group_whoami input:checked").each(function() { 4408 leaseInputChecked = $(this).val().toLowerCase(); 4409 switch (leaseInputChecked) { 4410 case "gm_protectionsorameriplus": 4411 case "dealership_contact": 4412 case "vendor_contact": 4413 case "gm protectionsorameriplus": 4414 case "dealership contact": 4415 case "vendor contact": 4416 displayEmailOrMail("form_input_checkbox_requiredaddress_norequired", "#form_input_checkbox_requiredaddress_norequired", "#form_group_requiredaddress"); 4417 break; 4418 default: 4419 $("#form_group_requiredaddress").removeClass("hide").show(); 4420 break; 4421 } 4422 }); 4423 $("#form_group_hrcontext input:checked").each(function() { 4424 leaseInputChecked = $(this).val(); 4425 if(leaseInputChecked == "current_former_contractor" || leaseInputChecked == "current former contractor") { 4426 displayEmailOrMail("form_input_checkbox_requiredaddress_norequired", "#form_input_checkbox_requiredaddress_norequired", "#form_group_requiredaddress"); 4427 } else { 4428 $("#form_group_requiredaddress").removeClass("hide").show(); 4429 $("#form_input_checkbox_requiredaddress_norequired").prop("required", false); 4430 } 4431 }); 4432 if(document.getElementById('form_input_checkbox_requiredemail_norequired').checked) { 4433 $("#form_input_checkbox_requiredemail_norequired").trigger("click"); 4434 } 4435 } else { //email 4436 if(document.getElementById('form_input_checkbox_requiredaddress_norequired').checked) { 4437 $("#form_input_checkbox_requiredaddress_norequired").trigger("click"); 4438 } 4439 $("#form_group_whoami input:checked").each(function() { 4440 leaseInputChecked = $(this).val().toLowerCase(); 4441 $("#form_input_checkbox_requiredemail_norequired").prop("required", false); 4442 switch (leaseInputChecked) { 4443 case "hr_contact": 4444 case "hr contact": 4445 $("#form_group_requiredemail").removeClass("hide").show(); 4446 break; 4447 default: 4448 displayEmailOrMail("form_input_checkbox_requiredemail_norequired", "#form_input_checkbox_requiredemail_norequired", "#form_group_requiredemail"); 4449 break; 4450 } 4451 }); 4452 } 4453 }); 4454 cleanHiddenErrorFields(); 4455 }); 4456 4457 $("#form_group_requesttype input").on("click", function() { 4458 // hide personal infomation fields when only opt out request selected 4459 if($("#form_input_checkbox_requesttype_opt_out").is(":checked") && $("#form_input_checkbox_requesttype_know").is(":not(:checked)") && $("#form_input_checkbox_requesttype_delete").is(":not(:checked)") && $("#form_input_checkbox_requesttype_request_correct").is(":not(:checked)")) { 4460 hidePersonalInfo(); 4461 } else { 4462 showPersonalInfo(); 4463 } 4464 }); 4465 4466 4467 function displayEmailOrMail(idchecked, idclick, idhide) { 4468 setTimeout(function() { 4469 if(!document.getElementById(idchecked).checked) { 4470 $(idclick).trigger("click"); 4471 $(idhide).hide(); 4472 } 4473 }, 50); 4474 } 4475 4476 function isChecked() { 4477 if($("#form_input_checkbox_newdeal3_norequired").prop("checked")) { 4478 $("#form_input_checkbox_newdeal3_norequired").trigger("click"); 4479 } 4480 if($("#form_input_checkbox_newdeal4_norequired").prop("checked")) { 4481 $("#form_input_checkbox_newdeal4_norequired").trigger("click"); 4482 } 4483 if($("#form_input_checkbox_newdeal5_norequired").prop("checked")) { 4484 $("#form_input_checkbox_newdeal5_norequired").trigger("click"); 4485 } 4486 } 4487 4488 function isRequestTypeOptOutChecked() { // hide input fields that do not reset 4489 // hide personal infomation fields when only opt out request selected 4490 if($("#form_input_checkbox_requesttype_opt_out").is(":checked") && $("#form_input_checkbox_requesttype_know").is(":not(:checked)") && $("#form_input_checkbox_requesttype_delete").is(":not(:checked)") && $("#form_input_checkbox_requesttype_request_correct").is(":not(:checked)")) { 4491 return true; 4492 } 4493 } 4494 4495 function cleanHiddenErrorFields() { // delete required attribute from inputs when hidden to avoid error bugs 4496 $('div[style="display: none;"]').children("input").prop("required", false); 4497 $("#form_input_checkbox_requiredemail_norequired").prop("required", false); 4498 } 4499 4500 function hideInputsFields() { // hide input fields that do not reset 4501 $("#form_group_requiredaddress, #form_group_emailforauthorizedagent, #form_group_email, #form_group_addressforauthorizedagent, #form_group_address2forauthorizedagent, #form_group_cityforauthorizedagent, #form_group_stateforauthorizedagent, #form_input_checkbox_requiredemailagent_norequired, #form_group_requiredemailagent, #form_group_requiredemail, #form_group_preferredaddress, #form_group_preferredaddress2, #form_group_preferredcity, #form_group_preferredstate, #form_group_preferredzip").hide(); 4502 cleanHiddenErrorFields(); 4503 } 4504 4505 function showPersonalInfo() { // show personal infomation fields 4506 if($("#form_input_radio_authorizedagent").val() == "yes" && $("#form_input_radio_authorizedagent").prop("checked") == true) { 4507 showCommonInfo('#form_group_contactmethodforagent'); 4508 $("#form_input_dropdown_contactmethodforagent").prop("required", true); 4509 showRelationshipInfo(); 4510 } else { 4511 showCommonInfo('#form_group_contactmethod'); 4512 $("#form_input_dropdown_contactmethod").prop("required", true); 4513 showRelationshipInfo(); 4514 } 4515 } 4516 4517 function showCommonInfo(contactMethod) { 4518 $(".form-element-title-mobile").removeClass("hide").show(); 4519 $("#form_group_tooltip").removeClass("hide").show(); 4520 $(contactMethod).removeClass("hide").show(); 4521 $("#form_group_firstname, #form_group_lastname").removeClass("hide").show(); 4522 $("#form_input_text_firstname, #form_input_text_lastname").prop("required", true); 4523 } 4524 4525 // show personal information for GMF Relationship selection 4526 function showRelationshipInfo() { 4527 $("#form_group_whoami input:checked").each(function() { 4528 var relationshipChecked = $(this).val().toLowerCase(); 4529 switch (relationshipChecked) { 4530 case "customer": 4531 showDependantsList($(this).data("dependants-list")); 4532 showCustomerInfo(); 4533 break; 4534 case "gm_protectionsorameriplus": 4535 case "gm protectionsorameriplus": 4536 showDependantsList($(this).data("dependants-list")); 4537 break; 4538 case "vendor_contact": 4539 case "vendor contact": 4540 showDependantsList($(this).data("dependants-list")); 4541 break; 4542 case "hr_contact": 4543 case "hr contact": 4544 showDependantsList($(this).data("dependants-list")); 4545 showHRcontextInfo(); 4546 break; 4547 case "other": 4548 showDependantsList($(this).data("dependants-list")); 4549 break; 4550 default: 4551 break; 4552 } 4553 }); 4554 } 4555 4556 // show customer information selection 4557 function showCustomerInfo() { 4558 $("#form_group_customertype input:checked").each(function() { 4559 var customerInfoChecked = $(this).val().toLowerCase(); 4560 switch (customerInfoChecked) { 4561 case "consumer": 4562 showDependantsList($(this).data("dependants-list")); 4563 break; 4564 case "commercial": 4565 showDependantsList($(this).data("dependants-list")); 4566 break; 4567 default: 4568 break; 4569 } 4570 }); 4571 } 4572 4573 // show personal information for HR Context selection 4574 function showHRcontextInfo() { 4575 $("#form_group_hrcontext input:checked").each(function() { 4576 var hrcontextChecked = $(this).val().toLowerCase(); 4577 switch (hrcontextChecked) { 4578 case "job_applic
4578ant": 4579 case "job applicant": 4580 showDependantsList($(this).data("dependants-list")); 4581 break; 4582 case "current_employee": 4583 case "current employee": 4584 showDependantsList($(this).data("dependants-list")); 4585 break; 4586 case "former_employee": 4587 case "former employee": 4588 showDependantsList($(this).data("dependants-list")); 4589 break; 4590 case "current_former_contractor": 4591 case "current former contractor": 4592 showDependantsList($(this).data("dependants-list")); 4593 break; 4594 case "dealership_contact": 4595 case "dealership contact": 4596 showDependantsList($(this).data("dependants-list")); 4597 break; 4598 case "commercial": 4599 showDependantsList($(this).data("dependants-list")); 4600 break; 4601 default: 4602 break; 4603 } 4604 }); 4605 } 4606 4607 function showDependantsList(dependantsList) { 4608 $dependantsRadio = $(dependantsList, $activeContainerRadio); 4609 cEnablingHiddenFields($dependantsRadio); 4610 $dependantsRadio.removeClass("hide").show(); 4611 } 4612 4613 function hidePersonalInfo() { // hide personal infomation fields 4614 if($("#form_input_radio_authorizedagent").val() == "yes" && $("#form_input_radio_authorizedagent").prop("checked") == true) { 4615 hideCommonInfo('#form_group_contactmethodforagent'); 4616 $("#form_input_dropdown_contactmethodforagent").val(''); 4617 $("#form_input_dropdown_contactmethodforagent").find('option:selected').removeAttr('selected'); 4618 $("#form_input_dropdown_contactmethodforagent").prop("required", false); 4619 hideRelationshipInfo(); 4620 } else { 4621 hideCommonInfo('#form_group_contactmethod'); 4622 $("#form_input_dropdown_contactmethod").val(''); 4623 $("#form_input_dropdown_contactmethod").find('option:selected').removeAttr('selected'); 4624 $("#form_input_dropdown_contactmethod option:eq(0)").prop('selected', true); 4625 $("#form_input_dropdown_contactmethod").prop("required", false); 4626 hideRelationshipInfo(); 4627 } 4628 } 4629 4630 function hideCommonInfo(contactMethod) { 4631 $(".form-element-title-mobile").hide(); 4632 $("#form_group_tooltip").hide(); 4633 $(contactMethod).hide(); 4634 hideInputsFields(); 4635 $("#form_group_firstname, #form_group_lastname").hide(); 4636 $("#form_input_text_firstname, #form_input_text_lastname").val(""); 4637 $("#form_input_text_firstname, #form_input_text_lastname").prop("required", false); 4638 } 4639 4640 // hide personal information for GMF Relationship selection 4641 function hideRelationshipInfo() { 4642 $("#form_group_whoami input:checked").each(function() { 4643 var relationshipChecked = $(this).val().toLowerCase(); 4644 switch (relationshipChecked) { 4645 case "customer": 4646 hideDependantsList($(this).data("dependants-list"), $(this).data("dependants-list-optout")); 4647 hideCustomerInfo(); 4648 break; 4649 case "gm_protectionsorameriplus": 4650 case "gm protectionsorameriplus": 4651 hideDependantsList($(this).data("dependants-list"), $(this).data("dependants-list-optout")); 4652 break; 4653 case "vendor_contact": 4654 case "vendor contact": 4655 hideDependantsList($(this).data("dependants-list"), $(this).data("dependants-list-optout")); 4656 break; 4657 case "hr_contact": 4658 case "hr contact": 4659 hideDependantsList($(this).data("dependants-list"), $(this).data("dependants-list-optout")); 4660 hideHRcontextInfo(); 4661 break; 4662 case "other": 4663 hideDependantsList($(this).data("dependants-list"), $(this).data("dependants-list-optout")); 4664 break; 4665 default: 4666 break; 4667 } 4668 }); 4669 } 4670 4671 // hide customer information selection 4672 function hideCustomerInfo() { 4673 $("#form_group_customertype input:checked").each(function() { 4674 var customerInfoChecked = $(this).val().toLowerCase(); 4675 switch (customerInfoChecked) { 4676 case "consumer": 4677 hideDependantsList($(this).data("dependants-list"), $(this).data("dependants-list-optout")); 4678 break; 4679 case "commercial": 4680 hideDependantsList($(this).data("dependants-list"), $(this).data("dependants-list-optout")); 4681 break; 4682 default: 4683 break; 4684 } 4685 }); 4686 } 4687 4688 // hide personal information for HR Context selection 4689 function hideHRcontextInfo() { 4690 $("#form_group_hrcontext input:checked").each(function() { 4691 var hrcontextChecked = $(this).val().toLowerCase(); 4692 switch (hrcontextChecked) { 4693 case "job_applicant": 4694 case "job applicant": 4695 hideDependantsList($(this).data("dependants-list"), $(this).data("dependants-list-optout")); 4696 break; 4697 case "current_employee": 4698 case "current employee": 4699 hideDependantsList($(this).data("dependants-list"), $(this).data("dependants-list-optout")); 4700 break; 4701 case "former_employee": 4702 case "former employee": 4703 hideDependantsList($(this).data("dependants-list"), $(this).data("dependants-list-optout")); 4704 break; 4705 case "current_former_contractor": 4706 case "current former contractor": 4707 hideDependantsList($(this).data("dependants-list"), $(this).data("dependants-list-optout")); 4708 break; 4709 case "dealership_contact": 4710 case "dealership contact": 4711 hideDependantsList($(this).data("dependants-list"), $(this).data("dependants-list-optout")); 4712 break; 4713 case "commercial": 4714 hideDependantsList($(this).data("dependants-list"), $(this).data("dependants-list-optout")); 4715 break; 4716 default: 4717 break; 4718 } 4719 }); 4720 } 4721 4722 function hideDependantsList(hiddenList, showListOptout) { 4723 if(hiddenList != "") {
4724 // Do not hide the options of showListOptout when Opt out request type is selected 4725 if(showListOptout != null) { 4726 var commonList = hiddenList.includes(showListOptout); 4727 if(commonList) { 4728 hiddenList = hiddenList.split(showListOptout).join('').replace(/\,,/g, ','); 4729 if(hiddenList.match("^,")) { 4730 hiddenList = hiddenList.slice(1); 4731 } 4732 if(hiddenList.match(",$")) { 4733 hiddenList = hiddenList.slice(0, -1); 4734 } 4735 } 4736 } 4737 $eHiddenRadio = $(hiddenList, $activeContainerRadio); 4738 /* Iterates over the 2nd children to hide them.*/ 4739 $eHiddenRadio.each(function(ele, val) { 4740 hideChildElements($(val)); 4741 }); 4742 /* Hides the 1st children*/ 4743 $eHiddenRadio.hide(); 4744 cDisablingHiddenFields($eHiddenRadio); 4745 cResetForm($eHiddenRadio); 4746 } 4747 } 4748}; 4749 4750//Initialize the component 4751gmfxMomentumUtils.component.init(".lease-info-fragment", gmfxWwwComponents.LeaseInfoFragment); 4752 4753/** 4754 * Image - scroll to ID path 4755 * 4756 * Created by ajena on 11/3/2017. 4757 */ 4758gmfxWwwComponents.Image = function(component) { 4759 'use strict'; 4760 var $component = gmfx$(component); 4761 // Image smooth scroll animation 4762 gmfx$("a.image-scroll").click(function() { 4763 var $imageLink = gmfx$(this).attr('href'), 4764 $imagePadding = 0; 4765 gmfxMomentumUtils.element.scrollTopAnimate($imageLink, $imagePadding, 1000); 4766 return false; 4767 }); 4768}; 4769//Initialize the component 4770gmfxMomentumUtils.component.init(".image-scroll", gmfxWwwComponents.Image); 4771 4772/** 4773 * HeroLogin 4774 * 4775 * @author subha 4776 * @since 9/23/2021 4777 */ 4778gmfxWwwComponents.HeroLogin = function(component) { 4779 'use strict'; 4780 4781 var $component = gmfx$(component), 4782 isCookie = gmfxMomentumServices.Cookie.get('gmf_MyAccount_userId'), 4783 $rememberMe = gmfx$('#rememberMe'), 4784 $heroLoginContainer = gmfx$(".brand-login-container"), 4785 isMaintenanceMode = $heroLoginContainer.data("ismaintenancemode"), 4786 $heroModal = gmfx$(".hero-video-modal:first"); 4787 4788 if(isCookie != null && isCookie != "") { 4789 $rememberMe.prop('checked', true); 4790 } 4791 4792 // Enable the maintenance message. NOTE: This solution allows re-usability of the experience fragment that already includes content and CSS styles 4793 if(typeof isMaintenanceMode !== 'undefined' && isMaintenanceMode.toLowerCase() === "on") { 4794 var maintenanceMessage = $heroLoginContainer.data("maintenancemessage"), 4795 $loginContainer = gmfx$(".login-section.brand-overlay", $heroLoginContainer), 4796 $loginSectionIntro = gmfx$(".login-section--intro", $loginContainer), 4797 $loginForm = gmfx$("#login-form", $loginContainer), 4798 $loginSectionRegister = gmfx$(".login-section--register", $loginContainer), 4799 $loginSectionLinks = gmfx$(".login-section__links", $loginContainer), 4800 $loginMaintenanceContainer = gmfx$(".login-section--form .form-level-error", $loginContainer); 4801 4802 // Hide other unused containers 4803 $loginSectionIntro.hide(); 4804 $loginForm.hide(); 4805 $loginSectionRegister.hide(); 4806 $loginSectionLinks.hide(); 4807 4808 // Show the maintenance message 4809 gmfx$("p", $loginMaintenanceContainer).append(maintenanceMessage); 4810 $loginMaintenanceContainer.show(); 4811 } 4812 4813 $heroModal.on('hidden.bs.modal', function(e) { 4814 var $if = $(e.delegateTarget).find('iframe'); 4815 var src = $if.attr("src"); 4816 $if.attr("src", '/empty.html'); 4817 $if.attr("src", src); 4818 4819 gmfxMomentumUtils.element.scrollTopAnimate(gmfx$(".hero-homepage"), 0, gmfxMomentumCoreConstants.PAGE_SCROLL_SPEED); 4820 }); 4821}; 4822 4823//Initialize the component 4824gmfxMomentumUtils.component.init(".hero-component-login", gmfxWwwComponents.HeroLogin); 4825 4826/** 4827 * HelpAndSupport - displays dealers info 4828 * 4829 * @author subha 4830 * @since 9/9/2021 4831 */ 4832gmfxWwwComponents.HelpAndSupport = function(component) { 4833 'use strict'; 4834 4835 var $component = gmfx$(component), 4836 isCookie = gmfxMomentumServices.Cookie.get("eol_uid"); 4837 4838 if(isCookie != null && isCookie != "") { 4839 isCookie = Base64.decode(isCookie); 4840 var jsonObject = JSON.parse(isCookie); 4841 4842 if(gmfx$('.help-and-support-public').length > 0) { 4843 gmfx$('.help-and-support-public').remove(); 4844 } 4845 4846 var isDealerCookie = gmfxMomentumServices.Cookie.get("GMF_dealer"); 4847 if(isDealerCookie == null || isDealerCookie == "") { 4848 var dealerName, dealerAddress, dealerZip; 4849 4850 // Retrieve input for GDL Call from EOL Service 4851 var dealer = jsonObject["eolData"]["gmfAccountDetail"]["dealer"]; 4852 var vehicleBrand = getFirstWord(jsonObject["eolData"]["gmfAccountDetail"]["vehicle"]["vehicleMake"]); 4853 if(dealer) { 4854 dealerName = (dealer["dealerName"] != undefined) ? dealer["dealerName"] : ""; 4855 dealerAddress = (dealer["dealerAddress"] != undefined) ? dealer["dealerAddress"] : ""; 4856 dealerZip = (dealer["dealerZip"] != undefined) ? dealer["dealerZip"] : ""; 4857 } 4858 4859 // Prepare Request Param for GDL 4860 var requestParam = "make=" + vehicleBrand + "&dealerName=" + dealerName + "&dealerAddress=" + dealerAddress + "&zipCode=" + dealerZip + "&requestPath=" + Base64.encode(gmfx$(".requestPath").text()); 4861 4862 gmfx$.ajax({ 4863 url: "/gmfdyn/eoldealer", 4864 type: "POST", 4865 beforeSend: function() { 4866 gmfx$('.help-and-support-purl').hide(); 4867 gmfx$('.help-support-spinner').append("<span class='spinner img-responsive'></span>"); 4868 }, 4869 data: requestParam, 4870 success: function(data) { 4871 // On AJAX success create cookie and retrieve data from cookie 4872 document.cookie = "GMF_dealer=" + data + "; mtracker=0; path=/; Secure; SameSite=Strict"; 4873 var isDealerCookie = gmfxMomentumServices.Cookie.get("GMF_dealer"); 4874 if(isDealerCookie != null && isDealerCookie != "" && isNotEmptyGDLData(isDealerCookie)) { 4875 populateDealerInfo(isDealerCookie); 4876 } else { 4877 populateEOLDealerInfo(jsonObject); 4878 } 4879 showVisitDealerContent(); 4880 }, 4881 error: function(response) { 4882 showVisitDealerContent(); 4883 gmfx$('.help-support-spinner').find(".spinner").remove(); 4884 populateEOLDealerInfo(jsonObject); 4885 } 4886 }); 4887 } else { 4888 //gmfx$('.help-and-support-purl').show(); 4889 gmfx$('.help-support-spinner').append("<span class='spinner img-responsive'></span>"); 4890 if(isDealerCookie != null && isDealerCookie != "" && isNotEmptyGDLData(isDealerCookie)) { 4891 populateDealerInfo(isDealerCookie); 4892 } else { 4893 populateEOLDealerInfo(jsonObject); 4894 } 4895 } 4896 } else { 4897 if(gmfx$('.help-and-support-purl').length > 0) { 4898 gmfx$('.help-and-support-purl').remove(); 4899 } 4900 } 4901 4902 // Populate DealerInfo 4903 function populateDealerInfo(data) { 4904 var decodedData = Base64.decode(data); 4905 decodedData = JSON.parse(decodedData); 4906 4907 var dealerInfo = decodedData["dealerData"]; 4908 if(dealerInfo != null && dealerInfo != "") { 4909 var dName = dealerInfo["dealerName"]; 4910 var dStreet = dealerInfo["dealerStreet"]; 4911 var dCity = dealerInfo["dealerCity"]; 4912 var dRegionCode = dealerInfo["regionCode"]; 4913 var dealerPurlZip = dealerInfo["postalCode"]; 4914 var dPhone = dealerInfo["phone"]; 4915 4916 dealerPurlZip = dealerPurlZip.slice(0, 5); 4917 if(dName != null && dName != "") { 4918 gmfx$('.dealer-name').text(capitalize(dName)); 4919 } 4920 if(dStreet != null && dStreet != "") { 4921 gmfx$('.dealer-details').text(capitalize(dStreet)); 4922 } 4923 if(dCity != null && dCity != "") { 4924 gmfx$('.dealer-city-state-zip').text(capitalize(dCity) + showFormattedData(dRegionCode) + showFormattedData(dealerPurlZip)); 4925 } 4926 // If dealer contact name is not available in EOL Response, remove the element from HTML 4927 var dealer = jsonObject["eolData"]["gmfAccountDetail"]["dealer"]; 4928 var dealerContactName; 4929 if(dealer) { 4930 dealerContactName = (dealer["dealerContactName"] != undefined) ? dealer["dealerContactName"] : ""; 4931 } 4932 if(dealerContactName != null && dealerContactName != "") { 4933 gmfx$('.contact-name').text(dealerContactName); 4934 } else { 4935 gmfx$('.contact-name').remove(); 4936 } 4937 // If dealer contact number is not available in GDL Response, remove the element from HTML 4938 if(dPhone != null && dPhone != "") { 4939 var PhoneNumber = formatPhone(dPhone); 4940 gmfx$('.contact-num').text(PhoneNumber); 4941 gmfx$(".contact-num").attr("href", "tel:" + PhoneNumber); 4942 } else { 4943 gmfx$('.contact-num').remove(); 4944 } 4945 } 4946 gmfx$('.help-support-spinner').find(".spinner").remove(); 4947 gmfx$('.help-and-support-purl').show(); 4948 } 4949 4950 // Populate DealerInfo from EOL 4951 function populateEOLDealerInfo(eolData) { 4952 // Read from EOL if GDL is not available 4953 var dealerName = "", 4954 dealerAddress = "", 4955 dealerCity = "", 4956 dealerState = "", 4957 dealerZip = ""; 4958 var dealer = eolData["eolData"]["gmfAccountDetail"]["dealer"]; 4959 if(dealer) { 4960 dealerName = (dealer["dealerName"]) ? dealer["dealerName"] : ""; 4961 dealerAddress = (dealer["dealerAddress"]) ? dealer["dealerAddress"] : ""; 4962 dealerCity = (dealer["dealerCity"]) ? dealer["dealerCity"] : ""; 4963 dealerState = (dealer["dealerState"]) ? dealer["dealerState"] : ""; 4964 dealerZip = (dealer["dealerZip"]) ? dealer["dealerZip"] : ""; 4965 } 4966 gmfx$('.dealer-name').text(capitalize(dealerName)); 4967 gmfx$('.dealer-details').text(capitalize(dealerAddress)); 4968 gmfx$('.dealer-city-state-zip').text(capitalize(dealerCity) + showFormattedData(dealerState) + showFormattedData(dealerZip)); 4969 gmfx$('.contact-name').remove(); 4970 gmfx$('.contact-num').remove(); 4971 gmfx$('.help-support-spinner').find(".spinner").remove(); 4972 gmfx$('.help-and-support-purl').show(); 4973 } 4974 4975 function showFormattedData(data) { 4976 var region = ""; 4977 if(data != null && data != "") { 4978 region = ", " + data; 4979 } 4980 return region; 4981 } 4982 4983 // Checking if the GDL response is not returning empty data 4984 function isNotEmptyGDLData(isDealerCookie) { 4985 var decodedDealerCookie = Base64.decode(isDealerCookie); 4986 var decodedDealerData = JSON.parse(decodedDealerCookie); 4987 var dealerInfo = decodedDealerData["dealerData"]; 4988 if(dealerInfo != null && dealerInfo != "") { 4989 var dName = dealerInfo["dealerName"]; 4990 var dAddress = dealerInfo["dealerStreet"]; 4991 var dCity = dealerInfo["dealerCity"]; 4992 if(dName != null && dName != "" && dAddress != null && dAddress != "" && 4993 dCity != null && dCity != "") { 4994 return true; 4995 } 4996 } 4997 return false;
4998 } 4999 5000}; 5001 5002//Initialize the component 5003gmfxMomentumUtils.component.init(".help-and-support", gmfxWwwComponents.HelpAndSupport); 5004 5005/** 5006 * changing return link to anchor tag with history API for 404 error page 5007 * 5008 * @author aagrawal 5009 * @since 6/28/2021 5010 */ 5011 5012gmfxWwwComponents.Headingcomp = function(component) { 5013 'use strict'; 5014 5015 var $component = gmfx$(component); 5016 5017 // Replace span tag with anchor tag and add return-link class 5018 gmfx$('.return-link').each(function() { 5019 gmfx$(this).replaceWith( 5020 "<a class='return-link'>" + gmfx$(this).html() + '</a>' 5021 ); 5022 }); 5023 gmfx$('.return-link').attr('href', 'javascript:history.go(-1)'); 5024}; 5025 5026// Initialize the component 5027gmfxMomentumUtils.component.init( 5028 '.headingcomp-container', 5029 gmfxWwwComponents.Headingcomp 5030); 5031 5032/** 5033 * FaqContainer - Navigate to categories, keydown and tab functions handled 5034 * 5035 * @author subha 5036 * @since 6/18/2021 5037 */ 5038gmfxWwwComponents.Glossary = function(component) { 5039 'use strict'; 5040 5041 var $component = gmfx$(component); 5042 5043 var termList = gmfx$(".term strong"); 5044 var charList = []; 5045 5046 // Retrieving the first character list from available terms 5047 for(var i = 0, size = termList.length; i < termList.length; i++) { 5048 var item = termList[i].innerHTML; 5049 charList.push(item.charAt(0)); 5050 } 5051 5052 //getting unique char from first character of available terms 5053 var uniqueChar = []; 5054 gmfx$.each(charList, function(i, el) { 5055 if($.inArray(el, uniqueChar) === -1) 5056 uniqueChar.push(el.toUpperCase()); 5057 5058 }); 5059 5060 var chars = [].concat.apply([], Array(26)) 5061 .map(function(_, i) { 5062 return String.fromCharCode(i + 65); 5063 }) 5064 .join(""); 5065 5066 var html = ""; 5067 for(var i = 0, size = chars.length; i < chars.length; i++) { 5068 if($.inArray(chars[i], uniqueChar) === -1) { 5069 // print as plain text 5070 html += "<li><span class='read-more-inactive'>" + chars[i] + "</span></li>"; 5071 } else { 5072 // print as link 5073 html += "<li><a class='read-more' href='#" + chars[i].toLowerCase() + "'>" + chars[i] + "</a></li>"; 5074 } 5075 } 5076 if(document.getElementById("alphabetList") != null) { 5077 document.getElementById("alphabetList").innerHTML = html; 5078 } 5079}; 5080 5081//Initialize the component 5082gmfxMomentumUtils.component.init(".c40-glossary", gmfxWwwComponents.Glossary); 5083 5084/** 5085 * Form controller facilitating email validation and submission to backend servlet 5086 * 5087 * @author mmustaine 5088 * @since 11/8/2021 5089 */ 5090gmfxWwwComponents.FormSendExpert = function(component) { 5091 'use strict'; 5092 5093 var $component = gmfx$(component), 5094 config = {}, 5095 $formId = gmfx$("#sendExpert-form"), 5096 $submitId = gmfx$("#sendExpert-submit"), 5097 $phoneNumber = document.querySelector("#sendExpert-phone"), 5098 $disclosureContent = gmfx$(".form-send-expert-disclosure"), 5099 $modalContent = gmfx$(".modal-content-disclosure"), 5100 $optionSelected = gmfx$("#sendExpert-contactMethod option"), 5101 $alertSuccess = gmfx$(".form-send-expert-success-content"), 5102 $mainTitle = gmfx$(".form-send-expert-main-title"); 5103 5104 // hyphen's to phone number on input/keydown (ex: 555-555-5555) 5105 gmfxMomentumUtils.element.addHyphenToPhoneNumber($phoneNumber); 5106 5107 // reset form on cancel button click 5108 gmfx$(".form-send-expert-close").on("click", function() { 5109 gmfxMomentumUtils.element.formResetMain("#sendExpert"); 5110 gmfxMomentumUtils.element.formResetDropdownField(".sendExpert-contact-method-container", "#dropdown-index-1", "Select"); 5111 gmfxMomentumUtils.element.formResetDropdownField(".sendExpert-help-with-container", "#dropdown-index-2", "Select"); 5112 gmfxMomentumUtils.element.formResetDropdownField(".sendExpert-vehicle-type-container", "#dropdown-index-3", "Select"); 5113 gmfxMomentumUtils.element.formResetDropdownField(".sendExpert-vehicle-time-frame-container", "#dropdown-index-4", "Select"); 5114 gmfxMomentumUtils.element.formResetDropdownField(".sendExpert-time-business-frame-container", "#dropdown-index-5", "Select"); 5115 }); 5116 5117 // custom validation for select dropdowns 5118 gmfxMomentumUtils.element.validateParsleyDropdown(".sendExpert-contact-method-container", "#sendExpert-contactMethod", $formId, $submitId); 5119 gmfxMomentumUtils.element.validateParsleyDropdown(".sendExpert-help-with-container", "#sendExpert-helpWith", $formId, $submitId); 5120 gmfxMomentumUtils.element.validateParsleyDropdown(".sendExpert-vehicle-type-container", "#sendExpert-vehicleType", $formId, $submitId); 5121 gmfxMomentumUtils.element.validateParsleyDropdown(".sendExpert-vehicle-time-frame-container", "#sendExpert-vehicleTimeFrame", $formId, $submitId); 5122 gmfxMomentumUtils.element.validateParsleyDropdown(".sendExpert-time-business-frame-container", "#sendExpert-businessTimeFrame", $formId, $submitId); 5123 5124 // disclosure show 5125 gmfx$("#sendExpert-disclosureOpen").click(function() { 5126 $disclosureContent.removeClass("hide"); 5127 $modalContent.removeClass("hide"); 5128 gmfx$("#sendExpert-disclosureCheckbox").removeAttr("disabled"); 5129 }); 5130 5131 // disclosure hide 5132 gmfx$("#sendExpert-disclosureClose").click(function() { 5133 $disclosureContent.addClass("hide"); 5134 $modalContent.addClass("hide"); 5135 }); 5136 5137 //radio selection 5138 gmfx$("input[type=radio]").on("click", function() { 5139 var selected = gmfx$(this).val(); 5140 $optionSelected.removeAttr('selected'); 5141 $optionSelected.each(function(index) { 5142 if(gmfx$(this).val() == selected) { 5143 gmfx$(this).attr('selected', 'selected').val(); 5144 } 5145 }); 5146 }); 5147 5148 // submit function 5149 gmfx$($submitId).on("click", function() { 5150 // success content show and hide 5151 var myInterval = setInterval(waitAlert, 1000); 5152 5153 // get referral URL and remove .html 5154 var $referralUrl = document.referrer.replace(".html", ""); 5155 5156 // remove all left side text from URL except page name 5157 var $referralUrlFormatted = $referralUrl.substring($referralUrl.lastIndexOf("/") + 1); 5158 5159 // replace URL hyphens with spaces to avoid email format issues 5160 $referralUrlFormatted = $referralUrlFormatted.split("-").join(" "); 5161 5162 // display referral URL in email 5163 gmfx$("#sendExpert-referral").val($referralUrlFormatted); 5164 5165 //wait Alert to show 5166 function waitAlert() { 5167 var successAlert = document.getElementById("sendExpert-alert").getElementsByClassName("alert-success"); 5168 var dangerAlert = document.getElementById("sendExpert-alert").getElementsByClassName("alert-danger"); 5169 if(successAlert.length > 0) { 5170 $mainTitle.addClass("hide"); 5171 $alertSuccess.removeClass("hide"); 5172 clearInterval(myInterval); 5173 } else if(dangerAlert.length > 0) { 5174 $mainTitle.removeClass("hide"); 5175 $alertSuccess.addClass("hide"); 5176 clearInterval(myInterval); 5177 } 5178 setTimeout(function() { 5179 clearInterval(myInterval); 5180 }, 10000); 5181 } 5182 }); 5183 5184 5185 5186 // Instantiate global email controller and initialize the form 5187 config[gmfxMomentumFormConstants.FORM_EMAIL_SERVICE] = new gmfxWwwServices.SendExpertForm($component); 5188 config[gmfxMomentumFormConstants.FORM_EMAIL_SERVICE][gmfxMomentumFormConstants.FORM_DATA][gmfxMomentumJcrConstants.CURRENT_NODE] = "/content/gmf/en/fragments/email-fragments/send-to-expert-form" + "/"
5188+ gmfxMomentumJcrConstants.JCR_CONTENT + "/" + gmfxMomentumJcrConstants.NODE_FORM_SEND_EXPERT; 5189 new gmfxMomentumControllers.Email(config); 5190}; 5191 5192// Initialize the component 5193gmfxMomentumUtils.component.init(".send-form-content", gmfxWwwComponents.FormSendExpert); 5194 5195/** 5196 * Form controller for the Send To Fleet Expert form. 5197 * 5198 * Reuses BaseForm (via SendFleetExpertForm) for field validation and submit-button 5199 * enabling, then performs a custom submit: reCAPTCHA v3 -> AJAX to the AEM proxy 5200 * servlet -> redirect to the success page. The servlet sends the notification email 5201 * and forwards the case to Salesforce, keeping that endpoint off the page. 5202 * 5203 * @author grajas 5204 */ 5205gmfxWwwComponents.FormSendFleetExpert = function(component) { 5206 'use strict'; 5207 5208 var $component = gmfx$(component), 5209 $phoneNumber = document.querySelector("#sendFleetExpert-phone"), 5210 $disclosureContent = gmfx$(".form-send-expert-disclosure"), 5211 $modalContent = gmfx$(".modal-content-disclosure"), 5212 SUBMIT_ENDPOINT = "/gmfdyn/fleetexpertsubmit", 5213 SUCCESS_REDIRECT_FALLBACK = "/en-us/success.html", 5214 RECAPTCHA_TIMEOUT_MS = 10000, 5215 $currentNode = gmfx$("input[name='currentnode']", $component); 5216 5217 // hyphen's to phone number on input/keydown (ex: 555-555-5555) 5218 gmfxMomentumUtils.element.addHyphenToPhoneNumber($phoneNumber); 5219 5220 // disclosure show 5221 gmfx$("#sendFleetExpert-disclosureOpen").click(function() { 5222 $disclosureContent.removeClass("hide"); 5223 $modalContent.removeClass("hide"); 5224 gmfx$("#sendFleetExpert-disclosureCheckbox").removeAttr("disabled"); 5225 }); 5226 5227 // disclosure hide 5228 gmfx$("#sendFleetExpert-disclosureClose").click(function() { 5229 $disclosureContent.addClass("hide"); 5230 $modalContent.addClass("hide"); 5231 }); 5232 5233 // BaseForm wires field validation and enables/disables the submit button 5234 var formService = new gmfxWwwServices.SendFleetExpertForm($component), 5235 formData = formService.getFormData(), 5236 $form = formData.$currentForm, 5237 $submitButton = formData.$submitButton, 5238 $alert = formData.$alert, 5239 isSubmitting = false; 5240 5241 $form.on("submit", function(e) { 5242 e.preventDefault(); 5243 5244 if (isSubmitting) { 5245 return; 5246 } 5247 5248 var $parsleyForm = $form.parsley(); 5249 $parsleyForm.validate(); 5250 if (!$parsleyForm.isValid()) { 5251 return; 5252 } 5253 5254 isSubmitting = true; 5255 $submitButton.prop("disabled", true); 5256 5257 try { 5258 verifyRecaptcha().then(function() { 5259 var utmCampaign = toCampaignToken(new URLSearchParams(window.location.search).get("utm_campaign")), 5260 payload = { 5261 firstName: gmfx$("#sendFleetExpert-firstName").val(), 5262 lastName: gmfx$("#sendFleetExpert-lastName").val(), 5263 emailAddress: gmfx$("#sendFleetExpert-emailAddress").val(), 5264 phone: gmfx$("#sendFleetExpert-phone").val(), 5265 business: gmfx$("#sendFleetExpert-business").val(), 5266 zipCode: gmfx$("#sendFleetExpert-zipCode").val(), 5267 additionalInfo: gmfx$("#sendFleetExpert-information").val(), 5268 disclosureCheckbox: gmfx$("#sendFleetExpert-disclosureCheckbox").is(":checked") ? "Yes" : "No", 5269 marketingCheckbox: gmfx$("#sendFleetExpert-marketingCheckbox").is(":checked") ? "Yes" : "No", 5270 utmCampaign: utmCampaign, 5271 currentnode: $currentNode.val() 5272 }; 5273 payload["g-recaptcha-response"] = gmfx$("#g-recaptcha-response").val(); 5274 5275 gmfx$.ajax({ 5276 url: SUBMIT_ENDPOINT, 5277 method: "POST", 5278 data: payload 5279 }).done(function(response) { 5280 var redirectUrl = (response && response.redirectUrl) ? response.redirectUrl : SUCCESS_REDIRECT_FALLBACK; 5281 window.location.href = toSameOriginPath(redirectUrl); 5282 }).fail(function() { 5283 resetSubmission(); 5284 showError(); 5285 }); 5286 }).catch(function() { 5287 resetSubmission(); 5288 showError(); 5289 }); 5290 } catch (error) { 5291 resetSubmission(); 5292 showError(); 5293 } 5294 }); 5295 5296 // The shared verifier calls grecaptcha.execute() inside grecaptcha.ready(), so a throw 5297 // there (missing or domain-mismatched site key) leaves its promise unsettled forever. 5298 function verifyRecaptcha() { 5299 if (typeof grecaptcha === "undefined" || typeof grecaptcha.ready !== "function") { 5300 return Promise.reject(new Error("reCAPTCHA failed to load")); 5301 } 5302 5303 return new Promise(function(resolve, reject) { 5304 var timer = setTimeout(function() { 5305 reject(new Error("reCAPTCHA timed out")); 5306 }, RECAPTCHA_TIMEOUT_MS); 5307 5308 Promise.resolve(verifyReCaptchaStatus()).then(function(result) { 5309 clearTimeout(timer); 5310 resolve(result); 5311 }).catch(function(error) { 5312 clearTimeout(timer); 5313 reject(error); 5314 }); 5315 }); 5316 } 5317 5318 function toCampaignToken(value) { 5319 if (typeof value !== "string") { 5320 return ""; 5321 } 5322 return value.replace(/[^A-Za-z0-9_-]/g, "").slice(0, 64); 5323 } 5324 5325 function toSameOriginPath(url) { 5326 if (typeof url !== "string") { 5327 return SUCCESS_REDIRECT_FALLBACK; 5328 } 5329 5330 var parsed; 5331 try { 5332 parsed = new URL(url, window.location.origin); 5333 } catch (e) { 5334 return SUCCESS_REDIRECT_FALLBACK; 5335 } 5336 5337 if (parsed.origin !== window.location.origin || !/^\/[A-Za-z0-9/_\-.]*$/.test(parsed.pathname)) { 5338 return SUCCESS_REDIRECT_FALLBACK; 5339 } 5340 return parsed.pathname; 5341 } 5342 5343 function resetSubmission() { 5344 isSubmitting = false;
5345 $submitButton.prop("disabled", false); 5346 } 5347 5348 function showError() { 5349 if ($alert && $alert.length) { 5350 $alert.removeClass("hidden hide") 5351 .addClass("alert alert-danger") 5352 .text("We were unable to submit your request. Please try again later."); 5353 } 5354 } 5355}; 5356 5357// Initialize the component 5358gmfxMomentumUtils.component.init(".send-fleet-form-content", gmfxWwwComponents.FormSendFleetExpert); 5359 5360gmfxWwwComponents.EmailSignature = function(component) { 5361 'use strict'; 5362 5363 var $component = gmfx$(component); 5364 5365 function toggleAddressOrLogo($checkId, $elementId, $elementHtml) { 5366 if(!gmfx$("input:checked" + $checkId).val()) { 5367 gmfx$('#signaturePreview ' + $elementId).html($elementHtml); 5368 } else { 5369 gmfx$('#signaturePreview ' + $elementId).html(''); 5370 } 5371 } 5372 5373 function updateLinkedin(linkedinCheck, inputValue) { 5374 if(linkedinCheck && inputValue != "") { 5375 gmfx$('#signaturePreview #signatureLinkedin').html('Connect with me on <a href="https://www.linkedin.com/" id="signatureLinkedinLink" target="_blank">LinkedIn</a>') 5376 gmfx$('#signaturePreview #signatureLinkedinLink').attr('href', gmfx$('#linkedinInput').val()); 5377 } else { 5378 gmfx$('#signaturePreview #signatureLinkedin').html(''); 5379 } 5380 } 5381 5382 function updateInputNumber($inputCheck, $inputValue, $signatureId, $inputType) { 5383 var $signaturePreview = "#signaturePreview"; 5384 var $selectedTemplate = gmfx$('#selectedTemplateHidden').val(); 5385 if($inputCheck && $inputValue != "") { // When user filled the number and selected the check box for it 5386 if($selectedTemplate != 'template-standard-horizontal') { 5387 var $inputTypeUpdate = updateInputNumberSeparator($inputType); 5388 gmfx$($signaturePreview + ' ' + $signatureId).html($inputTypeUpdate + $inputValue); 5389 } else { 5390 gmfx$($signaturePreview + ' ' + $signatureId).html($inputType + $inputValue); 5391 } 5392 } else { 5393 gmfx$($signaturePreview + ' ' + $signatureId).html(''); 5394 } 5395 } 5396 5397 // Function to remove or add separator '|' according to toll free number on reply-simple and standard-vertical templates 5398 function updateInputNumberSeparator($inputType) { 5399 var $inputTypeUpdate = $inputType; 5400 var $tollFreeNumber = $('#signatureTollFree').text(); 5401 var $workNumber = $('#signatureWorkPhone').text(); 5402 var $mobileNumber = $('#signatureMobilePhone').text(); 5403 5404 if($tollFreeNumber == "" && !$inputType.includes("(toll-free)")) { // remove '|' from first number when toll free is not there already 5405 if($inputType.includes("(w)")) { 5406 $inputTypeUpdate = "(w) "; 5407 } else if($inputType.includes("(m)") && $workNumber == "") { 5408 $inputTypeUpdate = "(m) "; 5409 } else if($inputType.includes("(f)") && $workNumber == "" && $mobileNumber == "") { 5410 $inputTypeUpdate = "(f) "; 5411 } 5412 } else if($inputType.includes("(toll-free)")) { // Add '|' to first number when toll free is selected 5413 updateInputNumberForTollFree(gmfx$("input:checked#workPhoneCheck").val(), gmfx$('#workInput').val(), "#signatureWorkPhone", "| (w) "); 5414 updateInputNumberForTollFree(gmfx$("input:checked#mobilePhoneCheck").val(), gmfx$('#telInput').val(), "#signatureMobilePhone", "| (m) "); 5415 updateInputNumberForTollFree(gmfx$("input:checked#faxCheck").val(), gmfx$('#faxInput').val(), "#signatureFax", "| (f) "); 5416 } 5417 return $inputTypeUpdate; 5418 } 5419 5420 //Function to update phone number separator '|' when toll-free is selected for reply-simple and standard-vertical templates 5421 function updateInputNumberForTollFree($inputCheck, $inputValue, $signatureId, $inputType) { 5422 var $signaturePreview = "#signaturePreview"; 5423 if($inputCheck && $inputValue != "") { 5424 gmfx$($signaturePreview + ' ' + $signatureId).html($inputType + $inputValue); 5425 } else { 5426 gmfx$($signaturePreview + ' ' + $signatureId).html(''); 5427 } 5428 } 5429 5430 gmfx$('#templateSelect').bind('DOMSubtreeModified', function() { 5431 5432 gmfx$("#templateSelect").children() 5433 .each(function() { 5434 var $selectedOption = gmfx$(this).attr("selected"); 5435 var $templateId = gmfx$(this).val(); 5436 if($selectedOption == 'selected') { 5437 gmfx$('#' + $templateId).removeClass('hide'); 5438 gmfx$('#selectedTemplateHidden').val($templateId); 5439 } else { 5440 if($templateId != "") { 5441 gmfx$('#' + $templateId).addClass('hide'); 5442 } 5443 } 5444 }); 5445 }); 5446 5447 5448 gmfx$('#addressCheck', $component).on('change', function() { 5449 toggleAddressOrLogo('#addressCheck', '#signatureAddress', gmfx$('#selectedAddressHidden').val()); 5450 }); 5451 5452 gmfx$('#logoSelectList').bind('DOMSubtreeModified', function() {
5453 $("#logoSelectList").children() 5454 .each(function() { 5455 updateLogo(gmfx$(this).attr("selected")); 5456 }); 5457 }); 5458 5459 5460 gmfx$('#addressSelect').bind('DOMSubtreeModified', function() { 5461 5462 gmfx$("#addressSelect").children() 5463 .each(function() { 5464 var $selectedOption = gmfx$(this).attr("selected"); 5465 var $addressSelected = gmfx$(this).val(); 5466 if($selectedOption == 'selected') { 5467 gmfx$('#signaturePreview #signatureAddress').html($addressSelected); 5468 gmfx$('#selectedAddressHidden').val(gmfx$('#signaturePreview #signatureAddress').html()); 5469 toggleAddressOrLogo('#addressCheck', '#signatureAddress', gmfx$('#signaturePreview #signatureAddress').html()); 5470 } 5471 }); 5472 }); 5473 5474 gmfx$('#companySelectList').bind('DOMSubtreeModified', function() { 5475 5476 gmfx$("#companySelectList").children() 5477 .each(function() { 5478 var $selectedOption = gmfx$(this).attr("selected"); 5479 var $companySelected = gmfx$(this).val(); 5480 if($selectedOption == 'selected') { 5481 gmfx$('#signaturePreview #signatureCompany').html($companySelected); 5482 gmfx$('#selectedCompanyHidden').val(gmfx$('#signaturePreview #signatureCompany').html()); 5483 toggleAddressOrLogo('#companySelectList', '#signatureCompany', gmfx$('#signaturePreview #signatureCompany').html()); 5484 } 5485 }); 5486 }); 5487 5488 gmfx$('#nameInput', $component).keyup(function() { 5489 var enteredName = gmfx$('#nameInput').val(); 5490 gmfx$('#signaturePreview #signatureName').html(enteredName); 5491 }); 5492 5493 gmfx$('#emailInput', $component).keyup(function() { 5494 gmfx$('#signaturePreview #signatureEmail').html(gmfx$('#emailInput').val()); 5495 gmfx$('#signaturePreview #signatureEmail').attr('href', 'mailto:' + gmfx$('#emailInput').val()); 5496 }); 5497 5498 gmfx$('#jobTitleInput', $component).keyup(function() { 5499 gmfx$('#signaturePreview #signatureJobTitle').html(gmfx$('#jobTitleInput').val()); 5500 }); 5501 5502 gmfx$('#departmentInput', $component).keyup(function() { 5503 gmfx$('#signaturePreview #signatureDepartment').html(gmfx$('#departmentInput').val()); 5504 }); 5505 5506 5507 gmfx$('#templateSelect').bind('DOMSubtreeModified', function() { 5508 gmfx$("#templateSelect").children() 5509 .each(function() { 5510 var $selectedOption = gmfx$(this).attr("selected"); 5511 var $templateId = gmfx$(this).val(); 5512 if($selectedOption == 'selected') { 5513 if($templateId == 'template-standard-horizontal') { 5514 gmfx$('#workInput', $component).keyup(function() { 5515 updateInputNumber(gmfx$("input:checked#workPhoneCheck").val(), gmfx$('#workInput').val(), "#signatureWorkPhone", "(w) "); 5516 }); 5517 5518 gmfx$('#workPhoneCheck', $component).on('change', function() { 5519 updateInputNumber(gmfx$("input:checked#workPhoneCheck").val(), gmfx$('#workInput').val(), "#signatureWorkPhone", "(w) "); 5520 }); 5521 5522 gmfx$('#telInput', $component).keyup(function() { 5523 updateInputNumber(gmfx$("input:checked#mobilePhoneCheck").val(), gmfx$('#telInput').val(), "#signatureMobilePhone", "(m) "); 5524 }); 5525 5526 gmfx$('#mobilePhoneCheck', $component).on('change', function() { 5527 updateInputNumber(gmfx$("input:checked#mobilePhoneCheck").val(), gmfx$('#telInput').val(), "#signatureMobilePhone", "(m) "); 5528 5529 }); 5530 5531 gmfx$('#tollfreeCheck', $component).on('change', function() { 5532 updateInputNumber(gmfx$("input:checked#tollfreeCheck").val(), gmfx$('#tollfreeInput').val(), "#signatureTollFree", "(toll-free) "); 5533 5534 }); 5535 5536 gmfx$('#tollfreeInput', $component).keyup(function() { 5537 updateInputNumber(gmfx$("input:checked#tollfreeCheck").val(), gmfx$('#tollfreeInput').val(), "#signatureTollFree", "(toll-free) "); 5538 5539 }); 5540 5541 gmfx$('#faxCheck', $component).on('change', function() { 5542 updateInputNumber(gmfx$("input:checked#faxCheck").val(), gmfx$('#faxInput').val(), "#signatureFax", "(f) "); 5543 5544 }); 5545 5546 gmfx$('#faxInput', $component).keyup(function() { 5547 updateInputNumber(gmfx$("input:checked#faxCheck").val(), gmfx$('#faxInput').val(), "#signatureFax", "(f) "); 5548 }); 5549 5550 updateLogo("selected"); 5551 updateInputNumber(gmfx$("input:checked#workPhoneCheck").val(), gmfx$('#workInput').val(), "#signatureWorkPhone", "(w) "); 5552 updateInputNumber(gmfx$("input:checked#mobilePhoneCheck").val(), gmfx$('#telInput').val(), "#signatureMobilePhone", "(m) "); 5553 updateInputNumber(gmfx$("input:checked#tollfreeCheck").val(), gmfx$('#tollfreeInput').val(), "#signatureTollFree", "(toll-free) "); 5554 updateInputNumber(gmfx$("input:checked#faxCheck").val(), gmfx$('#faxInput').val(), "#signatureFax", "(f) "); 5555 5556 } else { 5557 gmfx$('#workInput', $component).keyup(function() { 5558 updateInputNumber(gmfx$("input:checked#workPhoneCheck").val(), gmfx$('#workInput').val(), "#signatureWorkPhone", "| (w) "); 5559 5560 }); 5561 5562 gmfx$('#workPhoneCheck', $component).on('change', function() { 5563 updateInputNumber(gmfx$("input:checked#workPhoneCheck").val(), gmfx$('#workInput').val(), "#signatureWorkPhone", "| (w) "); 5564 }); 5565 5566 gmfx$('#telInput', $component).keyup(function() { 5567 updateInputNumber(gmfx$("input:checked#mobilePhoneCheck").val(), gmfx$('#telInput').val(), "#signatureMobilePhone", "| (m) "); 5568 }); 5569 5570 gmfx$('#mobilePhoneCheck', $component).on('change', function() { 5571 updateInputNumber(gmfx$("input:checked#mobilePhoneCheck").val(), gmfx$('#telInput').val(), "#signatureMobilePhone", "| (m) "); 5572 5573 }); 5574 5575 gmfx$('#tollfreeCheck', $component).on('change', function() { 5576 updateInputNumber(gmfx$("input:checked#tollfreeCheck").val(), gmfx$('#tollfreeInput').val(), "#signatureTollFree", "(toll-free) "); 5577 5578 }); 5579 5580 gmfx$('#tollfreeInput', $component).keyup(function() { 5581 updateInputNumber(gmfx$("input:checked#tollfreeCheck").val(), gmfx$('#tollfreeInput').val(), "#signatureTollFree", "(toll-free) "); 5582 5583 }); 5584 5585 gmfx$('#faxCheck', $component).on('change', function() { 5586 updateInputNumber(gmfx$("input:checked#faxCheck").val(), gmfx$('#faxInput').val(), "#signatureFax", "| (f) "); 5587 5588 }); 5589 5590 gmfx$('#faxInput', $component).keyup(function() { 5591 updateInputNumber(gmfx$("input:checked#faxCheck").val(), gmfx$('#faxInput').val(), "#signatureFax", "| (f) "); 5592 }); 5593 5594 updateLogo("selected"); 5595 updateInputNumber(gmfx$("input:checked#workPhoneCheck").val(), gmfx$('#workInput').val(), "#signatureWorkPhone", "| (w) "); 5596 updateInputNumber(gmfx$("input:checked#mobilePhoneCheck").val(), gmfx$('#telInput').val(), "#signatureMobilePhone", "| (m) "); 5597 updateInputNumber(gmfx$("input:checked#tollfreeCheck").val(), gmfx$('#tollfreeInput').val(), "#signatureTollFree", "(toll-free) "); 5598 updateInputNumber(gmfx$("input:checked#faxCheck").val(), gmfx$('#faxInput').val(), "#signatureFax", "| (f) "); 5599 } 5600 } 5601 }); 5602 }); 5603 5604 gmfx$('#workInput, #telInput, #tollfreeInput, #faxInput').keyup(phonehandler).keypress(phonehandler).blur(phonehandler); 5605 5606 function phonehandler(event) { 5607 var input = this.value.replace(/[^0-9]+/g, ""); 5608 var keyPressed = String.fromCharCode(event.which); 5609 var unicode = event.charCode ? event.charCode : event.keyCode; 5610 if(rx.test(keyPressed) || event.which == 8) { 5611 if(input.length > 3 && input.length <= 5) { 5612 this.value = input.slice(0, 3) + "-" + input.slice(3); 5613 } else if(input.length > 6) { 5614 this.value = input.slice(0, 3) + "-" + input.slice(3, 6) + "-" + input.slice(6); 5615 } 5616 } else if((unicode == 9) && event.which == 0) { 5617 return true; 5618 } else { 5619 return false;
5620 } 5621 } 5622 5623 5624 gmfx$('#linkedinInput', $component).keyup(function() { 5625 updateLinkedin($("input:checked#linkedinCheck").val(), gmfx$('#linkedinInput').val()); 5626 5627 }); 5628 5629 gmfx$('#linkedinCheck', $component).on('change', function() { 5630 updateLinkedin(gmfx$("input:checked#linkedinCheck").val(), gmfx$('#linkedinInput').val()); 5631 }); 5632 5633 5634 function updateTeamsLink(personalTeamsCheck, inputValue) { 5635 if(personalTeamsCheck && inputValue == "") { 5636 gmfx$('#signaturePreview #signatureTeams').html('<a href="https://teams.microsoft.com/l/chat/0/0?users=Send me a message on Teams" target="_blank">Send me a message on Teams</a>'); 5637 } else if(personalTeamsCheck && inputValue != "") { 5638 gmfx$('#signaturePreview #signatureTeams').html('<a href="https://teams.microsoft.com/l/chat/0/0?users=Send me a message on Teams" id="signatureTeamsLink" target="_blank">Send me a message on Teams</a>') 5639 gmfx$('#signaturePreview #signatureTeamsLink').attr('href', 'https://teams.microsoft.com/l/chat/0/0?users=' + gmfx$('#emailInput').val()); 5640 5641 } else { 5642 gmfx$('#signaturePreview #signatureTeams').html(''); 5643 } 5644 } 5645 5646 gmfx$('#emailInput', $component).keyup(function() { 5647 updateTeamsLink($("input:checked#personalTeamsCheck").val(), gmfx$('#emailInput').val()); 5648 5649 }); 5650 5651 gmfx$('#personalTeamsCheck', $component).on('change', function() { 5652 updateTeamsLink(gmfx$("input:checked#personalTeamsCheck").val(), gmfx$('#emailInput').val()); 5653 }); 5654 5655 5656 function updateGraphicsLogoLink(graphicsCheck) { 5657 if(graphicsCheck) { 5658 gmfx$('#signaturePreview #graphicsHorizontalLogo').html('<br><img id="graphicsLogoLink" src="https://www.gmfinancial.com/content/dam/gmf/email-signature/GM-Financial-Promo-Loyalty.png" style="margin-top: -5px;">'); 5659 gmfx$('#signaturePreview #graphicsVerticalLogo').html('<br><img id="graphicsLogoLink" src="https://www.gmfinancial.com/content/dam/gmf/email-signature/GM-Financial-Promo-Loyalty.png">'); 5660 } else { 5661 gmfx$('#signaturePreview #graphicsHorizontalLogo').html(''); 5662 gmfx$('#signaturePreview #graphicsVerticalLogo').html(''); 5663 } 5664 } 5665 5666 function updateLogo(selectedOption) { 5667 var $selectedPath = gmfx$('#logoSelectList').val(); 5668 var $selectedTemplate = gmfx$('#selectedTemplateHidden').val(); 5669 5670 if(selectedOption == 'selected') { 5671 if($selectedTemplate == 'template-standard-horizontal' && $selectedPath.indexOf('-DEI') >= 0) { 5672 gmfx$('#signaturePreview #signatureLogo').html('<img id="signatureDAMpath" src="https://www.gmfinancial.com/content/dam/gmf/email-signature/GM-Financial-DEI-email-stacked.png">'); 5673 } 5674 if($selectedTemplate == 'template-standard-vertical' && $selectedPath.indexOf('-DEI') >= 0) { 5675 gmfx$('#signaturePreview #signatureLogo').html('<img id="signatureDAMpath" src="https://www.gmfinancial.com/content/dam/gmf/email-signature/GM-Financial-DEI-email-side-by-side.png">'); 5676 } 5677 5678 if($selectedTemplate == 'template-standard-horizontal' && $selectedPath.indexOf('-WIN') >= 0) { 5679 gmfx$('#signaturePreview #signatureLogo').html('<img id="signatureDAMpath" src="https://www.gmfinancial.com/content/dam/gmf/email-signature/GM-Financial-WIN-email-stacked.png">'); 5680 } 5681 if($selectedTemplate == 'template-standard-vertical' && $selectedPath.indexOf('-WIN') >= 0) { 5682 gmfx$('#signaturePreview #signatureLogo').html('<img id="signatureDAMpath" src="https://www.gmfinancial.com/content/dam/gmf/email-signature/GM-Financial-WIN-email-side-by-side.png">'); 5683 } 5684 5685 if($selectedTemplate == 'template-standard-horizontal' && $selectedPath.indexOf('-FRN') >= 0) { 5686 gmfx$('#signaturePreview #signatureLogo').html('<img id="signatureDAMpath" src="https://www.gmfinancial.com/content/dam/gmf/email-signature/GM-Financial-FRN-email.png">'); 5687 } 5688 if($selectedTemplate == 'template-standard-vertical' && $selectedPath.indexOf('-FRN') >= 0) { 5689 gmfx$('#signaturePreview #signatureLogo').html('<img id="signatureDAMpath" src="https://www.gmfinancial.com/content/dam/gmf/email-signature/GM-Financial-FRN-email.png">'); 5690 } 5691 5692 if($selectedTemplate == 'template-standard-horizontal' && $selectedPath.indexOf('-ACF') >= 0) { 5693 gmfx$('#signaturePreview #signatureLogo').html('<img id="signatureDAMpath" src="https://www.gmfinancial.com/content/dam/gmf/email-signature/GM-Financial-ACF-email-stacked.png">'); 5694 } 5695 if($selectedTemplate == 'template-standard-vertical' && $selectedPath.indexOf('-ACF') >= 0) { 5696 gmfx$('#signaturePreview #signatureLogo').html('<img id="signatureDAMpath" src="https://www.gmfinancial.com/content/dam/gmf/email-signature/GM-Financial-ACF-email-side-by-side.png">'); 5697 } 5698 5699 if($selectedPath.indexOf('/content/dam/gmf/email-signature/AmeriCredit-email.png') >= 0) { 5700 gmfx$('#signaturePreview #signatureLogo').html('<img id="signatureDAMpath" src="https://gmfinancial.com/content/dam/gmf/email-signature/AmeriCredit-email.png">'); 5701 } 5702 5703 if($selectedPath.indexOf('/content/dam/gmf/email-signature/GM-Financial-email.png') >= 0) { 5704 gmfx$('#signaturePreview #signatureLogo').html('<img id="signatureDAMpath" src="https://www.gmfinancial.com/content/dam/gmf/email-signature/GM-Financial-email.png">'); 5705 } 5706 5707 if($selectedPath.indexOf('/content/dam/gmf/email-signature/Cadillac-Financial-email.png') >= 0) { 5708 gmfx$('#signaturePreview #signatureLogo').html('<img id="signatureDAMpath" src="https://www.gmfinancial.com/content/dam/gmf/email-signature/Cadillac-Financial-email.png">'); 5709 } 5710 if($selectedPath.indexOf('/content/dam/gmf/email-signature/OSI-logo.png') >= 0) { 5711 gmfx$('#signaturePreview #signatureLogo').html('<img id="signatureDAMpath" src="/content/dam/gmf/email-signature/OSI-logo.png">'); 5712 } 5713 5714 gmfx$('#selectedLogoPathHidden').val(gmfx$('#signaturePreview #signatureLogo').html()); 5715 5716 toggleAddressOrLogo('#logoCheck', '#signatureLogo', gmfx$('#signaturePreview #signatureLogo').html()); 5717 } 5718 } 5719 5720 gmfx$('#graphicsCheck').on('change', function() { 5721 updateGraphicsLogoLink(gmfx$("input:checked#graphicsCheck").val()); 5722 }); 5723 5724 gmfx$('#templateSelect').bind('DOMSubtreeModified', function() { 5725 gmfx$("#templateSelect").children() 5726 .each(function() { 5727 var $selectedOption = gmfx$(this).attr("selected"); 5728 var $templateId = gmfx$(this).val(); 5729 if($selectedOption == 'selected') { 5730 if($templateId == 'template-reply-simple') { 5731 gmfx$('.logo-disabled').css({ 5732 "display": "none" 5733 }); 5734 gmfx$('#logoSelectList').attr('disabled', true); 5735 gmfx$('#logoCheck').attr('disabled', true); 5736 gmfx$('.company-disabled').css({ 5737 "display": "block" 5738 }); 5739 gmfx$('#companySelectList').attr('disabled', false); 5740 gmfx$('.graphics-disabled').css({ 5741 "display": "none" 5742 }); 5743 } else { 5744 gmfx$('.logo-disabled').css({ 5745 "display": "block" 5746 }); 5747 gmfx$('#logoSelectList').attr('disabled', false); 5748 gmfx$('#logoCheck').attr('disabled', false); 5749 gmfx$('.company-disabled').css({ 5750 "display": "none" 5751 }); 5752 gmfx$('#companySelectList').attr('disabled', true); 5753 gmfx$('.graphics-disabled').css({ 5754 "display": "block" 5755 }); 5756 } 5757 } 5758 }); 5759 }); 5760 5761 gmfx$('#copyBtn').click(function() { 5762 var templateStyle = gmfx$('#selectedTemplateHidden').val(); 5763 var value = gmfx$('#' + templateStyle).html(); 5764 var dt = new clipboard.DT(); 5765 dt.setData("text/plain", value); 5766 dt.setData("text/html", value); 5767 clipboard.write(dt); 5768 }); 5769 5770}; 5771gmfxMomentumUtils.component.init(".email-signature", gmfxWwwComponents.EmailSignature); 5772 5773! function(t, e) { 5774 "object" == typeof exports && "undefined" != typeof module ? e() : "function" == typeof define && define.amd ? define(e) : e() 5775}(0, function() { 5776 "use strict"; 5777 5778 function t(t) { 5779 var e = this.constructor; 5780 return this.then(function(n) { 5781 return e.resolve(t()).then(function() { 5782 return n 5783 }) 5784 }, function(n) { 5785 return e.resolve(t()).then(function() { 5786 return e.reject(n) 5787 }) 5788 }) 5789 } 5790 5791 function e(t) { 5792 return !(!t || void 0 === t.length) 5793 } 5794 5795 function n() {} 5796 5797 function r(t) { 5798 if(!(this instanceof r)) throw new TypeError("Promises must be constructed via new"); 5799 if("function" != typeof t) throw new TypeError("not a function"); 5800 this._state = 0, this._handled = !1, this._value = void 0, this._deferreds = [], c(t, this) 5801 } 5802 5803 function o(t, e) { 5804 for(; 3 === t._state;) t = t._value; 5805 0 !== t._state ? (t._handled = !0, r._immediateFn(function() { 5806 var n = 1 === t._state ? e.onFulfilled : e.onRejected; 5807 if(null !== n) { 5808 var r; 5809 try { 5810 r = n(t._value) 5811 } catch (t) { 5812 return void a(e.promise, t) 5813 } 5814 i(e.promise, r) 5815 } else(1 === t._state ? i : a)(e.promise, t._value) 5816 })) : t._deferreds.push(e) 5817 } 5818 5819 function i(t, e) { 5820 try { 5821 if(e === t) throw new TypeError("A promise cannot be resolved with itself."); 5822 if(e && ("object" == typeof e || "function" == typeof e)) { 5823 var n = e.then; 5824 if(e instanceof r) return t._state = 3, t._value = e, void u(t); 5825 if("function" == typeof n) return void c(function(t, e) { 5826 return function() { 5827 t.apply(e, arguments) 5828 } 5829 }(n, e), t) 5830 } 5831 t._state = 1, t._value = e, u(t) 5832 } catch (e) { 5833 a(t, e) 5834 } 5835 } 5836 5837 function a(t, e) { 5838 t._state = 2, t._value = e, u(t) 5839 } 5840 5841 function u(t) { 5842 2 === t._state && 0 === t._deferreds.length && r._immediateFn(function() { 5843 t._handled || r._unhandledRejectionFn(t._value) 5844 }); 5845 for(var e = 0, n = t._deferreds.length; n > e; e++) o(t, t._deferreds[e]); 5846 t._deferreds = null 5847 } 5848 5849 function c(t, e) { 5850 var n = !1; 5851 try { 5852 t(function(t) { 5853 n || (n = !0, i(e, t)) 5854 }, function(t) { 5855 n || (n = !0, a(e, t)) 5856 }) 5857 } catch (t) { 5858 if(n) return; 5859 n = !0, a(e, t) 5860 } 5861 } 5862 var f = setTimeout; 5863 r.prototype.catch = function(t) { 5864 return this.then(null, t) 5865 }, r.prototype.then = function(t, e) { 5866 var r = new this.constructor(n); 5867 return o(this, new function(t, e, n) { 5868 this.onFulfilled = "function" == typeof t ? t : null, this.onRejected = "function" == typeof e ? e : null, this.promise = n 5869 }(t, e, r)), r 5870 }, r.prototype.finally = t, r.all = function(t) { 5871 return new r(function(n, r) { 5872 function o(t, e) { 5873 try { 5874 if(e && ("object" == typeof e || "function" == typeof e)) { 5875 var u = e.then; 5876 if("function" == typeof u) return void u.call(e, function(e) { 5877 o(t, e) 5878 }, r) 5879 } 5880 i[t] = e, 0 == --a && n(i) 5881 } catch (t) { 5882 r(t) 5883 } 5884 } 5885 if(!e(t)) return r(new TypeError("Promise.all accepts an array")); 5886 var i = Array.prototype.slice.call(t);
5887 if(0 === i.length) return n([]); 5888 for(var a = i.length, u = 0; i.length > u; u++) o(u, i[u]) 5889 }) 5890 }, r.resolve = function(t) { 5891 return t && "object" == typeof t && t.constructor === r ? t : new r(function(e) { 5892 e(t) 5893 }) 5894 }, r.reject = function(t) { 5895 return new r(function(e, n) { 5896 n(t) 5897 }) 5898 }, r.race = function(t) { 5899 return new r(function(n, o) { 5900 if(!e(t)) return o(new TypeError("Promise.race accepts an array")); 5901 for(var i = 0, a = t.length; a > i; i++) r.resolve(t[i]).then(n, o) 5902 }) 5903 }, r._immediateFn = "function" == typeof setImmediate && function(t) { 5904 setImmediate(t) 5905 } || function(t) { 5906 f(t, 0) 5907 }, r._unhandledRejectionFn = function(t) { 5908 void 0 !== console && console && console.warn("Possible Unhandled Promise Rejection:", t) 5909 }; 5910 var s = function() { 5911 if("undefined" != typeof self) return self; 5912 if("undefined" != typeof window) return window; 5913 if("undefined" != typeof global) return global; 5914 throw Error("unable to locate global object") 5915 }(); 5916 "Promise" in s ? s.Promise.prototype.finally || (s.Promise.prototype.finally = t) : s.Promise = r 5917}), 5918function(t, e) { 5919 "object" == typeof exports && "undefined" != typeof module ? e(exports) : "function" == typeof define && define.amd ? define(["exports"], e) : e((t = t || self).clipboard = {}) 5920}(this, function(t) { 5921 "use strict"; 5922 5923 function e(t, e, n, r) { 5924 return new(n || (n = Promise))(function(o, i) { 5925 function a(t) { 5926 try { 5927 c(r.next(t)) 5928 } catch (t) { 5929 i(t) 5930 } 5931 } 5932 5933 function u(t) { 5934 try { 5935 c(r.throw(t)) 5936 } catch (t) { 5937 i(t) 5938 } 5939 } 5940 5941 function c(t) { 5942 t.done ? o(t.value) : new n(function(e) { 5943 e(t.value) 5944 }).then(a, u) 5945 } 5946 c((r = r.apply(t, e || [])).next()) 5947 }) 5948 } 5949 5950 function n(t, e) { 5951 var n, r, o, i, a = { 5952 label: 0, 5953 sent: function() { 5954 if(1 & o[0]) throw o[1]; 5955 return o[1] 5956 }, 5957 trys: [], 5958 ops: [] 5959 }; 5960 return i = { 5961 next: u(0), 5962 throw: u(1), 5963 return: u(2) 5964 }, "function" == typeof Symbol && (i[Symbol.iterator] = function() { 5965 return this 5966 }), i; 5967 5968 function u(i) { 5969 return function(u) { 5970 return function(i) { 5971 if(n) throw new TypeError("Generator is already executing."); 5972 for(; a;) try { 5973 if(n = 1, r && (o = 2 & i[0] ? r.return : i[0] ? r.throw || ((o = r.return) && o.call(r), 0) : r.next) && !(o = o.call(r, i[1])).done) return o; 5974 switch (r = 0, o && (i = [2 & i[0], o.value]), i[0]) { 5975 case 0: 5976 case 1: 5977 o = i; 5978 break; 5979 case 4: 5980 return a.label++, { 5981 value: i[1], 5982 done: !1 5983 }; 5984 case 5: 5985 a.label++, r = i[1], i = [0]; 5986 continue; 5987 case 7: 5988 i = a.ops.pop(), a.trys.pop(); 5989 continue; 5990 default: 5991 if(!(o = (o = a.trys).length > 0 && o[o.length - 1]) && (6 === i[0] || 2 === i[0])) { 5992 a = 0; 5993 continue 5994 } 5995 if(3 === i[0] && (!o || i[1] > o[0] && i[1] < o[3])) { 5996 a.label = i[1]; 5997 break 5998 } 5999 if(6 === i[0] && a.label < o[1]) { 6000 a.label = o[1], o = i; 6001 break 6002 } 6003 if(o && a.label < o[2]) { 6004 a.label = o[2], a.ops.push(i); 6005 break 6006 } 6007 o[2] && a.ops.pop(), a.trys.pop(); 6008 continue 6009 } 6010 i = e.call(t, a) 6011 } catch (t) { 6012 i = [6, t], r = 0 6013 } finally { 6014 n = o = 0 6015 } 6016 if(5 & i[0]) throw i[1]; 6017 return { 6018 value: i[0] ? i[1] : void 0, 6019 done: !0 6020 } 6021 }([i, u]) 6022 } 6023 } 6024 } 6025 var r = ["text/plain", "text/html"]; 6026 var o = function() { 6027 (console.warn || console.log).call(arguments) 6028 }.bind(console, "[clipboard-polyfill]"), 6029 i = !0; 6030 var a = function() { 6031 function t() { 6032 this.m = {} 6033 } 6034 return t.prototype.setData = function(t, e) { 6035 i && -1 === r.indexOf(t) && o("Unknown data type: " + t, "Call clipboard.suppressWarnings() to suppress this warning."), this.m[t] = e 6036 }, t.prototype.getData = function(t) { 6037 return this.m[t] 6038 }, t.prototype.forEach = function(t) { 6039 for(var e in this.m) t(this.m[e], e) 6040 }, t 6041 }(), 6042 u = function(t) {}, 6043 c = !0; 6044 var f = function() { 6045 (console.warn || console.log).apply(console, arguments) 6046 }.bind("[clipboard-polyfill]"), 6047 s = "text/plain"; 6048 6049 function l(t) { 6050 u = t 6051 } 6052 6053 function d() { 6054 c = !1, i = !1 6055 } 6056 6057 function p(t) { 6058 return e(this, void 0, void 0, function() { 6059 var e; 6060 return n(this, function(n) { 6061 if(c && !t.getData(s) && f("clipboard.write() was called without a `text/plain` data type. On some platforms, this may result in an empty clipboard. Call clipboard.suppressWarnings() to suppress this warning."), j()) { 6062 if(function(t) { 6063 var e = t.getData(s); 6064 if(void 0 !== e) return window.clipboardData.setData("Text", e); 6065 throw new Error("No `text/plain` value was specified.") 6066 }(t)) return [2]; 6067 throw new Error("Copying failed, possibly because the user rejected it.") 6068 } 6069 if(x(t)) return u("regular execCopy worked"), [2]; 6070 if(navigator.userAgent.indexOf("Edge") > -1) return u('UA "Edge" => assuming success'), [2]; 6071 if(_(document.body, t)) return u("copyUsingTempSelection worked"), [2]; 6072 if(function(t) { 6073 var e = document.createElement("div"); 6074 e.setAttribute("style", "-webkit-user-select: text !important"), e.textContent = "temporary element", document.body.appendChild(e); 6075 var n = _(e, t); 6076 return document.body.removeChild(e), n 6077 }(t)) return u("copyUsingTempElem worked"), [2]; 6078 if(void 0 !== (e = t.getData(s)) && function(t) { 6079 u("copyTextUsingDOM"); 6080 var e = document.createElement("div"); 6081 e.setAttribute("style", "-webkit-user-select: text !important"); 6082 var n = e; 6083 e.attachShadow && (u("Using shadow DOM."), n = e.attachShadow({ 6084 mode: "open" 6085 })); 6086 var r = document.createElement("span"); 6087 r.innerText = t, n.appendChild(r), document.body.appendChild(e), T(r); 6088 var o = document.execCommand("copy"); 6089 return E(), document.body.removeChild(e), o 6090 }(e)) return u("copyTextUsingDOM worked"), [2]; 6091 throw new Error("Copy command failed.") 6092 }) 6093 }) 6094 } 6095 6096 function h(t) { 6097 return e(this, void 0, void 0, function() { 6098 return n(this, function(e) { 6099 return navigator.clipboard && navigator.clipboard.writeText ? (u("Using `navigator.clipboard.writeText()`."), [2, navigator.clipboard.writeText(t)]) : [2, p(D(t))] 6100 }) 6101 }) 6102 } 6103 6104 function v() { 6105 return e(this, void 0, void 0, function() { 6106 var t; 6107 return n(this, function(e) { 6108 switch (e.label) { 6109 case 0: 6110 return t = D, [4, y()]; 6111 case 1: 6112 return [2, t.apply(void 0, [e.sent()])] 6113 } 6114 }) 6115 }) 6116 } 6117 6118 function y() { 6119 return e(this, void 0, void 0, function() { 6120 return n(this, function(t) { 6121 if(navigator.clipboard && navigator.clipboard.readText) return u("Using `navigator.clipboard.readText()`."), [2, navigator.clipboard.readText()]; 6122 if(j()) return u("Reading text using IE strategy."), [2, C()]; 6123 throw new Error("Read is not supported in your browser.") 6124 }) 6125 }) 6126 } 6127 var m = !1; 6128 6129 function w() { 6130 m || (c && f('The deprecated default object of `clipboard-polyfill` was called. Please switch to `import * as clipboard from "clipboard-polyfill"` and see https://github.com/lgarron/clipboard-polyfill/issues/101 for more info.'), m = !0) 6131 } 6132 var b = { 6133 DT: a, 6134 setDebugLog: function(t) { 6135 return w(), l(t) 6136 }, 6137 suppressWarnings: function() { 6138 return w(), d() 6139 }, 6140 write: function(t) { 6141 return e(this, void 0, void 0, function() { 6142 return n(this, function(e) { 6143 return w(), [2, p(t)] 6144 }) 6145 }) 6146 }, 6147 writeText: function(t) { 6148 return e(this, void 0, void 0, function() { 6149 return n(this, function(e) { 6150 return w(), [2, h(t)] 6151 }) 6152 }) 6153 }, 6154 read: function() { 6155 return e(this, void 0, void 0, function() { 6156 return n(this, function(t) { 6157 return w(), [2, v()] 6158 }) 6159 }) 6160 }, 6161 readText: function() { 6162 return e(this, void 0, void 0, function() { 6163 return n(this, function(t) { 6164 return w(), [2, y()] 6165 }) 6166 }) 6167 } 6168 }, 6169 g = function() { 6170 this.success = !1 6171 }; 6172 6173 function x(t) { 6174 var e = new g, 6175 n = function(t, e, n) { 6176 u("listener called"), t.success = !0, e.forEach(function(e, r) { 6177 var o = n.clipboardData; 6178 o.setData(r, e), r === s && o.getData(r) !== e && (u("setting text/plain failed"), t.success = !1) 6179 }), n.preventDefault() 6180 }.bind(this, e, t); 6181 document.addEventListener("copy", n); 6182 try { 6183 document.execCommand("copy") 6184 } finally { 6185 document.removeEventListener("copy", n) 6186 } 6187 return e.success 6188 } 6189 6190 function _(t, e) { 6191 T(t); 6192 var n = x(e); 6193 return E(), n 6194 } 6195 6196 function T(t) { 6197 var e = document.getSelection(); 6198 if(e) { 6199 var n = document.createRange(); 6200 n.selectNodeContents(t), e.removeAllRanges(), e.addRange(n) 6201 } 6202 } 6203 6204 function E() { 6205 var t = document.getSelection(); 6206 t && t.removeAllRanges() 6207 } 6208 6209 function D(t) { 6210 var e = new a; 6211 return e.setData(s, t), e 6212 } 6213 6214 function j() { 6215 return "undefined" == typeof ClipboardEvent && void 0 !== window.clipboardData && void 0 !== window.clipboardData.setData 6216 } 6217 6218 function C() { 6219 return e(this, void 0, void 0, function() { 6220 var t; 6221 return n(this, function(e) { 6222 if("" === (t = window.clipboardData.getData("Text"))) throw new Error("Empty clipboard or could not read plain text from clipboard"); 6223 return [2, t] 6224 }) 6225 }) 6226 } 6227 t.DT = a, t.default = b, t.read = v, t.readText = y, t.setDebugLog = l, t.suppressWarnings = d, t.write = p, t.writeText = h, Object.defineProperty(t, "__esModule", { 6228 value: !0 6229 }) 6230}); 6231! function(t, e) { 6232 "object" == typeof exports && "undefined" != typeof module ? e() : "function" == typeof define && define.amd ? define(e) : e() 6233}(0, function() { 6234 "use strict"; 6235 6236 function t(t) { 6237 var e = this.constructor; 6238 return this.then(function(n) { 6239 return e.resolve(t()).then(function() { 6240 return n 6241 }) 6242 }, function(n) { 6243 return e.resolve(t()).then(function() { 6244 return e.reject(n) 6245 }) 6246 }) 6247 } 6248 6249 function e(t) { 6250 return !(!t || void 0 === t.length) 6251 } 6252 6253 function n() {} 6254 6255 function r(t) { 6256 if(!(this instanceof r)) throw new TypeError("Promises must be constructed via new"); 6257 if("function" != typeof t) throw new TypeError("not a function"); 6258 this._state = 0, this._handled = !1, this._value = void 0, this._deferreds = [], c(t, this) 6259 } 6260 6261 function o(t, e) { 6262 for(; 3 === t._state;) t = t._value; 6263 0 !== t._state ? (t._handled = !0, r._immediateFn(function() { 6264 var n = 1 === t._state ? e.onFulfilled : e.onRejected; 6265 if(null !== n) { 6266 var r; 6267 try { 6268 r = n(t._value) 6269 } catch (t) { 6270 return void a(e.promise, t) 6271 } 6272 i(e.promise, r) 6273 } else(1 === t._state ? i : a)(e.promise, t._value) 6274 })) : t._deferreds.push(e) 6275 } 6276 6277 function i(t, e) { 6278 try { 6279 if(e === t) throw new TypeError("A promise cannot be resolved with itself."); 6280 if(e && ("object" == typeof e || "function" == typeof e)) { 6281 var n = e.then; 6282 if(e instanceof r) return t._state = 3, t._value = e, void u(t); 6283 if("function" == typeof n) return void c(function(t, e) { 6284 return function() { 6285 t.apply(e, arguments) 6286 } 6287 }(n, e), t) 6288 } 6289 t._state = 1, t._value = e, u(t) 6290 } catch (e) { 6291 a(t, e) 6292 } 6293 } 6294 6295 function a(t, e) { 6296 t._state = 2, t._value = e, u(t) 6297 } 6298 6299 function u(t) { 6300 2 === t._state && 0 === t._deferreds.length && r._immediateFn(function() { 6301 t._handled || r._unhandledRejectionFn(t._value) 6302 }); 6303 for(var e = 0, n = t._deferreds.length; n > e; e++) o(t, t._deferreds[e]); 6304 t._deferreds = null 6305 } 6306 6307 function c(t, e) { 6308 var n = !1; 6309 try { 6310 t(function(t) { 6311 n || (n = !0, i(e, t)) 6312 }, function(t) { 6313 n || (n = !0, a(e, t)) 6314 }) 6315 } catch (t) { 6316 if(n) return; 6317 n = !0, a(e, t) 6318 } 6319 } 6320 var f = setTimeout; 6321 r.prototype.catch = function(t) { 6322 return this.then(null, t) 6323 }, r.prototype.then = function(t, e) { 6324 var r = new this.constructor(n); 6325 return o(this, new function(t, e, n) { 6326 this.onFulfilled = "function" == typeof t ? t : null, this.onRejected = "function" == typeof e ? e : null, this.promise = n 6327 }(t, e, r)), r 6328 }, r.prototype.finally = t, r.all = function(t) { 6329 return new r(function(n, r) { 6330 function o(t, e) { 6331 try { 6332
6332 if(e && ("object" == typeof e || "function" == typeof e)) { 6333 var u = e.then; 6334 if("function" == typeof u) return void u.call(e, function(e) { 6335 o(t, e) 6336 }, r) 6337 } 6338 i[t] = e, 0 == --a && n(i) 6339 } catch (t) { 6340 r(t) 6341 } 6342 } 6343 if(!e(t)) return r(new TypeError("Promise.all accepts an array")); 6344 var i = Array.prototype.slice.call(t); 6345 if(0 === i.length) return n([]); 6346 for(var a = i.length, u = 0; i.length > u; u++) o(u, i[u]) 6347 }) 6348 }, r.resolve = function(t) { 6349 return t && "object" == typeof t && t.constructor === r ? t : new r(function(e) { 6350 e(t) 6351 }) 6352 }, r.reject = function(t) { 6353 return new r(function(e, n) { 6354 n(t) 6355 }) 6356 }, r.race = function(t) { 6357 return new r(function(n, o) { 6358 if(!e(t)) return o(new TypeError("Promise.race accepts an array")); 6359 for(var i = 0, a = t.length; a > i; i++) r.resolve(t[i]).then(n, o) 6360 }) 6361 }, r._immediateFn = "function" == typeof setImmediate && function(t) { 6362 setImmediate(t) 6363 } || function(t) { 6364 f(t, 0) 6365 }, r._unhandledRejectionFn = function(t) { 6366 void 0 !== console && console && console.warn("Possible Unhandled Promise Rejection:", t) 6367 }; 6368 var s = function() { 6369 if("undefined" != typeof self) return self; 6370 if("undefined" != typeof window) return window; 6371 if("undefined" != typeof global) return global; 6372 throw Error("unable to locate global object") 6373 }(); 6374 "Promise" in s ? s.Promise.prototype.finally || (s.Promise.prototype.finally = t) : s.Promise = r 6375}), 6376function(t, e) { 6377 "object" == typeof exports && "undefined" != typeof module ? e(exports) : "function" == typeof define && define.amd ? define(["exports"], e) : e((t = t || self).clipboard = {}) 6378}(this, function(t) { 6379 "use strict"; 6380 6381 function e(t, e, n, r) { 6382 return new(n || (n = Promise))(function(o, i) { 6383 function a(t) { 6384 try { 6385 c(r.next(t)) 6386 } catch (t) { 6387 i(t) 6388 } 6389 } 6390 6391 function u(t) { 6392 try { 6393 c(r.throw(t)) 6394 } catch (t) { 6395 i(t) 6396 } 6397 } 6398 6399 function c(t) { 6400 t.done ? o(t.value) : new n(function(e) { 6401 e(t.value) 6402 }).then(a, u) 6403 } 6404 c((r = r.apply(t, e || [])).next()) 6405 }) 6406 } 6407 6408 function n(t, e) { 6409 var n, r, o, i, a = { 6410 label: 0, 6411 sent: function() { 6412 if(1 & o[0]) throw o[1]; 6413 return o[1] 6414 }, 6415 trys: [], 6416 ops: [] 6417 }; 6418 return i = { 6419 next: u(0), 6420 throw: u(1), 6421 return: u(2) 6422 }, "function" == typeof Symbol && (i[Symbol.iterator] = function() { 6423 return this 6424 }), i; 6425 6426 function u(i) { 6427 return function(u) { 6428 return function(i) { 6429 if(n) throw new TypeError("Generator is already executing."); 6430 for(; a;) try { 6431 if(n = 1, r && (o = 2 & i[0] ? r.return : i[0] ? r.throw || ((o = r.return) && o.call(r), 0) : r.next) && !(o = o.call(r, i[1])).done) return o; 6432 switch (r = 0, o && (i = [2 & i[0], o.value]), i[0]) { 6433 case 0: 6434 case 1: 6435 o = i; 6436 break; 6437 case 4: 6438 return a.label++, { 6439 value: i[1], 6440 done: !1 6441 }; 6442 case 5: 6443 a.label++, r = i[1], i = [0]; 6444 continue; 6445 case 7: 6446 i = a.ops.pop(), a.trys.pop(); 6447 continue; 6448 default: 6449 if(!(o = (o = a.trys).length > 0 && o[o.length - 1]) && (6 === i[0] || 2 === i[0])) { 6450 a = 0; 6451 continue 6452 } 6453 if(3 === i[0] && (!o || i[1] > o[0] && i[1] < o[3])) { 6454 a.label = i[1]; 6455 break 6456 } 6457 if(6 === i[0] && a.label < o[1]) { 6458 a.label = o[1], o = i; 6459 break 6460 } 6461 if(o && a.label < o[2]) { 6462 a.label = o[2], a.ops.push(i); 6463 break 6464 } 6465 o[2] && a.ops.pop(), a.trys.pop(); 6466 continue 6467 } 6468 i = e.call(t, a) 6469 } catch (t) { 6470 i = [6, t], r = 0 6471 } finally { 6472 n = o = 0 6473 } 6474 if(5 & i[0]) throw i[1]; 6475 return { 6476 value: i[0] ? i[1] : void 0, 6477 done: !0 6478 } 6479 }([i, u]) 6480 } 6481 } 6482 } 6483 var r = ["text/plain", "text/html"]; 6484 var o = function() { 6485 (console.warn || console.log).call(arguments) 6486 }.bind(console, "[clipboard-polyfill]"), 6487 i = !0; 6488 var a = function() { 6489 function t() { 6490 this.m = {} 6491 } 6492 return t.prototype.setData = function(t, e) { 6493 i && -1 === r.indexOf(t) && o("Unknown data type: " + t, "Call clipboard.suppressWarnings() to suppress this warning."), this.m[t] = e 6494 }, t.prototype.getData = function(t) { 6495 return this.m[t] 6496 }, t.prototype.forEach = function(t) { 6497 for(var e in this.m) t(this.m[e], e) 6498 }, t 6499 }(), 6500 u = function(t) {}, 6501 c = !0; 6502 var f = function() { 6503 (console.warn || console.log).apply(console, arguments) 6504 }.bind("[clipboard-polyfill]"), 6505 s = "text/plain"; 6506 6507 function l(t) { 6508 u = t 6509 } 6510 6511 function d() { 6512 c = !1, i = !1 6513 } 6514 6515 function p(t) { 6516 return e(this, void 0, void 0, function() { 6517 var e; 6518 return n(this, function(n) { 6519 if(c && !t.getData(s) && f("clipboard.write() was called without a `text/plain` data type. On some platforms, this may result in an empty clipboard. Call clipboard.suppressWarnings() to suppress this warning."), j()) { 6520 if(function(t) { 6521 var e = t.getData(s); 6522 if(void 0 !== e) return window.clipboardData.setData("Text", e); 6523 throw new Error("No `text/plain` value was specified.") 6524 }(t)) return [2]; 6525 throw new Error("Copying failed, possibly because the user rejected it.") 6526 } 6527 if(x(t)) return u("regular execCopy worked"), [2]; 6528 if(navigator.userAgent.indexOf("Edge") > -1) return u('UA "Edge" => assuming success'), [2]; 6529 if(_(document.body, t)) return u("copyUsingTempSelection worked"), [2]; 6530 if(function(t) { 6531 var e = document.createElement("div"); 6532 e.setAttribute("style", "-webkit-user-select: text !important"), e.textContent = "temporary element", document.body.appendChild(e); 6533 var n = _(e, t); 6534 return document.body.removeChild(e), n 6535 }(t)) return u("copyUsingTempElem worked"), [2]; 6536 if(void 0 !== (e = t.getData(s)) && function(t) { 6537 u("copyTextUsingDOM"); 6538 var e = document.createElement("div"); 6539 e.setAttribute("style", "-webkit-user-select: text !important"); 6540 var n = e; 6541 e.attachShadow && (u("Using shadow DOM."), n = e.attachShadow({ 6542 mode: "open" 6543 })); 6544 var r = document.createElement("span"); 6545 r.innerText = t, n.appendChild(r), document.body.appendChild(e), T(r); 6546 var o = document.execCommand("copy"); 6547 return E(), document.body.removeChild(e), o 6548 }(e)) return u("copyTextUsingDOM worked"), [2]; 6549 throw new Error("Copy command failed.") 6550 }) 6551 }) 6552 } 6553 6554 function h(t) { 6555 return e(this, void 0, void 0, function() { 6556 return n(this, function(e) { 6557 return navigator.clipboard && navigator.clipboard.writeText ? (u("Using `navigator.clipboard.writeText()`."), [2, navigator.clipboard.writeText(t)]) : [2, p(D(t))] 6558 }) 6559 }) 6560 } 6561 6562 function v() { 6563 return e(this, void 0, void 0, function() { 6564 var t; 6565 return n(this, function(e) { 6566 switch (e.label) { 6567 case 0: 6568 return t = D, [4, y()]; 6569 case 1: 6570 return [2, t.apply(void 0, [e.sent()])] 6571 } 6572 }) 6573 }) 6574 } 6575 6576 function y() { 6577 return e(this, void 0, void 0, function() { 6578 return n(this, function(t) { 6579 if(navigator.clipboard && navigator.clipboard.readText) return u("Using `navigator.clipboard.readText()`."), [2, navigator.clipboard.readText()]; 6580 if(j()) return u("Reading text using IE strategy."), [2, C()]; 6581 throw new Error("Read is not supported in your browser.") 6582 }) 6583 }) 6584 } 6585 var m = !1; 6586 6587 function w() { 6588 m || (c && f('The deprecated default object of `clipboard-polyfill` was called. Please switch to `import * as clipboard from "clipboard-polyfill"` and see https://github.com/lgarron/clipboard-polyfill/issues/101 for more info.'), m = !0) 6589 } 6590 var b = { 6591 DT: a, 6592 setDebugLog: function(t) { 6593 return w(), l(t) 6594 }, 6595 suppressWarnings: function() { 6596 return w(), d() 6597 }, 6598 write: function(t) { 6599 return e(this, void 0, void 0, function() { 6600 return n(this, function(e) { 6601 return w(), [2, p(t)] 6602 }) 6603 }) 6604 }, 6605 writeText: function(t) { 6606 return e(this, void 0, void 0, function() { 6607 return n(this, function(e) { 6608 return w(), [2, h(t)] 6609 }) 6610 }) 6611 }, 6612 read: function() { 6613 return e(this, void 0, void 0, function() { 6614 return n(this, function(t) { 6615 return w(), [2, v()] 6616 }) 6617 }) 6618 }, 6619 readText: function() { 6620 return e(this, void 0, void 0, function() { 6621 return n(this, function(t) { 6622 return w(), [2, y()] 6623 }) 6624 }) 6625 } 6626 }, 6627 g = function() { 6628 this.success = !1 6629 }; 6630 6631 function x(t) { 6632 var e = new g, 6633 n = function(t, e, n) { 6634 u("listener called"), t.success = !0, e.forEach(function(e, r) { 6635 var o = n.clipboardData; 6636 o.setData(r, e), r === s && o.getData(r) !== e && (u("setting text/plain failed"), t.success = !1) 6637 }), n.preventDefault() 6638 }.bind(this, e, t); 6639 document.addEventListener("copy", n); 6640 try { 6641 document.execCommand("copy") 6642 } finally { 6643 document.removeEventListener("copy", n) 6644 } 6645 return e.success 6646 } 6647 6648 function _(t, e) { 6649 T(t); 6650 var n = x(e); 6651 return E(), n 6652 } 6653 6654 function T(t) { 6655 var e = document.getSelection(); 6656 if(e) { 6657 var n = document.createRange(); 6658 n.selectNodeContents(t), e.removeAllRanges(), e.addRange(n) 6659 } 6660 } 6661 6662 function E() { 6663 var t = document.getSelection(); 6664 t && t.removeAllRanges() 6665 } 6666 6667 function D(t) { 6668 var e = new a; 6669 return e.setData(s, t), e 6670 } 6671 6672 function j() { 6673 return "undefined" == typeof ClipboardEvent && void 0 !== window.clipboardData && void 0 !== window.clipboardData.setData 6674 } 6675 6676 function C() { 6677 return e(this, void 0, void 0, function() { 6678 var t; 6679 return n(this, function(e) { 6680 if("" === (t = window.clipboardData.getData("Text"))) throw new Error("Empty clipboard or could not read plain text from clipboard"); 6681 return [2, t] 6682 }) 6683 }) 6684 } 6685 t.DT = a, t.default = b, t.read = v, t.readText = y, t.setDebugLog = l, t.suppressWarnings = d, t.write = p, t.writeText = h, Object.defineProperty(t, "__esModule", { 6686 value: !0 6687 }) 6688}); 6689 6690/** 6691 * Form controller facilitating email validation and submission to backend servlet 6692 * 6693 * @author mmustaine 6694 * @since 9/27/2021 6695 */ 6696gmfxWwwComponents.FormEmailRequest = function(component) { 6697 'use strict'; 6698 6699 var $component = gmfx$(component), 6700 config = {}, 6701 $phoneNumber = document.querySelector("#emailRequest-phone"), 6702 $faxNumber = document.querySelector("#emailRequest-fax"); 6703 6704 // hyphen's to phone and fax number on input/keydown (ex: 555-555-5555) 6705 gmfxMomentumUtils.element.addHyphenToPhoneNumber($phoneNumber); 6706 gmfxMomentumUtils.element.addHyphenToPhoneNumber($faxNumber); 6707 6708 // reset form on cancel button click 6709 gmfx$(".form-email-request-close").on("click", function() { 6710 gmfxMomentumUtils.element.formResetMain("#emailRequest"); 6711 gmfxMomentumUtils.element.formResetDropdownField(".emailRequest-state-container", "#dropdown-index-1", "State*"); 6712 }); 6713 6714 // custom validation for select dropdown 6715 gmfxMomentumUtils.element.validateParsleyDropdown(".emailRequest-state-container", "#emailRequest-state", "#emailRequest-form", "#emailRequest-submit"); 6716 6717 // Instantiate global email controller and initialize the form 6718 config[gmfxMomentumFormConstants.FORM_EMAIL_SERVICE] = new gmfxWwwServices.EmailRequestForm($component); 6719 config[gmfxMomentumFormConstants.FORM_EMAIL_SERVICE][gmfxMomentumFormConstants.FORM_DATA][gmfxMomentumJcrConstants.CURRENT_NODE] = "/content/gmf/en/fragments/email-fragments/email-request-form" + "/"
6719+ gmfxMomentumJcrConstants.JCR_CONTENT + "/" + gmfxMomentumJcrConstants.NODE_FORM_EMAIL_REQUEST; 6720 new gmfxMomentumControllers.Email(config); 6721}; 6722 6723// Initialize the component 6724gmfxMomentumUtils.component.init(".form-email-request-modal", gmfxWwwComponents.FormEmailRequest); 6725 6726/** 6727 * Form controller facilitating email validation and submission to backend servlet 6728 * 6729 * @author dvo2, mmustaine 6730 * @since 04/14/2021 6731 */ 6732gmfxWwwComponents.FormArticleContact = function(component) { 6733 'use strict'; 6734 6735 var $component = gmfx$(component), 6736 config = {}; 6737 6738 // Instantiate global email controller and initialize the form 6739 config[gmfxMomentumFormConstants.FORM_EMAIL_SERVICE] = new gmfxWwwServices.ArticleContactForm($component); 6740 config[gmfxMomentumFormConstants.FORM_EMAIL_SERVICE][gmfxMomentumFormConstants.FORM_DATA][gmfxMomentumJcrConstants.CURRENT_NODE] = gmfxMomentumConfigs.page.resourcePath + "/" + gmfxMomentumJcrConstants.NODE_FORM_ARTICLE_CONTACT; 6741 new gmfxMomentumControllers.Email(config); 6742}; 6743 6744// Initialize the component 6745gmfxMomentumUtils.component.init("#form-article-contact-container", gmfxWwwComponents.FormArticleContact); 6746 6747/** 6748 * Refactoring Alert Message JS with Component Closure to avoid Document Ready Issues 6749 * 6750 * @author mmustaine 6751 * @since 5/4/2021 6752 */ 6753gmfxWwwComponents.FormAlertMessage = function(component) { 6754 'use strict'; 6755 6756 var $component = gmfx$(component); 6757 6758 gmfx$('.alert-dismissible').append('<div class="alert-x form-alert-close" tabindex="0"></div>'); 6759 var formAlert = gmfx$(".alert-x", $component); 6760 6761 // hide form alert on click 6762 gmfx$(formAlert, $component).on('click', function() { 6763 gmfx$(this).parent('.alert').addClass('fadeOut'); 6764 var $this = gmfx$(this).parent('.alert'); 6765 setTimeout(function() { 6766 $this.remove(); 6767 }, 100); 6768 }); 6769 6770 // hide form alert on enter key 6771 gmfx$(formAlert).keypress(function(e) { 6772 var alertKey = e.which; 6773 if(alertKey == 13) { 6774 gmfx$(this).parent('.alert').addClass('fadeOut'); 6775 var $this = gmfx$(this).parent('.alert'); 6776 setTimeout(function() { 6777 $this.remove(); 6778 }, 100); 6779 } 6780 }); 6781}; 6782 6783// Initialize the component 6784gmfxMomentumUtils.component.init(".alert-ccpa", gmfxWwwComponents.FormAlertMessage); 6785 6786/** 6787 * Form controller facilitating validation and logic functions 6788 * 6789 * @author mmustaine, ssaikiran 6790 * @since 7/6/2021 6791 */ 6792gmfxWwwComponents.FinalInstallment = function(component) { 6793 'use strict'; 6794 6795 var $component = gmfx$(component), 6796 $windowWidth = gmfx$(window).width(), 6797 $finalInstallmentDisclaimerDate, 6798 $finalInstallmentDisclaimerDateField, 6799 $finalInstallmentAmountField = gmfx$("#form-final-installment-amount"), 6800 $finalInstallmentScrollPadding = 0; 6801 6802 // determine scroll padding based off window width 6803 $finalInstallmentScrollPadding = gmfxMomentumUtils.element.scrollTopResponsivePadding(135, 135, 180); 6804 6805 // display final installment amount as $0.00 on page load 6806 $finalInstallmentAmountField.html("$0.00"); 6807 6808 // display current date for final installment disclaimer 6809 $finalInstallmentDisclaimerDateField = gmfxMomentumUtils.moment.dateTodayUSAFormat($finalInstallmentDisclaimerDate); 6810 gmfx$("#form-final-installment-disclaimer-date").html($finalInstallmentDisclaimerDateField); 6811 6812 // validate datepicker w/ parsley onchange for desktop only 6813 if($windowWidth >= gmfxMomentumCoreConstants.BREAK_POINT_MEDIUM) { 6814 gmfx$(".datepicker").datepicker().on("hide changeDate", function() { 6815 gmfx$(this).parsley().validate(); 6816 }); 6817 } 6818 6819 // remove $, comma, and % from input fields on input focus for recalculating validation 6820 gmfx$(".convertInteger").on("focus change click", (convertInteger)); 6821 6822 function convertInteger() { 6823 var $currentBalanceField = gmfx$("#finalInstallment-currentBalance"), 6824 $rateInputField = gmfx$("#finalInstallment-apr"), 6825 $monthlyPaymentField = gmfx$("#finalInstallment-monthlyPayment"), 6826 $convertCurrentBalanceInput, 6827 $convertRateInput, 6828 $convertMonthlyPaymentInput; 6829 6830 // remove formatted $ and comma from current balance field 6831 $convertCurrentBalanceInput = $currentBalanceField.val().replace(/[^0-9.]/g, "").replace(/\.00$/, ''); 6832 $currentBalanceField.val($convertCurrentBalanceInput); 6833 6834 // remove formatted % from annual percentage rate field 6835 $convertRateInput = $rateInputField.val().replace(/[^0-9.]/g, "").replace(/\.00$/, ''); 6836 $rateInputField.val($convertRateInput); 6837 6838 // remove formatted $ and comma from monthly payment field 6839 $convertMonthlyPaymentInput = $monthlyPaymentField.val().replace(/[^0-9.]/g, "").replace(/\.00$/, ''); 6840 $monthlyPaymentField.val($convertMonthlyPaymentInput); 6841 6842 // validate fields if changed 6843 gmfx$(".convertIntegerValidate").on("change", function() { 6844 gmfx$(this).parsley().validate(); 6845 }); 6846 } 6847 6848 // custom validation for datepicker 6849 window.Parsley.addValidator("custom", { 6850 validateString: function(value, requirement) { 6851 var $dateValue = new Date(value), 6852 $parsleyToday = new Date(); 6853 6854 // if date is today or after return false 6855 if(requirement == "past") { 6856 if($dateValue >= ($parsleyToday.setDate($parsleyToday.getDate() - 1))) { 6857 return false 6858 } 6859 } else if(requirement == "future") { 6860 // if date is before today return false 6861 if($dateValue < $parsleyToday) { 6862 return false 6863 } 6864 } 6865 return $dateValue; 6866 } 6867 }); 6868 6869 // calculate function 6870 gmfx$("#finalInstallment-submit").on("click", function(event) { 6871 event.preventDefault(); 6872 6873 // strip special formatted characters for recalculation 6874 convertInteger(); 6875 6876 var $currentBalanceConstant = parseFloat(gmfx$("#finalInstallment-currentBalance").val()), 6877 $currentBalanceInput = parseFloat(gmfx$("#finalInstallment-currentBalance").val()), 6878 $lastPaymentReceivedInput = new Date(gmfx$("#finalInstallment-lastPaymentReceived").val()), 6879 $nextDueDateInput = new Date(gmfx$("#finalInstallment-nextDueDate").val()), 6880 $maturityDateInput = new Date(gmfx$("#finalInstallment-maturityDate").val()), 6881 $rateInput = parseFloat(gmfx$("#finalInstallment-apr").val()), 6882 $rateInput = $rateInput / 100,
6883 $monthlyPaymentInput = parseFloat(gmfx$("#finalInstallment-monthlyPayment").val()), 6884 $accumulatedInterest = [], 6885 $accumulatedPaidPrincipal = [], 6886 $sumOfPrincipal = 0, 6887 $negativeScenarioFlag = 0; 6888 6889 // calculate term number 6890 var $spanOfInstallments = gmfxMomentumUtils.moment.getDateDifference($nextDueDateInput, $maturityDateInput), 6891 $term = Math.trunc(($spanOfInstallments + 30) / 30); 6892 6893 // calculate final installment 6894 try { 6895 if($term >= 0) { 6896 for(var i = 0; i < $term; i++) { 6897 $nextDueDateInput = getNextDueDateInput($lastPaymentReceivedInput); 6898 var $yearType = gmfxMomentumUtils.moment.checkLeapYear($nextDueDateInput), 6899 $timePeriod = gmfxMomentumUtils.moment.getDateDifference($lastPaymentReceivedInput, $nextDueDateInput), 6900 $interest = ($currentBalanceInput * $rateInput * $timePeriod) / $yearType; 6901 6902 $accumulatedInterest.push($interest); 6903 $lastPaymentReceivedInput = $nextDueDateInput; 6904 var $principalPaid = $monthlyPaymentInput - $interest; 6905 $accumulatedPaidPrincipal.push($principalPaid); 6906 $currentBalanceInput = $currentBalanceInput - $principalPaid; 6907 $sumOfPrincipal = gmfxMomentumUtils.element.getArraySum($accumulatedPaidPrincipal); 6908 if(($sumOfPrincipal + $monthlyPaymentInput) >= $currentBalanceConstant) { 6909 // flag for negative scenarios (example: incorrect maturity date) 6910 if($term == 1) { 6911 $negativeScenarioFlag = 0; 6912 } else { 6913 $negativeScenarioFlag = 1; 6914 } 6915 break; 6916 } 6917 } 6918 } 6919 } catch (error) { 6920 document.write(error); 6921 } 6922 6923 // get same day of the next month, example: june 7th, july 7th 6924 function getNextDueDateInput(previousDate) { 6925 var $nextDate = new Date(previousDate); 6926 $nextDate.setMonth($nextDate.getMonth() + 1, $nextDate.getDate()); 6927 return new Date($nextDate); 6928 } 6929 6930 // calculate and display results, if $negativeScenarioFlag equals 0 then calculate, else display message 6931 if($negativeScenarioFlag == 0) { 6932 // hide negative scenario message 6933 gmfx$("#form-final-installment-negative-scenario").addClass("hide"); 6934 6935 // calculate final installment amount 6936 var $finalRemainingPrincipal = ($currentBalanceConstant - $sumOfPrincipal), 6937 $finalInstallment = ($finalRemainingPrincipal + $monthlyPaymentInput); 6938 6939 // convert to decimal format 6940 $currentBalanceConstant = gmfxMomentumUtils.element.decimalFormat($currentBalanceConstant); 6941 $monthlyPaymentInput = gmfxMomentumUtils.element.decimalFormat($monthlyPaymentInput); 6942 $finalInstallment = gmfxMomentumUtils.element.decimalFormat($finalInstallment); 6943 6944 // display final installment amount 6945 $finalInstallmentAmountField.html("$" + $finalInstallment); 6946 6947 // scroll to results 6948 gmfxMomentumUtils.element.scrollTopAnimate($finalInstallmentAmountField, $finalInstallmentScrollPadding, gmfxMomentumCoreConstants.PAGE_SCROLL_SPEED); 6949 6950 } else { 6951 // set value to $0.00** (with double asterisk) 6952 $finalInstallmentAmountField.html("$0.00**"); 6953 6954 // show negative scenario message 6955 gmfx$("#form-final-installment-negative-scenario").removeClass("hide"); 6956 } 6957 6958 // format input fields 6959 gmfx$("#finalInstallment-currentBalance").val("$" + $currentBalanceConstant); 6960 gmfx$("#finalInstallment-apr").val(gmfxMomentumUtils.element.formatInterestRate($rateInput)); 6961 gmfx$("#finalInstallment-monthlyPayment").val("$" + $monthlyPaymentInput); 6962
6963 // change calculate button text to recalculate 6964 gmfx$("#finalInstallment-submit").text("Recalculate"); 6965 6966 // show disclaimer date container 6967 gmfx$("#form-final-installment-disclaimer-info").removeClass("hide"); 6968 6969 // scroll to results 6970 gmfxMomentumUtils.element.scrollTopAnimate($finalInstallmentAmountField, $finalInstallmentScrollPadding, gmfxMomentumCoreConstants.PAGE_SCROLL_SPEED); 6971 }); 6972 6973 // final installment image click 6974 gmfx$(".form-final-installment-icon").on("click", function() { 6975 // "this" id variable 6976 var $iconId = gmfx$(this).attr("id"); 6977 // slice "this" id, example: current-balance-icon = .current-balance- 6978 var $iconName = "." + $iconId.slice(0, -4); 6979 6980 if($windowWidth >= gmfxMomentumCoreConstants.BREAK_POINT_MEDIUM) { 6981 // show and hide desktop image and description for each icon 6982 toggleDesktopImageAndDescription($iconName); 6983 } else { 6984 // hide all modal images and descriptions 6985 hideAllImagesAndDescriptions(); 6986 6987 // show this id's image and description 6988 showImageAndDescription($iconName); 6989 6990 // add modal attributes to icon on mobile view 6991 gmfx$(".form-final-installment-icon").attr({ 6992 "data-target": "#form-final-installment-modal", 6993 "data-toggle": "modal" 6994 }); 6995 } 6996 }); 6997 6998 // final installment image desktop keyboard tab 6999 gmfx$(".form-final-installment-icon").keydown(function(e) { 7000 // "this" id variable 7001 var $iconId = gmfx$(this).attr("id"); 7002 // slice "this" id, example: current-balance-icon = .current-balance- 7003 var $iconName = "." + $iconId.slice(0, -4); 7004 7005 if($windowWidth >= gmfxMomentumCoreConstants.BREAK_POINT_MEDIUM) { 7006 // run when enter key is pushed 7007 if(e.keyCode === 13) { 7008 // show and hide desktop image and description for each icon 7009 toggleDesktopImageAndDescription($iconName); 7010 } 7011 } 7012 }); 7013 7014 // show and hide image and description for each icon 7015 function toggleDesktopImageAndDescription($iconName) { 7016 // example: .current-balance- = .current-balance-image 7017 var $iconImage = $iconName + "image"; 7018 7019 if(gmfx$($iconImage).hasClass("hide")) { 7020 // if this icon's image is already hidden, hide others 7021 hideAllImagesAndDescriptions(); 7022 7023 // then show this icon's image and description 7024 showImageAndDescription($iconName); 7025 } else { 7026 // if this icon's image is already visible when user clicks the same icon, hide it and show nothing (open/close button behavior) 7027 hideAllImagesAndDescriptions(); 7028 } 7029 } 7030 7031 function showImageAndDescription($iconName) { 7032 // show this id's image and description, example: (.current-balance- + "image") = gmfx$(.current-balance-image).removeClass("hide"); 7033 gmfx$($iconName + "image").removeClass("hide"); 7034 gmfx$($iconName + "description").removeClass("hide"); 7035 } 7036 7037 // hide all field images and descriptions 7038 function hideAllImagesAndDescriptions() { 7039 gmfx$(".form-final-installment-image, .form-final-installment-image-description").addClass("hide"); 7040 } 7041 7042 // Initialize Final Installment form service 7043 var finalInstallmentFormService = new gmfxWwwServices.FinalInstallmentForm($component); 7044}; 7045 7046// Initialize the component 7047gmfxMomentumUtils.component.init("#form-final-installment-container", gmfxWwwComponents.FinalInstallment); 7048 7049 7050 7051/** 7052 * FaqContainer - Navigate to categories, keydown and tab functions handled 7053 * 7054 * @author subha, grajas 7055 * @since 6/18/2021 7056 */ 7057gmfxWwwComponents.FaqContainer = function(component) { 7058 'use strict'; 7059 7060 var $component = gmfx$(component); 7061 7062 /*$('.faqSearch').keyup(search); 7063 7064 function search() { 7065 displayAll(); 7066 var key = $("#filter").val().toUpperCase(); 7067 var panels = $(".panel-title"); 7068 var panelBody = $(".panel-body"); 7069 var aMatch = []; 7070 7071 for(i = 0; i < panels.length; i++) { 7072 var heading = panels[i].parentElement.parentElement.parentElement.getElementsByClassName("faqHeading")[0]; 7073 if(panels[i].innerText.toUpperCase().indexOf(key) > -1 || panelBody[i].innerText.toUpperCase().indexOf(key) > -1) { 7074 aMatch.push(heading.innerText.trim()); 7075 panels[i].style.display = 'block'; 7076 } else { //no match 7077 panels[i].style.display = 'none'; 7078 panelBody[i].style.display = 'none'; 7079 } 7080 } 7081 7082 var headings = $(".faqHeading"); 7083 for(i = 0; i < headings.length; i++) { 7084 if(aMatch.indexOf(headings[i].innerText.trim()) < 0) { 7085 headings[i].parentElement.style.display = 'none'; 7086 } 7087 } 7088 7089 if(aMatch.length == 0) { 7090 $("#result")[0].style.display = 'block'; 7091 //$("#liveSearch")[0].innerText = "No Results. Please try again."; 7092 } else { 7093 $("#result")[0].style.display = 'none'; 7094 } 7095 } 7096 7097 function displayAll() { 7098 var panels = $(".panel-title"); 7099 var panelBody = $(".panel-body"); 7100 var headings = $(".faqHeading"); 7101 for(i = 0; i < headings.length; i++) { 7102 headings[i].parentElement.style.display = 'block'; 7103 } 7104 7105 for(i = 0; i < panels.length; i++) { 7106 var heading = panels[i].parentElement.parentElement.parentElement.getElementsByClassName("faqHeading")[0]; 7107 heading.style.display = 'block'; 7108 panels[i].style.display = 'block'; 7109 panelBody[i].style.display = 'block'; 7110 } 7111 } 7112 $(".search-FAQ").submit(function(event) { 7113 event.preventDefault() 7114 });*/ 7115 7116 // scroll for faq box anchor links 7117 gmfx$(".faqbox-item a", $component).click(function() { 7118 var $faqLink = gmfx$(this).attr("href"), // get href link id 7119 $faqScrollPadding = 0; 7120 7121 // determine scroll padding based off window width 7122 $faqScrollPadding = gmfxMomentumUtils.element.scrollTopResponsivePadding(110, 165, 145); 7123 7124 // scroll 7125 gmfxMomentumUtils.element.scrollTopAnimate($faqLink, $faqScrollPadding, gmfxMomentumCoreConstants.PAGE_SCROLL_SPEED); 7126 }); 7127 7128 // prevent faq accordion from jumping to top of screen on keyboard + enter, and n
7128ot adding # to URL 7129 gmfx$("a.faq-button-link").click(function(e) { 7130 // hides focus color border when clicking 7131 gmfx$("a.faq-button-link").addClass("faq-focus-outline"); 7132 // prevents page jumping and adding # to URL 7133 e.preventDefault(); 7134 }); 7135 7136 gmfx$("a.faq-button-link").keydown(function(e) { 7137 // add focus color border when tabbing through on keyboard 7138 if(e.keyCode === 9) { 7139 gmfx$("a.faq-button-link").removeClass("faq-focus-outline"); 7140 } 7141 }); 7142 7143 // Scroll for when selector found in url which matches with uniqueIdentifier 7144 var faqLocator = $('.faq-container-selector').val(); 7145 if(faqLocator) { 7146 // determine scroll padding based off window width 7147 var $faqPageScrollPadding = gmfxMomentumUtils.element.scrollTopResponsivePadding(95, 105, 75); 7148 7149 // scroll function 7150 gmfxMomentumUtils.element.scrollTopAnimate(('#' + faqLocator), $faqPageScrollPadding, gmfxMomentumCoreConstants.PAGE_SCROLL_SPEED); 7151 } 7152 7153 7154}; 7155 7156//Initialize the component 7157gmfxMomentumUtils.component.init(".faq-container", gmfxWwwComponents.FaqContainer); 7158 7159/** 7160 * Event List - 7161 * display active event for the current by default 7162 * if no upcoming event present display appropriate message 7163 * filter events based on month, state and organization 7164 * 7165 * @author subha 7166 * @since 6/10/2021 7167 */ 7168gmfxWwwComponents.EventList = function(component) { 7169 'use strict'; 7170 7171 var $component = gmfx$(component); 7172 7173 gmfx$('.wsTheme #month-selection #month-selection-input').attr('value', ''); 7174 gmfx$('.wsTheme #month-selection #month-selection-input').prop('value', ''); 7175 gmfx$('.wsTheme #month-selection #state-selection-input').attr('value', ''); 7176 gmfx$('.wsTheme #month-selection #state-selection-input').prop('value', ''); 7177 gmfx$('.wsTheme #month-selection #org-selection-input').attr('value', ''); 7178 gmfx$('.wsTheme #month-selection #org-selection-input').prop('value', ''); 7179 7180 gmfx$('#month-selection').on('click touchstart', '.dropdown-menu li a', function() { 7181 var div = document.createElement('div'); 7182 div.innerHTML = this.innerHTML; 7183 var secOptionValue = div.firstChild.nodeValue; 7184 gmfx$('.wsTheme #month-selection .dropdown-toggle .option').text(secOptionValue); 7185 gmfx$('.wsTheme #month-selection #month-selection-input').attr('value', secOptionValue); 7186 gmfx$('.wsTheme #month-selection #month-selection-input').prop('value', secOptionValue); 7187 gmfx$('.wsTheme #month-selection .dropdown-toggle').prop('disabled', false); 7188 gmfx$('.wsTheme #state-selection .dropdown-toggle').prop('disabled', false); 7189 gmfx$('.wsTheme #event-search-submit').attr('disabled', false); 7190 gmfx$('#clear-all-selections').attr('disabled', false); 7191 7192 }); 7193 7194 gmfx$('#state-selection', $component).on('click touchstart', '.dropdown-menu li a', function() { 7195 var div = document.createElement('div'); 7196 div.innerHTML = this.innerHTML; 7197 var secOptionValue = div.firstChild.nodeValue; 7198 gmfx$('.wsTheme #state-selection .dropdown-toggle .option').text(secOptionValue); 7199 gmfx$('.wsTheme #state-selection #state-selection-input').attr('value', secOptionValue); 7200 gmfx$('.wsTheme #state-selection #state-selection-input').prop('value', secOptionValue); 7201 gmfx$('.wsTheme #state-selection .dropdown-toggle').prop('disabled', false); 7202 gmfx$('.wsTheme #event-search-submit').attr('disabled', false); 7203 gmfx$('#clear-all-selections').attr('disabled', false); 7204 }); 7205 7206 gmfx$('#org-selection', $component).on('click touchstart', '.dropdown-menu li a', function() { 7207 var div = document.createElement('div'); 7208 div.innerHTML = this.innerHTML; 7209 var secOptionValue = div.firstChild.nodeValue; 7210 gmfx$('.wsTheme #org-selection .dropdown-toggle .option').text(secOptionValue); 7211 gmfx$('.wsTheme #org-selection #org-selection-input').attr('value', secOptionValue); 7212 gmfx$('.wsTheme #org-selection #org-selection-input').prop('value', secOptionValue); 7213 gmfx$('.wsTheme #org-selection .dropdown-toggle').prop('disabled', false); 7214 gmfx$('.wsTheme #event-search-submit').attr('disabled', false); 7215 gmfx$('#clear-all-selections').attr('disabled', false); 7216 }); 7217 7218 // remove underscore from event preview title 7219 gmfx$(".eventlist-title").text(function(i, text) { 7220 return text.replace(/_/g, " "); 7221 }); 7222 7223 gmfx$('.event-results #event-search-submit', $component).on('click touchstart', function(e) { 7224 var formData = { 7225 monthSelection: gmfx$('.wsTheme #month-selection-input').val(), 7226 stateSelection: gmfx$('.wsTheme #state-selection-input').val(), 7227 orgSelection: gmfx$('.wsTheme #org-selection-input').val(), 7228 eventRootPath: gmfx$('.wsTheme #event-root-path').val() 7229 }; 7230 gmfx$.ajax({ 7231 type: 'POST', 7232 beforeSend: function() { 7233 gmfx$('.wsTheme #event-results-display-container').append("<span class='spinner img-responsive'></span>"); 7234 }, 7235 url: '/gmfdyn/eventResultsListing', 7236 data: formData, 7237 success: function(response) { 7238 gmfx$('.wsTheme #event-results-display-container').empty(); 7239 var totalResults = parseInt(response.totalResults); 7240 var rowDiv = '<div class="row">'; 7241 if(totalResults > 0) { 7242 gmfx$.each(response.events, function(i, $event) { 7243 var ctaTarget = '_self'; 7244 if($event.ctaWindow != null && $event.ctaWindow == 'true') { 7245 ctaTarget = '_blank'; 7246 } 7247 7248 var eventCity = $event.city, 7249 eventAddress = $event.streetAddress, 7250 eventZipCode = $event.zipCode, 7251 eventOrganization = $event.organization; 7252 7253 // if variables are undefined remove "undefined" text display 7254 if(eventCity == undefined) { 7255 eventCity = ""; 7256 } 7257 7258 if(eventAddress == undefined) { 7259 eventAddress = ""; 7260 } 7261 7262 if(eventZipCode == undefined) { 7263 eventZipCode = ""; 7264 } 7265 7266 // remove underscore from event organization 7267 eventOrganization = eventOrganization.replace(/_/g, " "); 7268 7269 var tileContent = '<article class="event-tile col-lg-6 col-sm-6 col-xs-12"> <div class="date-icon"><date><span class="date">' + $event.dateDisplay + '</span><span class="month">' + $event.shortMonth + '</span></date></div><a href="' + $event.ctaUrl + '"><picture class="data-icon"><source srcset="' + $event.thumbnailImage + '" media="(min-width: 320px)"><img class="img-responsive" src="' + $event.thumbnailImage + '" alt="' + $event.title + '"></picture></a><h4 class="eventlist-title">' + 7270 $event.title + ' at ' + eventOrganization + ', ' + eventCity + ' ' + $event.state + '</h4><p class="tiny">' + $event.description + '</p><div class="address"><p>' + 7271 eventAddress + ' ' + eventCity + ' ' + $event.state + ' ' + eventZipCode + '</p></div><div class="time"><p>' + 7272 $event.eventTimeDisplay + '</p></div><div class="date-display"><p>' + 7273 $event.longMonth + ' ' + $event.dateDisplay + ' , ' + $event.year + '</p></div><a class="read-more" target="' + ctaTarget + '" href="' + 7274 $event.ctaUrl + '">
7274' + $event.ctaText + '</a></article>'; 7275 gmfx$('.wsTheme #event-results-display-container').append(tileContent); 7276 }); 7277 7278 } else { 7279 gmfx$('.wsTheme #event-results-display-container').append('<div class="event-filters">No events found</div>'); 7280 } 7281 7282 gmfx$('.wsTheme #event-results-display-container').find('.spinner').remove(); 7283 }, 7284 error: function(jqXHR, textStatus, errorThrown) { 7285 gmfx$('.wsTheme #event-results-display-container').append(errorThrown); 7286 gmfx$('.wsTheme #event-results-display-container').find('.spinner').remove(); 7287 } 7288 }); 7289 }); 7290}; 7291 7292//Initialize the component 7293gmfxMomentumUtils.component.init(".wsTheme", gmfxWwwComponents.EventList); 7294 7295 7296 7297/** 7298 * Momentum CSV Listing to parse a CSV file 7299 * 7300 * @author pramirez 7301 * @since 11/16/2020 7302 */ 7303gmfxWwwComponents.CvsListing = function(component) { 7304 'use strict'; 7305 7306 if(gmfx$('.csv-listing-component').length) { 7307 var $component, 7308 $csvListingContainer, 7309 csvFile, 7310 csvHeader, 7311 csvFinal, 7312 csvFileResults, 7313 $csvDownloadBtn, 7314 $csvFilterClearBtn, 7315 $csvFilterInput, 7316 csvdata; 7317 7318 gmfx$('.csv-listing-component').find(".list-results").each(function(index) { 7319 if(gmfx$(this).find('*').length == 0 && !$component) { 7320 $component = gmfx$(this).closest('.csv-listing-component'); 7321 CSVAjaxCall(); 7322 } else { 7323 $component = gmfx$(this).closest('.csv-listing-component'); 7324 } 7325 }); 7326 7327 $csvDownloadBtn = $component.find('.listing-table-download'), 7328 $csvFilterClearBtn = $component.find('.listing-table-clear'), 7329 $csvFilterInput = $component.find('.listing-table-filter'), 7330 csvFileResults = $component.find('.listing-container').data("csvfile"); 7331 7332 function CSVAjaxCall() { 7333 $csvListingContainer = $component.find('.listing-container'), 7334 csvFile = $csvListingContainer.data("csvfile"), 7335 csvHeader = $csvListingContainer.data("csvheader"), 7336 csvFinal = ""; 7337 gmfx$.ajax({ 7338 type: "GET", 7339 url: csvFile, 7340 dataType: "text", 7341 success: function(data) { 7342 CSVParse(data); 7343 } 7344 }); 7345 } 7346 7347 function CSVParse(csv) { 7348 csvdata = CSVToArray(csv, ','); 7349 var csvColNumber = csvdata[0].length; 7350 7351 csvFinal += "<table class='w-100'>"; 7352 for(var i = 0; i < csvdata.length; ++i) { 7353 if(csvdata[i].length == csvColNumber) { 7354 if(csvHeader == "y" && i == 0) { 7355 csvFinal += "<tr class='table-head b-b-1 light-gray-border'>"; 7356 } else { 7357 csvFinal += "<tr class='b-b-1 light-gray-border'>"; 7358 } 7359 for(var x = 0; x < csvdata[i].length; ++x) { 7360 var rightpadding = ''; 7361 if(((csvdata[i].length) - 1) != x) { 7362 rightpadding = 'p-r-15 p-r-10-sm'; 7363 } 7364 if(csvHeader == "y" && i == 0) { 7365 csvFinal += "<th class='fs-16 p-t-15 p-b-15 fs-14-sm p-t-15-sm p-b-15-sm " + rightpadding + "'>" + csvdata[i][x] + "</th>"; 7366 } else { 7367 csvFinal += "<td class='fs-16 p-t-15 p-b-15 fs-14-sm p-t-15-sm p-b-15-sm " + rightpadding + "'>" + csvdata[i][x] + "</td>"; 7368 } 7369 } 7370 csvFinal += "</tr>"; 7371 } 7372 } 7373 csvFinal += "</table>"; 7374 $component.find(".list-results").html(csvFinal); 7375 } 7376 7377 function CSVToArray(strData, strDelimiter) { 7378 strDelimiter = (strDelimiter || ","); 7379 var objPattern = new RegExp( 7380 ( 7381 "(\\" + strDelimiter + "|\\r?\\n|\\r|^)" + 7382 "(?:\"([^\"]*(?:\"\"[^\"]*)*)\"|" + 7383 "([^\"\\" + strDelimiter + "\\r\\n]*))" 7384 ), 7385 "gi" 7386 ); 7387 var arrData = [ 7388 [] 7389 ]; 7390 var arrMatches = null; 7391 while(arrMatches = objPattern.exec(strData)) { 7392 var strMatchedDelimiter = arrMatches[1]; 7393 if( 7394 strMatchedDelimiter.length && 7395 (strMatchedDelimiter != strDelimiter) 7396 ) { 7397 arrData.push([]); 7398 } 7399 if(arrMatches[2]) { 7400 var strMatchedValue = arrMatches[2].replace( 7401 new RegExp("\"\"", "g"), 7402 "\"" 7403 ); 7404 } else { 7405 var strMatchedValue = arrMatches[3]; 7406 } 7407 arrData[arrData.length - 1].push(strMatchedValue); 7408 } 7409 return (arrData); 7410 } 7411 7412 //Clear filter 7413 $csvFilterClearBtn.click(function(e) { 7414 gmfx$(this).closest('.row').find('.listing-table-filter').val('').trigger('change'); 7415 e.preventDefault(); 7416 }); 7417 7418 //Keyword filter 7419 $csvFilterInput.bind("keyup change", function(event) { 7420 var $input, filter, $table, $listresults; 7421 $input = gmfx$(this); 7422 filter = $input.val().toUpperCase(); 7423 $table = $input.closest('.csv-listing-component').find('.list-results > table'); 7424 $listresults = $input.closest('.csv-listing-component').find('.list-results'); 7425 $table.find('tr:not(.table-head)').each(function(index) { 7426 gmfx$(this).hide(); 7427 gmfx$(this).find('td').each(function(index) { 7428 if(gmfx$(this).text().toUpperCase().indexOf(filter) > -1) { 7429 gmfx$(this).closest('tr').show(); 7430 } 7431 }); 7432 }); 7433 7434 if($table.find('tr:not(.table-head):visible').length == 0) { 7435 $listresults.next().find('h3').removeClass("hidden"); 7436 $csvDownloadBtn.addClass("hidden"); 7437 } else { 7438 $listresults.next().find('h3').addClass("hidden"); 7439 $csvDownloadBtn.removeClass("hidden"); 7440 } 7441 }); 7442 7443 //Download filtered results 7444 $csvDownloadBtn.bind("click", function(e) { 7445 var $filteredTable = gmfx$(this).closest('.csv-listing-component').find('.list-results > table'), 7446 $filteredTableName = gmfx$(this).closest('.csv-listing-component').find('.listing-container').data("filtered-name"); 7447 7448 if(csvFileResults) { 7449 $csvDownloadBtn.attr('href', csvFileResults); 7450 } 7451 7452 if(!csvFileResults || ($filteredTable.find('tr').length != $filteredTable.find('tr:visible').length)) { 7453 tableToCSV($filteredTable, $filteredTableName); 7454 e.preventDefault(); 7455 } 7456 }); 7457 7458 //Convert table to CSV 7459 function tableToCSV(filteredTable, filteredTableName) { 7460 var clean_text = function(text) { 7461 text = text.replace(/"/g, '\\"').replace(/'/g, "\\'");
7462 return '"' + text + '"'; 7463 }; 7464 7465 filteredTable.each(function() { 7466 var table = $(this), 7467 title = [], 7468 rows = []; 7469 7470 gmfx$(this).find('tr:visible').each(function() { 7471 var data = []; 7472 gmfx$(this).find('th').each(function() { 7473 var text = clean_text(gmfx$(this).text()); 7474 title.push(text); 7475 }); 7476 gmfx$(this).find('td').each(function() { 7477 var text = clean_text($ = gmfx$(this).text()); 7478 data.push(text); 7479 }); 7480 data = data.join(","); 7481 rows.push(data); 7482 }); 7483 title = title.join(","); 7484 rows = rows.join("\n"); 7485 7486 var csv = title + rows, 7487 uri = 'data:text/csv;charset=utf-8,' + encodeURIComponent(csv), 7488 download_link = document.createElement('a'); 7489 download_link.href = uri; 7490 var today = new Date(), 7491 dd = today.getDate(), 7492 mm = today.getMonth() + 1, 7493 yyyy = today.getFullYear().toString().substr(-2); 7494 7495 if(dd < 10) { 7496 dd = '0' + dd; 7497 } 7498 if(mm < 10) { 7499 mm = '0' + mm; 7500 } 7501 today = mm + '-' + dd + '-' + yyyy; 7502 7503 if(filteredTableName == "") { 7504 download_link.download = today + ".csv"; 7505 } else { 7506 download_link.download = filteredTableName + " - " + today + ".csv"; 7507 } 7508 document.body.appendChild(download_link); 7509 download_link.click(); 7510 document.body.removeChild(download_link); 7511 }); 7512 } 7513 } 7514}; 7515 7516//Initialize the component 7517gmfxMomentumUtils.component.init(".csv-listing-component", gmfxWwwComponents.CvsListing); 7518 7519/** 7520 * Carousel Component - Rotate each slide with its own image and text and handle the indicator interaction for each respective slide 7521 * TODO: This anonymous execution currently does NOT support multi Carousel components on the same page 7522 * 7523 * @author subha 7524 * @since 8/16/2021 7525 */ 7526gmfxWwwComponents.Carousel = function(component) { 7527 'use strict'; 7528 7529 var $component = gmfx$(component); 7530 var constant = { 7531 ACTION_ADD: "add", 7532 ACTION_REMOVE: "remove", 7533 ACTIVE_STATE: "active", 7534 ATTRIBUTE_CLASS: "class", 7535 ATTRIBUTE_SLIDE_TO: "slide-to", 7536 ATTRIBUTE_ARIA_CONTENT: "aria-content", 7537 ATTRIBUTE_TABINDEX: "tabindex" 7538 }, 7539 $currentSlide = null, 7540 $carousel = gmfx$("#carousel-container"), 7541 $textItems = gmfx$(".text-item", $carousel), 7542 $indicators = gmfx$(".carousel-indicators li", $carousel), 7543 $modalCarousel = gmfx$("#modal-video-carousel", $carousel), 7544 $iframe = gmfx$("iframe", $carousel), 7545 videoPath = ""; 7546 7547 // Ensure the Carousel component exists on the page 7548 if($carousel.length) { 7549 7550 videoPath = $carousel.data("video-path");; 7551 7552 setVideoId($carousel); 7553 7554 // Pause the carousel when it loads for the 1st time 7555 $carousel.carousel("pause"); 7556 7557 // Auto-play the carousel 7558 $carousel.carousel({ 7559 interval: 3000 // Delay every 3 seconds till the next slide 7560 }); 7561 7562 // ************************************************************************ 7563 // EVENT HANDLERS 7564 // ************************************************************************ 7565 // Fire this event AFTER the carousel completes its slide transition 7566 $carousel.on('slid.bs.carousel', handleSlideTransitionEvent); 7567 7568 // Handle click event for the indicators 7569 $indicators.on('click', handleIndicatorClickEvent); 7570 7571 $modalCarousel.on('shown.bs.modal', function() { 7572 $carousel.carousel("pause"); 7573 }); 7574 7575 $modalCarousel.on('hidden.bs.modal', function(e) { 7576 var $if = gmfx$(e.delegateTarget).find('iframe'); 7577 var src = $if.attr("src"); 7578 $if.attr("src", '/empty.html'); 7579 $if.attr("src", src); 7580 7581 $carousel.carousel({ 7582 interval: 3000 // Delay every 3 seconds till the next slide 7583 }); 7584 7585 gmfx$('html, body').animate({ 7586 scrollTop: $carousel.offset().top 7587 }); 7588 }); 7589 } 7590 7591 // ************************************************************************ 7592 // PRIVATE FUNCTIONS 7593 // ************************************************************************ 7594 /* 7595 * Listener to handle the slide transition event 7596 */ 7597 function handleSlideTransitionEvent() { 7598 $currentSlide = this; 7599 deactivateCurrentItem($textItems, $textItems, constant.ACTION_ADD); 7600 activateTextItem($currentSlide); 7601 setVideoId($carousel); 7602 } 7603 7604 /* 7605 * Listener to handle the indicator click event 7606 */ 7607 function handleIndicatorClickEvent() { 7608 var activeIndex = gmfx$(this).data(constant.ATTRIBUTE_SLIDE_TO), 7609 $imageSlides = gmfx$(".carousel-left .item", $carousel); 7610 7611 // Pause the carousel once the user interacts with the indicator 7612 $carousel.carousel("pause"); 7613 7614 deactivateCurrentItem($indicators, $imageSlides, constant.ACTION_REMOVE); 7615 7616 // Make the new indicator selection active and reflect it on the image slide 7617 gmfx$(this).addClass(constant.ACTIVE_STATE); 7618 gmfx$(this).attr(constant.ATTRIBUTE_TABINDEX, 0);; 7619 gmfx$(this).attr(constant.ATTRIBUTE_ARIA_CONTENT, "true"); 7620 gmfx$($imageSlides[activeIndex]).addClass(constant.ACTIVE_STATE); 7621 7622 // Deactivate the previous slide's text item and activate the new one 7623 if($currentSlide === null) $currentSlide = gmfx$(this).parent(); // NOTE: $currentSlide is null if user immediately clicks on a different indicator on page load 7624 deactivateCurrentItem($textItems, $textItems, constant.ACTION_ADD); 7625 activateTextItem($currentSlide); 7626 setVideoId($carousel); 7627 } 7628 7629 /* 7630 * Deactivate the current item from being active to inactive 7631 * 7632 * @param itemList - The list of items to iterate and find the current active item 7633 * @param targetObj - The target object to find the current active item and deactivate it 7634 * @param action - The action either "add" or "remove" the item's class 7635 */ 7636 function deactivateCurrentItem(itemList, targetObj, action) { 7637 // Iterate through the list of items to remove the current active item 7638 for(var i = 0, j = itemList.length; i < j; i++) { 7639 var tabIndexClass = itemList[i].getAttribute(constant.ATTRIBUTE_TABINDEX); 7640 var ariaContentClass = itemList[i].getAttribute(constant.ATTRIBUTE_ARIA_CONTENT); 7641 7642 //Toggle tab index to '-1' if currently set to '0' 7643 if(tabIndexClass !== null && tabIndexClass.indexOf("0") >= 0) { 7644 gmfx$(itemList[i]).attr(constant.ATTRIBUTE_TABINDEX, "-1"); 7645 } 7646 7647 //Toggle aria-content to 'false' if currently set to 'true' 7648 if(ariaContentClass !== null && ariaContentClass.indexOf("true") >= 0) { 7649 gmfx$(itemList[i]).attr(constant.ATTRIBUTE_ARIA_CONTENT, "false"); 7650 } 7651 7652 var currentElementClass = itemList[i].getAttribute(constant.ATTRIBUTE_CLASS); 7653 7654 // Remove the current active selection for both image slide and indicator 7655 if(currentElementClass !== null && currentElementClass.indexOf(constant.ACTIVE_STATE) >= 0) { 7656 gmfx$(itemList[i]).removeClass(constant.ACTIVE_STATE); 7657 if(action === constant.ACTION_REMOVE) gmfx$(targetObj[i]).removeClass(constant.ACTIVE_STATE); 7658 7659 // Exit the iteration as soon as the active item is found 7660 return false;
7661 } 7662 } 7663 } 7664 7665 /* 7666 * Activate the text item 7667 * 7668 * @param targetObj - The target object to find the current active slide 7669 */ 7670 function activateTextItem(targetObj) { 7671 var activeIndex = gmfx$(targetObj).find("li." + constant.ACTIVE_STATE).data(constant.ATTRIBUTE_SLIDE_TO); 7672 7673 gmfx$($textItems[activeIndex]).addClass(constant.ACTIVE_STATE); 7674 } 7675 7676 /* 7677 * Get the current videoId active in the carousel 7678 * */ 7679 function setVideoId(targetObj) { 7680 var $activeIndex = gmfx$(targetObj).find("div.text-item." + constant.ACTIVE_STATE), 7681 $videoId = gmfx$(".button-video", $activeIndex); 7682 7683 if($videoId.length && $videoId.data("video-id") != "") { 7684 $iframe.attr("src", "").attr("src", videoPath + $videoId.data("video-id")); 7685 } 7686 } 7687}; 7688 7689//Initialize the component 7690gmfxMomentumUtils.component.init(".carousel-container", gmfxWwwComponents.Carousel); 7691 7692/** 7693 * Buttonscomp Anchor Scroll Functions 7694 * 7695 * @author mmustaine 7696 * @since 7/27/2021 7697 */ 7698 7699gmfxWwwComponents.ButtonsComp = function(component) { 7700 'use strict'; 7701 7702 var $component = gmfx$(component), 7703 $buttonAnchorLink = gmfx$(".btn-anchor-link", $component); 7704 7705 // scroll for bullet anchor links 7706 gmfx$($buttonAnchorLink, $component).on("click", function() { 7707 var $buttonAnchorUrl = gmfx$(this).attr("href"), 7708 $buttonScrollPadding = 0; 7709 7710 // determine scroll padding based off window width 7711 $buttonScrollPadding = gmfxMomentumUtils.element.scrollTopResponsivePadding(160, 80, 85); 7712 7713 // scroll function 7714 gmfxMomentumUtils.element.scrollTopAnimate($buttonAnchorUrl, $buttonScrollPadding, gmfxMomentumCoreConstants.PAGE_SCROLL_SPEED); 7715 }); 7716}; 7717 7718// Initialize the component 7719gmfxMomentumUtils.component.init(".buttonscomp-container", gmfxWwwComponents.ButtonsComp); 7720 7721/** 7722 * Bulletcomp Scroll Functions 7723 * 7724 * @author mmustaine 7725 * @since 6/8/2021 7726 */ 7727 7728gmfxWwwComponents.BulletComp = function(component) { 7729 'use strict'; 7730 7731 var $component = gmfx$(component), 7732 bulletAnchorListLink = gmfx$("ul.bullet-anchor-link-list li a", $component), 7733 bulletAnchorLinkTag = gmfx$(".bullet-anchor-link-tag", $component); 7734 7735 // scroll for bullet anchor links 7736 gmfx$(bulletAnchorListLink, $component).on("click", function() { 7737 var $bulletLink = gmfx$(this).attr("href"), 7738 $bulletScrollPadding = 0; 7739 7740 // determine scroll padding based off window width 7741 $bulletScrollPadding = gmfxMomentumUtils.element.scrollTopResponsivePadding(60, 70, 85); 7742 7743 // scroll function 7744 gmfxMomentumUtils.element.scrollTopAnimate($bulletLink, $bulletScrollPadding, gmfxMomentumCoreConstants.PAGE_SCROLL_SPEED); 7745 }); 7746 7747 // to prevent list links from being hidden by mega menu when tabbing backwards 7748 gmfx$(bulletAnchorLinkTag, $component).on("keyup", function(e) { 7749 var bulletLinkTab = e.keyCode || e.which; 7750 7751 // run function only when tab + shift key is pressed 7752 if(bulletLinkTab == 9) { 7753 if(e.shiftKey) { 7754 var $bulletLink = gmfx$(this), 7755 $bulletScrollPadding = 0; 7756 7757 // determine scroll padding based off window width 7758 $bulletScrollPadding = gmfxMomentumUtils.element.scrollTopResponsivePadding(195, 190, 185); 7759 7760 // scroll function, 100 speed for faster tabbing to match keyboard speed 7761 gmfxMomentumUtils.element.scrollTopAnimate($bulletLink, $bulletScrollPadding, 100); 7762 } 7763 } 7764 }); 7765 7766 // Replace span tag with anchor tag and add return-link class 7767 gmfx$('.bullet-custom ul li>.return-link').each(function() { 7768 gmfx$(this).replaceWith("<a class='return-link'>" + gmfx$(this).html() + "</a>"); 7769 }); 7770 7771 gmfx$(".return-link").attr("href", "javascript:history.go(-1)"); 7772}; 7773 7774// Initialize the component 7775gmfxMomentumUtils.component.init(".bulletcomp-container", gmfxWwwComponents.BulletComp); 7776 7777/** 7778 * Asset backed securitization - load docs based on filters 7779 * 7780 * @author subha 7781 * @since 8/16/2021 7782 */ 7783gmfxWwwComponents.AssetBackedSecuritizarion = function(component) { 7784 'use strict'; 7785 7786 var $component = gmfx$(component); 7787 var constant = { 7788 DEAL_LABEL_REQUIRED: "Deal*", 7789 DEAL_LABEL_NOT_REQUIRED: "Deal" 7790 }, 7791 $dealDropDown = gmfx$("#deal-length label"), 7792 datasource = gmfx$("#abs-data-source").attr("datasource"), 7793 firstDealTag = ""; 7794 7795 // On load populate the Data Selection(1st) drop down values 7796 if(datasource != undefined) { 7797 var jsondatasource = jQuery.parseJSON(datasource); 7798 gmfx$.each(jsondatasource, function(key, valueobject) { 7799 gmfx$("#data-sel-length ul").append('<li><a data-dataselection="' + key + '">' + key + '</a></li>'); 7800 }); 7801 var ul = gmfx$('#data-sel-length .dropdown-menu'); 7802 ul.children().each(function(i, li) { 7803 ul.prepend(li) 7804 }) 7805 } 7806 // Disable Deal, Year and Month Drop downs(2nd, 3rd and 4th) 7807 disableDealDropdown(); 7808 disableYearDropdown(); 7809 disableMonthDropdown(); 7810 disableSubmitButton(); 7811 7812 // On click of Data selection dropdown: Updating the the dropdown with 7813 // selected value and refreshing the Deals Dropdown 7814 gmfx$('#data-sel-length', $component).on('click', '.dropdown-menu li a', function() { 7815 gmfx$('#data-sel-length .dropdown-toggle .option').text(this.innerHTML); 7816 gmfx$('#data-sel-length input').attr('value', this.innerHTML); 7817 7818 // Disable Deal, Year and Month Drop downs 7819 disableDealDropdown(); 7820 disableYearDropdown(); 7821 disableMonthDropdown(); 7822 disableSubmitButton(); 7823 7824 //Clear the Results 7825 gmfx$('#abs-results').hide(); 7826 7827 var dataselection = gmfx$(this).data('dataselection'), 7828 datasource = jQuery.parseJSON(gmfx$("#abs-data-source").attr("datasource")), 7829 dealinfo = datasource[dataselection]['data'], 7830 firstDeal = "", 7831 count = 0; 7832 7833 // Get the count of each data selection 7834 for(var k in dealinfo) 7835 if(dealinfo.hasOwnProperty(k)) count++; 7836 7837 // Enable Deals drop down if the Deals are available for data selection 7838 if(count > 1) { 7839 // Set empty value for data selection containing more than 1 deal 7840 firstDealTag = ""; 7841 7842 // Update the Deal's label 7843 $dealDropDown.html(constant.DEAL_LABEL_REQUIRED); 7844 7845 gmfx$('#deal-length .dropdown-toggle').prop('disabled', false); 7846 gmfx$.each(dealinfo, function(key, valueobject) { 7847 gmfx$("#deal-length ul").append('<li><a data-deal="' + key + '">' + key + '</a></li>'); 7848 }); 7849 var ul = gmfx$('#deal-length .dropdown-menu'); 7850 ul.children().each(function(i, li) { 7851 ul.prepend(li) 7852 }); 7853 } else if(count <= 1) { // Specifically validate against the "0 count" scenario b/c it's possible there's no deal data 7854 // Collect the 1st deal tag's value if there's only one deal 7855 firstDeal = Object.keys(dealinfo)[0]; 7856 if(firstDeal) firstDealTag = dealinfo[firstDeal]["tag"]; 7857 7858 // Update the Deal's label and disable its state 7859 $dealDropDown.html(constant.DEAL_LABEL_NOT_REQUIRED); 7860 $dealDropDown.prop("disabled", true); 7861 7862 // Enable submit button after no more options present 7863 if(count === 1) enableSubmitButton(); 7864 } 7865 }); 7866 7867 // On click of Deals drop down: Updating the the drop down with selected 7868 // value and refreshing the Year Drop down 7869 gmfx$('#deal-length', $component).on('click', '.dropdown-menu li a', function() { 7870 gmfx$('#deal-length .dropdown-toggle .option').text(this.innerHTML); 7871 gmfx$('deal-length input').attr('value', this.innerHTML); 7872 7873 // Disable and Reset Year and Month 7874 disableYearDropdown(); 7875 disableMonthDropdown(); 7876 disableSubmitButton(); 7877 7878 var dataselection = $('#abs-dataselection').html(); 7879 var deal = $(this).data('deal'); 7880 var datasource = jQuery.parseJSON($("#abs-data-source").attr("datasource")); 7881 var yearinfo = datasource[dataselection]['data'][deal]['data']; 7882 7883 // Enable Years drop down if the Years are available for the Deal 7884 // selected 7885 if(!gmfx$.isEmptyObject(yearinfo)) { 7886 gmfx$('#year-length .dropdown-toggle').prop('disabled', false); 7887 gmfx$('#year-length .dropdown-toggle .option').text("All"); 7888 gmfx$('year-length input').attr('value', 'All'); 7889 gmfx$.each(yearinfo, function(key, valueobject) { 7890 gmfx$("#year-length ul").append('<li><a data-year="' + key + '">' + key + '</a></li>'); 7891 }); 7892 gmfx$("#year-length ul").append('<li><a data-year="All">All</a></li>'); 7893 var ul = gmfx$('#year-length .dropdown-menu'); 7894 ul.children().each(function(i, li) { 7895 ul.prepend(li) 7896 }) 7897 } 7898 enableSubmitButton(); 7899 }); 7900 7901 7902 // On click of Year dropdown: Updating the the dropdown with selected value 7903 // and refreshing the Months Dropdown 7904 gmfx$('#year-length', $component).on('click', '.dropdown-menu li a', function() { 7905 gmfx$('#year-length .dropdown-toggle .option').text(this.innerHTML); 7906 gmfx$('year-length input').attr('value', this.innerHTML); 7907 7908 // Disable and Reset Month 7909 disableMonthDropdown(); 7910 7911 var dataselection = gmfx$('#abs-dataselection').html(); 7912 var deal = gmfx$('#abs-deal').html(); 7913 var year = gmfx$(this).data('year'); 7914 var datasource = jQuery.parseJSON(gmfx$("#abs-data-source").attr("datasource")); 7915 var monthinfo = datasource[dataselection]['data'][deal]['data'][year]['data']; 7916 7917 // Enable Months drop down if the Months are available for the Year 7918 // selected 7919 if(!gmfx$.isEmptyObject(monthinfo)) { 7920 gmfx$('#month-length .dropdown-toggle').prop('disabled', false); 7921 gmfx$('#month-length .dropdown-toggle .option').text("All"); 7922 gmfx$('month-length input').attr('value', 'All'); 7923 gmfx$.each(monthinfo, function(key, valueobject) { 7924 gmfx$("#month-length ul").append('<li><a data-month="' + key + '">' + key + '</a></li>'); 7925 }); 7926 gmfx$("#month-length ul").append('<li><a data-month="All">All</a></li>'); 7927 var ul = gmfx$('#month-length .dropdown-menu'); 7928 ul.children().each(function(i, li) { 7929 ul.prepend(li) 7930 }) 7931 } else { 7932 // Enable submit button after no more options present 7933 enableSubmitButton(); 7934 } 7935 }); 7936 7937 // On click of Month dropdown: Updating the the dropdown with selected value 7938 gmfx$('#month-length', $component).on('click', '.dropdown-menu li a', function() { 7939 gmfx$('#month-length .dropdown-toggle .option').text(this.innerHTML); 7940 gmfx$('month-length input').attr('value', this.innerHTML); 7941 7942 // Enable submit button after no more options present 7943 enableSubmitButton(); 7944 }); 7945 7946 gmfx$('#abs-submit').click(function(event) { 7947 event.preventDefault(); 7948 gmfx$('#abs-results').hide(); 7949 var dataselection = gmfx$("#abs-dataselection").html(); 7950 var deal = gmfx$("#abs-deal").html(); 7951 var year = gmfx$("#abs-year").html();
7952 var month = gmfx$("#abs-month").html(); 7953 var datasource = jQuery.parseJSON(gmfx$("#abs-data-source").attr("datasource")); 7954 7955 var dataselectionTag = datasource[dataselection]['tag']; 7956 var dealinfo = datasource[dataselection]['data']; 7957 7958 var dealTag = '', 7959 yearinfo, yearTag = '', 7960 monthinfo, monthTag = ''; 7961 7962 if(dealinfo != undefined) { 7963 var dealJson = dealinfo[deal]; 7964 if(dealJson != undefined) { 7965 dealTag = dealJson['tag']; 7966 yearinfo = dealJson['data']; 7967 if(yearinfo != undefined) { 7968 var yearJson = yearinfo[year]; 7969 if(yearJson != undefined) { 7970 yearTag = yearJson['tag']; 7971 monthinfo = yearJson['data']; 7972 if(monthinfo != undefined) { 7973 var monthJson = monthinfo[month]; 7974 if(monthJson != undefined) { 7975 monthTag = monthJson['tag']; 7976 } 7977 } 7978 } 7979 } 7980 } 7981 } 7982 7983 // If there's only one Data Selection's deal, use the 1st deal tag value 7984 if(firstDealTag !== "") dealTag = firstDealTag; 7985 7986 if(dataselectionTag.indexOf("securitization-documents") != -1) { 7987 fetchSecuritizationDocuments(dataselectionTag, dealTag); 7988 } else { 7989 fetchABSDetails(dataselectionTag, dealTag, yearTag, monthTag); 7990 } 7991 7992 return false; 7993 }); 7994 7995 function disableSubmitButton() { 7996 gmfx$('#abs-submit').prop('disabled', true); 7997 } 7998 7999 function enableSubmitButton() { 8000 gmfx$('#abs-submit').prop('disabled', false); 8001 } 8002 8003 function disableDealDropdown() { 8004 gmfx$('#deal-length .dropdown-toggle').prop('disabled', true); 8005 gmfx$('#deal-length .dropdown-toggle .option').text(""); 8006 gmfx$('#deal-length input').attr('value', ''); 8007 gmfx$("#deal-length ul").html(''); 8008 gmfx$("#abs-deal").html(''); 8009 } 8010 8011 function disableYearDropdown() { 8012 gmfx$('#year-length .dropdown-toggle').prop('disabled', true); 8013 gmfx$('#year-length .dropdown-toggle .option').text(""); 8014 gmfx$('#year-length input').attr('value', ''); 8015 gmfx$("#year-length ul").html(''); 8016 gmfx$("#abs-year").html(''); 8017 } 8018 8019 function disableMonthDropdown() { 8020 gmfx$('#month-length .dropdown-toggle').prop('disabled', true); 8021 gmfx$('#month-length .dropdown-toggle .option').text(""); 8022 gmfx$('#month-length input').attr('value', ''); 8023 gmfx$("#month-length ul").html(''); 8024 gmfx$("#abs-month").html(''); 8025 } 8026 8027 function fetchABSDetails(dataselection, deal, year, month) { 8028 console.log("--- fetchABSDetails()"); 8029 console.log("--- dataselection: " + dataselection + " | deal: " + deal + " | year: " + " | month: " + month); 8030 8031 $.ajax({ 8032 url: '/gmfdyn/fetchABSDetails', 8033 type: 'POST', 8034 beforeSend: function() { 8035 gmfx$('#abs-results').append("<span class='spinner img-responsive'></span>"); 8036 }, 8037 data: { 8038 dataselection: dataselection, 8039 deal: deal, 8040 year: year, 8041 month: month, 8042 }, 8043 dataType: 'json', 8044 success: function(response) { 8045 console.log("--- response"); 8046 console.log(response); 8047 8048 if(response.length > 0) { 8049 gmfx$("#abs-results-table > tbody").empty(); 8050 for(var i = 0; i < response.length; i++) { 8051 var row = gmfx$('<tr>'); 8052 row.append(gmfx$('<td>').html("<a href= '" + response[i].url + "' target='_new'>" + response[i].title + "</a>")); 8053 row.append(gmfx$('<td>').html("<a href= '" + response[i].url + "' target='_new'>" + "<img src='" + getIcon(response[i].url) + "'>" + "</a>")); 8054 gmfx$('#abs-results-table').append(row); 8055 } 8056 gmfx$('#abs-results').show(); 8057 } 8058 gmfx$('#abs-results').find(".spinner").remove(); 8059 }, 8060 error: function(data, errorThrown) { 8061 gmfx$('#abs-results').find(".spinner").remove(); 8062 console.error("Exception occured while fetching ABS details"); 8063 } 8064 }); 8065 } 8066 8067 function fetchSecuritizationDocuments(dataselectionTag, dealTag) { 8068 var sdsource = gmfx$("#abs-data-source").attr("sdsource"); 8069 if(sdsource != undefined) { 8070 gmfx$('#abs-results').append("<span class='spinner img-responsive'></span>"); 8071 gmfx$("#abs-results-table > tbody").empty(); 8072 var jsonSDSource = jQuery.parseJSON(sdsource); 8073 if(jsonSDSource.length > 0) { 8074 gmfx$.each(jsonSDSource, function(i, item) { 8075 var itemJson = jQuery.parseJSON(item); 8076 if(itemJson.securitizationtag == dealTag) { 8077 gmfx$.each(itemJson.securitzationdocuments, function(i, innerItem) { 8078 var row = $('<tr>'); 8079 row.append($('<td>').html("<a href= '" + innerItem.url + "' target='_new'>" + innerItem.title + "</a>")); 8080 row.append($('<td>').html("")); 8081 gmfx$('#abs-results-table').append(row); 8082 }); 8083 gmfx$('#abs-results').show(); 8084 return false;
8085 } 8086 }); 8087 } 8088 gmfx$('#abs-results').find(".spinner").remove(); 8089 } 8090 } 8091 8092 function getIcon(fileName) { 8093 if(fileName.indexOf(".doc") != -1 || fileName.indexOf(".docx") != -1) { 8094 return "/etc.clientlibs/gmf/clientlibs/core-script/resources/images/icons/doc.svg"; 8095 } else if(fileName.indexOf(".xls") != -1 || fileName.indexOf(".xlsx") != -1) { 8096 return "/etc.clientlibs/gmf/clientlibs/core-script/resources/images/icons/xlsx.svg"; 8097 } else if(fileName.indexOf(".ppt") != -1 || fileName.indexOf(".pptx") != -1) { 8098 return "/etc.clientlibs/gmf/clientlibs/core-script/resources/images/icons/pptx.svg"; 8099 } else { 8100 return "/etc.clientlibs/gmf/clientlibs/core-script/resources/images/icons/pdf.svg"; 8101 } 8102 } 8103 8104}; 8105 8106//Initialize the component 8107gmfxMomentumUtils.component.init(".asset-backed-securitization", gmfxWwwComponents.AssetBackedSecuritizarion); 8108 8109/** 8110 * ArticleLazyLoad - Show Articles in Newsroom page 8111 * Load more articles 8112 * Filter articles based on criteria and also load articles based on criteria from links under articles 8113 * Navigate to Author page and load related artciles 8114 * 8115 * @author subha 8116 * @since 6/7/2021 8117 */ 8118gmfxWwwComponents.ArticleLazyLoad = function(component) { 8119 'use strict'; 8120 8121 var $component = gmfx$(component); 8122 8123 // Read filter text from URL and decode to update the dropdown 8124 // To-Do Remove Global Variables 8125 var filterText = decodeURIComponent(window.location.hash).substr(1); 8126 filterText = filterText.replace(/\-_/g, ' '); 8127 articleFilter(filterText); 8128 8129 // Set dropdown input value and text value to user selection on click 8130 gmfx$('#article-filter', $component).on('click', '.dropdown-menu li a', function () { 8131 gmfx$('#article-filter .dropdown-toggle .option').text(this.innerHTML); 8132 var filterData = gmfx$(this).attr('data-filter'); 8133 gmfx$('#article-filter input').attr('value', filterData); 8134 8135 // Manually collapse the dropdown after selection 8136 gmfx$('#article-filter .dropdown-toggle').dropdown('toggle'); 8137 }); 8138 8139 var batch = parseInt(gmfx$('#numberof-article-lazy-load').text()); 8140 var start = 0; 8141 var noOfElements = batch; 8142 var articleSelector = start + "_" + noOfElements; 8143 var currentNode = gmfx$('#article-lazy-load-currentNode').text() + '.articlefulllist.'; 8144 var HTML = '.html'; 8145 var SLASH = '/'; 8146 var articleSuffix; 8147 var clicked = ""; 8148 var filterLabel = gmfx$('#article-filter-label').text(); 8149 8150 if (filterLabel == null || filterLabel == '') { 8151 gmfx$(".article-group .col-lg-12 hr:first").hide(); 8152 } 8153 8154 function fetchArticle(url) { 8155 gmfx$.ajax({ 8156 url: url, 8157 context: document.body, 8158 success: function (response) { 8159 if (gmfx$.trim(response).length > 0) { 8160 start = noOfElements; 8161 noOfElements += batch; 8162 articleSelector = start + "_" + batch; 8163 if (clicked == true) { 8164 gmfx$('#articleData').append(response); 8165 } else { 8166 gmfx$('#articleData').html(response); 8167 } 8168 var noOfArticles = getNoOfArticles(); 8169 var totalMatches = getTotalMatches(); 8170 if (noOfArticles == undefined || noOfArticles.length < batch || start >= totalMatches) { 8171 gmfx$("#loadMoreArticles").hide(); 8172 } else { 8173 gmfx$("#loadMoreArticles").show(); 8174 } 8175 } else { 8176 gmfx$("#loadMoreArticles").hide(); 8177 } 8178 } 8179 }); 8180 } 8181 8182 function updateDropdownAndFetch(filtertxt, $anchor) { 8183 var dropdowntext = $anchor.text(); 8184 if (filtertxt == dropdowntext) { 8185 gmfx$('#article-title-lazy-load').text(filtertxt + " Articles"); 8186 8187 // Manually set dropdown values and trigger article fetching 8188 gmfx$('#article-filter .dropdown-toggle .option').text($anchor.text()); 8189 var filterData = $anchor.attr('data-filter'); 8190 gmfx$('#article-filter input').attr('value', filterData); 8191 8192 articleSuffix = gmfx$('#article-filter input').val(); 8193 var url = currentNode + articleSelector + HTML + SLASH + articleSuffix; 8194 fetchArticle(url); 8195 } 8196 } 8197 8198 if (gmfx$('#article-filter').length > 0) { 8199 gmfx$('#article-filter ul.dropdown-menu li').each(function () { 8200 var $anchor = gmfx$(this).find('a'); 8201 updateDropdownAndFetch(filterText, $anchor); 8202 }); 8203 } 8204 8205 if (articleSuffix != null && articleSuffix != '') { 8206 var url = currentNode + articleSelector + HTML + SLASH + articleSuffix; 8207 fetchArticle(url); 8208 } else if (gmfx$('#numberof-article-lazy-load').length > 0) { 8209 var url = currentNode + articleSelector + HTML; 8210 fetchArticle(url); 8211 } 8212 8213 gmfx$('#loadMoreArticles', $component).click(function (e) { 8214 e.preventDefault(); 8215 start = start + 1; 8216 clicked = true; 8217 if (articleSuffix != null && articleSuffix != '') { 8218 var url = currentNode + articleSelector + HTML + SLASH + articleSuffix; 8219 fetchArticle(url); 8220 } else { 8221 var url = currentNode + articleSelector + HTML; 8222 fetchArticle(url); 8223 } 8224 return false;
8225 }); 8226 8227 gmfx$('#article-filter', $component).on('click', '.dropdown-menu li a', function (e) { 8228 clicked = false; 8229 e.preventDefault(); 8230 start = 0; 8231 batch = parseInt(gmfx$('#numberof-article-lazy-load').text()); 8232 noOfElements = batch; 8233 articleSelector = start + "_" + noOfElements; 8234 articleSuffix = gmfx$('#article-filter input').val(); 8235 var filteredOption = gmfx$('#article-filter .dropdown-toggle .option').text(); 8236 if (articleSuffix != null && articleSuffix != '') { 8237 var url = currentNode + articleSelector + HTML + SLASH + articleSuffix; 8238 fetchArticle(url); 8239 } else { 8240 var url = currentNode + articleSelector + HTML; 8241 fetchArticle(url); 8242 } 8243 // If the option is "All Categories", display "All Articles" 8244 if(filteredOption === "All Categories"){ 8245 filteredOption = "All"; 8246 } 8247 gmfx$('#article-title-lazy-load').text(filteredOption +" Articles"); 8248 8249 var $articlesScroll = 0; 8250 // determine scroll padding based off window width 8251 $articlesScroll = gmfxMomentumUtils.element.scrollTopResponsivePadding(150, 180, 210); 8252 // scroll to results 8253 gmfxMomentumUtils.element.scrollTopAnimate('#article-title-lazy-load', $articlesScroll, gmfxMomentumCoreConstants.PAGE_SCROLL_SPEED); 8254 }); 8255 8256 gmfx$(document, $component).on('click', '.article-category', function () { 8257 articleFilter(gmfx$(this).text()); 8258 gmfx$('#article-filter').trigger('click'); 8259 }); 8260 8261 gmfx$("#loadMoreArticles", $component).click(function(e) { 8262 e.preventDefault(); 8263 return false; 8264 }); 8265 8266 function articleFilter(filtertxt) { 8267 if (gmfx$('#article-filter ul.dropdown-menu').length > 0) { 8268 // Set "All Articles" title on page load 8269 gmfx$('#article-title-lazy-load').text("All Articles"); 8270 gmfx$('#article-filter ul.dropdown-menu li').each(function () { 8271 var $anchor = gmfx$(this).find('a'); 8272 updateDropdownAndFetch(filtertxt, $anchor); 8273 }); 8274 } 8275 } 8276 8277 function getTotalMatches() { 8278 var totalMatches = gmfx$('.article-total-matches').html(); 8279 return parseInt(totalMatches); 8280 } 8281 8282 function getNoOfArticles() { 8283 var articleFullList = gmfx$('.article-full-list').text(); 8284 var noOfArticles; 8285 if (articleFullList != "") { 8286 noOfArticles = articleFullList.split(","); 8287 } else { 8288 noOfArticles = new Array(); 8289 } 8290 return noOfArticles; 8291 } 8292 8293}; 8294 8295//Initialize the component 8296gmfxMomentumUtils.component.init(".article-group", gmfxWwwComponents.ArticleLazyLoad); 8297/** 8298 * Created by ajena on 10/30/2017. 8299 * Opens Facebook, Twitter and LinkedIn share in new window 8300 */ 8301gmfxWwwComponents.ArticleDetail = function(component) { 8302 'use strict'; 8303 8304 var $component = gmfx$(component); 8305 8306 var host = window.location.href; 8307 // Facebook share 8308 gmfx$('.facebook-share', $component).click(function () { 8309 var url = '?display=popup&ref=plugin&src=like&app_id=263776620336498'; 8310 var fbUrl = 'https://www.facebook.com/sharer.php?u='.concat(host).concat(url); 8311 popUp = window.open(fbUrl, 'popupwindow', 'scrollbars=yes,width=500,height=600'); 8312 popUp.focus(); 8313 return false; 8314 }); 8315 8316 // Twitter share 8317 gmfx$('.twitter-share', $component).click(function () { 8318 var tweetUrl = 'https://twitter.com/intent/tweet?url='.concat(host); 8319 popUp = window.open(tweetUrl, 'popupwindow', 'scrollbars=yes,width=500,height=600'); 8320 popUp.focus(); 8321 return false; 8322 }); 8323 8324 // Linkedln share 8325 gmfx$('.linkedln-share', $component).click(function () { 8326 var tweetUrl = 'https://www.linkedin.com/shareArticle?mini=true&url='.concat(host); 8327 popUp = window.open(tweetUrl, 'popupwindow', 'scrollbars=yes,width=500,height=600'); 8328 popUp.focus(); 8329 return false; 8330 }); 8331 8332 //Used for analytics 8333 if(gmfx$('.article-detail.article-analytics').length > 0){ 8334 var articleName = document.querySelector(".article-detail h2:first-child").innerText; 8335 var articleCategory = document.querySelector(".article-category").innerText; 8336 gmfxMomentumServices.Analytics.getArticles(articleName, articleCategory); 8337 } 8338}; 8339 8340//Initialize the component 8341gmfxMomentumUtils.component.init(".article-detail", gmfxWwwComponents.ArticleDetail); 8342 8343 8344gmfxWwwComponents.ApplyForCredit = function(component) { 8345 'use strict'; 8346 var $component = gmfx$(component), 8347 applyForCreditLocator = gmfx$('.apply-for-credit-selector').val(); 8348 8349 if(applyForCreditLocator) { 8350 // determine scroll padding based off window width 8351 var $applyForCreditScrollPadding = gmfxMomentumUtils.element.scrollTopResponsivePadding(85, 90, 80); 8352 8353 // scroll function 8354 gmfxMomentumUtils.element.scrollTopAnimate(('#' + applyForCreditLocator), $applyForCreditScrollPadding, gmfxMomentumCoreConstants.PAGE_SCROLL_SPEED); 8355 } 8356}; 8357// Initialize the component 8358gmfxMomentumUtils.component.init(".apply-for-credit-container", gmfxWwwComponents.ApplyForCredit); 8359 8360/** 8361 * RandomImage 8362 * 8363 * @author subha 8364 * @since 11/4/2021 8365 */ 8366gmfxWwwComponents.RandomImage = function(component) { 8367 'use strict'; 8368 8369 var $component = gmfx$(component); 8370 8371 if(gmfx$('.bannerImagePaths').length > 0) { 8372 var imagePathListDesktop = []; 8373 var imagePathListTablet = []; 8374 var desktopList = gmfx$(".bannerImagePaths").attr("data-desktop-img"); 8375 var tabletList = gmfx$(".bannerImagePaths").attr("data-tablet-img"); 8376 8377 if(desktopList != undefined && tabletList != undefined) { 8378 imagePathListDesktop = desktopList.split(","); 8379 imagePathListTablet = tabletList.split(","); 8380 8381 var randomImagePathDesktop = imagePathListDesktop[Math.floor(Math.random() * imagePathListDesktop.length)]; 8382 var randomImagePathTablet = imagePathListTablet[Math.floor(Math.random() * imagePathListTablet.length)]; 8383 8384 if(gmfx$(window).width() >= 768 && gmfx$(window).width() <= 1023) { 8385 gmfx$(".bannerImagePaths").find("picture source").attr("srcset", randomImagePathTablet); 8386 } else if(gmfx$(window).width() >= 1024) { 8387 gmfx$(".bannerImagePaths").find("picture source").attr("srcset", randomImagePathDesktop); 8388 gmfx$(".bannerImagePaths").find("picture img").attr("src", randomImagePathDesktop); 8389 } 8390 } 8391 } 8392}; 8393//Initialize the component 8394gmfxMomentumUtils.component.init(".bannerImagePaths", gmfxWwwComponents.RandomImage); 8395 8396/** 8397 * SearchOverlay 8398 * 8399 * @author subha 8400 * @since 11/5/2021 8401 */ 8402gmfxWwwComponents.SearchOverlay = function(component) { 8403 'use strict'; 8404 8405 var $component = gmfx$(component); 8406 8407 gmfx$(document).on('click', '.search-close', function(e) { 8408 hideSearchOverlay(); 8409 }); 8410 8411 function doOnOrientationChange() { 8412 switch (window.orientation) { 8413 case -90 || 90: 8414 //miSearchcont(); 8415 setTimeout(miSearchcont, 200); 8416 break; 8417 default: 8418 //miSearchcont(); 8419 setTimeout(miSearchcont, 200); 8420 break; 8421 } 8422 } 8423 8424 function miSearchcont() { 8425 var searchcont; 8426 if(gmfx$(".search-overlay .container").position() != undefined) { 8427 searchcont = gmfx$(".search-overlay .container").height() + gmfx$(".search-overlay .container").position().top; 8428 } 8429 if(gmfx$(".search-overlay").css("display") == "block") { 8430 if(searchcont > window.innerHeight) { 8431 if(gmfx$(".search-overlay").css("overflow") != "scroll") { 8432 gmfx$(".search-overlay").css("overflow", "scroll"); 8433 } 8434 } else { 8435 if(gmfx$(".search-overlay").css("overflow") == "scroll") { 8436 gmfx$(".search-overlay").css("overflow", "scroll"); 8437 } 8438 } 8439 } 8440 } 8441 window.addEventListener('orientationchange', doOnOrientationChange); 8442 doOnOrientationChange(); 8443 8444 gmfx$('#search-form-field').on('keyup', function(e) { 8445 if(gmfx$(this).val().length >= 3) { 8446 gmfx$('.searchoverlaysubmit').prop('disabled', false); 8447 } else { 8448 gmfx$('.searchoverlaysubmit').prop('disabled', true); 8449 } 8450 }); 8451 8452 gmfx$(document).on('click', '.searchoverlaysubmit', function(e) { 8453 e.preventDefault(); 8454 var searchTerm = gmfx$('#search-form-field').val(); 8455 if (!searchTerm || searchTerm.trim().length < 3) { 8456 return; 8457 } 8458 var searchResultsUrl = gmfx$('form.search').attr('action'); 8459 sessionStorage.setItem('searchTerm', searchTerm.trim()); 8460 window.location.assign(searchResultsUrl); 8461 }); 8462 8463 function hideSearchOverlay() { 8464 //$('.search-overlay').hide(); 8465 gmfx$('.search-overlay').fadeOut(150); 8466 gmfx$(".search-overlay").css("overflow", ""); 8467 gmfx$('.search .form-group').removeClass('has-error').removeClass('has-danger'); 8468 gmfx$('.search .with-errors').hide(); 8469 gmfx$('.searchtext').val(''); 8470 this.placeholder = gmfx$('.searchplaceholder').html(); 8471 } 8472 8473 gmfx$(document).on('click', '.searchOverlay', function(e) { 8474 //$('.search-overlay').show(); 8475 gmfx$('.search-overlay').fadeIn(200); 8476 gmfx$('.searchoverlaysubmit').addClass('disabled'); 8477 gmfx$('.search .form-group').removeClass('has-error has-danger'); 8478 gmfx$('.with-errors').html(""); 8479 gmfx$('.with-errors').show(); 8480 miSearchcont(); 8481 }); 8482 8483 gmfx$(document).keyup(function(e) { 8484 if(e.keyCode == 27) { 8485 setTimeout(function() { 8486 hideSearchOverlay(); 8487 }, 500); 8488 } 8489 }); 8490 8491 gmfx$(document).on('focus', 'input.searchtext', function(e) { 8492 this.placeholder = ''; 8493 }); 8494 8495 gmfx$(function() { 8496 var clicky; 8497 gmfx$(document).mousedown(function(e) { 8498 clicky = gmfx$(e.target); 8499 }); 8500 8501 gmfx$(document).mouseup(function(e) { 8502 clicky = null; 8503 }); 8504 8505 var popularlinkSize = parseInt(gmfx$('.popularlinkList').html()); 8506 gmfx$(document).on('blur', 'input.searchtext', function(e) { 8507 this.placeholder = gmfx$('.searchplaceholder').html(); 8508 if(clicky != null && clicky.attr('id') == 'search-close') { 8509 hideSearchOverlay(); 8510 } 8511 for(var i = 0; i < popularlinkSize; i++) { 8512 if(clicky != null && clicky.attr('id') == 'popularlinks' + i) { 8513 gmfx$('.search .form-group').removeClass('has-error').removeClass('has-danger'); 8514 gmfx$('.search .with-errors').hide(); 8515 gmfx$('.searchtext').val(''); 8516 this.placeholder = gmfx$('.searchplaceholder').html(); 8517 gmfx$('#popularlinks' + i)[0].click(); 8518 } 8519 } 8520 }); 8521 }); 8522}; 8523//Initialize the component 8524gmfxMomentumUtils.component.init(".search-overlay", gmfxWwwComponents.SearchOverlay); 8525 8526/** 8527 * Footer - generate script only on fr-CA/es-US 8528 * 8529 * @author subha 8530 * @since 10/8/2021 8531 */ 8532gmfxWwwComponents.Footer = function(component) { 8533 'use strict'; 8534 var $component = gmfx$(component); 8535 8536 // Change Footer link from French to English 8537 if(gmfx$("html").is(":lang(fr-CA)")) { 8538 var $languageText = gmfx$(".related ul li a").filter(function(index) { 8539 var trimText = gmfx$(this).text().trim(); 8540 return trimText === gmfxMomentumCoreConstants.TEXT_LINK_FRENCH || trimText === gmfxMomentumCoreConstants.TEXT_LINK_ENGLISH; 8541 }); 8542 8543 if($languageText.text().trim() == gmfxMomentumCoreConstants.TEXT_LINK_FRENCH) { 8544 $languageText.attr("href", gmfxMomentumCoreConstants.URL_FRENCH_TO_ENGLISH); 8545 $languageText.text(gmfxMomentumCoreConstants.TEXT_LINK_ENGLISH); 8546 } 8547 } 8548 8549 // Change Footer link from Spanish to English 8550 if(gmfx$("html").is(":lang(es-US)")) { 8551 var $languageText = gmfx$(".related ul li a").filter(function(index) { 8552 var trimText = gmfx$(this).text().trim(); 8553 return trimText === gmfxMomentumCoreConstants.TEXT_LINK_SPANISH || trimText === gmfxMomentumCoreConstants.TEXT_LINK_ENGLISH; 8554 }); 8555 8556 if($languageText.text().trim() == gmfxMomentumCoreConstants.TEXT_LINK_SPANISH) { 8557 $languageText.attr("href", gmfxMomentumCoreConstants.URL_SPANISH_TO_ENGLISH); 8558 $languageText.text(gmfxMomentumCoreConstants.TEXT_LINK_ENGLISH); 8559 } 8560 } 8561 8562 var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; 8563 var iOSVersion; 8564 if(iOS) { 8565 var version = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/); 8566 iOSVersion = [parseInt(version[1], 10), parseInt(version[2], 10), parseInt(version[3] || 0, 10)]; 8567 } 8568 if((iOS == false) || (iOSVersion != null && iOSVersion != "" && iOSVersion[0] < 13)) { 8569 var el = document.getElementsByClassName('apple-business-chat-banner-container'); 8570 el[0].remove(); 8571 } 8572 8573}; 8574//Initialize the component 8575gmfxMomentumUtils.component.init(".footerjs", gmfxWwwComponents.Footer); 8576 8577 8578if(document.getElementById("payment-calculator") != null) { 8579 8580 //validation for input field 8581 $('#ex1a').keyup(isNumber).keypress(isNumber); 8582 $('#ex2a').keyup(isNumber).keypress(isNumber); 8583 $('#ex3a').keyup(isNumber).keypress(isNumber); 8584 8585 //validation for preventing cut copy and paste 8586 $(".inputstl").bind("cut copy paste", function(e) { 8587 e.preventDefault(); 8588 }); 8589 8590 //preventing undo functionality 8591 document.onkeydown = function(e) { 8592 if(e.ctrlKey && e.key === 'z') { 8593 e.preventDefault(); 8594 } 8595 } 8596 8597 //slider functionality for loan-amount 8598 $(function() { 8599 //getting values from authorable field 8600 var min = parseInt($(".loan-amt-min").text()); 8601 var max = parseInt($(".loan-amt-max").text()); 8602 var initialValue = min; 8603
8604 $(".loan-amount-min").append("$" + min.toLocaleString()); 8605 $(".loan-amount-max").append("$" + max.toLocaleString()); 8606 8607 $("#pc-loan-amount").slider({ 8608 classes: { 8609 'ui-slider': "highlight" 8610 }, 8611 range: 'min', 8612 value: initialValue, 8613 max: max, 8614 min: min, 8615 step: 500, 8616 slide: function(event, ui) { 8617 $("#ex1a").val("$" + (ui.value).toLocaleString()); 8618 } 8619 }); 8620 8621 //setting max-length to input field 8622 $("#ex1a").attr('maxlength', $(".loan-amount-max").text().length); 8623 8624 //adding placeholder to input field with min value 8625 $("#ex1a").attr('placeholder', "$" + min.toLocaleString()); 8626 8627 //updating the slider value @ input-field 8628 $("#ex1a").val("$" + ($("#pc-loan-amount").slider("value")).toLocaleString()); 8629 8630 8631 //update the slider position on change of textbox value 8632 $("#ex1a").change(function() { 8633 $("#pc-loan-amount").slider("value", $(this).val().replace(/[^\d]+/g, "")); 8634 if($(this).val().replace(/[^\d]+/g, "") >= parseInt($(".loan-amt-min").text()) && $(this).val().replace(/[^\d]+/g, "") <= parseInt($(".loan-amt-max").text())) { 8635 $(this).val("$" + (new Intl.NumberFormat).format($(this).val().replace(/[^\d]+/g, ""))); 8636 } else { 8637 $(this).val("$" + $("#pc-loan-amount").slider("value").toLocaleString()); 8638 } 8639 }); 8640 }); 8641 8642 //slider functionality for loan-term 8643 $(function() { 8644 //getting values from authorable field 8645 var min = parseInt($(".loan-term-min").text().replace("Months", "")); 8646 var max = parseInt($(".loan-term-max").text().replace("Months", "")); 8647 var initialValue = min; 8648 8649 $("#pc-loan-term").slider({ 8650 classes: { 8651 'ui-slider': "highlight" 8652 }, 8653 range: 'min', 8654 value: initialValue, 8655 max: max, 8656 min: min, 8657 step: 12, 8658 slide: function(event, ui) { 8659 $("#ex2a").val(ui.value); 8660 } 8661 }); 8662 8663 //setting max-length to input field 8664 $("#ex2a").attr('maxlength', max.toString().length); 8665 8666 //adding placeholder to input field with min value 8667 $("#ex2a").attr('placeholder', min) 8668 8669 //updating the slider value @ input-field 8670 $("#ex2a").val($("#pc-loan-term").slider("value")); 8671 8672 //update the slider position on change of textbox value 8673 $("#ex2a").change(function() { 8674 $("#pc-loan-term").slider("value", $(this).val().replace(/[^\d]+/g, "")); 8675 $(this).val($("#pc-loan-term").slider("value")); 8676 }); 8677 }); 8678 8679 //slider functionality for interest-rate 8680 $(function() { 8681 //getting values from authorable field 8682 var min = parseFloat($(".int-rate-min").text()); 8683 var max = parseFloat($(".int-rate-max").text()); 8684 var initialValue = min; 8685 8686 $(".interest-rate-min").append(min.toFixed(1) + "%"); 8687 $(".interest-rate-max").append(max.toFixed(2) + "%"); 8688 8689 $("#pc-interest-rate").slider({ 8690 classes: { 8691 'ui-slider': "highlight" 8692 }, 8693 range: 'min', 8694 value: initialValue, 8695 max: max * 10, 8696 min: min * 10, 8697 step: .1 * 10, 8698 slide: function(event, ui) { 8699 $("#ex3a").val(((ui.value) / 10).toFixed(2) + "%"); 8700 } 8701 }); 8702 8703 //setting max-length to input field 8704 $("#ex3a").attr('maxlength', $(".interest-rate-max").text().length); 8705 8706 //adding placeholder to input field with min value 8707 $("#ex3a").attr('placeholder', min.toFixed(2) + "%"); 8708 8709 //updating the slider value @ input-field 8710 $("#ex3a").val(($("#pc-interest-rate").slider("value") / 10).toFixed(2) + "%"); 8711 8712 //update the slider position on change of textbox value 8713 $("#ex3a").change(function() { 8714 $("#pc-interest-rate").slider("value", ($(this).val().replace(/[^\d\\.]+/g, "")) * 10); 8715 if(parseFloat($(this).val().replace(/[^\d\\.]+/g, "")) >= parseFloat($(".int-rate-min").text()) && parseFloat($(this).val().replace(/[^\d\\.]+/g, "")) <= parseFloat($(".int-rate-max").text())) { 8716 $(this).val($(this).val().replace(/[^\d\\.]+/g, "") + "%"); 8717 } else { 8718 $(this).val(($("#pc-interest-rate").slider("value") / 10).toFixed(2) + "%"); 8719 } 8720 }); 8721 }); 8722 8723 //function for calculation 8724 $(".calculate").click(function() { 8725 var loanAmount = parseInt($("#ex1a").val().replace(/[^\d]+/g, "")); 8726 var loanTerm = parseInt($("#ex2a").val()); 8727 var intRate = parseFloat($("#ex3a").val()); 8728 8729 if((loanAmount != null && loanAmount > 0) && (loanTerm != null && loanTerm > 0) && (intRate != null)) { 8730 if(intRate == 0) { 8731 intRate = 0.001; 8732 } 8733 var R = (intRate / 1200); 8734 var a = Math.pow((R + 1), loanTerm); 8735 var monthPayment = ((loanAmount * R * a) / (a - 1)); 8736 8737 //displaying result 8738 var x = "" + Math.round(monthPayment); 8739 var array = x.split(""); // contains all the digits of result 8740 8741 var tempHtml = "<span class='display_mile checkDol'>$</span>"; 8742 for(i = 0; i < array.length; i++) { 8743 tempHtml += "<span class='display_mile'>" + array[i] + "</span>"; 8744 } 8745 8746 $(".disp_mileage").html(tempHtml); 8747 $(".calc-output").show(); 8748 $(".calculate").text("Recalculate"); 8749 $(".fine-print-hide").show(); 8750 } 8751 }); 8752}; 8753 8754if(document.getElementById("afford-calculator") != null) { 8755 8756 //validation for input field 8757 $('#ac1a').keyup(isNumber).keypress(isNumber); 8758 $('#ac2a').keyup(isNumber).keypress(isNumber); 8759 $('#ac3a').keyup(isNumber).keypress(isNumber); 8760 $('#ac4a').keyup(isNumber).keypress(isNumber); 8761 $('#ac5a').keyup(isNumber).keypress(isNumber); 8762 $('#ac6a').keyup(isNumber).keypress(isNumber); 8763 8764 //validation for preventing cut copy and paste 8765 $(".inputstl").bind("cut copy paste", function(e) { 8766 e.preventDefault(); 8767 }); 8768 8769 //preventing undo functionality 8770 document.onkeydown = function(e) { 8771 if(e.ctrlKey && e.key === 'z') { 8772 e.preventDefault(); 8773 } 8774 } 8775 8776 //slider functionality for monthly-payment 8777 $(function() { 8778 //getting values from authorable field 8779 var min = parseInt($(".month-pay-min").text()); 8780 var max = parseInt($(".month-pay-max").text()); 8781 var initialValue = min; 8782
8783 $(".monthly-payment-min").append("$" + min.toLocaleString()); 8784 $(".monthly-payment-max").append("$" + max.toLocaleString()); 8785 8786 $("#ac-monthly-payment").slider({ 8787 classes: { 8788 'ui-slider': "highlight" 8789 }, 8790 range: 'min', 8791 value: initialValue, 8792 max: max, 8793 min: min, 8794 step: 50, 8795 slide: function(event, ui) { 8796 $("#ac1a").val("$" + (ui.value).toLocaleString()); 8797 } 8798 }); 8799 8800 //setting max-length to input field 8801 $("#ac1a").attr('maxlength', $(".monthly-payment-max").text().length); 8802 8803 //adding placeholder to input field with min value 8804 $("#ac1a").attr('placeholder', "$" + min.toLocaleString()); 8805 8806 //updating the slider value @ input-field 8807 $("#ac1a").val("$" + ($("#ac-monthly-payment").slider("value")).toLocaleString()); 8808 8809 //update the slider position on change of textbox value 8810 $("#ac1a").change(function() { 8811 $("#ac-monthly-payment").slider("value", $(this).val().replace(/[^\d]+/g, "")); 8812 if($(this).val().replace(/[^\d]+/g, "") >= parseInt($(".month-pay-min").text()) && $(this).val().replace(/[^\d]+/g, "") <= parseInt($(".month-pay-max").text())) { 8813 $(this).val("$" + (new Intl.NumberFormat).format($(this).val().replace(/[^\d]+/g, ""))); 8814 } else { 8815 $(this).val("$" + $("#ac-monthly-payment").slider("value").toLocaleString()); 8816 } 8817 }); 8818 }); 8819 8820 //slider functionality for loan-term 8821 $(function() { 8822 //getting values from authorable field 8823 var min = parseInt($(".loan-term-min").text().replace("Months", "")); 8824 var max = parseInt($(".loan-term-max").text().replace("Months", "")); 8825 var initialValue = min; 8826 8827 $("#ac-loan-terms").slider({ 8828 classes: { 8829 'ui-slider': "highlight" 8830 }, 8831 range: 'min', 8832 value: initialValue, 8833 max: max, 8834 min: min, 8835 step: 12, 8836 slide: function(event, ui) { 8837 $("#ac2a").val(ui.value); 8838 } 8839 }); 8840 8841 //setting max-length to input field 8842 $("#ac2a").attr('maxlength', max.toString().length); 8843 8844 //adding placeholder to input field with min value 8845 $("#ac2a").attr('placeholder', min); 8846 8847 //updating the slider value @ input-field 8848 $("#ac2a").val($("#ac-loan-terms").slider("value")); 8849 8850 //update the slider position on change of textbox value 8851 $("#ac2a").change(function() { 8852 $("#ac-loan-terms").slider("value", $(this).val().replace(/[^\d]+/g, "")); 8853 $(this).val($("#ac-loan-terms").slider("value")); 8854 }); 8855 }); 8856 8857 //slider functionality for interest-rate 8858 $(function() { 8859 //getting values from authorable field 8860 var min = parseFloat($(".int-rate-min").text()); 8861 var max = parseFloat($(".int-rate-max").text()); 8862 var initialValue = min; 8863 8864 $(".interest-rate-min").append(min.toFixed(1) + "%"); 8865 $(".interest-rate-max").append(max.toFixed(2) + "%"); 8866 8867 $("#ac-interest-rate").slider({ 8868 classes: { 8869 'ui-slider': "highlight" 8870 }, 8871 range: 'min', 8872 value: initialValue, 8873 max: max * 10, 8874 min: min * 10, 8875 step: .1 * 10, 8876 slide: function(event, ui) { 8877 $("#ac3a").val(((ui.value) / 10).toFixed(2) + "%"); 8878 } 8879 }); 8880 8881 //setting max-length to input field 8882 $("#ac3a").attr('maxlength', $(".interest-rate-max").text().length); 8883 8884 //adding placeholder to input field with min value 8885 $("#ac3a").attr('placeholder', min.toFixed(2) + "%"); 8886 8887 //updating the slider value @ input-field 8888 $("#ac3a").val(($("#ac-interest-rate").slider("value") / 10).toFixed(2) + "%"); 8889 8890 //update the slider position on change of textbox value 8891 $("#ac3a").change(function() { 8892 $("#ac-interest-rate").slider("value", ($(this).val().replace(/[^\d\\.]+/g, "")) * 10); 8893 if(parseFloat($(this).val().replace(/[^\d\\.]+/g, "")) >= parseFloat($(".int-rate-min").text()) && parseFloat($(this).val().replace(/[^\d\\.]+/g, "")) <= parseFloat($(".int-rate-max").text())) { 8894 $(this).val($(this).val().replace(/[^\d\\.]+/g, "") + "%"); 8895 } else { 8896 $(this).val(($("#ac-interest-rate").slider("value") / 10).toFixed(2) + "%"); 8897 } 8898 }); 8899 }); 8900 8901 //slider functionality for sales-tax 8902 $(function() { 8903 //getting values from authorable field 8904 var min = parseFloat($(".sale-tx-min").text()); 8905 var max = parseFloat($(".sale-tx-max").text()); 8906 var initialValue = min; 8907 8908 $(".sales-tax-min").append(min.toFixed(1) + "%"); 8909 $(".sales-tax-max").append(max.toFixed(2) + "%"); 8910 8911 $("#ac-sales-tax").slider({ 8912 classes: { 8913 'ui-slider': "highlight" 8914 }, 8915 range: 'min', 8916 value: initialValue, 8917 max: max * 10, 8918 min: min * 10, 8919 step: .05 * 10, 8920 slide: function(event, ui) { 8921 $("#ac4a").val(((ui.value) / 10).toFixed(2) + "%"); 8922 } 8923 }); 8924 8925 //setting max-length to input field 8926 $("#ac4a").attr('maxlength', $(".sales-tax-max").text().length); 8927 8928 //adding placeholder to input field with min value 8929 $("#ac4a").attr('placeholder', min.toFixed(2) + "%"); 8930 8931 //updating the slider value @ input-field 8932 $("#ac4a").val(($("#ac-sales-tax").slider("value") / 10).toFixed(2) + "%"); 8933 8934 //update the slider position on change of textbox value 8935 $("#ac4a").change(function() { 8936 $("#ac-sales-tax").slider("value", ($(this).val().replace(/[^\d\\.]+/g, "")) * 10); 8937 if(parseFloat($(this).val().replace(/[^\d\\.]+/g, "")) >= parseFloat($(".sale-tx-min").text()) && parseFloat($(this).val().replace(/[^\d\\.]+/g, "")) <= parseFloat($(".sale-tx-max").text())) { 8938 $(this).val($(this).val().replace(/[^\d\\.]+/g, "") + "%"); 8939 } else { 8940 $(this).val(($("#ac-sales-tax").slider("value") / 10).toFixed(2) + "%"); 8941 } 8942 }); 8943 }); 8944 8945 //slider functionality for trade-in-value 8946 $(function() { 8947 //getting values from authorable field 8948 var min = parseInt($(".trade-min").text()); 8949 var max = parseInt($(".trade-max").text()); 8950 var initialValue = min; 8951
8952 $(".trade-in-min").append("$" + min.toLocaleString()); 8953 $(".trade-in-max").append("$" + max.toLocaleString()); 8954 8955 $("#ac-trade-in-value").slider({ 8956 classes: { 8957 'ui-slider': "highlight" 8958 }, 8959 range: 'min', 8960 value: initialValue, 8961 max: max, 8962 min: min, 8963 step: 500, 8964 slide: function(event, ui) { 8965 $("#ac5a").val("$" + (ui.value).toLocaleString()); 8966 } 8967 }); 8968 8969 //setting max-length to input field 8970 $("#ac5a").attr('maxlength', $(".trade-in-max").text().length); 8971 8972 //adding placeholder to input field with min value 8973 $("#ac5a").attr('placeholder', "$" + min.toLocaleString()); 8974 8975 //updating the slider value @ input-field 8976 $("#ac5a").val("$" + ($("#ac-trade-in-value").slider("value")).toLocaleString()); 8977 8978 //update the slider position on change of textbox value 8979 $("#ac5a").change(function() { 8980 $("#ac-trade-in-value").slider("value", $(this).val().replace(/[^\d]+/g, "")); 8981 if($(this).val().replace(/[^\d]+/g, "") >= parseInt($(".trade-min").text()) && $(this).val().replace(/[^\d]+/g, "") <= parseInt($(".trade-max").text())) { 8982 $(this).val("$" + (new Intl.NumberFormat).format($(this).val().replace(/[^\d]+/g, ""))); 8983 } else { 8984 $(this).val("$" + $("#ac-trade-in-value").slider("value").toLocaleString()); 8985 } 8986 }); 8987 }); 8988 8989 //slider functionality for down-payment 8990 $(function() { 8991 //getting values from authorable field 8992 var min = parseInt($(".down-pay-min").text()); 8993 var max = parseInt($(".down-pay-max").text()); 8994 var initialValue = min; 8995 8996 $(".down-payment-min").append("$" + min.toLocaleString()); 8997 $(".down-payment-max").append("$" + max.toLocaleString()); 8998 8999 $("#ac-down-payment").slider({ 9000 classes: { 9001 'ui-slider': "highlight" 9002 }, 9003 range: 'min', 9004 value: initialValue, 9005 max: max, 9006 min: min, 9007 step: 500, 9008 slide: function(event, ui) { 9009 $("#ac6a").val("$" + (ui.value).toLocaleString()); 9010 } 9011 }); 9012 9013 //setting max-length to input field 9014 $("#ac6a").attr('maxlength', $(".down-payment-max").text().length); 9015 9016 //adding placeholder to input field with min value 9017 $("#ac6a").attr('placeholder', "$" + min.toLocaleString()); 9018 9019 //updating the slider value @ input-field 9020 $("#ac6a").val("$" + ($("#ac-down-payment").slider("value")).toLocaleString()); 9021 9022 //update the slider position on change of textbox value 9023 $("#ac6a").change(function() { 9024 $("#ac-down-payment").slider("value", $(this).val().replace(/[^\d]+/g, "")); 9025 if($(this).val().replace(/[^\d]+/g, "") >= parseInt($(".down-pay-min").text()) && $(this).val().replace(/[^\d]+/g, "") <= parseInt($(".down-pay-max").text())) { 9026 $(this).val("$" + (new Intl.NumberFormat).format($(this).val().replace(/[^\d]+/g, ""))); 9027 } else { 9028 $(this).val("$" + $("#ac-down-payment").slider("value").toLocaleString()); 9029 } 9030 }); 9031 }); 9032 9033 //function for calculation 9034 $(".calculate").click(function() { 9035 var monthlyPayment = parseInt($("#ac1a").val().replace(/[^\d]+/g, "")); 9036 var loanTerm = parseInt($("#ac2a").val()); 9037 var intRate = parseFloat($("#ac3a").val()); 9038 var salesTax = parseFloat($("#ac4a").val()); 9039 var tradeVal = parseInt($("#ac5a").val().replace(/[^\d]+/g, "")); 9040 var downPayment = parseInt($("#ac6a").val().replace(/[^\d]+/g, "")); 9041 var loanAmt; 9042 var loanAmtDownPayment; 9043 var finalLoanAmt; 9044 9045 if((monthlyPayment != null && monthlyPayment > 0) && (loanTerm != null && loanTerm > 0) && (intRate != null) && (salesTax != null) && (tradeVal != null) && (downPayment != null)) { 9046 if(intRate == 0) { 9047 intRate = 0.001; 9048 } 9049 var R = (intRate / 1200); 9050 var a = Math.pow((R + 1), loanTerm); 9051 loanAmt = monthlyPayment * (a - 1) / (R * a); 9052 loanAmtDownPayment = (loanAmt + downPayment + tradeVal); 9053 finalLoanAmt = (loanAmtDownPayment / (1 + (salesTax / 100))); 9054 //displaying result 9055 var x = "" + Math.round(finalLoanAmt); 9056 var array = x.split(""); // contains all the digits of result 9057 9058 var tempHtml = "<span class='display_mile checkDol'>$</span>"; 9059 for(i = 0; i < array.length; i++) { 9060 tempHtml += "<span class='display_mile'>" + array[i] + "</span>"; 9061 } 9062 9063 $(".disp_mileage").html(tempHtml); 9064 $(".calc-output").show(); 9065 $(".calculate").text("Recalculate"); 9066 $(".fine-print-hide").show(); 9067 } 9068 }); 9069}; 9070 9071$(document).ready(function() { 9072 $('.privacyoptform').validator(); 9073 $('.optOutThanks').hide(); 9074 $('.optoutsyserror').hide(); 9075 $('.optoutserviceerror').hide(); 9076 $('.optOutContent').show(); 9077 privacyoptValidation(); 9078 9079 $('.optOutSubmit').on('click touchstart', function(e) { 9080 privacyoptValidation(); 9081 if($(this).hasClass("disabled")) { 9082 privacyoptValidation(); 9083 } else { 9084 e.preventDefault(); 9085 $.ajax({ 9086 type: 'POST', 9087 url: '/gmfdyn/privacyOptOutServlet', 9088 data: 'accountNumber=' + $('.account-number').val() + '&ssnNumber=' + $('.ssnNumber').val(), 9089 success: function(response) { 9090 if($.trim(response).length > 0) { 9091 // if there is a response, there was an issue...for now we assume it's an accnt # + ssn issue 9092 $('.optOutThanks').hide(); 9093 $('.optoutserviceerror').text(` 9094 ${response.indexOf("404") != -1 ? 'Account Number not found... Please try again.' 9095 : response.indexOf("400") != -1 ? 'Incorrect Social Security Number... Please try again.' 9096 : 'There was an issue with the information provided.'}`); 9097 $('.optoutserviceerror').show(); 9098 $('.optoutsyserror').hide(); 9099 } else { 9100 // no response means success 9101 $('.optOutThanks').show(); 9102 $('.optoutsyserror').hide(); 9103 $('.optoutserviceerror').hide(); 9104 } 9105 }, 9106 error: function(data, errorThrown) { 9107 //there was an error connecting to the service 9108 $('.optOutThanks').hide(); 9109 $('.optoutserviceerror').hide(); 9110 $('.optoutsyserror').show(); 9111 } 9112 }); 9113 } 9114 }); 9115 9116 // On Modal close clear reset to default state 9117 $('body').on('hidden.bs.modal', function() { 9118 setTimeout(function() { 9119 $('.optOutThanks').hide(); 9120 $('.optoutsyserror').hide(); 9121 $('.optoutserviceerror').hide(); 9122 $('.optOutContent').show(); 9123 }, 500); 9124 }); 9125}); 9126 9127function privacyoptValidation() { 9128 $(".privacyoptform input").each(function() { 9129 if(!$(this).val() && $(this).prop('required')) { 9130 $('.optOutSubmit').addClass("disabled"); 9131 $('.with-errors').show(); 9132 return; 9133 } 9134 }); 9135} 9136 9137$(document).ready(function() { 9138 $('.sendtoexpertform').validator(); 9139 $('.sendemailresult').hide(); 9140 $('.sendemailerror').hide(); 9141 $('.sendtoexpertcontent').show(); 9142 sendExpertFormValidation(); 9143 $('.sendtoexpertsubmit').on('click', function(e) { 9144 sendExpertFormValidation(); 9145 if($(this).hasClass('disabled')) { 9146 sendExpertFormValidation(); 9147 } else { 9148 e.preventDefault(); 9149 $.ajax({ 9150 type: 'POST', 9151 url: '/gmfdyn/sendemail', 9152 data: $('form').serialize(), 9153 success: function(response) { 9154 if( 9155 $.trim(response).length > 0 && 9156 response.trim() === 'Email sent successfully.' 9157 ) { 9158 $('.sendemailresult').show(); 9159 $('.sendtoexpertcontent').hide(); 9160 $('.sendemailerror').hide(); 9161 } else { 9162 $('.sendemailresult').hide(); 9163 $('.sendtoexpertcontent').hide(); 9164 $('.sendemailerror').show(); 9165 } 9166 }, 9167 error: function(data, errorThrown) { 9168 $('.sendemailresult').hide(); 9169 $('.sendtoexpertcontent').hide(); 9170 $('.sendemailerror').show(); 9171 }, 9172 }); 9173 } 9174 }); 9175 $('.sendemailresult .close,.sendemailresult .modal-footer .btn').click( 9176 resetResultModal 9177 );
9178 $('.sendemailerror .close,.sendemailerror .modal-footer .btn').click( 9179 resetResultModal 9180 ); 9181 $('.promo-footer .buttonoverlay').click(resetFormModal); 9182 $( 9183 '.sendtoexpertcontent .modal-header .close,.sendtoexpertform .cancel-btn' 9184 ).click(resetErrorFields); 9185}); 9186 9187function resetFormModal() { 9188 $('.sendtoexpertcontent').show(); 9189} 9190 9191function resetResultModal() { 9192 $('.sendemailresult').hide(); 9193 $('.sendemailerror').hide(); 9194} 9195 9196function resetErrorFields() { 9197 if($('.sendtoexpertform .form-group').hasClass('has-danger')) { 9198 $('.sendtoexpertform .form-group').removeClass('has-danger has-error'); 9199 } 9200} 9201 9202function sendExpertFormValidation() { 9203 $('.sendtoexpertform input, .sendtoexpertform textarea').each(function() { 9204 if(!$(this).val() && $(this).prop('required')) { 9205 $('.sendtoexpertsubmit').addClass('disabled'); 9206 $('.with-errors').show(); 9207 return; 9208 } 9209 }); 9210} 9211 9212function phoneNumberValid() { 9213 setTimeout(function() { 9214 if($('.phoneNumberform').hasClass('has-danger')) { 9215 $('.with-errors.phoneext').addClass('phoneextmargin'); 9216 } else { 9217 $('.with-errors.phoneext').removeClass('phoneextmargin'); 9218 } 9219 }, 10); 9220} 9221 9222var rx = /\d/; 9223 9224function ziphandler(event) { 9225 setTimeout(function() { 9226 if($('.zipCodeform').hasClass('has-error')) { 9227 $('.zipCodeform > .with-errors').show(); 9228 } 9229 }, 1000); 9230 var input = this.value.replace(/[^0-9]+/g, ''); 9231 var keyPressed = String.fromCharCode(event.which); 9232 var unicode = event.charCode ? event.charCode : event.keyCode; 9233 if(rx.test(keyPressed) || event.which == 8) { 9234 if(input.length > 5) { 9235 this.value = input.slice(0, 5) + '-' + input.slice(5); 9236 } 9237 } else if(unicode == 9 && event.which == 0) { 9238 return true; 9239 } else { 9240 return false; 9241 } 9242} 9243 9244function phonehandler(event) { 9245 setTimeout(function() { 9246 if($('.phoneNumberform').hasClass('has-error')) { 9247 $('.phoneNumberform > .with-errors').show(); 9248 } 9249 }, 1000); 9250 var input = this.value.replace(/[^0-9]+/g, ''); 9251 var keyPressed = String.fromCharCode(event.which); 9252 var unicode = event.charCode ? event.charCode : event.keyCode; 9253 if(rx.test(keyPressed) || event.which == 8) { 9254 if(input.length > 3 && input.length <= 5) { 9255 this.value = input.slice(0, 3) + '-' + input.slice(3); 9256 } else if(input.length > 6) { 9257 this.value = 9258 input.slice(0, 3) + 9259 '-' + 9260 input.slice(3, 6) + 9261 '-' + 9262 input.slice(6); 9263 } 9264 } else if(unicode == 9 && event.which == 0) { 9265 return true; 9266 } else { 9267 return false; 9268 } 9269} 9270 9271$('#phoneExt').keyup(phexthandler).keypress(phexthandler).blur(phexthandler); 9272 9273function phexthandler(event) { 9274 var input = this.value.replace(/[^0-9]+/g, ''); 9275 var keyPressed = String.fromCharCode(event.which); 9276 var unicode = event.charCode ? event.charCode : event.keyCode; 9277 if(rx.test(keyPressed) || event.which == 8) {} else if(unicode == 9 && event.which == 0) { 9278 return true; 9279 } else { 9280 return false; 9281 } 9282} 9283 9284$('#firstName').keyup(fNamehandler).keypress(fNamehandler).blur(fNamehandler); 9285 9286function fNamehandler(event) { 9287 setTimeout(function() { 9288 if($('.firstNameform').hasClass('has-error')) { 9289 $('.firstNameform > .with-errors').show(); 9290 } 9291 }, 1000); 9292} 9293 9294$('#lastName').keyup(lNamehandler).keypress(lNamehandler).blur(lNamehandler); 9295 9296function lNamehandler(event) { 9297 setTimeout(function() { 9298 if($('.lastNameform').hasClass('has-error')) { 9299 $('.lastNameform > .with-errors').show(); 9300 } 9301 }, 1000); 9302} 9303 9304$('#email').keyup(emailhandler).keypress(emailhandler).blur(emailhandler); 9305 9306function emailhandler(event) { 9307 setTimeout(function() { 9308 if($('.emailform').hasClass('has-error')) { 9309 $('.emailform > .with-errors').show(); 9310 } 9311 }, 1000); 9312} 9313 9314$('#businessName') 9315 .keyup(bNamehandler) 9316 .keypress(bNamehandler) 9317 .blur(bNamehandler); 9318 9319function bNamehandler(event) { 9320 setTimeout(function() { 9321 if($('.businessNameform').hasClass('has-error')) { 9322 $('.businessNameform > .with-errors').show(); 9323 } 9324 }, 1000); 9325} 9326 9327$('#message') 9328 .keyup(messagehandler) 9329 .keypress(messagehandler) 9330 .blur(messagehandler); 9331 9332function messagehandler(event) { 9333 setTimeout(function() { 9334 if($('.messageform').hasClass('has-error')) { 9335 $('.messageform > .with-errors').show(); 9336 } 9337 }, 1000); 9338} 9339 9340/**
9341 * Make a Payment component displaying selected payment option result 9342 * 9343 * @author epsilon, dvo2 9344 * @since 3/17/2024 9345 */ 9346gmfxWwwComponents.MakePayment = function(component) { 9347 'use strict'; 9348 9349 var $component = gmfx$(component), 9350 $makePaymentForm = gmfx$("#makePaymentForm", $component), 9351 $submitButton = gmfx$("#payments-submit", $makePaymentForm), 9352 $paymentMethodDropDown = gmfx$("#payment-method", $component), 9353 accountTagHtml = gmfx$('#account_tag').html(), 9354 account = "", 9355 paymentMethodSelection = ""; // Find out which payment method the user selects 9356 9357 // Handle form's submit button 9358 $submitButton.on('click', function(e) { 9359 e.preventDefault(); 9360 9361 // Submit the form 9362 displayPaymentMethod(); 9363 }); 9364 9365 // Handle payment method/type dropdown's click event 9366 $paymentMethodDropDown.on('click', function(e) { 9367 e.preventDefault(); 9368 9369 // Store the current selected payment method/type option 9370 paymentMethodSelection = gmfx$("#payment-method-input", $makePaymentForm).val().trim(); 9371 }); 9372 9373 if(typeof accountTagHtml !== 'undefined') { 9374 account = accountTagHtml ? accountTagHtml.split('/')[1] : ""; 9375 account = account.charAt(0).toUpperCase() + account.slice(1); 9376 } 9377 9378 if(account != null && account != "") { 9379 gmfx$('#account-type input').attr('value', accountTagHtml); 9380 gmfx$('#account-type .dropdown-toggle .option').text(account); 9381 gmfx$('#financing-type .dropdown-toggle').prop('disabled', false); 9382 validatePayments(); 9383 } 9384 9385 gmfx$('#account-type').on('click', '.dropdown-menu li a', function() { 9386 var bus21valid = false; 9387 9388 gmfx$('#account-type .dropdown-toggle .option').text(this.innerHTML); 9389 gmfx$('#account-type input').attr('value', gmfx$(this).data('make')); 9390 9391 if(gmfx$('#account-type-input').val().split('/')[1] != "business21") { 9392 gmfx$('#financing-type .dropdown-toggle').prop('disabled', false); 9393 gmfx$('#fin-type, #pay-method').show(); 9394 9395 bus21valid = false; 9396 9397 gmfx$('#act-type').removeClass('col-md-7'); 9398 gmfx$('#act-type').addClass('col-md-3'); 9399 } else { 9400 gmfx$('#fin-type, #pay-method').hide(); 9401 9402 bus21valid = true; 9403 9404 gmfx$('#act-type').removeClass('col-md-3'); 9405 gmfx$('#act-type').addClass('col-md-7'); 9406 } 9407 9408 validatePayments(bus21valid); 9409 }); 9410 9411 //On page load, if account type is not available, remove the disabled attribute from financing types 9412 if(gmfx$('#account-type').length == 0) { 9413 gmfx$('#financing-type .dropdown-toggle').prop('disabled', false); 9414 } 9415 9416 var tagfinance = gmfx$('#finance_tag').html(), 9417 finance = ""; 9418 9419 if(typeof gmfx$('#finance_tag').html() !== 'undefined') { 9420 finance = gmfx$('#finance_tag').html() ? gmfx$('#finance_tag').html().split('/')[1] : ""; 9421 finance = finance.charAt(0).toUpperCase() + finance.slice(1); 9422 } 9423 9424 if(finance != null && finance != "") { 9425 if(window.location.href.indexOf("fr-ca") >= 0) { 9426 Granite.I18n.setLocale("fr"); 9427 } 9428 var financeI18n = Granite.I18n.get(finance); 9429 gmfx$('#financing-type .dropdown-toggle .option').text(financeI18n); 9430 gmfx$('#financing-type input').attr('value', tagfinance); 9431 gmfx$('#payment-method .dropdown-toggle').prop('disabled', false); 9432 validatePayments(); 9433 } 9434 9435 gmfx$('#financing-type').on('click', '.dropdown-menu li a', function() { 9436 gmfx$('#financing-type .dropdown-toggle .option').text(this.innerHTML); 9437 gmfx$('#financing-type input').attr('value', $(this).data('make')); 9438 gmfx$('#payment-method .dropdown-toggle').prop('disabled', false); 9439 validatePayments(); 9440 }); 9441 9442 gmfx$('#payment-method').on('click', '.dropdown-menu li a', function() { 9443 gmfx$('#payment-method .dropdown-toggle .option').text(this.innerHTML); 9444 gmfx$('#payment-method input').attr('value', $(this).data('make')); 9445 validatePayments(); 9446 }); 9447 9448 // ************************************************************************ 9449 // PRIVATE FUNCTIONS 9450 // ************************************************************************ 9451 function validatePayments(e) { 9452 var $paymentSubmission = gmfx$('#payments-submit'); 9453 9454 if(gmfx$('#account-type').length > 0) { 9455 if((gmfx$('#account-type input').attr('value') && gmfx$('#financing-type input').attr('value') && gmfx$('#payment-method input').attr('value')) || e) { 9456 $paymentSubmission.attr('disabled', false); 9457 $paymentSubmission.removeClass('disabled'); 9458 } else { 9459 $paymentSubmission.attr('disabled', true); 9460 $paymentSubmission.addClass('disabled'); 9461 } 9462 } else { 9463 //Remove disabled attribute from Financing Type HTML 9464 gmfx$('#financing-type .dropdown-toggle').prop('disabled', false); 9465 9466 if((gmfx$('#financing-type input').attr('value') && gmfx$('#payment-method input').attr('value')) || e) { 9467 $paymentSubmission.attr('disabled', false); 9468 $paymentSubmission.removeClass('disabled'); 9469 } else { 9470 $paymentSubmission.attr('disabled', true); 9471 $paymentSubmission.addClass('disabled'); 9472 } 9473 } 9474 } 9475 9476 /**
9477 * Display payment method/type result 9478 */ 9479 function displayPaymentMethod() { 9480 var selector = ""; 9481 9482 if(gmfx$('#account-type').length > 0) { 9483 if(gmfx$('#account-type-input').val().split('/')[1] == 'business21') { 9484 gmfx$(location).attr('href', gmfx$('#payment-redirect').html()); 9485 } else { 9486 var account = gmfx$("#account-type input").val(), 9487 finance = gmfx$("#financing-type input").val(), 9488 payment = gmfx$("#payment-method input").val(); 9489 9490 selector = account + "." + finance + "." + payment; 9491 getFragmentUrl(selector); 9492 } 9493 } else { 9494 var finance = gmfx$("#financing-type input").val(), 9495 payment = gmfx$("#payment-method input").val(); 9496 9497 selector = finance + "." + payment; 9498 getFragmentUrl(selector); 9499 } 9500 } 9501 9502 /** 9503 * Display payment result for the selected option 9504 * 9505 * @param {String} id - For example Credit card value Western Union or MoneyGram 9506 */ 9507 function radioSwitcher(id) { 9508 var displayElement = "#" + id; 9509 9510 gmfx$('.radio-switcher').hide(); 9511 gmfx$(displayElement).parent().css("display", "block"); 9512 gmfx$(displayElement).show(); 9513 } 9514 9515 /** 9516 * Get the payment fragment url 9517 * 9518 * @param {String} selector - Sling selector, cf:financingtype/lease.cf:payment-method for example 9519 */ 9520 function getFragmentUrl(selector) { 9521 $.ajax({ 9522 url: gmfx$("#makeapaymentnode").val() + ".paymentcontent" + "/" + selector + ".html", 9523 context: document.body, 9524 success: function(response) { 9525 loadResult(response.trim()); 9526 } 9527 }); 9528 } 9529 9530 /** 9531 * Load the pre-defined fragment page as the result 9532 * 9533 * @param {String} response - The fragment url, /content/cf-canada/en/fragments/payment-fragments/lease/mail for example 9534 */ 9535 function loadResult(response) { 9536 var ERROR_CSS = "has-error has-danger", 9537 ERROR_MESSAGE = "Can NOT load result due to an error. Please try again later.", // TODO: Expand this to support multi locales 9538 fragmentUrl = response + ".preview.html", 9539 $resultPanel = gmfx$('#payment-options-panel'), 9540 // Handle callback when user selects any option (for example Credit Card, Cash, Mail etc) 9541 handlePaymentCallback = function() { 9542 // Handle any selected payment method's radio click 9543 var $paymentMethodRadio = gmfx$(".paymentMethodAll", $component); // Use class over id selector to target multi occurences 9544 9545 // Handle any selected payment method's radio click 9546 $paymentMethodRadio.on('click', function(e) { 9547 e.preventDefault(); 9548 var activeRadioButtonId = gmfx$(this).data('section'); 9549 radioSwitcher(activeRadioButtonId); 9550 }); 9551 }; 9552 9553 // Show the result panel if Ajax response is NOT blank. Otherwise, display error message 9554 (response != "") ? $resultPanel.removeClass(ERROR_CSS).load(fragmentUrl, handlePaymentCallback): $resultPanel.show().addClass(ERROR_CSS).html(ERROR_MESSAGE); 9555 $resultPanel.css("display", "block"); 9556 gmfx$(".hr-tag").html('<hr class="mt50 mb30">'); 9557 } 9558}; 9559 9560// Initialize the component 9561gmfxMomentumUtils.component.init(".make-a-payment", gmfxWwwComponents.MakePayment); 9562 9563var responseData, dealerPurlZip, dealerLatitude, dealerLongitude, dealerPurlBrand, dealersData, purlType, 9564 dealerPurlName, isCookie, isEolData = false; 9565var googleMapsLink = $('.googleMapsLink').html(); 9566 9567$(document).ready(function() { 9568 $('.visitdealersubmit').on('click touchstart', function(e) { 9569 var formData = { 9570 dealerZip: $('.myModal.in .dealerZip').val().replace(" ", ""), 9571 dealerBrand: $('.myModal.in .dealerBrand').attr("value"), 9572 desiredCount: "5", 9573 requestPath: Base64.encode($(".requestPath").text()) 9574 }; 9575 if(isCookie != null && isCookie != "") { 9576 if(purlType == "nonpurl") { 9577 returnOnValidation("nonpurl", e, formData); 9578 } else { 9579 returnOnValidation("purlTwo", e, formData); 9580 } 9581 } else { 9582 returnOnValidation("nonpurl", e, formData); 9583 } 9584 }); 9585 9586 $('.different-dealer').on('click touchstart', function(e) { 9587 $('.myModal.in .visitDealerModalPublic').show(); 9588 var brandMake = getFirstWord(dealerPurlBrand); 9589 brandMake = getBrandMake(brandMake); 9590 $('.dealerZip').val(dealerPurlZip); 9591 $('.dealer-brand').html(brandMake); 9592 $('.dealerBrand').prop('value', brandMake); 9593 $('.myModal.in .visitDealerModalPurl').hide(); 9594 var formData = { 9595 dealerZip: dealerPurlZip, 9596 dealerBrand: brandMake, 9597 desiredCount: "5", 9598 requestPath: Base64.encode($(".requestPath").text()) 9599 }; 9600 returnOnValidation("purl", e, formData); 9601 }); 9602}) 9603 9604function showVisitDealerContent() { 9605 isCookie = getCookie("eol_uid"); 9606 var isDealerCookie = getCookie("GMF_dealer"); 9607 if(isCookie != null && isCookie != "") { 9608 isEolData = false;
9609 var jsonObject; 9610 if(isDealerCookie != null && isDealerCookie != "") { 9611 isDealerCookie = Base64.decode(isDealerCookie); 9612 jsonObject = JSON.parse(isDealerCookie); 9613 } 9614 isCookie = Base64.decode(isCookie); 9615 var jsonEolObject = JSON.parse(isCookie); 9616 var validVehicle = jsonEolObject["eolData"]["gmfAccountDetail"]["vehicle"]; 9617 if(validVehicle != null && validVehicle != "") { 9618 dealerPurlBrand = validVehicle["vehicleMake"]; 9619 } 9620 if(jsonObject != null && jsonObject != "" && jsonObject["dealerData"] != null && jsonObject["dealerData"] != "" && isNotEmpty(jsonObject)) { 9621 purlType = "purl"; 9622 isEolData = false; 9623 dealerPurlName = jsonObject["dealerData"]["dealerName"]; 9624 var dealerPurlAddress = jsonObject["dealerData"]["dealerStreet"]; 9625 var dealerPurlCity = jsonObject["dealerData"]["dealerCity"]; 9626 var dealerPurlState = jsonObject["dealerData"]["regionCode"]; 9627 dealerPurlZip = jsonObject["dealerData"]["postalCode"]; 9628 dealerPurlZip = dealerPurlZip.slice(0, 5); 9629 $('.dealerPurlName').text(capitalize(dealerPurlName)); 9630 $('.dealerPurlAddress').text(capitalize(dealerPurlAddress)); 9631 $('.dealerPurlCityStateZip').text(capitalize(dealerPurlCity) + ', ' + dealerPurlState + ' ' + dealerPurlZip); 9632 $('.visitDealerModalPublic').hide(); 9633 $('.visitDealerBody').hide(); 9634 $('.visitdealererror').hide(); 9635 $('.visitDealerModalPurl').show(); 9636 dealerLatitude = jsonObject["dealerData"]["latitude"]; 9637 dealerLongitude = jsonObject["dealerData"]["longitude"]; 9638 var dealerPurlDistance = jsonObject["dealerData"]["dealerDistance"]; 9639 var dealerPurlContactNum = jsonObject["dealerData"]["phone"]; 9640 $('.dealerPurlContactNum').text(formatDealerPhone(dealerPurlContactNum)); 9641 var googleMapUrl = googleMapsLink + dealerPurlName.split(' ').join('+') + ('+') + dealerPurlAddress.split(' ').join('+') + ('+') + 9642 dealerPurlCity.split(' ').join('+') + ('+') + dealerPurlState.split(' ').join('+') + ('+') + dealerPurlZip; 9643 9644 var div = document.createElement('div'); 9645 div.innerHTML = googleMapUrl; 9646 googleMapUrl = div.firstChild.nodeValue; 9647 $('.dealerPurlGoogleMaps').attr('href', googleMapUrl); 9648 responseData = ''; 9649 responseData = [{ 9650 "dealerDistance": dealerPurlDistance, 9651 "dealerName": dealerPurlName, 9652 "dealerStreet": dealerPurlAddress, 9653 "dealerCity": dealerPurlCity, 9654 "regionCode": dealerPurlState, 9655 "postalCode": dealerPurlZip, 9656 "latitude": dealerLatitude, 9657 "longitude": dealerLongitude, 9658 "phone": dealerPurlContactNum 9659 }]; 9660 } else { 9661 purlType = "nonpurl"; 9662 $('.visitDealerModalPublic').show(); 9663 $('.visitDealerModalPurl').hide(); 9664 var dealer = jsonEolObject["eolData"]["gmfAccountDetail"]["dealer"]; 9665 if(dealer) { 9666 dealerPurlZip = (dealer["dealerZip"] != undefined) ? dealer["dealerZip"] : ""; 9667 } 9668 if(dealerPurlBrand != null && dealerPurlBrand != "" && dealerPurlZip != null && dealerPurlZip != "") { 9669 $('.visitDealerBody').hide(); 9670 $('.visitdealererror').hide(); 9671 isEolData = true; 9672 } else { 9673 isEolData = false; 9674 $('.visitDealerBody').hide(); 9675 $('.visitdealererror').show(); 9676 } 9677 } 9678 } else { 9679 isEolData = false; 9680 $('.visitDealerModalPublic').show(); 9681 $('.visitDealerModalPurl').hide(); 9682 $('.visitDealerBody').hide(); 9683 $('.visitdealererror').hide(); 9684 } 9685} 9686 9687function isPurlDealerRequired(formData) { 9688 return formData.dealerBrand === getFirstWord(dealerPurlBrand) && formData.dealerZip === dealerPurlZip; 9689} 9690 9691function makePurlServiceCall(formData, data) { 9692 $(".nearby-btn").show(); 9693 dealersData = []; 9694 var defaultDealerRequired = isPurlDealerRequired(formData); 9695 if(data == "purlTwo") { 9696 if(defaultDealerRequired) { 9697 dealersData = responseData; 9698 } 9699 } else { 9700 dealersData = responseData; 9701 } 9702 $.ajax({ 9703 url: '/gmfdyn/dealerLocator', 9704 type: 'POST', 9705 beforeSend: function() { 9706 $('.myModal.in .visitdealersubmit').addClass("disabled"); 9707 $('.myModal.in .visitDealerModalPublic').append("<span class='spinner img-responsive'></span>"); 9708 }, 9709 data: formData, 9710 dataType: 'json', 9711 success: function(response) { 9712 $('.myModal.in .visitDealerModalPublic').find(".spinner").remove(); 9713 $('.myModal.in .visitdealersubmit').removeClass("disabled"); 9714 if($.trim(response).length > 0) { 9715 response = getPurlDataList(response, responseData); 9716 dealersData = dealersData.concat(response); 9717 $('.myModal.in .visitDealerBody').show(); 9718 $('.myModal.in .visitdealererror').hide(); 9719 constructDealerLocations(dealersData, defaultDealerRequired, true); 9720 constructDealerDetails(dealersData, defaultDealerRequired); 9721 constructMapInputs(dealersData, defaultDealerRequired); 9722 if(data == "purlTwo") { 9723 centerLat = locations[0][1]; 9724 centerLng = locations[0][2]; 9725 } 9726 initMap("nonpurlMap"); 9727 } else { 9728 $('.myModal.in .visitDealerBody').hide(); 9729 $('.myModal.in .visitdealererror').show(); 9730 } 9731 }, 9732 error: function(data, errorThrown) { 9733 $('.myModal.in .visitDealerModalPublic').find(".spinner").remove(); 9734 $('.myModal.in .visitDealerBody').hide(); 9735 $('.myModal.in .visitdealererror').show(); 9736 } 9737 }); 9738} 9739 9740function getPurlDataList(response, responseData) { 9741 var respDealerName, respDealerAdd; 9742 var eolDealerName = responseData[0].dealerName.replace("[-+.^:,]", ""); 9743 var eolDealerAdd = responseData[0].dealerStreet.replace("[-+.^:,]", ""); 9744 for(var x = 0; x < response.length; x++) {
9745 respDealerName = response[x].dealerName.replace("[-+.^:,]", ""); 9746 respDealerAdd = response[x].dealerStreet.replace("[-+.^:,]", ""); 9747 if(eolDealerName.toLowerCase() == respDealerName.toLowerCase() || 9748 eolDealerAdd.toLowerCase() == respDealerAdd.toLowerCase()) { 9749 response.splice(x, 1); 9750 break; 9751 } 9752 } 9753 if(response.length == "5") { 9754 response.splice(4, 1); 9755 } 9756 return response; 9757} 9758 9759function makeServiceCall(formData) { 9760 dealersData = ''; 9761 $.ajax({ 9762 url: '/gmfdyn/dealerLocator', 9763 type: 'POST', 9764 beforeSend: function() { 9765 $('.myModal.in .visitdealersubmit').addClass("disabled"); 9766 $('.myModal.in .visitDealerModalPublic').append("<span class='spinner img-responsive'></span>"); 9767 }, 9768 data: formData, 9769 dataType: 'json', 9770 success: function(response) { 9771 $('.myModal.in .visitDealerModalPublic').find(".spinner").remove(); 9772 $('.myModal.in .visitdealersubmit').removeClass("disabled"); 9773 if($.trim(response).length > 0) { 9774 dealersData = response; 9775 $('.myModal.in .visitDealerBody').show(); 9776 $('.myModal.in .visitdealererror').hide(); 9777 constructDealerLocations(dealersData, true, false); 9778 constructDealerDetails(dealersData, true); 9779 constructMapInputs(dealersData, true); 9780 initMap("nonpurlMap"); 9781 } else { 9782 $('.myModal.in .visitDealerBody').hide(); 9783 $('.myModal.in .visitdealererror').show(); 9784 } 9785 }, 9786 error: function(data, errorThrown) { 9787 $('.myModal.in .visitDealerModalPublic').find(".spinner").remove(); 9788 $('.myModal.in .visitDealerBody').hide(); 9789 $('.myModal.in .visitdealererror').show(); 9790 } 9791 }); 9792} 9793 9794var locations, markerIcons, centerLat, centerLng; 9795var markerIconPath = $('.markerIconPath').html(); 9796var markerPath = $('.markerPath').html(); 9797 9798function constructMapInputs(response, populateDefault) { 9799 locations = []; 9800 markerIcons = []; 9801 centerLat = 0; 9802 centerLng = 0; 9803 for(var i = 0; i < response.length; i++) { 9804 var locArr = [response[i].dealerName, response[i].latitude, response[i].longitude, i]; 9805 locations.push(locArr); 9806 } 9807 for(var i = 0; i < locations.length; i++) { 9808 centerLat = parseFloat(centerLat) + parseFloat(locations[i][1]); 9809 centerLng = parseFloat(centerLng) + parseFloat(locations[i][2]); 9810 if(i === 0 && populateDefault) { 9811 var locArr = [response[i].latitude, markerPath]; 9812 markerIcons.push(locArr); 9813 } else { 9814 var locArr = [response[i].latitude, markerIconPath]; 9815 markerIcons.push(locArr); 9816 } 9817 } 9818 centerLat = centerLat / locations.length; 9819 centerLng = centerLng / locations.length; 9820} 9821 9822var map; 9823 9824function initMap(data) { 9825 var parent = document.getElementsByClassName('myModal in visit-a-dealer'); 9826 if(parent != null && parent != "") { 9827 if(data == "purlMap") { 9828 map = new google.maps.Map(parent[0].getElementsByClassName('mapPurl')[0], { 9829 zoom: 6, 9830 center: new google.maps.LatLng(dealerLatitude, dealerLongitude), 9831 mapTypeId: google.maps.MapTypeId.ROADMAP 9832 }); 9833 var markerIcon = { 9834 url: $('.markerPath').html(), 9835 labelOrigin: new google.maps.Point(20, 55) 9836 }; 9837 var marker = new google.maps.Marker({ 9838 position: new google.maps.LatLng(dealerLatitude, dealerLongitude), 9839 label: capitalize(dealerPurlName), 9840 map: map, 9841 icon: markerIcon 9842 }); 9843 } else { 9844 map = new google.maps.Map(parent[0].getElementsByClassName('map')[0], { 9845 zoom: 9, 9846 center: new google.maps.LatLng(centerLat, centerLng), 9847 mapTypeId: google.maps.MapTypeId.ROADMAP 9848 }); 9849 var marker, i; 9850 var bounds = new google.maps.LatLngBounds(); 9851 for(var i = 0; i < locations.length; i++) { 9852 for(var j = 0; j < markerIcons.length; j++) { 9853 if(locations[i][1] == markerIcons[j][0]) { 9854 if(i === j) { 9855 if(markerIcons[j][1] == markerPath) { 9856 var markerIcon = { 9857 url: markerIcons[j][1], 9858 labelOrigin: new google.maps.Point(20, 55) 9859 }; 9860 marker = new google.maps.Marker({ 9861 position: new google.maps.LatLng(locations[i][1], locations[i][2]), 9862 label: capitalize(locations[i][0]), 9863 map: map, 9864 icon: markerIcon 9865 }); 9866 bounds.extend(marker.getPosition()); 9867 } else { 9868 marker = new google.maps.Marker({ 9869 position: new google.maps.LatLng(locations[i][1], locations[i][2]), 9870 map: map, 9871 icon: markerIcons[j][1] 9872 }); 9873 bounds.extend(marker.getPosition()); 9874 } 9875 break; 9876 } 9877 } 9878 } 9879 } 9880 map.fitBounds(bounds); 9881 } 9882 } 9883} 9884 9885function constructDealerLocations(response, populateDefault, displayPrevious) { 9886 container = $('.myModal.in .left-pane'); 9887 var mileslabel = $('.mileslabel').html(); 9888 $('.myModal.in .left-pane').empty(); 9889 for(var i = 0; i < response.length; i++) { 9890 var divMainItem = $('<div>').addClass('list-group dealer' + i), 9891 labelItem = $('<label>').addClass('list-group-item'), 9892 divRowItem = $('<div>').addClass('row'), 9893 divGlyphItem = $('<div>').addClass('glyph-bullet text-center'), 9894 spanItem = $('<span>'), 9895 radioItem = $('<div class="rad-div">'), 9896 divDlLocItem = $('<div>').addClass('dealer-location'), 9897 inputItem = $('<input>').attr('type', 'radio').attr('name', 'dealerLocator'), 9898 hItem = $('<h5>').addClass('list-group-item-heading'), 9899 pItem = $('<p>').addClass('list-group-item-text'); 9900 if(i === 0 && populateDefault) { 9901 divMainItem.addClass('selected'); 9902 spanItem.addClass('iradio_square-blue checked'); 9903 } else { 9904 divMainItem.removeClass('selected'); 9905 spanItem.addClass('iradio_square-blue'); 9906 } 9907 hItem.text(capitalize(response[i].dealerName)); 9908 var dealerDistance = response[i].dealerDistance; 9909 dealerDistance = parseFloat(dealerDistance); 9910 if(dealerDistance < 1 && dealerDistance != 0) { 9911 dealerDistance = dealerDistance.toFixed(2); 9912 } else { 9913 dealerDistance = Math.round(dealerDistance); 9914 } 9915 pItem.text(dealerDistance + " " + mileslabel); 9916 divGlyphItem.append(spanItem); 9917 radioItem.appendTo(divRowItem); 9918 divGlyphItem.appendTo(radioItem); 9919 divDlLocItem.append(hItem, pItem, inputItem); 9920 divDlLocItem.appendTo(divRowItem); 9921 divRowItem.appendTo(labelItem); 9922 labelItem.appendTo(divMainItem); 9923 divMainItem.appendTo(container); 9924 } 9925 if(displayPrevious) { 9926 var previousLabel = $(".previousLabel").html(); 9927 var prevBtn = $(".myModal.in .visitDealerBody .left-pane").append("<a href='' class='previous-btn'>" + previousLabel + "</a>"); 9928 prevBtn.appendTo(container); 9929 } 9930} 9931 9932function constructDealerDetails(response, populateDefault) { 9933 var locationsDetails = []; 9934 for(var i = 0; i < response.length; i++) { 9935 var locArray = [response[i].dealerName, response[i].dealerStreet, response[i].dealerCity, response[i].regionCode, response[i].postalCode]; 9936 locationsDetails.push(locArray); 9937 } 9938 var googleMapLabel = $('.openGoogleMapsLabel').html(); 9939 container = $('.myModal.in .dealerDetails'); 9940 $('.myModal.in .dealerDetails').empty(); 9941 for(var i = 0; i < response.length; i++) { 9942 var divRowItem = $('<div>').addClass('specificDealer dealer' + i), 9943 divColItem = $('<div>').addClass('col-lg-12 txt-pad'), 9944 hItem = $('<h5>'), 9945 pItem = $('<p>').addClass('tiny'), 9946 brItemTag = $('<br>'), 9947 brItem = $('<br>'), 9948 spanAddItem = $('<span>'), 9949 spanCityItem = $('<span>'), 9950 spanPhItem = $('<span>'), 9951 divMapItem = $('<span>').addClass('col-lg-6 openGoogleMaps'); 9952 hItem.text(capitalize(response[i].dealerName)); 9953 spanAddItem.text(capitalize(response[i].dealerStreet)); 9954 spanCityItem.text(capitalize(response[i].dealerCity) + ", " + response[i].regionCode + " " + (response[i].postalCode).slice(0, 5)); 9955 spanPhItem.text("(" + (response[i].phone).slice(0, 3) + ") " + (response[i].phone).slice(3, 6) + "-" + (response[i].phone).slice(6, 10)); 9956 pItem.append(spanAddItem, brItemTag, spanCityItem, brItem, spanPhItem); 9957 divColItem.append(hItem, pItem); 9958 divColItem.appendTo(divRowItem); 9959 for(var j = 0; j < locationsDetails.length; j++) { 9960 if(i === j) { 9961 var googleMapUrl = googleMapsLink + encodeURIComponent(locationsDetails[j][0].split(' ').join('+')) + ('+') + locationsDetails[j][1].split(' ').join('+') + ('+') + 9962 locationsDetails[j][2].split(' ').join('+') + ('+') + locationsDetails[j][3].split(' ').join('+') + ('+') + locationsDetails[j][4]; 9963 var div = document.createElement('div'); 9964 div.innerHTML = googleMapUrl; 9965 googleMapUrl = div.firstChild.nodeValue; 9966 var links = $('<a>').addClass('pull-right pull-down').attr('target', '_blank').attr('href', googleMapUrl); 9967 links.text(googleMapLabel); 9968 links.appendTo(divMapItem); 9969 } 9970 } 9971 divMapItem.appendTo(divRowItem); 9972 divRowItem.appendTo(container); 9973 if(i === 0 && populateDefault) { 9974 $(".myModal.in .dealerDetails .dealer" + [i]).show(); 9975 } else { 9976 $(".myModal.in .dealerDetails .dealer" + [i]).hide(); 9977 } 9978 } 9979} 9980 9981function findDivId(divId) { 9982 if(divId.indexOf("list-group selected") >= 0) { 9983 divId = divId.slice(20, 27); 9984 } else { 9985 divId = divId.slice(11, 18); 9986 } 9987 return divId; 9988} 9989 9990function findDealerDetailsId(dealerDetailsId) { 9991 if(dealerDetailsId.indexOf("specificDealer") >= 0) { 9992 dealerDetailsId = dealerDetailsId.slice(15, 22); 9993 } 9994 return dealerDetailsId; 9995} 9996 9997$('body') 9998 .on('mouseover', '.myModal.in .list-group-item', function(e) { 9999 if($(this).parents('.list-group').hasClass('selected')) { 10000 $(this).parents('.list-group').addClass('hover'); 10001 $(this).find("span").attr('class', 'iradio_square-blue checked hover'); 10002 } else { 10003 $(this).find("span").attr('class', 'iradio_square-blue hover'); 10004 } 10005 }) 10006 .on('mouseout', '.myModal.in .list-group-item', function(e) { 10007 if($(this).parents('.list-group').hasClass('selected')) { 10008 $(this).parents('.list-group').removeClass('hover'); 10009 $(this).find("span").attr('class', 'iradio_square-blue checked'); 10010 } else { 10011 $(this).find("span").attr('class', 'iradio_square-blue'); 10012 } 10013 }); 10014 10015$(document).on('click', '.left-pane div', function(e) { 10016 e.preventDefault(); 10017 var divId = $(this).closest('.list-group').attr('class'); 10018 divId = findDivId(divId); 10019 if(divId !== null && divId !== "") { 10020 $(".dealerDetails ." + divId).show(); 10021 var dealerArr = $(".left-pane").children().map(function() { 10022 return this.className; 10023 }).get(); 10024 for(var j = 0; j < dealerArr.length; j++) { 10025 var dealerArrId = dealerArr[j]; 10026 dealerArrId = findDivId(dealerArrId); 10027 if(divId != dealerArrId) { 10028 $(".left-pane ." + dealerArrId).removeClass('selected'); 10029 $(".left-pane ." + dealerArrId).find("span").attr('class', 'iradio_square-blue'); 10030 } else { 10031 $(".left-pane ." + dealerArrId).addClass('selected'); 10032 $(".left-pane ." + dealerArrId).find("span").attr('class', 'iradio_square-blue checked'); 10033 } 10034 } 10035 var dealerDetailsArr = $(".dealerDetails").children().map(function() { 10036 return this.className; 10037 }).get(); 10038 for(var i = 0; i < dealerDetailsArr.length; i++) { 10039 var dealerDetailsId = dealerDetailsArr[i]; 10040 dealerDetailsId = findDealerDetailsId(dealerDetailsId); 10041 if(divId != dealerDetailsId) { 10042 $(".dealerDetails ." + dealerDetailsId).hide(); 10043 } 10044 } 10045 markerIcons = []; 10046 for(var k = 0; k < dealersData.length; k++) { 10047 if(k == divId.slice(6, 7)) { 10048 centerLat = dealersData[k].latitude; 10049 centerLng = dealersData[k].longitude; 10050 var locArr = [dealersData[k].latitude, markerPath]; 10051 markerIcons.push(locArr); 10052 } else { 10053 var locArr = [dealersData[k].latitude, markerIconPath]; 10054 markerIcons.push(locArr); 10055 } 10056 } 10057 } 10058 initMap("nonpurlMap"); 10059 10060}); 10061 10062// Checking if the GDL response is not returning empty data 10063function isNotEmpty(decodedDealerData) { 10064 var dealerInfo = decodedDealerData["dealerData"]; 10065 if(dealerInfo != null && dealerInfo != "") { 10066 var dName = dealerInfo["dealerName"]; 10067 var dAddress = dealerInfo["dealerStreet"]; 10068 var dCity = dealerInfo["dealerCity"]; 10069 if(dName != null && dName != "" && dAddress != null && dAddress != "" && 10070 dCity != null && dCity != "") { 10071 return true; 10072 } 10073 } 10074 return false;
10075} 10076 10077// Return to previous button 10078$(document).on("click", ".previous-btn", function(e) { 10079 e.preventDefault(); 10080 showVisitDealerContent(); 10081}); 10082 10083function formatDealerPhone(phone) { 10084 var formatted = "(" + phone.slice(0, 3) + ") " + phone.slice(3, 6) + '-' + phone.slice(6, 10); 10085 return formatted; 10086} 10087 10088$(document).ready(function() { 10089 showVisitDealerContent(); 10090 $('.myModal').on('hide.bs.modal', function() { 10091 10092 $('.visitdealersubmit').prop('disabled', true); 10093 10094 $("#optionExample option:selected").removeAttr("selected"); 10095 if(getCookie("deal_brnd")) { 10096 var dealerBrand = getCookie("deal_brnd"); 10097 dealerBrand = Base64.decode(dealerBrand); 10098 $.each($("#brandDropdown .select-data li"), function(key, val) { 10099 if($(this).attr("value") == dealerBrand) { 10100 if($(this).attr("class") != "active") { 10101 $(this).find("a").click(); 10102 $(this).addClass("active"); 10103 } 10104 $('.modal.in .dealerBrand').attr('value', dealerBrand); 10105 } 10106 }); 10107 $.each($("#brandDropdown .dropdown option"), function(key, val) { 10108 if($(this).attr("data-make") == dealerBrand) { 10109 if($(this).attr("selected") != "selected") { 10110 $(this).click(); 10111 } 10112 $('.modal.in .dealerBrand').attr('value', dealerBrand); 10113 } 10114 }); 10115 } else { 10116 $('.modal.in .dealerBrand').removeAttr('value'); 10117 } 10118 10119 }); 10120 10121 $('button[data-dismiss=modal]').on('click', function() { 10122 $('.visitdealersubmit').prop("disabled", true); 10123 }); 10124 $('.visitDealerForm').validator(); 10125 $('.myModal').on('show.bs.modal', function(e) { 10126 setTimeout(function(e) { 10127 if($('.myModal.in .dealerZip').length > 0 && $('.myModal.in .dealerZip').val() == '') { 10128 $(".myModal.in .dealerZip").focus(); 10129 return false; 10130 } else if($('.myModal.in .dealerBrand').length > 0 && ($('.myModal.in .dealerBrand').attr("value") == '' || $('.myModal.in .dealerBrand').attr("value") == undefined)) { 10131 $(".myModal.in .dealerBrand").focus(); 10132 } 10133 if(!(isCookie != null && isCookie != "")) { 10134 var offersModalId = $('.visit-a-dealer').parents('.myModal.in').attr("id"); 10135 if(offersModalId) { 10136 if(offersModalId.slice(0, 11) == "offersModal") { 10137 showOfferDetails(e); 10138 } 10139 } 10140 $('.visitDealerModalPublic').show(); 10141 $('.visitDealerModalPurl').hide(); 10142 } 10143 }, 1000); 10144 10145 if(!$('.visitDealerModalPurl').length > 0) { 10146 $('.myModal.in .dealer-brand').html('Select Brand'); 10147 $('.myModal.in .dealerBrand').attr('value', ''); 10148 } 10149 if($('.visit-a-dealer').length > 0) { 10150 $('.visit-a-dealer').parents('.myModal').addClass('visit-a-dealer'); 10151 $('.visit-a-dealer').parents('.modal-dialog').addClass('modal-lg'); 10152 } 10153 if(purlType == "purl") { 10154 $('.visitDealerModalPublic').hide(); 10155 $('.visitDealerBody').hide(); 10156 $('.visitdealererror').hide(); 10157 $('.visitDealerModalPurl').show(); 10158 } 10159 if($('.visitDealerModalPurl').length > 0 && ($('.visitDealerModalPurl').css('display') == 'block')) { 10160 $('.visitDealerModalPublic').hide(); 10161 $('.visitDealerBody').hide(); 10162 $('.visitdealererror').hide(); 10163 $('.visitDealerModalPurl').show(); 10164 } 10165 10166 }); 10167 10168 $('.myModal').on('shown.bs.modal', function(e) { 10169 if($('.visitDealerModalPurl').length > 0 && ($('.visitDealerModalPurl').css('display') == 'block') && $('.visit-a-dealer').parents('.myModal').hasClass("in")) { 10170 initMap("purlMap"); 10171 google.maps.event.trigger(map, "resize"); 10172 } 10173 10174 if(dealerPurlBrand != null && dealerPurlBrand != "" && dealerPurlZip != null && dealerPurlZip != "" && isEolData) { 10175 $('.myModal .visitDealerModalPublic').show(); 10176 var brandMake = getFirstWord(dealerPurlBrand); 10177 brandMake = getBrandMake(brandMake); 10178 $('.dealerZip').val(dealerPurlZip); 10179 $('.dealer-brand').html(brandMake); 10180 $('input.dealerBrand').prop('value', brandMake); 10181 var formData = { 10182 dealerZip: dealerPurlZip, 10183 dealerBrand: brandMake, 10184 desiredCount: "5", 10185 requestPath: Base64.encode($(".requestPath").text()) 10186 }; 10187 10188 returnOnValidation("nonpurl", e, formData); 10189 } 10190 }); 10191 $('.dealerZip').keyup(zipCodeDealerForm).keypress(zipCodeDealerForm).blur(zipCodeDealerForm); 10192 $('.myModal.in .visitdealersubmit').on('click', function(event) { 10193 brandDropdown(); 10194 }); 10195 $(".brandDropdown").on("hide.bs.dropdown", function(event) { 10196 brandDropdown(); 10197 }); 10198 $('.myModal').on('show.bs.modal', function() { 10199 $('.brandDropdown .with-errors').html(""); 10200 $('.brandDropdown .with-errors').show(); 10201 //dynamic id for Dealer Zip Field 10202 $(this).find(".dealerZip").prop("id", "data-" + $(this).prop("id")); 10203 $(this).find(".dealerZip").prev().attr("for", "data-" + $(this).prop("id")); 10204 }); 10205 $('.visitDealerModalPublic').on('click touchstart', '.selectDropdown .select-data li a', function() { 10206 var make = $(this).html(); 10207 $('.visitDealerModalPublic input.dealerBrand').attr('value', make); 10208 $('.visitDealerModalPublic input.dealerBrand').prop('value', make); 10209 $('.visitDealerModalPublic div.brandDropdown').removeClass("has-error has-danger"); 10210 brandDropdown(); 10211 }); 10212 $('.visitDealerModalPublic .brandDropdown').on('keydown', function(e) { 10213 if(e.which == 13) { 10214 var selected = $(this).find(".select-data li.active").text(); 10215 $('.visitDealerModalPublic input.dealerBrand').attr('value', selected); 10216 $('.visitDealerModalPublic input.dealerBrand').prop('value', selected); 10217 $('.visitDealerModalPublic div.brandDropdown').removeClass("has-error has-danger"); 10218 brandDropdown(); 10219 } 10220 }); 10221 10222 $('#brandDropdown .dropdown').on('change', function(e) { 10223 $('.modal.in .dealerBrand').attr('value', $(this).val()); 10224 removeSubmitDisabled(); 10225 }); 10226}); 10227 10228function showOfferDetails(e) { 10229 var offersbrand = $('#offers-make-input').val(); 10230 var offersZipcode = $('#offers-zip').val(); 10231 if(offersZipcode) { 10232 $(".myModal.in .dealerZip").val(offersZipcode); 10233 } 10234 if(offersbrand) { 10235 $('.myModal.in .dealer-brand').html(offersbrand); 10236 $('.myModal.in .dealerBrand').prop('value', getMakeCode(offersbrand.toUpperCase())); 10237 } 10238 10239 var formData = { 10240 dealerZip: $('.myModal.in .dealerZip').val().replace(" ", ""), 10241 dealerBrand: $('.myModal.in .dealerBrand').attr('value'), 10242 desiredCount: "5", 10243 requestPath: Base64.encode($(".requestPath").text()) 10244 }; 10245 returnOnValidation("nonpurl", e, formData); 10246} 10247 10248function returnOnValidation(data, e, formData) { 10249 if(!($('.myModal.in .dealerBrand').attr('value') && $('.myModal.in .dealerZip').val())) { 10250 $('.myModal.in .visitdealersubmit').prop('disabled', true); 10251 return; 10252 } 10253 removeSubmitDisabled(); 10254 if($('.myModal.in .visitdealersubmit').prop('disabled')) { 10255 $('.with-errors').show(); 10256 return; 10257 } else { 10258 if(e) { 10259 e.preventDefault(); 10260 } 10261 if(data == "purl" || data == "purlTwo") { 10262 makePurlServiceCall(formData, data); 10263 } else { 10264 makeServiceCall(formData); 10265 } 10266 } 10267} 10268 10269function zipCodeDealerForm(event) { 10270 if($(".zipCodeDealerForm").hasClass('has-error')) { 10271 $('.zipCodeDealerForm > .with-errors').show(); 10272 } 10273 removeSubmitDisabled(); 10274} 10275 10276function brandDropdown() { 10277 if($(".brandDropdown").hasClass('has-error')) { 10278 $('.brandDropdown .with-errors').show(); 10279 } else { 10280 $('.brandDropdown .with-errors').hide(); 10281 } 10282 removeSubmitDisabled(); 10283} 10284 10285function removeSubmitDisabled() { 10286 var regex = $(".zipRegularExpression").html(); 10287 if($('.modal.in .dealerBrand').length > 0 && $('.modal.in .dealerBrand').attr('value') != undefined && 10288 ($('.modal.in .dealerZip').length > 0 && $('.modal.in .dealerZip').val().match(regex))) { 10289 $('.visitdealersubmit').prop('disabled', false); 10290 $('.visitdealersubmit').removeClass('disabled'); 10291 } else { 10292 $('.visitdealersubmit').prop('disabled', true); 10293 } 10294} 10295 10296$(window).on("shown.bs.modal", function() { 10297 if(!getCookie("gmfMyAccount_UserLogon") && !getCookie("eol_uid") && $(".visit-a-dealer.in").length > 0) { 10298 var geoZip = $("html > body").attr("data-geo-zip"); 10299 if(geoZip) { 10300 $(".dealerZip").val(geoZip); 10301 } 10302 $(".visitdealersubmit").on("click touchstart", function() { 10303 var dealerBrand = $(".dealerBrand").attr("value"); 10304 document.cookie = "deal_brnd=" + Base64.encode(dealerBrand) + "; mtracker=0; path=/; Secure; SameSite=Strict"; 10305 }); 10306 if(getCookie("deal_brnd")) { 10307 var dealerBrand = getCookie("deal_brnd"); 10308 dealerBrand = Base64.decode(dealerBrand); 10309 $.each($("#brandDropdown .select-data li"), function(key, val) { 10310 if($(this).attr("value") == dealerBrand) { 10311 if($(this).attr("class") != "active") { 10312 $(this).find("a").click(); 10313 $(this).addClass("active"); 10314 } 10315 $('.modal.in .dealerBrand').attr('value', dealerBrand); 10316 } 10317 }); 10318 10319 $.each($("#brandDropdown .dropdown option"), function(key, val) { 10320 if($(this).attr("data-make") == dealerBrand) { 10321 if($(this).attr("selected") != "selected") { 10322 $(this).click(); 10323 } 10324 $('.modal.in .dealerBrand').attr('value', dealerBrand); 10325 } 10326 }); 10327 } 10328 removeSubmitDisabled(); 10329 } 10330}); 10331 10332$(function() { 10333 initializeForm(); 10334 10335 $('button[data-dismiss=modal]').on('click', function() { 10336 initializeForm(); 10337 }); 10338 10339 10340 $('body').on('hidden.bs.modal', function() { 10341 $('.form-group').removeClass('has-error').removeClass('has-danger'); 10342 }); 10343 10344 10345 // validation for Public 10346 $('.onlinecontactpublic form').validator().on('submit', function(e) { 10347 if(e.isDefaultPrevented()) { 10348 $('.with-errors').show(); 10349 10350 } else { 10351 e.preventDefault(); 10352 $.ajax({ 10353 type: 'POST', 10354 url: '/gmfdyn/sendemail', 10355 data: $(this).serialize(), 10356 success: function(response) { 10357 if($.trim(response).length > 0 && response.trim() === 'Email sent successfully.') { 10358 $(".sendEmailPublicStepTwo").show(); 10359 $(".sendEmailPublicStepOne").hide(); 10360 $('.onlinecontacterror').hide(); 10361 } else { 10362 $(".sendEmailPublicStepTwo").hide(); 10363 $(".sendEmailPublicStepOne").hide(); 10364 $('.onlinecontacterror').show(); 10365 } 10366 }, 10367 error: function(data, errorThrown) { 10368 $(".sendEmailPublicStepTwo").hide(); 10369 $(".sendEmailPublicStepOne").hide(); 10370 $('.onlinecontacterror').show(); 10371 } 10372 }); 10373 } 10374 }); 10375 10376 // validation for PURL 10377 $('.onlinecontactpurl form').validator().on('submit', function(e) { 10378 if(e.isDefaultPrevented()) { 10379 $('.with-errors').show(); 10380 $('.onlinecontactpurl form').validator('update'); 10381 } else { 10382 e.preventDefault(); 10383 $.ajax({ 10384 type: 'POST', 10385 url: '/gmfdyn/sendemail', 10386 data: $(this).serialize(), 10387 success: function(response) { 10388 if($.trim(response).length > 0 && response.trim() === 'Email sent successfully.') { 10389 var successMessageType = $('input[name=questionType]:checked', '#questionType').attr("id"); 10390 if(successMessageType.toLowerCase() != 'complaint') { 10391 $('.sendEmailPurlStepOne').hide(); 10392 $('.ideasuccessmessage').show(); 10393 $('.compaintsuccessmessage').hide(); 10394 $('.onlinecontacterrorpurl').hide(); 10395 } else { 10396 $('.sendEmailPurlStepOne').hide(); 10397 $('.ideasuccessmessage').hide(); 10398 $('.compaintsuccessmessage').show(); 10399 $('.onlinecontacterrorpurl').hide(); 10400 } 10401 } else { 10402 $('.sendEmailPurlStepOne').hide(); 10403 $('.ideasuccessmessage').hide(); 10404 $('.compaintsuccessmessage').hide(); 10405 $('.onlinecontacterrorpurl').show(); 10406 } 10407 }, 10408 error: function(data, errorThrown) { 10409 $('.sendEmailPurlStepOne').hide(); 10410 $('.ideasuccessmessage').hide(); 10411 $('.compaintsuccessmessage').hide(); 10412 $('.onlinecontacterrorpurl').show(); 10413 } 10414 }); 10415 } 10416 }); 10417 10418 //validation for accountNumber 10419 $('#accountNumber').keyup(isNumber).keypress(isNumber); 10420 10421 $('#phoneNumber, #faxNumber').keyup(phonehandler).keypress(phonehandler).blur(phonehandler); 10422 10423 function phonehandler(event) { 10424 var input = this.value.replace(/[^0-9]+/g, ""); 10425 var keyPressed = String.fromCharCode(event.which); 10426 var unicode = event.charCode ? event.charCode : event.keyCode; 10427 if(rx.test(keyPressed) || event.which == 8) { 10428 if(input.length > 3 && input.length <= 5) { 10429 this.value = input.slice(0, 3) + "-" + input.slice(3); 10430 } else if(input.length > 6) { 10431 this.value = input.slice(0, 3) + "-" + input.slice(3, 6) + "-" + input.slice(6); 10432 } 10433 } else if((unicode == 9) && event.which == 0) { 10434 return true; 10435 } else { 10436 return false;
10437 } 10438 } 10439 10440 $('#bestTimeDropdown').on('click', '.dropdown-menu li a', function() { 10441 $('.onlinecontactpurl .dropdown-toggle .option').text(this.innerHTML); 10442 $('.onlinecontactpurl input#bestTimeInput').attr('value', this.innerHTML); 10443 $('.onlinecontactpurl input#bestTimeInput').val($(this).text()); 10444 $('.onlinecontactpurl input#bestTimeInput').trigger('input'); 10445 }); 10446 10447 //display Public and PURL copy based on cookie availability 10448 var isCookie = getCookie("eol_uid"); 10449 if(isCookie != null && isCookie != "") { 10450 isCookie = b64DecodeUnicode(isCookie); 10451 //var jsonString = JSON.parse(isCookie); 10452 var jsonObject = JSON.parse(isCookie); 10453 var validUserAccount = jsonObject["eolData"]["gmfAccountDetail"]["leaseaccount"]; 10454 if(validUserAccount != null && validUserAccount != "") { 10455 $('.onlinecontactpublic').remove(); 10456 } else { 10457 $('.onlinecontactpurl').remove(); 10458 } 10459 } else { 10460 $('.onlinecontactpurl').remove(); 10461 } 10462}); 10463 10464function initializeForm() { 10465 $('.onlinecontacterror').hide(); 10466 $(".sendEmailPublicStepTwo").hide(); 10467 $(".sendEmailPublicStepOne").show(); 10468 10469 $('.sendEmailPurlStepOne').show(); 10470 $('.ideasuccessmessage').hide(); 10471 $('.compaintsuccessmessage').hide(); 10472 $('.onlinecontacterrorpurl').hide(); 10473} 10474 10475var compFormId, 10476 eDatePicker, 10477 complaintDetailsContent = $('.complaintDetailsContent'), 10478 complaintDateInput = $('#date-input'); 10479 10480$(document).ready(function() { 10481 10482 $('.complaintDetailsForm').validator(); 10483 $('.complaintDetailsResult').hide(); 10484 $('.complaintDetailsError').hide(); 10485 $('.complaintDetailsContent').show(); 10486 10487 10488 $('.complaint-date-picker').each(function() { //Iterate through each instance of date picker 10489 var currentDatePicker = $(this); 10490 var eContainerDatePicker = currentDatePicker.parent().parent().next()[0]; //Obtaining relative container for the date-picker to stick to input 10491 eDatePicker = currentDatePicker.datepicker({ //Initialized the input to date picker 10492 container: eContainerDatePicker, 10493 format: "mm/dd/yyyy", 10494 startDate: "-365d", 10495 endDate: "dateToday", 10496 autoclose: true, 10497 forceParse: false, 10498 todayHighlight: true 10499 }); 10500 currentDatePicker.next().click(function() { //Wire up adjacent glyphicon click event to invoke respective date picker 10501 $(eDatePicker).datepicker("show"); 10502 }); 10503 }); 10504 10505 10506 // clear out date picker if date is invalid 10507 complaintDateInput.on("blur", function() { 10508 if($(".complaint-date-group").find(".has-error").length > 0) { 10509 complaintDateInput.val(''); 10510 } 10511 }); 10512 10513 $('.myModal').on('show.bs.modal', function() { 10514 setTimeout(function(e) { 10515 if($('.complaint-details-form').parents('.myModal.in').length > 0) { 10516 var compFormElem = $('.complaint-details-form').parents('.myModal.in'); 10517 for(var i = 0; i < compFormElem.length; i++) { 10518 compFormId = compFormElem.eq(i).attr("id"); 10519 } 10520 } 10521 compFormValidation(compFormId); 10522 preventCloseModalOnHittingEnter(compFormId); 10523 }, 1000); 10524 }); 10525 10526 populateComplaintFormPartyType(); 10527 10528 $('#party-type').on('click', '.dropdown-menu li a', function() { 10529 var div = document.createElement('div'); 10530 div.innerHTML = this.innerHTML; 10531 var partyTypeValue = div.firstChild.nodeValue; 10532 $('#party-type .dropdown-toggle .option').text(partyTypeValue); 10533 $('#party-type #party-type-input').prop('value', partyTypeValue); 10534 $('#party-type .partyTypeOption').prop('value', partyTypeValue); 10535 }); 10536 10537 //Reset the form on either on Cancel and success / failure modal after submission 10538 $('.complaint-submit-form-reset').on('click', function(e) { 10539 $('.complaintDetailsForm').trigger('reset'); 10540 grecaptcha.reset(); 10541 $('#complaint-recpatcha-validation').addClass('hide'); 10542 10543 // Remove radio selection 10544 $('label.radioButtonFunc').removeClass('checked'); 10545 $('input[name=preferred-contact-method]').prop('checked', false); 10546 $('span.iradio_square-blue').removeClass('checked'); 10547 $('#' + compFormId + ' .complaintDetailsForm' + " .phone").attr('required', false); 10548 10549 // Reset Party Type Option to first value 10550 var partyTypeOptFirstValue = $(".dropdown-menu li")[0].innerText; 10551 $('#party-type #party-type-input').prop('value', partyTypeOptFirstValue); 10552 $('#party-type .partyTypeOption').prop('value', partyTypeOptFirstValue); 10553 $('#party-type .dropdown-toggle .option').text(partyTypeOptFirstValue); 10554 }); 10555 10556 $('.complaintDetailButton').on('click', function(e) { 10557 var contactMethodType; 10558 var complaintData = $('#' + compFormId + ' .complaintDetailsForm').serializeArray(); 10559 for(var j = 0; j < complaintData.length; j++) { 10560 if(complaintData[j].name == "phone") { 10561 complaintData[j].value = complaintData[j].value.replace(/-/g, ''); 10562 } 10563 if(complaintData[j].name == "preferred-contact-method") { 10564 contactMethodType = complaintData[j].value; 10565 // Replacing the value from spanish to english as api is accepting only these keywords in preferred contact method 10566 if(complaintData[j].value == "Correo electrónico") { 10567 complaintData[j].value = "Email"; 10568 } else if(complaintData[j].value == "Teléfono") { 10569 complaintData[j].value = "Phone"; 10570 } else if(complaintData[j].value == "No se requiere contacto") { 10571 complaintData[j].value = "No Contact Required"; 10572 } 10573 } 10574 } 10575 validateContactMethod(contactMethodType); 10576 compFormValidation(compFormId); 10577 10578 var buttonDisabled = $(this).hasClass("disabled"); 10579 10580 if(buttonDisabled) { 10581 compFormValidation(compFormId); 10582 } else { 10583 e.preventDefault(); 10584 verifyReCaptchaStatus().then(function() { 10585 $('.complaintDetailButton').prop('disabled', true); 10586 $.ajax({ 10587 type: 'POST', 10588 url: '/gmfdyn/complaintTrackingServlet', 10589 data: $.param(complaintData), 10590 success: function(response) { 10591 $('.complaintDetailsResult').show(); 10592 $('.complaintDetailsContent').hide(); 10593 $('.complaintDetailsError').hide(); 10594 $('#complaint-recpatcha-validation').addClass('hide'); 10595 }, 10596 error: function(data, errorThrown) { 10597 $('.complaintDetailsResult').hide(); 10598 $('.complaintDetailsContent').hide(); 10599 $('.complaintDetailsError').show(); 10600 }, 10601 complete: function () { 10602 $('.complaintDetailButton').prop('disabled', false); 10603 } 10604 }); 10605 }).catch(function() { 10606 $('#complaint-recpatcha-validation').removeClass('hide'); 10607 }); 10608 } 10609 }); 10610 10611 $('#date-input', complaintDetailsContent).keyup(dateHandler).keypress(dateHandler).blur(dateHandler); 10612 10613}); 10614 10615function compFormValidation(compFormId) { 10616 $("#" + compFormId + " .complaintDetailsForm input, #" + compFormId + " .complaintDetailsForm textarea").each(function() { 10617 if((!$(this).val() && $(this).prop('required'))) { 10618 $('.complaintDetailButton').addClass("disabled"); 10619 $('.with-errors').show(); 10620 return; 10621 } 10622 }); 10623} 10624 10625function validateContactMethod(contactType) { 10626 if(typeof contactType !== 'undefined' && contactType !== null) { 10627 if(contactType.toLowerCase().indexOf("phone") != -1) { 10628 $('#' + compFormId + ' .complaintDetailsForm' + " .phone").attr('required', true); 10629 } else { 10630 $('#' + compFormId + ' .complaintDetailsForm' + " .phone").attr('required', false); 10631 } 10632 if(contactType.toLowerCase().indexOf("no contact required") != -1) { 10633 $('#' + compFormId + ' .complaintDetailsForm' + " .phone").attr('required', false); 10634 } 10635 } 10636 compFormValidation(compFormId); 10637} 10638 10639function populateComplaintFormPartyType() { 10640 var partyTypeOpt = document.createElement('div'); 10641 partyTypeOpt.innerHTML = $('.partyTypeOption').val(); 10642 if(partyTypeOpt !== null && partyTypeOpt.firstChild !== null) { 10643 var partyTypeOptValue = partyTypeOpt.firstChild.nodeValue; 10644 $('#party-type #party-type-input').prop('value', partyTypeOptValue); 10645 $('#party-type .dropdown-toggle .option').text(partyTypeOptValue); 10646 } 10647} 10648 10649function dateHandler(event) { 10650 var input = this.value.replace(/[^0-9]+/g, ""), 10651 keyPressed = String.fromCharCode(event.which), 10652 unicode = event.charCode ? event.charCode : event.keyCode; 10653 if(rx.test(keyPressed) || event.which == 8) { 10654 $(eDatePicker).datepicker("show"); 10655 if(input.length > 2 && input.length <= 4) { 10656 this.value = input.slice(0, 2) + "-" + input.slice(2); 10657 10658 } else if(input.length > 4) { 10659 this.value = input.slice(0, 2) + "-" + input.slice(2, 4) + "-" + input.slice(4); 10660 } 10661 } else if((unicode == 9) && event.which == 0) { 10662 return true; 10663 } 10664} 10665 10666$('body').on('mouseover', '#contactMethod .iradio_square-blue', function(e) { 10667 $(this).addClass('hover'); 10668}).on('mouseout', '#contactMethod .iradio_square-blue', function(e) { 10669 $(this).removeClass('hover'); 10670}).on('click', '#contactMethod .iradio_square-blue', function(e) { 10671 validateContactMethod($(this).parent().find('[type=radio]').val()); 10672 $('span').removeClass('checked'); 10673 $(this).addClass('checked'); 10674 $('#contactMethod input').prop('checked', false); 10675 $(this).next('input').prop('checked', true); 10676}); 10677 10678function preventCloseModalOnHittingEnter(compFormId) { 10679 var fieldsComplaintForm = $("#" + compFormId + " .complaintDetailsForm input, #" + compFormId + " .complaintDetailsForm textarea"); 10680 fieldsComplaintForm.on("keypress", function(e) { 10681 if(e.keyCode == 13) { 10682 e.preventDefault(); 10683 } 10684 }); 10685} 10686 10687$(document).ready(function() { 10688 $('.sendComplaintStepOne').show(); 10689 $('.sendComplaintSecondary').hide(); 10690 $('.sendComplaintPrimary').hide(); 10691 if($('.primary-popup') != null) { 10692 var x = $('.primary-popup'); 10693 for(i = 0; i < x.length; i++) { 10694 if(x[i].parentElement.nodeName == "A") { 10695 x[i].parentElement.setAttribute('class', 'buttonoverlay primaryPopup'); 10696 } else if(x[i].firstChild.nodeName == 'A') { 10697 x[i].firstChild.setAttribute('class', 'buttonoverlay primaryPopup'); 10698 } 10699 } 10700 } 10701 10702 if($('.secondary-popup') != null) { 10703 var x = $('.secondary-popup'); 10704 for(i = 0; i < x.length; i++) { 10705 if(x[i].parentElement.nodeName == "A") { 10706 x[i].parentElement.setAttribute('class', 'buttonoverlay
10706secondaryPopup'); 10707 } else if(x[i].firstChild.nodeName == 'A') { 10708 x[i].firstChild.setAttribute('class', 'buttonoverlay secondaryPopup'); 10709 } 10710 } 10711 } 10712}); 10713 10714$(document).on('click', '.primaryPopup', function(e) { 10715 $('.sendComplaintStepOne').hide(); 10716 $('.sendComplaintSecondary').hide(); 10717 $('.sendComplaintPrimary').show(); 10718}); 10719$(document).on('click', '.secondaryPopup', function(e) { 10720 $('.sendComplaintStepOne').hide(); 10721 $('.sendComplaintSecondary').show(); 10722 $('.sendComplaintPrimary').hide(); 10723}); 10724$('body').on('hidden.bs.modal', function(e) { 10725 $('.sendComplaintStepOne').show(); 10726 $('.complaintDetailsContent').show(); 10727 $('.sendComplaintSecondary').hide(); 10728 $('.sendComplaintPrimary').hide(); 10729 $('.complaintDetailsError').hide(); 10730 $('.complaintDetailsResult').hide(); 10731}); 10732 10733$(document).ready(function() { 10734 $('.emailsubscription').validator(); 10735 $('.emailsubsresult').hide(); 10736 $('.emailsubserror').hide(); 10737 $(".alertTypes").on("change", function() { 10738 checkboxValidator($(".alertTypes"), $('.emailsubscription'), 1); 10739 displayErrors(); 10740 }); 10741 10742 $('.emailsubscription .form-group').removeClass('has-error').removeClass('has-danger'); 10743 $('.emailsubscription .with-errors').hide(); 10744 $('.emailsubsemail').val(''); 10745 10746 function checkboxValidator(group, form, goal) { 10747 var isChecked = false; 10748 if(group.filter(':checked').length >= goal) { 10749 isChecked = true; 10750 } 10751 group.not(':checked').prop('required', !isChecked); 10752 form.validator('destroy').validator(); 10753 if(!isChecked) { 10754 $(form).find(".alertTypes").attr('class', 'icheckbox_square-blue alertTypes error'); 10755 } else { 10756 $(form).find(".alertTypes").attr('class', 'icheckbox_square-blue alertTypes'); 10757 } 10758 } 10759 10760 $('.emailsubsbutton').on('click touchstart', function(e) { 10761 $(".alertTypes").change(); 10762 if(!($(".alertTypes").is(":checked") && $('.emailsubsemail').val())) { 10763 $('.emailsubsbutton').addClass("disabled"); 10764 $('.emailsubscription .with-errors').show(); 10765 if($('.help-block.with-errors').hasClass("hide")) { 10766 $('.help-block.with-errors').removeClass("hide"); 10767 } 10768 return; 10769 } 10770 10771 if($(this).hasClass("disabled")) { 10772 $('.with-errors').show(); 10773 return; 10774 } else { 10775 var alerts = []; 10776 $('.alertTypes:checked').each(function() { 10777 alerts.push($(this).val()); 10778 }); 10779 10780 e.preventDefault(); 10781 $.ajax({ 10782 type: 'POST', 10783 url: '/gmfdyn/emailSubscription', 10784 data: 'email=' + $('.emailsubsemail').val() + '&alertTypes=' + alerts.join('&alertTypes='), 10785 success: function(response) { 10786 if($.trim(response).length > 0) { 10787 var jsonData = JSON.parse(response); 10788 if(!(Object.keys(jsonData).length === 0)) { 10789 for(var i = 0; i < jsonData.responseCode.length; i++) { 10790 var counter = jsonData.responseCode[i]; 10791 if(counter == "0") { 10792 $('.emailsubsresult').show(); 10793 } else { 10794 $('.emailsubserror').show(); 10795 } 10796 break; 10797 } 10798 } else { 10799 $('.emailsubserror').show(); 10800 } 10801 } else { 10802 $('.emailsubserror').show(); 10803 } 10804 }, 10805 error: function(data, errorThrown) { 10806 $('.emailsubserror').show(); 10807 } 10808 }); 10809 } 10810 }); 10811}); 10812 10813$('.emailsubscription .emailsubsemail').keyup(displayErrors).keypress(displayErrors).blur(displayErrors); 10814 10815function displayErrors() { 10816 if($(".emailsubscription .form-group").hasClass('has-error')) { 10817 $('.emailsubscription .with-errors').show(); 10818 } 10819 if($(".alertTypes").hasClass('error')) { 10820 if($('.help-block.with-errors').hasClass("hide")) { 10821 $('.help-block.with-errors').removeClass("hide"); 10822 } 10823 $('.emailsubscription .with-errors').show(); 10824 } 10825} 10826 10827$(function() { 10828 10829 initilizeForm(); 10830 10831 $('.general_inquiry form').validator().on('submit', function(e) { 10832 if(e.isDefaultPrevented()) { 10833 $('.with-errors').show(); 10834 } else { 10835 e.preventDefault(); 10836 $.ajax({ 10837 type: 'POST', 10838 url: '/gmfdyn/sendemail', 10839 data: $(this).serialize(), 10840 success: function(response) { 10841 if($.trim(response).length > 0 && response.trim() === 'Email sent successfully.') { 10842 $(".general_inquiry_result").show(); 10843 $(".general_inquiry_content").hide(); 10844 $('.general_inquiry_error').hide(); 10845 } else { 10846 $(".general_inquiry_result").hide(); 10847 $(".general_inquiry_content").hide(); 10848 $('.general_inquiry_error').show(); 10849 } 10850 }, 10851 error: function(data, errorThrown) { 10852 $(".general_inquiry_result").hide(); 10853 $(".general_inquiry_content").hide(); 10854 $('.general_inquiry_error').show(); 10855 } 10856 }); 10857 } 10858 }); 10859 10860 // On Modal close, reset to default state 10861 $('body').on('hidden.bs.modal', function() { 10862 setTimeout(function() { 10863 initilizeForm(); 10864 }, 500); 10865 }); 10866 10867}); 10868 10869function initilizeForm() { 10870 $('.general_inquiry_error').hide(); 10871 $(".general_inquiry_result").hide(); 10872 $(".general_inquiry_content").show(); 10873 $(".general_inquiry_content .submit-btn").addClass("disabled"); 10874} 10875 10876$(document).ready(function() { 10877 if($('.make-call').length > 0) { 10878 $('.make-call').on('click', function() { 10879 var call = $(this)[0].innerHTML; 10880 window.location.href = "tel:" + call; 10881 }); 10882 } 10883 10884 if($('.mileage_calculator_popup').length > 0) { 10885 var x = $('.mileage_calculator_popup'); 10886 var mileageCalcModalID = $('#mileage-calculator-modal-id').html(); 10887 if(mileageCalcModalID) { 10888 for(i = 0; i < x.length; i++) { 10889 if(x[i].parentElement.nodeName == "A") { 10890 x[i].parentElement.setAttribute('data-toggle', 'modal'); 10891 x[i].parentElement.setAttribute('data-target', '#' + mileageCalcModalID); 10892 x[i].parentElement.setAttribute('class', 'buttonoverlay'); 10893 } else if(x[i].firstChild.nodeName == 'A') { 10894 x[i].firstChild.setAttribute('data-toggle', 'modal'); 10895 x[i].firstChild.setAttribute('data-target', '#' + mileageCalcModalID); 10896 x[i].firstChild.setAttribute('class', 'buttonoverlay'); 10897 } 10898 } 10899 } 10900 } 10901 10902 10903 if($('.schedule_inspection_popup').length > 0) { 10904 var x = $('.schedule_inspection_popup'); 10905 var scheduleInspectionModalId = $('#schedule-inspection-modal-id').html(); 10906 if(scheduleInspectionModalId) { 10907 for(i = 0; i < x.length; i++) { 10908 if(x[i].parentElement.nodeName == "A") { 10909 x[i].parentElement.setAttribute('data-toggle', 'modal'); 10910 x[i].parentElement.setAttribute('data-target', '#' + scheduleInspectionModalId); 10911 x[i].parentElement.setAttribute('class', 'buttonoverlay'); 10912 } else if(x[i].firstChild.nodeName == 'A') { 10913 x[i].firstChild.setAttribute('data-toggle', 'modal'); 10914 x[i].firstChild.setAttribute('data-target', '#' + scheduleInspectionModalId); 10915 x[i].firstChild.setAttribute('class', 'buttonoverlay'); 10916 } 10917 } 10918 } 10919 } 10920 10921 if($('.send_inquiry_popup').length > 0) { 10922 var x = $('.send_inquiry_popup'); 10923 var sendInquiryModalId = $('#send-inquiry-richtext-modal-id').html(); 10924 if(sendInquiryModalId) { 10925 for(i = 0; i < x.length; i++) { 10926 if(x[i].parentElement.nodeName == 'A') { 10927 x[i].parentElement.setAttribute('data-toggle', 'modal'); 10928 x[i].parentElement.setAttribute('data-target', '#' + sendInquiryModalId); 10929 x[i].parentElement.setAttribute('class', 'buttonoverlay'); 10930 } else if(x[i].firstChild.nodeName == 'A') { 10931 x[i].firstChild.setAttribute('data-toggle', 'modal'); 10932 x[i].firstChild.setAttribute('data-target', '#' + sendInquiryModalId); 10933 x[i].firstChild.setAttribute('class', 'buttonoverlay'); 10934 } 10935 } 10936 } 10937 } 10938 10939 // Open the "Visit Dealer" popup modal 10940 openModal(".visit_dealer_popup", "#visit-dealer-modal-id", "#visitDealerModal"); 10941 10942 // Open the "Request Information" popup modal 10943 openModal(".request_information_modal", "#request-information-modal-id", "#requestInformationModal"); 10944 10945 if($('.online-contact-form-popup').length > 0) { 10946 var x = $('.online-contact-form-popup'); 10947 var onlineContactFormModalID = $('#online-contact-form-modal-id').html(); 10948 if(onlineContactFormModalID) { 10949 for(i = 0; i < x.length; i++) { 10950 if(x[i].parentElement.nodeName == "A") { 10951 x[i].parentElement.setAttribute('data-toggle', 'modal'); 10952 x[i].parentElement.setAttribute('data-target', '#' + onlineContactFormModalID); 10953 x[i].parentElement.setAttribute('class', 'buttonoverlay'); 10954 } else if(x[i].firstChild.nodeName == 'A') { 10955 x[i].firstChild.setAttribute('data-toggle', 'modal'); 10956 x[i].firstChild.setAttribute('data-target', '#' + onlineContactFormModalID); 10957 x[i].firstChild.setAttribute('class', 'buttonoverlay'); 10958 } 10959 } 10960 } 10961 } 10962 10963 /* 10964 * Open the popup modal 10965 * 10966 * TODO: Let's revisit this design in the future. Currently, there was a hack on the headingComp for pages like "get-inspected.html" where it's coded to search for the existing of the primary "Visit Dealer" modal HTML markup 10967 * 10968 * @param {String} targetSelector - The class/id name of the target element that the user clicks on to open the popup modal 10969 * @param {String} modalSelectorPrimary - The class/id name of the primary modal. NOTE: Example is the Help and
10969Support component containing the modal's HTML markup 10970 * @param {String} modalSelectorSecondary - The class/id name of the secondary modal. NOTE: Example is the Promo Standard component containing the modal's HTML markup 10971 */ 10972 function openModal(targetSelector, modalSelectorPrimary, modalSelectorSecondary) { 10973 var $targetSelector = $(targetSelector), 10974 targetSelectorLength = $targetSelector.length; 10975 10976 // Ensure the target element's selector exists 10977 if(targetSelectorLength > 0) { 10978 var constant = { 10979 DATA_TOGGLE: "data-toggle", 10980 DATA_TARGET: "data-target", 10981 CLASS: "class", 10982 MODAL: "modal", 10983 BUTTON_OVERLAY: "buttonoverlay" 10984 }, 10985 foundModalSelectorPrimary = $(modalSelectorPrimary).html(), 10986 foundModalSelector = foundModalSelectorPrimary || modalSelectorSecondary, // Verify if the primary modal exists. Otherwise, use the secondary one. This was a bad hack!!! 10987 dataTarget = (foundModalSelectorPrimary) ? (modalSelectorPrimary.substring(0, 1) + foundModalSelector) : foundModalSelector; 10988 10989 if(foundModalSelector) { 10990 for(i = 0, j = targetSelectorLength; i < j; i++) { 10991 var $currentElement = $targetSelector[i], 10992 $parent = $currentElement.parentElement, 10993 $firstChild = $currentElement.firstChild, 10994 parentNodeName = $parent.nodeName, 10995 childNodeName = $firstChild.nodeName, 10996 isAnchorElement = parentNodeName === "A" || childNodeName === "A", 10997 $executableNode = (parentNodeName === "A") ? $parent : $firstChild; 10998 10999 if(isAnchorElement) { 11000 $executableNode.setAttribute(constant.DATA_TOGGLE, constant.MODAL); 11001 $executableNode.setAttribute(constant.DATA_TARGET, dataTarget); 11002 $executableNode.setAttribute(constant.CLASS, constant.BUTTON_OVERLAY); 11003 } 11004 } 11005 } 11006 } 11007 } 11008}); 11009 11010$(function() { 11011 $('.modal-success').hide(); 11012 $('.modal-error').hide(); 11013 $('.informationrequest-close').hide(); 11014 11015 $('.dropdown-menu li a').on('click', function() { 11016 $('#state-option').text($(this).text()); 11017 $('#state').attr('value', $(this).text()); 11018 $('#state').val($(this).text()); 11019 $('#state').trigger('input'); 11020 }); 11021 11022 $('.btn-dropdown ul a').click(function() { 11023 var drpvalue = $(this).closest('div').children('input').attr('value'); 11024 if(drpvalue) { 11025 $(this).closest('div').removeClass('has-error'); 11026 } else if($(this).text()) { 11027 $(this).closest('div').removeClass('has-error'); 11028 } 11029 }); 11030 11031 $('#state-input').on('change', function() { 11032 $('#information-request-form').validator(); 11033 }); 11034 11035 $('#state-input').on('click', function() { 11036 $("ul.dropdown-menu ").animate({ 11037 scrollTop: 0 11038 }, "fast"); 11039 }); 11040 11041 // On Modal close clear form and reset to default state 11042 $('body').on('hidden.bs.modal', function() { 11043 setTimeout(function() { 11044 $("ul.dropdown-menu li").removeClass('dd-focus'); 11045 $('#state-option').text(''); 11046 $('#state').attr('value', ''); 11047 $('#informationrequest-submit').addClass('disabled'); 11048 $('.modal-body').find('textarea,select').val(''); 11049 $('.modal-body').find("input[type!='hidden']").not("input[type='radio']").val(''); 11050 $('.information-request-content').show(); 11051 $('.modal-error').hide(); 11052 $('.modal-success').hide(); 11053 $('.informationrequest-close').hide(); 11054 $('#informationrequest-cancel').show(); 11055 $('#informationrequest-submit').show(); 11056 }, 500); 11057 }); 11058 11059 $('#information-request-form').validator().on('submit', function(e) { 11060 if(e.isDefaultPrevented()) { 11061 $('.with-errors').show(); 11062 $('#state').addClass('has-error has-danger'); 11063 } else { 11064 11065 11066 $.ajax({ 11067 type: 'POST', 11068 url: '/gmfdyn/sendemail', 11069 data: $(this).serialize(), 11070 success: function(response) { 11071 if($.trim(response).length > 0 && response.trim() === 'Email sent successfully.') { 11072 $('.information-request-content').hide(); 11073 $('.modal-success').show(); 11074 $('#informationrequest-cancel').hide(); 11075 $('#informationrequest-submit').hide(); 11076 $('.informationrequest-close').show(); 11077 } else { 11078 $('.information-request-content').hide(); 11079 $('.modal-error').show(); 11080 $('#informationrequest-cancel').hide(); 11081 $('#informationrequest-submit').hide(); 11082 $('.informationrequest-close').show(); 11083 } 11084 }, 11085 error: function(data, errorThrown) { 11086 $('.information-request-content').hide(); 11087 $('.modal-error').show(); 11088 $('#informationrequest-cancel').hide(); 11089 $('#informationrequest-submit').hide(); 11090 $('.informationrequest-close').show(); 11091 } 11092 }); 11093 } 11094 11095 e.preventDefault(); 11096 }); 11097}); 11098 11099var rx = /\d/; 11100 11101$('#zipCode').keyup(ziphandler).keypress(ziphandler).blur(ziphandler); 11102 11103function ziphandler(event) { 11104 setTimeout(function() { 11105 if($(".zipCodeform").hasClass('has-error')) { 11106 $('.zipCodeform > .with-errors').show(); 11107 } 11108 }, 1000); 11109 var input = this.value.replace(/[^0-9]+/g, ""); 11110 var keyPressed = String.fromCharCode(event.which); 11111 var unicode = event.charCode ? event.charCode : event.keyCode; 11112 if(rx.test(keyPressed) || event.which == 8) { 11113 if(input.length > 5) { 11114 this.value = input.slice(0, 5) + "-" + input.slice(5); 11115 } 11116 } else if((unicode == 9) && event.which == 0) { 11117 return true; 11118 } else { 11119 return false;
11120 } 11121} 11122 11123$('#phoneNumber, #faxNumber').keyup(phonehandler).keypress(phonehandler).blur(phonehandler); 11124 11125function phonehandler(event) { 11126 setTimeout(function() { 11127 if($(".phoneNumberform").hasClass('has-error')) { 11128 $('.phoneNumberform > .with-errors').show(); 11129 } 11130 }, 1000); 11131 var input = this.value.replace(/[^0-9]+/g, ""); 11132 var keyPressed = String.fromCharCode(event.which); 11133 var unicode = event.charCode ? event.charCode : event.keyCode; 11134 if(rx.test(keyPressed) || event.which == 8) { 11135 if(input.length > 3 && input.length <= 5) { 11136 this.value = input.slice(0, 3) + "-" + input.slice(3); 11137 } else if(input.length > 6) { 11138 this.value = input.slice(0, 3) + "-" + input.slice(3, 6) + "-" + input.slice(6); 11139 } 11140 } else if((unicode == 9) && event.which == 0) { 11141 return true; 11142 } else { 11143 return false; 11144 } 11145} 11146 11147var GMFApp = {}; 11148GMFApp = GMFApp || {}; 11149 11150GMFApp.utils = GMFApp.utils || {}; 11151 11152GMFApp.utils.cookie = (function () { 11153 function getCookie(cookieName) { 11154 var name = cookieName + '='; 11155 var cookieArray = document.cookie.split(';'); 11156 var cookie; 11157 var i; 11158 for (i = 0; i < cookieArray.length; i++) { 11159 cookie = cookieArray[i]; 11160 while (cookie.charAt(0) == ' ') { 11161 cookie = cookie.substring(1); 11162 } 11163 if (cookie.indexOf(name) == 0) { 11164 return cookie.substring(name.length, cookie.length); 11165 } 11166 } 11167 return ''; 11168 } 11169 11170 function setCookie(name, value, expireDays) { 11171 var date = new Date(); 11172 var expires; 11173 date.setTime(date.getTime() + expireDays * 24 * 60 * 60 * 1000); //cookie expire date 11174 expires = 'expires=' + date.toGMTString(); 11175 document.cookie = name + '=' + value + ';' + expires + ';path=/'; 11176 } 11177 11178 function setNoTimeCookie(name, value) { 11179 document.cookie = name + '=' + value + ';path=/'; 11180 } 11181 11182 function deleteCookie(name) { 11183 var date = new Date(); 11184 var expires; 11185 date.setDate(date.getDate() - 1); 11186 expires = 'expires=' + date.toGMTString(); 11187 document.cookie = name + '=' + ';' + expires + ';path=/'; 11188 } 11189 11190 return { 11191 getCookie: getCookie, 11192 setCookie: setCookie, 11193 setNoTimeCookie: setNoTimeCookie, 11194 deleteCookie: deleteCookie 11195 }; 11196})(); 11197var isLEWindowsShowing = false; 11198var isLECallback = false; 11199function nth_occurrence(string, char, nth) { 11200 var first_index = string.indexOf(char); 11201 var length_up_to_first_index = first_index + 1; 11202 11203 if (nth == 1) { 11204 return first_index; 11205 } else { 11206 var string_after_first_occurrence = string.slice(length_up_to_first_index); 11207 var next_occurrence = nth_occurrence(string_after_first_occurrence, char, nth - 1); 11208 11209 if (next_occurrence === -1) { 11210 return -1; 11211 } else { 11212 return length_up_to_first_index + next_occurrence; 11213 } 11214 } 11215} 11216var chatCloseCheckInterval; 11217//*** messaging icon placement when window scrolling. 11218//*** 11219// Returns a function, that, as long as it continues to be invoked, will not 11220// be triggered. The function will be called after it stops being called for 11221// N milliseconds. If `immediate` is passed, trigger the function on the 11222// leading edge, instead of the trailing. 11223function debounce(func, wait, immediate) { 11224 var timeout; 11225 return function () { 11226 var context = this, args = arguments; 11227 var later = function () { 11228 timeout = null; 11229 if (!immediate) func.apply(context, args); 11230 }; 11231 var callNow = immediate && !timeout; 11232 clearTimeout(timeout); 11233 timeout = setTimeout(later, wait); 11234 if (callNow) func.apply(context, args); 11235 }; 11236}; 11237 11238var calMessagingPositionDelay = debounce(function () { 11239 calMessagingPosition(); 11240}, 500); 11241 11242function isScrolledIntoView(elem) { 11243 var docViewTop = $(document).scrollTop(); 11244 var docViewBottom = docViewTop + $(window).height(); 11245 var elemTop = $(elem).offset().top; 11246 var elemBottom = elemTop + $(elem).height(); 11247 return (elemTop <= docViewBottom); 11248} 11249 11250function calMessagingPosition() { 11251 var path = window.location.href; 11252 var msg_container = document.getElementById("messaging-container"); 11253 //NM:: Item 11978 Message ICON fro CustomerSupport (middle of the page),for all other pages(bottom) 11254 if (/contact-us/.test(self.location.href)) { 11255 // msg_container.style.position = 'relative'; 11256 } else { 11257 if (msg_container != undefined && msg_container != null) { 11258 11259 if (isScrolledIntoView($('.main-footer'))) { 11260 var docViewTop = $(document).scrollTop(); 11261 var docViewBottom = docViewTop + $(window).height(); 11262 var elemTop = $(".main-footer").offset().top; 11263 var iconBottom = docViewBottom - elemTop + 15; 11264 msg_container.style.bottom = iconBottom + "px"; 11265 msg_container.style.position = 'fixed'; 11266 } 11267 else { 11268 msg_container.style.bottom = "15px"; 11269 msg_container.style.position = 'fixed'; 11270 } 11271 //Fix for icon overlapping grey area in mobile 11272 if (browser.mobile) { 11273 msg_container.style.bottom = "15px"; 11274 msg_container.style.position = 'fixed'; 11275 } 11276 } 11277 } 11278} 11279 11280 11281//*** hide messaging icon when conversation started. 11282//*** 11283function hideMessagingIcon() { 11284 var msg_div = $(".header-msg-container"); 11285 if (msg_div != undefined && msg_div.length > 0) { 11286 for(var i=0;i<msg_div.length;i++){ 11287 msg_div[i].style.display = 'none'; 11288 } 11289 } 11290}; 11291 11292function showMessagingIcon() { 11293 var msg_div = $(".header-msg-container"); 11294 if (msg_div != undefined && msg_div.length > 0) { 11295 for(var i=0;i<msg_div.length;i++){ 11296 msg_div[i].style.display = 'block'; 11297 } 11298 } 11299}; 11300 11301function checkMessagingWindow() { 11302 var msg_window; 11303 showMessagingIcon(); 11304} 11305 11306function closeMessagingWindowClick() { 11307 setTimeout(function () { 11308 checkMessagingWindow(); 11309 }, 1000); 11310} 11311 11312function bindOpenCloseBtnClick() { 11313 var open_close_btn = document.getElementsByClassName("openclose-trigger"); 11314 var i; 11315 for (i = 0; i < open_close_btn.length; i++) { 11316 open_close_btn[i].addEventListener("click", calMessagingPositionDelay); 11317 } 11318} 11319 11320var chatCheckCount = 0; 11321 11322$(document).ready(function() { 11323 11324 // add listeners to openclose-trigger 11325 bindOpenCloseBtnClick(); 11326 // wait 1 sec and cal initial position the Messaging icon 11327 setTimeout(function () { 11328 // calMessagingPosition(); 11329 //HDO:: INFO - check for chat transition 11330 if (!isLECallback) { 11331 //Test CustomerSupport 11332 chatCloseCheckInterval = setInterval(checkForChatCloseBtn, 500); 11333 } 11334 11335 }, 2500); 11336 11337 //HDO:: INFO - determine to show or hide messaging icon 11338 setTimeout(function () { 11339 if (isLEWindowsShowing || isLECallback) { 11340 hideMessagingIcon(); 11341 } else { 11342 showMessagingIcon(); 11343 } 11344 }, 7000); 11345 11346}); 11347 11348function checkForChatCloseBtn() { 11349 var lp_close_btn = document.getElementsByClassName("lp_close"); 11350 if (chatCheckCount < 6 && (lp_close_btn == undefined || lp_close_btn.length == 0)) { 11351 isLEWindowsShowing = false;
11352 chatCheckCount++; 11353 showMessagingIcon(); 11354 } else { 11355 11356 if (chatCheckCount == 6) { 11357 isLEWindowsShowing = false; 11358 showMessagingIcon(); 11359 } 11360 else { 11361 isLEWindowsShowing = true; 11362 bindLPCloseBtnClick(); 11363 } 11364 clearInterval(chatCloseCheckInterval); 11365 chatCheckCount = 0; 11366 } 11367} 11368 11369function bindLPCloseBtnClick() { 11370 var lp_close_btn = document.getElementsByClassName("lp_close"); 11371 var i; 11372 for (i = 0; i < lp_close_btn.length; i++) { 11373 lp_close_btn[i].addEventListener("click", closeMessagingWindowClick); 11374 } 11375} 11376$(function() { 11377 var ErrorCount = 0; 11378 var pageName; 11379 function UpdateErrorCount(pageErrors) { 11380 // Calling this on the form submit events, so not counting errors yet 11381 var sendError = function () { 11382 if (typeof lpTag.sdes.send === 'function') { 11383 path(); 11384 writeLivePersonError(ErrorCode(), ErrorMessage()); 11385 console.log("writeLivePersonError called"); 11386 return true; 11387 } else { 11388 setTimeout(sendError, 250); 11389 } 11390 } 11391 sendError(); 11392 } 11393 11394 11395 //Add page specific error codes here 11396 function ErrorCode() { 11397 switch (pageName) { 11398 case "login": 11399 return "L-1-001"; 11400 case "security-questions": 11401 return "L-1-001"; 11402 case "registration": 11403 return "R-1-001"; 11404 default: 11405 return "L-1-001" 11406 } 11407 } 11408 11409 //Add page specific error messages here 11410 function ErrorMessage() { 11411 switch (pageName) { 11412 case "login": 11413 return "Login Error Encountered"; 11414 case "security-questions": 11415 return "Login Error Encountered"; 11416 case "registration": 11417 return "Registration Error Encountered"; 11418 default: 11419 return "Login Error Encountered" 11420 } 11421 } 11422 11423 function path() { 11424 pageName = window.location.pathname; 11425 if(/registration/.test(window.location.href)) { 11426 pageName = "registration" 11427 } else if(/home/.test(window.location.href) || /security-questions/.test(window.location.href)) { 11428 pageName = "login" 11429 } 11430 return pageName 11431 } 11432 11433 //Passing Engagement Attributes (EAs) 11434 function writeLivePersonError(lperrorcode, lperrormessage) { 11435 lpTag.sdes = lpTag.sdes || []; 11436 lpTag.sdes.send({ 11437 type: "error", 11438 error: { 11439 message: lperrormessage, // THE ERROR MESSAGE. Variable of String type to be used to provide information to agents. 11440 code: lperrorcode // THE ERROR CODE. Variable of String type to passed when visitor experience multiple login errors. 11441 } 11442 }) 11443 } 11444 11445 //Passing Engagement Attributes - Login Complete(EAs) 11446 function writeLivePersonLoginComplete() { 11447 lpTag.sdes = lpTag.sdes || []; 11448 lpTag.sdes.push({ 11449 type: "service", //MANDATORY 11450 service: { 11451 topic: "Login Complete", // SERVICE ACTIVITY TOPIC OR NAME - Login Complete or Registration Complete, for example 11452 status: 0 // STATUS ENUM 11453 // 0-Complete, 1-In Progress, 2-Approved, 3-cancelled, 4-Not Approved, 11454 // 5-Reviewed, 6-Missing Details, 7-Closed, 8-Removed, 9-Assigned, 11455 // 10-Waiting for Customer Response, 11-Waiting for Response, 12-Pending, 13-Resolved 11456 } 11457 }) 11458 } 11459 11460 //Passing Engagement Attributes - Registartion Complete(EAs) 11461 function writeLivePersonRegistrationComplete() { 11462 lpTag.sdes = lpTag.sdes || []; 11463 lpTag.sdes.push( 11464 { 11465 "type": "service", //MANDATORY 11466 "service": { 11467 "topic": "Registration Complete", // SERVICE ACTIVITY TOPIC OR NAME - Login Complete or Registration Complete, for example 11468 "status": 0 // STATUS ENUM 11469 // 0-Complete, 1-In Progress, 2-Approved, 3-cancelled, 4-Not Approved, 11470 // 5-Reviewed, 6-Missing Details, 7-Closed, 8-Removed, 9-Assigned, 11471 // 10-Waiting for Customer Response, 11-Waiting for Response, 12-Pending, 13-Resolved 11472 } 11473 } 11474 ); 11475 } 11476 11477 function writeLivePersonError(n, t) { 11478 lpTag.sdes.push({ 11479 type: "error", 11480 error: { 11481 code: n, 11482 message: t 11483 } 11484 }); 11485 try { 11486 lpTag.sdes.send() 11487 } catch (i) {} 11488 } 11489 11490 var browser = gmfxMomentumServices.BrowserInfo.getBrowserInfo(); 11491 11492 //*** messaging icon placement when window scrolling. 11493 //*** 11494 //Returns a function, that, as long as it continues to be invoked, will not 11495 //be triggered. The function will be called after it stops being called for 11496 //N milliseconds. If `immediate` is passed, trigger the function on the 11497 //leading edge, instead of the trailing. 11498 function debounce(func, wait, immediate) { 11499 var timeout; 11500 return function () { 11501 var context = this, args = arguments; 11502 var later = function () { 11503 timeout = null;
11504 if (!immediate) func.apply(context, args); 11505 }; 11506 var callNow = immediate && !timeout; 11507 clearTimeout(timeout); 11508 timeout = setTimeout(later, wait); 11509 if (callNow) func.apply(context, args); 11510 }; 11511 }; 11512 11513 function waitForChatWindow() { 11514 hideChatIcon(); 11515 11516 //*** binding click event to messaging window close button - check until close button are not hidden. 11517 checkForLPCloseBtn(); 11518 } 11519 11520 function checkForLPCloseBtn() { 11521 var lp_close_btn = document.getElementsByClassName("lp_close"); 11522 var lp_close_btn_hidden = document.getElementsByClassName("lp_close lp_hidden"); 11523 11524 if (lp_close_btn_hidden == undefined || lp_close_btn_hidden.length == 0) { 11525 11526 bindLPCloseBtnClick(); 11527 //add "web-cont" class so we don't print messaging window 11528 if (browser.mobile) { 11529 var lp_mobile = document.getElementsByClassName("lp_mobile"); 11530 if(lp_mobile.length>0){ 11531 lp_mobile[0].classList.add("web-cont"); 11532 } 11533 } 11534 else { 11535 var lp_desktop = document.getElementsByClassName("lp_desktop"); 11536 // lp_desktop[0].classList.add("web-cont"); 11537 } 11538 } 11539 } 11540 11541 function bindLPCloseBtnClick() { 11542 var lp_close_btn = document.getElementsByClassName("lp_close"); 11543 var i; 11544 for (i = 0; i < lp_close_btn.length; i++) { 11545 lp_close_btn[i].addEventListener("click", closeChatWindowClick); 11546 } 11547 } 11548 11549 //*** hide Chat icon when conversation started. 11550 //*** 11551 function hideChatIcon() { 11552 var chat_div = document.getElementsByClassName("LPMcontainer"); 11553 if (chat_div != undefined && chat_div.length > 0) { 11554 for(var i=0;i<chat_div.length;i++){ 11555 chat_div[i].style.display = 'none'; 11556 } 11557 } 11558 } 11559 11560 function showChatIcon() { 11561 var chat_div = document.getElementsByClassName("LPMcontainer"); 11562 if (chat_div != undefined && chat_div.length > 0) { 11563 for(var i=0;i<chat_div.length;i++){ 11564 chat_div[i].style.display = 'block'; 11565 } 11566 } 11567 } 11568 11569 function checkChatWindow() { 11570 var chat_window; 11571 if (browser.mobile) { 11572 chat_window = document.getElementsByClassName("lp_mobile"); 11573 } 11574 else { 11575 chat_window = document.getElementsByClassName("lp_desktop"); 11576 } 11577 if (chat_window == undefined || chat_window.length == 0) { 11578 showChatIcon(); 11579 } 11580 } 11581 11582 function closeChatWindowClick() { 11583 setTimeout(function () { 11584 checkChatWindow(); 11585 }, 1000); 11586 } 11587 11588 $('.LPMimage').on('click', function(e){ 11589 e.preventDefault(); 11590 waitForChatWindow(); 11591 }); 11592 11593 function nth_occurrence(string, char, nth) { 11594 var first_index = string.indexOf(char); 11595 var length_up_to_first_index = first_index + 1; 11596 11597 if (nth == 1) { 11598 return first_index; 11599 } else { 11600 var string_after_first_occurrence = string.slice(length_up_to_first_index); 11601 var next_occurrence = nth_occurrence(string_after_first_occurrence, char, nth - 1); 11602 11603 if (next_occurrence === -1) { 11604 return -1; 11605 } else { 11606 return length_up_to_first_index + next_occurrence; 11607 } 11608 } 11609 } 11610 ErrorCount = 0; 11611}); 11612/** 11613 * TODO: This is duplicated as aem-myaccount-consumer repo 11614 * 11615 * This is the authentication JSMethod for LiveEngage.The js name is configured 11616 * on the live engage end.This function is overridden to pass the authentication 11617 * token to LE based on which the chat window shows up. 11618 */ 11619var lpGetAuthenticationToken = function lpGetAuthenticationToken(callback) { 11620 isLECallback = true; 11621 var token = GMFApp.utils.cookie.getCookie('gmfMyAccount_MessageUs_Token'); 11622 if (token.length > 0) { 11623 callback(token); 11624 } else { 11625 hideChatIcon(); // hide for no valid accounts 11626 callback("no token"); 11627 } 11628 //*** binding click event to messaging window close button - check until close button is not hidden. 11629 hideMessagingIcon(); 11630 //Test CustomerSupport 11631 closeBtnCheckInterval = setInterval(checkForChatCloseBtn, 500); 11632} 11633/** 11634 * The functionality of the message now in the header and on contact us page is as follows : 11635 * The message now image with a mapped div id is included in the "message us" campaign on 11636 * live engage site. This div id will need to be included in the aem component. In addition 11637 * to the div id, all required live engage scripts including this will need to be loaded 11638 * across all my account pages such that the following snippet will be responsible for sending 11639 * profile data to live engage to provide that the user is authenticated. These two are 11640 * the prerequisities based on which once the user clicks on message now button, live engage 11641 * invokes lpGetAuthenticationToken function. 11642 * 11643 */ 11644GMFApp = GMFApp || {}; 11645GMFApp.pages = GMFApp.pages || {}; 11646$(document).ready(function() { 11647 var genesysChatBubble = $('#genesys-data'); 11648 if(!genesysChatBubble.length){ 11649 GMFApp.pages.liveengage = (function () {
11650 function init() { 11651 var _language; 11652 //Passing Engagement Attributes (EAs) 11653 var lp_sdes = []; 11654 var _domain = window.location.protocol+'//'+window.location.host+'/'; 11655 var urlTokens = window.location.pathname.replace("/content/gmf", "").split('/'); 11656 if (urlTokens.length > 1) { 11657 var lang = urlTokens[1].split("_"); 11658 if (lang.length > 1) { 11659 _language = lang[0]; 11660 } 11661 } 11662 11663 var myAccountEmailAddress = GMFApp.utils.cookie.getCookie('gmfMyaConsumer.login.emailAddress'); 11664 var token = GMFApp.utils.cookie.getCookie('gmfMyAccount_MessageUs_Token'); 11665 11666 if ((myAccountEmailAddress.length > 0) && (token.length > 0)) { 11667 var lp_sdes = [ 11668 { 11669 // Customer Info EA - To pass visitor emailAddress for agent visibility 11670 "type": "ctmrinfo", //MANDATORY 11671 "info": { 11672 "customerId": myAccountEmailAddress, //Variable handling emailAddress 11673 "companyBranch": "Web CXO", 11674 "role" : "Domain:" + _domain + ",Language:" + _language + ",Application:MyAccountWeb,MessagingType:Chat,AppVersion:" 11675 } 11676 }, 11677 { 11678 //Personal EA - To pass visitor DOB 11679 "type": "personal", //MANDATORY 11680 "personal": { 11681 "contacts" : [{ 11682 }], 11683 "company" : _domain, 11684 "language" : _language 11685 } 11686 }, 11687 { 11688 "type": "cart", //MANDATORY 11689 } 11690 ]; 11691 lpTag = lpTag|| []; 11692 lpTag.sdes = lpTag.sdes || []; 11693 lpTag.sdes.push(lp_sdes); 11694 } 11695 } 11696 return { init: init }; 11697 })(); 11698 GMFApp.pages.liveengage.init(); 11699 } 11700}); 11701function IsJsonString(str) { 11702 try { 11703 if(typeof str == 'object') { 11704 return JSON.parse(JSON.stringify(str)); 11705 } else { 11706 return JSON.parse(str); 11707 } 11708 } catch (e) { 11709 return false; 11710 } 11711} 11712 11713function getSession(sessionName) { 11714 return sessionStorage.getItem(sessionName); 11715} 11716 11717function setSession(sessionName, sessionValue) { 11718 sessionStorage.setItem(sessionName, sessionValue); 11719} 11720 11721//TODO:Remove after OKTA-Phase2 11722// Remove gmf-myaccount.session-timeout clientlib from gmfx-www.component category before deploying OKTA Phase-2 to UAT 11723/* 11724var userLogonCookie = gmfxMomentumServices.Cookie.get(gmfxMomentumCookieConstants.USER_LOGON), 11725 renewSessionClaimsToken; 11726 11727//TODO:Remove after OKTA-Phase2 11728if(userLogonCookie) { 11729 var renewTokenLoginJson = JSON.parse(userLogonCookie); 11730 renewSessionClaimsToken = renewTokenLoginJson.claimsToken; 11731} 11732if (!renewSessionClaimsToken) { 11733 11734 var gmfMyaccountTimerFunction = GMFApp.utils.cookie.getCookie('gmf.myaccount.timerFunction'), 11735 gmfMyAccountCountdownTime = GMFApp.utils.cookie.getCookie("countdownTime"); 11736 11737 if (gmfMyAccountCountdownTime) { 11738 // get deadline value from session storage 11739 var deadline = GMFApp.utils.cookie.getCookie("countdownTime"); 11740 } 11741 11742 $.idleTimer(720000); 11743 11744 if (gmfMyaccountTimerFunction) { 11745 console.log('Inside Initialize clock'); 11746 initializeClock(deadline); 11747 } 11748 11749 //check for idle timeout. 11750 $(document).on('idle.idleTimer', function (event, elem, obj) { 11751 // Display the Session Timeout Modal 11752 //renewToken = false; 11753 var cookie = GMFApp.utils.cookie.getCookie('gmfMyAccount_UserLogon'); 11754 if (cookie) { 11755 $('#authenticationsessiontimout-modal').modal('show'); 11756 } 11757 11758 }); 11759 11760 //check for active timeout. 11761 $(document).on('active.idleTimer', function (event, elem, obj) { 11762 //Reset Idle Timer to 12 minutes 11763 $.idleTimer(720000); 11764 11765 }); 11766 11767 counterTimer(); 11768} 11769//TODO:Remove after OKTA-Phase2 11770*/ 11771 11772function countdownTimer(renewToken) { 11773 //if renewToken variable is true, then renew the auth token and call CountdownTimer again on the next 14th minute. 11774 if (renewToken === true) { 11775 //renew auth token 11776 //call timeout again 11777 renewAccessToken(); 11778 } 11779 //if renewToken variable is false, then expire the auth token and logout the user. 11780 else { 11781 //expire auth token. 11782 //logout user. 11783 logout(); 11784 } 11785} 11786 11787//this is called from initializeClock function below. 11788function getTimeRemaining(endtime) { 11789 var currentDateTime = new Date(), 11790 endTimeMilliseconds = Date.parse(endtime), 11791 currentTimeMilliseconds = Date.parse(currentDateTime), 11792 totalMilliseconds = endTimeMilliseconds - currentTimeMilliseconds; 11793 11794 return { 11795 'total': totalMilliseconds 11796 } 11797} 11798 11799//this is called from line 100 - initializeClock(deadline) function below. 11800function initializeClock(endtime) { 11801 //count down to 14 minutes. when count down is 0, call CountdownTiner function and the clear the time. 11802 function updateClock() { 11803 var tokenRenewed = GMFApp.utils.cookie.getCookie('gmfMyAccount_tokenRenewed'); 11804 if (tokenRenewed === 'yes') { 11805 endtime = GMFApp.utils.cookie.getCookie("countdownTime"); 11806 GMFApp.utils.cookie.deleteCookie('gmfMyAccount_tokenRenewed'); 11807 } 11808 var t = getTimeRemaining(endtime); 11809 var renewToken, timerStatus = GMFApp.utils.cookie.getCookie('gmfMyAccount_timerStatus'); 11810 if (!timerStatus) { 11811 renewToken = false;
11812 //call countdown timer here after 14 minutes. 11813 countdownTimer(renewToken); 11814 } else if (t.total <= 0) { 11815 clearInterval(timeinterval); 11816 //set renewToken to false 11817 renewToken = true; 11818 //call countdown timer here after 14 minutes. 11819 countdownTimer(); 11820 } 11821 } 11822 11823 updateClock(); 11824 11825 //call updateClock every 1 second. 11826 var timeinterval = setInterval(updateClock, 1000); 11827} 11828 11829function counterTimer() { 11830 //AEM notes - The countdown only fires when this modal opens on line #22. When it's open it fires a the function, myTimeouttoggle(theTime1, squareAmount, timerId). The 1st arguement is the time amount in milsec, 2nd is how many squares you want to display and 3rd is the ID you want to select for the countdown. 11831 11832 //AEM notes - There is another function that calls when the timer runs out or they click 'logout.' This is the function, mySessionlogout(); 11833 11834 //var theTime1 = 900000, theTime2 = 720000; 11835 //var theTime1 = 5000, theTime2 = 12000; 11836 var theTime1 = 180000, //change this to a smaller value for testing. 11837 squareAmount = 6, 11838 $timerId = $('#sessiontimeout'), 11839 countDownDate, xtime, now, distance, days, hours, minutes, seconds, countertimer, countertimerfin, i; 11840 11841 $('#authenticationsessionLogout').on('click', function () { 11842 mySessionlogout(); 11843 }); 11844 11845 function mySessionlogout() { 11846 //AEM notes - When time expires in modal or they click 'logout' then the user gets redirected from here 11847 logout(); 11848 11849 GMFApp.utils.cookie.deleteCookie('countdownTime'); 11850 11851 $('#authenticationsessiontimout-modal').modal('hide'); 11852 } 11853 11854 $('#authenticationsessiontimout-modal').on('show.bs.modal', function () { 11855 //start timer when modal is shown 11856 myTimeouttoggle(theTime1, squareAmount, $timerId); 11857 }); 11858 $('#authenticationsessiontimout-modal').on('hide.bs.modal', function () { 11859 //whem modal is hidden or on click of keep me logged in, clear timer. 11860 clearInterval(xtime); //stop timer. 11861 $timerId.find('span').each(function () { 11862 $(this).text('0'); 11863 }); 11864 $.idleTimer(720000); 11865 }); 11866 11867 function myTimeouttoggle(timer1, squares, timerId) { 11868 countDownDate = new Date().getTime() + timer1; 11869 xtime = setInterval(function () { 11870 now = new Date().getTime(); 11871 distance = countDownDate - now; 11872 countertimerfin = ''; 11873 days = Math.floor(distance / (1000 * 60 * 60 * 24)); 11874 hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); 11875 minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); 11876 seconds = Math.floor((distance % (1000 * 60)) / 1000); 11877 countertimer = ('0' + days).slice(-2) + ('0' + hours).slice(-2) + ('0' + minutes).slice(-2) + ('0' + seconds).slice(-2); 11878 countertimer = countertimer.toString(); 11879 countertimer = countertimer.slice(countertimer.length - squares); 11880 for (i = 0, j = countertimer.length; i < j; i++) { 11881 countertimerfin += '<span>' + countertimer.charAt(i) + '</span>'; 11882 } 11883 timerId.html(countertimerfin); 11884 if (distance < 0) { 11885 clearInterval(xtime); //stop timer 11886 timerId.find('span').each(function () { 11887 $(this).text('0'); 11888 }); 11889 logout(); //call logout here. 11890 GMFApp.utils.cookie.deleteCookie('countdownTime'); 11891 } 11892 }, 100); 11893 } 11894} 11895 11896function logout() { 11897 11898 var currentPagePath = $('.logout-section').data('content-path'); 11899 if (!currentPagePath) { 11900 currentPagePath = $('#authenticationsessiontimout-modal').data('content-path'); 11901 } 11902 var logoutServiceUrl = currentPagePath + '/jcr:content.myaccountlogoff.json'; 11903 var userLogonJson = IsJsonString(GMFApp.utils.cookie.getCookie('gmfMyAccount_UserLogon')); 11904 var refreshToken = userLogonJson.refreshToken; 11905 var accessToken = userLogonJson.accessToken; 11906 11907 $.post(logoutServiceUrl, { 11908 refreshToken: refreshToken, 11909 accessToken: accessToken, 11910 currentPagePath: currentPagePath 11911 }, function (data) { 11912 var cookie = GMFApp.utils.cookie.getCookie('gmfMyAccount_UserLogon'); 11913 if (cookie) { 11914 GMFApp.utils.cookie.deleteCookie('gmfMyAccount_UserLogon'); 11915 } 11916 if (data) { 11917 window.location.href = data; 11918 } 11919 }, 'text').fail(function (response) { 11920 var cookie = GMFApp.utils.cookie.getCookie('gmfMyAccount_UserLogon'); 11921 if (cookie) { 11922 GMFApp.utils.cookie.deleteCookie('gmfMyAccount_UserLogon'); 11923 } 11924 if (response) { 11925 window.location.href = response.responseText; 11926 } 11927 }).always(function () { 11928 deleteCookieForLogout(); 11929 });
11930} 11931 11932function deleteCookieForLogout() { 11933 var cookie = GMFApp.utils.cookie.getCookie('gmfMyAccount_UserLogon'); 11934 if (cookie) { 11935 GMFApp.utils.cookie.deleteCookie('gmfMyAccount_UserLogon'); 11936 } 11937 11938 var loginTimeCookie = GMFApp.utils.cookie.getCookie('gmfMyAccount_UserLogonTime'); 11939 if (loginTimeCookie) { 11940 GMFApp.utils.cookie.deleteCookie('gmfMyAccount_UserLogonTime'); 11941 } 11942 11943 var pageVistCountCookie = GMFApp.utils.cookie.getCookie('gmfMyAccount_UserPageVisitCount'); 11944 if (pageVistCountCookie) { 11945 GMFApp.utils.cookie.deleteCookie('gmfMyAccount_UserPageVisitCount'); 11946 } 11947 11948 if (GMFApp.utils.cookie.getCookie('gmfMyAccount_Question_Ids')) { 11949 GMFApp.utils.cookie.deleteCookie('gmfMyAccount_Question_Ids'); 11950 } 11951 11952 if (GMFApp.utils.cookie.getCookie('gmfMyAccount_survey_eligible')) { 11953 GMFApp.utils.cookie.deleteCookie('gmfMyAccount_survey_eligible'); 11954 } 11955 if (GMFApp.utils.cookie.getCookie('gmfMyAccount_MessageUs_Token')) { 11956 GMFApp.utils.cookie.deleteCookie('gmfMyAccount_MessageUs_Token'); 11957 } 11958 11959 if (GMFApp.utils.cookie.getCookie('gmf.myaccount.timerFunction')) { 11960 GMFApp.utils.cookie.deleteCookie('gmf.myaccount.timerFunction'); 11961 } 11962 if (GMFApp.utils.cookie.getCookie('gmfMyAccount_timerStatus')) { 11963 GMFApp.utils.cookie.deleteCookie('gmfMyAccount_timerStatus'); 11964 } 11965 if (GMFApp.utils.cookie.getCookie('countdownTime')) { 11966 GMFApp.utils.cookie.deleteCookie('countdownTime'); 11967 } 11968 if (GMFApp.utils.cookie.getCookie('gmfMyAccount_wallet')) { 11969 GMFApp.utils.cookie.deleteCookie('gmfMyAccount_wallet'); 11970 } 11971 11972 // Terminate user profile session storage 11973 var authenticationService = new gmfxMomentumServices.Authentication(); 11974 authenticationService.terminateSession(); 11975} 11976 11977 11978function renewAccessToken() { 11979 var inputJson; 11980 var logonJson = IsJsonString(GMFApp.utils.cookie.getCookie('gmfMyAccount_UserLogon')); 11981 if (typeof logonJson === 'object') { 11982 inputJson = GMFApp.utils.cookie.getCookie('gmfMyAccount_UserLogon'); 11983 } else { 11984 inputJson = logonJson; 11985 } 11986 if (logonJson) { 11987 var renewTokenUrl = $('#authenticationsessiontimout-modal').data('content-path') + '/jcr:content.renewtoken.json' 11988 $.post(renewTokenUrl, 11989 {refreshToken: inputJson}).done(function (data) { 11990 var logonJson = IsJsonString(GMFApp.utils.cookie.getCookie('gmfMyAccount_UserLogon')); 11991 var status = logonJson.status; 11992 var dashboardUrl = logonJson.dashboardUrl; 11993 11994 GMFApp.utils.cookie.deleteCookie('gmfMyAccount_UserLogon'); 11995 11996 var jsonData = IsJsonString(data); 11997 var json = IsJsonString(jsonData); 11998 var userLogonCookie = { 11999 "accessToken": json.accessToken, 12000 "refreshToken": json.refreshToken, 12001 "tokenExpiration": json.tokenExpiration, 12002 "status": status, 12003 "dashboardUrl": dashboardUrl 12004 }; 12005 GMFApp.utils.cookie.setCookie('gmfMyAccount_UserLogon', JSON.stringify(userLogonCookie), 7); 12006 12007 GMFApp.utils.cookie.deleteCookie('countdownTime'); 12008 GMFApp.utils.cookie.deleteCookie('gmf.myaccount.timerFunction'); 12009 12010 var timeInMinutes = 13; 12011 var currentTime = Date.parse(new Date()); 12012 var deadline = new Date(currentTime + timeInMinutes*60*1000); 12013 12014 // store deadline in cookie for future reference 12015 GMFApp.utils.cookie.deleteCookie("countdownTime"); 12016 GMFApp.utils.cookie.setCookie("countdownTime", deadline, 1); 12017 initializeClock(deadline); 12018 GMFApp.utils.cookie.setCookie('gmfMyAccount_tokenRenewed', 'yes', 1); 12019 GMFApp.utils.cookie.setCookie('gmf.myaccount.timerFunction', 'yes', 1); 12020 12021 // Terminate user profile session storage 12022 var authenticationService = new gmfxMomentumServices.Authentication(); 12023 authenticationService.terminateSession(); 12024 12025 init(); 12026 12027 }).fail(function () { 12028 GMFApp.utils.cookie.deleteCookie('gmfMyAccount_UserLogon'); 12029 sessionStorage.removeItem('visited'); 12030 12031 GMFApp.utils.cookie.deleteCookie('countdownTime'); 12032 GMFApp.utils.cookie.deleteCookie('gmfMyAccount_timerStatus'); 12033 GMFApp.utils.cookie.deleteCookie('gmf.myaccount.timerFunction'); 12034 }); 12035 } 12036} 12037 12038$(document).ready(function () { 12039 var logonJson = IsJsonString(GMFApp.utils.cookie.getCookie('gmfMyAccount_UserLogon')); 12040 if ($('.logout-section').length > 0 && logonJson) { 12041 logout(); 12042 12043 GMFApp.utils.cookie.deleteCookie('countdownTime'); 12044 } 12045 12046 $('#authenticationlogin').on('click', function () { 12047 $('#authenticationsessiontimout-modal').modal('hide'); 12048 12049 renewAccessToken(); 12050 12051 GMFApp.utils.cookie.deleteCookie('gmf.myaccount.timerFunction'); 12052 GMFApp.utils.cookie.deleteCookie('countdownTime'); 12053 12054 init(); 12055 12056 GMFApp.utils.cookie.setCookie('gmf.myaccount.timerFunction', 'yes', 1); 12057 });
12058 12059}); 12060// Beta Experience Feedback Form 12061$("#feedback-survey-form") 12062 .validator() 12063 .on("submit", function(e) { 12064 e.preventDefault(); 12065 $.ajax({ 12066 type: "POST", 12067 url: "/gmfdyn/sendemail", 12068 data: $(this).serialize(), 12069 success: function(response) { 12070 if( 12071 $.trim(response).length > 0 && 12072 response.trim() === "Email sent successfully." 12073 ) { 12074 $(".beta-feedback").hide(); 12075 $(".beta-feedback-success").show(); 12076 $(".beta-feedback-title").hide(); 12077 $(".feedback-btn").hide(); 12078 } else { 12079 $(".beta-feedback").hide(); 12080 $(".beta-feedback-failure").show(); 12081 } 12082 }, 12083 error: function(data, errorThrown) { 12084 console.log(data); 12085 console.log(errorThrown); 12086 $(".beta-feedback").hide(); 12087 $(".beta-feedback-failure").show(); 12088 }, 12089 }); 12090 }); 12091 12092$("#overall-content-rating label").on("click", function() { 12093 $("#overall-content-rating label").removeClass("selected"); 12094 $(this).addClass("selected"); 12095 $("#overall-content-input").attr("value", $(this).text()); 12096 validateForm(); 12097}); 12098$("#feedback-eou-rating label").on("click", function() { 12099 $("#feedback-eou-rating label").removeClass("selected"); 12100 $(this).addClass("selected"); 12101 $("#feedback-eou-input").attr("value", $(this).text()); 12102 validateForm(); 12103}); 12104$("#feedback-design-rating label").on("click", function() { 12105 $("#feedback-design-rating label").removeClass("selected"); 12106 $(this).addClass("selected"); 12107 $("#feedback-design-input").attr("value", $(this).text()); 12108 validateForm(); 12109}); 12110 12111$("#reason-type .dropdown-menu li a").on("click", function() { 12112 $("#reason-type .option").html($(this).text()); 12113 $("#reason-input").attr("value", $(this).text()); 12114 $("#reason-type .dropdown-toggle").addClass("dd-selected"); 12115 validateForm(); 12116}); 12117 12118$("#preferred-contact-method-type .dropdown-menu li a").on( 12119 "click", 12120 function() { 12121 $("#preferred-contact-method-type .option").html($(this).text()); 12122 $("#preferred-contact-method-input").attr("value", $(this).text()); 12123 $("#preferred-contact-method-type .dropdown-toggle").addClass( 12124 "dd-selected" 12125 ); 12126 validateForm(); 12127 } 12128); 12129 12130//$('#beta-feedback-message').on('keyup', function(){ 12131// console.log($('#beta-feedback-message').val()); 12132// if($('#beta-feedback-message').val() != ""){ 12133// $(".betaFeedbackSubmit").prop("disabled", false); 12134// }else{ 12135// $(".betaFeedbackSubmit").prop("disabled", true); 12136// } 12137//}); 12138 12139$("#betaModal").on("hidden.bs.modal", function() { 12140 $("#beta-feedback-message").val(""); 12141 $(".beta-feedback").show(); 12142 $(".beta-feedback-title").show(); 12143 $(".feedback-btn").show(); 12144 $(".beta-feedback-success").hide(); 12145 $(".beta-feedback-failure").hide(); 12146 /*$('.modal-footer').show();*/ 12147}); 12148 12149var boolChecked = false; 12150$("body") 12151 .on("mouseover", "#feedback-boolean .iradio_square-blue", function(e) { 12152 $(this).addClass("hover"); 12153 }) 12154 .on("mouseout", "#feedback-boolean .iradio_square-blue", function(e) { 12155 $(this).removeClass("hover"); 12156 }) 12157 .on("click", "#feedback-boolean .iradio_square-blue", function(e) { 12158 $("span").removeClass("checked"); 12159 $(this).addClass("checked"); 12160 $("#feedback-boolean input").prop("checked", false); 12161 boolChecked = true; 12162 $(this).next("input").prop("checked", true); 12163 validateForm(); 12164 }); 12165 12166function validateForm() { 12167 if( 12168 $("#reason-input").val() && 12169 $("#feedback-content-input").val() && 12170 $("#feedback-eou-input").val() && 12171 $("#feedback-design-input").val() 12172 ) { 12173 $(".betaFeedbackSubmit").prop("disabled", false); 12174 } else { 12175 $(".betaFeedbackSubmit").prop("disabled", false); 12176 } 12177} 12178 12179/* 12180$(document).on('mouseup', function() { 12181 validateForm(); 12182 console.log("mouse up"); 12183});
12184*/ 12185 12186 12187 12188$(":radio.form_radio_hide").on("click", function() { 12189 if($("#formHideYes").prop("checked") == true) { 12190 $(".form__container").removeClass("hideFormContainer"); 12191 $(".form-response-container").addClass("form-hide-response"); 12192 } else if($("#formHideNo").prop("checked") == true) { 12193 $(".form__container").addClass("hideFormContainer"); 12194 $(".form-response-container").removeClass("form-hide-response"); 12195 } 12196}); 12197 12198$(function() { 12199 var $activeContainerRadio = $(".form__container", $activeContainerTab), 12200 $eHiddenRadio, 12201 $dependantsRadio, 12202 dependantsR = "", 12203 eHidden = "", 12204 formInputRadioButton = $(".form_input_radio"); 12205 12206 12207 $(":radio", $activeContainerRadio).on('change', function() { 12208 var parentRadio = $(this).closest(".form-group-radio"); 12209 eHidden = $(":radio.dependants", parentRadio).not($(this)) 12210 .map(function() { 12211 return $(this).data("dependants-list"); 12212 }) 12213 .get().join(','); 12214 if(eHidden != "") { 12215 $eHiddenRadio = $(eHidden, $activeContainerRadio); 12216 /* Iterates over the 2nd children to hide them.*/ 12217 $eHiddenRadio.each(function(ele, val) { 12218 hideChildElements($(val)); 12219 }); 12220 12221 /* Hides the 1st children*/ 12222 $eHiddenRadio.hide(); 12223 12224 cDisablingHiddenFields($eHiddenRadio); 12225 cResetForm($eHiddenRadio); 12226 } 12227 12228 if($(this).data("dependants-list") && $(this).data("dependants-list") != "" && !isRequestTypeOptOutChecked()) { 12229 dependantsR = $(this).data("dependants-list"); 12230 $dependantsRadio = $(dependantsR, $activeContainerRadio); 12231 cEnablingHiddenFields($dependantsRadio); 12232 $dependantsRadio.removeClass("hide").show(); 12233 $(".alert", $eHiddenRadio).removeClass("hide"); 12234 } else { 12235 if($(this).data("dependants-list-optout") && $(this).data("dependants-list-optout") != "" && isRequestTypeOptOutChecked()) { 12236 dependantsR = $(this).data("dependants-list-optout"); 12237 $dependantsRadio = $(dependantsR, $activeContainerRadio); 12238 cEnablingHiddenFields($dependantsRadio); 12239 $dependantsRadio.removeClass("hide").show(); 12240 $(".alert", $eHiddenRadio).removeClass("hide"); 12241 } 12242 } 12243 }); 12244 12245 // add hover color/image to custom radio buttons when on tab/focus 12246 $(formInputRadioButton).on("focus", function() { 12247 var formRadioTab = $(this).closest(".radioButtonFunc");
12248 formRadioTab.find(".iradio_square-blue").addClass("hover"); 12249 }); 12250 12251 // remove hover color/image from custom radio buttons when off tab/focus 12252 $(formInputRadioButton).on("blur", function() { 12253 var formRadioTab = $(this).closest(".radioButtonFunc"); 12254 formRadioTab.find(".iradio_square-blue").removeClass("hover"); 12255 }); 12256}); 12257 12258var $datepickerObject; 12259$(function() { 12260 $datepickerObject = $('.form_input_datepicker'); 12261 var $datepickerOptions = { 12262 format: "mm/dd/yyyy", 12263 startDate: "-73000d", 12264 endDate: "-5840d", 12265 autoclose: true, 12266 todayHighlight: true 12267 }; 12268 12269 $datepickerObject.datepicker($datepickerOptions); 12270 12271 $(".input-group-addon.datepicker-icon", ".form-group-datepicker").on("click", function() { 12272 $datepickerObject.datepicker("show"); 12273 }); 12274 12275 $datepickerObject.keyup(dateHandlerContainer).keypress(dateHandlerContainer).blur(dateHandlerContainer); 12276}); 12277 12278function dateHandlerContainer(event) { 12279 var input = this.value.replace(/[^0-9]+/g, ""), 12280 keyPressed = String.fromCharCode(event.which), 12281 unicode = event.charCode ? event.charCode : event.keyCode; 12282 if(rx.test(keyPressed) || event.which == 8) { 12283 $datepickerObject.datepicker("show"); 12284 if(input.length > 2 && input.length <= 4) { 12285 this.value = input.slice(0, 2) + "/" + input.slice(2); 12286 } else if(input.length > 4) { 12287 this.value = input.slice(0, 2) + "/" + input.slice(2, 4) + "/" + input.slice(4); 12288 } 12289 } else if((unicode == 9) && event.which == 0) { 12290 return true; 12291 } 12292} 12293 12294$(function() { 12295 var $activeContainerCheckbox = $(".form__container", $activeContainerTab), 12296 $dependantsCheckbox, 12297 dependantsC = "", 12298 formInputCheckbox = $(".form_input_checkbox_tab"), 12299 checkboxCheckClass = ".checkbox-check", 12300 hoverFormCheckbox = "hover-form-checkbox", 12301 hoverFormCheckboxChecked = "hover-form-checkbox-checked"; 12302 12303 $(":checkbox.dependants", $activeContainerCheckbox).on('change', function() { 12304 if($(this).data("dependants-list") && $(this).data("dependants-list") != "") { 12305 dependantsC = $(this).data("dependants-list"); 12306 $dependantsCheckbox = $(dependantsC, $activeContainerCheckbox); 12307 if($(this).is(":checked")) { 12308 cEnablingHiddenFields($dependantsCheckbox); 12309 $dependantsCheckbox.removeClass('hide').show(); 12310 } else { 12311 /* Iterates over the 2nd children to hide them.*/ 12312 $dependantsCheckbox.each(function(ele, val) { 12313 hideChildElements($(val)); 12314 }); 12315 12316 $dependantsCheckbox.hide().addClass('hide'); 12317 cDisablingHiddenFields($dependantsCheckbox); 12318 cResetForm($dependantsCheckbox); 12319 } 12320 12321 } 12322 }); 12323 12324 // add hover color/image to custom checkboxes when on tab/focus 12325 $(formInputCheckbox).on("focus", function() { 12326 var formCheckboxTab = $(this).closest(".checkbox"); 12327 // if checkbox is checked remove unchecked hover class and add checked hover class 12328 if($(this).is(":checked")) { 12329 formCheckboxTab.find(checkboxCheckClass).removeClass(hoverFormCheckbox); 12330 formCheckboxTab.find(checkboxCheckClass).addClass(hoverFormCheckboxChecked); 12331 } 12332 // if checkbox is not checked remove checked hover class and add unchecked hover class 12333 else { 12334 formCheckboxTab.find(checkboxCheckClass).removeClass(hoverFormCheckboxChecked); 12335 formCheckboxTab.find(checkboxCheckClass).addClass(hoverFormCheckbox); 12336 } 12337 }); 12338 12339 // remove hover color/image from custom checkboxes when off tab/focus 12340 $(formInputCheckbox).on("blur", function() { 12341 var formCheckboxTab = $(this).closest(".checkbox"); 12342 // if checkbox is checked remove checked hover class 12343 if($(this).is(":checked")) { 12344 formCheckboxTab.find(checkboxCheckClass).removeClass(hoverFormCheckboxChecked); 12345 } 12346 // if checkbox is not checked remove unchecked hover class 12347 else { 12348 formCheckboxTab.find(checkboxCheckClass).removeClass(hoverFormCheckbox); 12349 } 12350 }); 12351}); 12352 12353$(function() { 12354 $('.form_input_tel').keyup(phonehandlerContainer).keypress(phonehandlerContainer).blur(phonehandlerContainer); 12355}); 12356 12357function phonehandlerContainer(event) { 12358 setTimeout(function() { 12359 if($(".form-group-input-tel").hasClass('has-error')) { 12360 $('.form-group-input-tel > .with-errors').show(); 12361 } 12362 }, 1000); 12363 var input = this.value.replace(/[^0-9]+/g, ""); 12364 var keyPressed = String.fromCharCode(event.which); 12365 var unicode = event.charCode ? event.charCode : event.keyCode; 12366 if(rx.test(keyPressed) || event.which == 8) { 12367 if(input.length > 3 && input.length <= 5) { 12368 this.value = input.slice(0, 3) + "-" + input.slice(3); 12369 } else if(input.length > 6) { 12370 this.value = input.slice(0, 3) + "-" + input.slice(3, 6) + "-" + input.slice(6); 12371 } 12372 } else if((unicode == 9) && event.which == 0) { 12373 return true; 12374 } else { 12375 return false;
12376 } 12377} 12378 12379 12380$(function() { 12381 dropdownInit(); 12382}); 12383 12384function dropdownInit() { 12385 var $activeContainerDropdown = $(".form__container", $activeContainerTab), 12386 $eHiddenDropdown, 12387 $dependantsDropdown, 12388 idSelect = "", 12389 optionSelected = "", 12390 dependantsD = "", 12391 eDropdownHidden = "", 12392 selectSelector = ".form-group-select select"; 12393 12394 $(selectSelector).change(function() { 12395 idSelect = $(this).attr("id"), 12396 optionSelected = $("option:selected", this); 12397 12398 eDropdownHidden = $("#" + idSelect + " option.dependants", $activeContainerDropdown).not($(this)) 12399 .map(function() { 12400 return $(this).data("dependants-list"); 12401 }) 12402 .get().join(','); 12403 12404 if(eDropdownHidden != "") { 12405 $eHiddenDropdown = $(eDropdownHidden, $activeContainerDropdown); 12406 /* Iterates over the 2nd children to hide them.*/ 12407 $eHiddenDropdown.each(function(ele, val) { 12408 hideChildElements($(val)); 12409 }); 12410 12411 /* Hides the 1st children*/ 12412 $eHiddenDropdown.hide(); 12413 cDisablingHiddenFields($eHiddenDropdown); 12414 cResetForm($eHiddenDropdown); 12415 } 12416 12417 if($(optionSelected).data("dependants-list") && $(optionSelected).data("dependants-list") != "") { 12418 dependantsD = $(optionSelected).data("dependants-list"); 12419 $dependantsDropdown = $(dependantsD, $activeContainerDropdown); 12420 cEnablingHiddenFields($dependantsDropdown); 12421 $dependantsDropdown.removeClass("hide").show(); 12422 } 12423 }); 12424} 12425 12426var $activeContainerTab = "", 12427 $formContainer = $(".form__container"), 12428 concatenateDropdown = ""; 12429 12430$(function () { 12431 var $activeContainerTab = getActiveTab(), 12432 $formModal, 12433 $emailResultContainer, 12434 $emailErrorContainer; 12435 12436 var $formFileGroup = $(".form-file-upload-group", $activeContainerTab), 12437 $activeFormFileUpload = $(".form__container", $activeContainerTab); 12438 12439 // offset error focus for mega menu height 12440 $.fn.validator.Constructor.FOCUS_OFFSET = 200; 12441 12442 // check if form file upload exists 12443 if ($formFileGroup.length > 0) { 12444 12445 // run function on change 12446 $(":radio.fileUploadDependent", $activeFormFileUpload).on("change", function () { 12447 var $thisRadio = $(this); 12448 $("#fileupload").val("true"); 12449 // check if form file upload is required 12450 if ($thisRadio.val() == "yes" && $thisRadio.prop("checked") == true) { 12451 var $formFileUploadContainer = $(".form-file-upload-container"); 12452 12453 $formFileUploadContainer.each(function (index, element) { 12454 var $parentFormFileUploadContainer = $(this); 12455 var $formFileUploadFormId = $parentFormFileUploadContainer.find(".form-file-upload-form").attr("id"); 12456 var $formFileUploadDropId = $parentFormFileUploadContainer.find(".form-file-upload-drop").attr("id"); 12457 var $formFileUploadTemplatePreviewId = $parentFormFileUploadContainer.find(".form-file-upload-template-preview").attr("id"); 12458 12459 createDropzone($formFileUploadDropId, $formFileUploadFormId, $formFileUploadTemplatePreviewId); 12460 }); 12461 12462 function createDropzone(uploadDropId, uploadFormId, templatePreviewId) { 12463 var formUpload = $("#" + uploadDropId); 12464 var $formFileUploadForm = $("#" + uploadFormId); 12465 var $previewTemplate = $("#" + templatePreviewId); 12466 12467 // Ensure code execution proceeds only if DropZone exists 12468 if (formUpload.length) { 12469 var $dragDropForm = $formFileUploadForm, 12470 $errorSelector = $(".form-file-upload-error-message", $dragDropForm), 12471 maxSizeTotal = 5.0e6, 12472 maxNumberOfFiles = 2, 12473 defaultThumbnail = "/content/dam/gmf/icons/file-content.svg", 12474 errorMessages = { 12475 duplicate: "Duplicate files not allowed", 12476 oneFile: "Please upload at least one file", 12477 allowedFiles: "Only PDF, Word Docs, and TXT files are allowed", 12478 sizeExceeded: "You have exceeded the maximum 5MB allowed for attachments", 12479 minSizeValidation: "Please upload a valid file", 12480 limitExceeded: "You have exceeded the maximum 2 files allowed for attachments" 12481 }; 12482 12483 Dropzone.autoDiscover = false;
12484 12485 formUpload.dropzone({ 12486 type: 'POST', 12487 url: "/gmfdyn/snowservlet", 12488 autoProcessQueue: false, 12489 uploadMultiple: true, 12490 parallelUploads: 100, 12491 previewTemplate: $previewTemplate.html(), 12492 previewsContainer: document.getElementById(templatePreviewId), 12493 init: function () { 12494 var myDropzone = this; 12495 var totalFilesSize = 0; 12496 var emptyFile = false; 12497 12498 radioValueDisplay(); 12499 12500 var dateTime = new Date().toString(); 12501 var dateTimeSerialized = "dateTime=" + encodeURI(dateTime) + "&"; 12502 var formData = dateTimeSerialized + concatenateDropdown + $(this).serialize(); 12503 12504 $("form[class*='form_cpaform']").validator().on('submit', function (e) { 12505 // run ajax call if dropzone is being used 12506 if ($thisRadio.val() == "yes" && $thisRadio.prop("checked") == true) { 12507 totalFilesSize = getTotalFilesSize(); 12508 //Bug 21309 set it to false on submit and update value to true on validation 12509 $("#fileupload").val(""); 12510 12511 // test that at least one file is uploaded 12512 if (myDropzone.files.length < 1) { 12513 setErrorMessage(errorMessages.oneFile); 12514 $(".form-file-upload-container").addClass("has-error"); 12515 $("#form_group_fileupload").addClass("has-error"); 12516 $(".form-file-upload-error-message").focus(); 12517 e.preventDefault(); 12518 return false; 12519 } 12520 12521 // test that the files do not exceed maximum limit for attachments 12522 if (myDropzone.files.length > maxNumberOfFiles) { 12523 setErrorMessage(errorMessages.limitExceeded); 12524 $(".form-file-upload-container").addClass("has-error"); 12525 $("#form_group_fileupload").addClass("has-error"); 12526 $(".form-file-upload-error-message").focus(); 12527 e.preventDefault(); 12528 return false; 12529 } 12530 12531 // test that the files do not exceed maximum size for attachments 12532 if (totalFilesSize > maxSizeTotal) { 12533 setErrorMessage(errorMessages.sizeExceeded); 12534 $(".form-file-upload-container").addClass("has-error"); 12535 $("#form_group_fileupload").addClass("has-error"); 12536 $(".form-file-upload-error-message").focus(); 12537 e.preventDefault(); 12538 return false; 12539 } 12540 12541 // test that the files with zero size attachments 12542 if (totalFilesSize === 0) { 12543 setErrorMessage(errorMessages.sizeValid); 12544 $(".form-file-upload-container").addClass("has-error"); 12545 $("#form_group_fileupload").addClass("has-error"); 12546 $(".form-file-upload-error-message").focus(); 12547 e.preventDefault(); 12548 return false;
12549 } 12550 12551 // test for empty file attachments 12552 if (emptyFile) { 12553 setErrorMessage(errorMessages.minSizeValidation); 12554 $(".form-file-upload-container").addClass("has-error"); 12555 $("#form_group_fileupload").addClass("has-error"); 12556 $(".form-file-upload-error-message").focus(); 12557 e.preventDefault(); 12558 return false; 12559 } 12560 12561 //bug 21309 12562 if (myDropzone.files.length >= 1 && myDropzone.files.length <= maxNumberOfFiles && totalFilesSize <= maxSizeTotal && totalFilesSize != 0 && !emptyFile) { 12563 $("#fileupload").val("true"); 12564 $(".form-file-upload-container").removeClass("has-error"); 12565 $("#form_group_fileupload").removeClass("has-error"); 12566 } else { 12567 $("#fileupload").val(""); 12568 $(".form-file-upload-container").addClass("has-error"); 12569 $("#form_group_fileupload").addClass("has-error"); 12570 e.preventDefault(); 12571 return false; 12572 } 12573 12574 if (!(e.isDefaultPrevented())) { 12575 e.preventDefault(); 12576 e.stopPropagation(); 12577 12578 if ($(".has-error").not(".form__container").length != 0) { 12579 $("html, body").animate({ 12580 scrollTop: $(".has-error").offset().top - 50 12581 }, 500); 12582 return false; 12583 } 12584 12585 var dateTime = new Date().toString(); 12586 var dateTimeSerialized = "dateTime=" + encodeURI(dateTime) + "&"; 12587 var formData = dateTimeSerialized + concatenateDropdown + $("form[class*='form_cpaform']").serialize(); 12588 12589 verifyReCaptchaStatus().then(function () { 12590 myDropzone.processQueue(); 12591 // Display Success message immediately 12592 // Success message for Optout request type only 12593 if (formData.indexOf("requesttype=opt_out") >= 0 && formData.indexOf("requesttype=know") < 0 && formData.indexOf("requesttype=delete") < 0 && formData.indexOf("requesttype=request_correct") < 0) { 12594 showSuccessModal('#form__success-modal-optout-only'); 12595 // Success message for any combination of request type with Optout 12596 } else if ((formData.indexOf("requesttype=opt_out") >= 0) && (formData.indexOf("requesttype=know") >= 0 || formData.indexOf("requesttype=delete") >= 0 || formData.indexOf("requesttype=request_correct") >= 0)) { 12597 showSuccessModal('#form__success-modal-with-optout'); 12598 // Success message for any combination of request type without Optout 12599 } else if ((formData.indexOf("requesttype=opt_out") < 0) && (formData.indexOf("requesttype=know") >= 0 || formData.indexOf("requesttype=delete") >= 0 || formData.indexOf("requesttype=request_correct") >= 0)) { 12600 showSuccessModal('#form__success-modal-without-optout'); 12601 } 12602 reloadPageAfterClosingSuccessModal(); 12603 $("span.spinner", $dragDropForm).remove(); 12604 //this.removeAllFiles(true); 12605 formUpload.show(); 12606 $(".form-file-upload-template-preview", $dragDropForm).show(); 12607 cleanErrorMessage(); 12608 $("input[type!='hidden']", $dragDropForm).val(""); 12609 }).catch(function () { 12610 showReCaptchaValidation(); 12611 }); 12612 } 12613 } 12614 }); 12615 12616 this.on("thumbnail", function (file) { 12617 file.previewElement.querySelector("img").src = defaultThumbnail; 12618 }); 12619 12620 this.on("addedfile", function (file) { 12621 var currentElement = file.previewElement, 12622 totalFileSize = getTotalFilesSize(); 12623 12624 cleanErrorMessage(); 12625 myDropzone.emit("thumbnail", file, defaultThumbnail); 12626 12627 // check for duplicates 12628 if (myDropzone.files.length) { 12629 var _i, _len; 12630 for (_i = 0, _len = myDropzone.files.length; _i < 12631 _len - 12632 1; _i++) // -1 to exclude current file 12633 { 12634 if (myDropzone.files[_i].name === file.name && 12635 myDropzone.files[_i].size === file.size && 12636 myDropzone.files[_i].type === file.type) { 12637 myDropzone.removeFile(file); 12638 setErrorMessage(errorMessages.duplicate); 12639 } 12640 } 12641 } 12642 12643 var fileExtension = ["application/pdf", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "text/plain"]; 12644 if ($.inArray(file.type, fileExtension) == -1) { 12645 myDropzone.removeFile(file); 12646 setErrorMessage(errorMessages.allowedFiles); 12647 } 12648 12649 if (totalFileSize > maxSizeTotal) { 12650 setErrorMessage(errorMessages.sizeExceeded); 12651 } 12652 12653 if (emptyFile) { 12654 setErrorMessage(errorMessages.minSizeValidation); 12655 } 12656 12657 if (myDropzone.files.length > maxNumberOfFiles) { 12658 setErrorMessage(errorMessages.limitExceeded); 12659 } 12660 }); 12661 12662 this.on("sendingmultiple", function (data, xhr, formData) { 12663 var dateTime = new Date().toString(); 12664 var dateTimeSerialized = "dateTime=" + encodeURI(dateTime) + "&"; 12665 var temp = dateTimeSerialized + concatenateDropdown + $("form[class*='form_cpaform']").serialize(); 12666 var formFields; 12667 $.each(temp.split("&"), function (index, elem) { 12668 formFields = elem.split("="); 12669 formData.append(formFields[0], formFields[1]); 12670 }); 12671 formData.append("dateTime", encodeURI(dateTime)) 12672 disableForm(); 12673 cleanErrorMessage(); 12674 formUpload.hide(); 12675 $(".form-file-upload-template-preview", $dragDropForm) 12676 .hide(); 12677 $(".required-document-info", $dragDropForm).after( 12678 "<span class='img-responsive spinner'></span>") 12679 }); 12680 12681 // getting the success response from the ajax call 12682 this.on("success", function (file, responseText) { enableForm(); }); 12683 12684 // getting the error response from the ajax call 12685 this.on("error", function (file, responseText) { enableForm(); }); 12686 12687 this.on("removedfile", function (file) { 12688 totalFilesSize = getTotalFilesSize(); 12689 12690 if ($errorSelector.text() == errorMessages.duplicate) { 12691 cleanErrorMessage(); 12692 } else if ((totalFilesSize < maxSizeTotal)) { 12693 cleanErrorMessage(); 12694 } else if ((!emptyFile) && ($errorSelector.text() == errorMessages.minSizeValidation)) { 12695 cleanErrorMessage(); 12696 } else if (myDropzone.files.length <= maxNumberOfFiles) { 12697 cleanErrorMessage(); 12698 } 12699 12700 // Check for error messages again to display after remov
12700ing any file 12701 if (totalFilesSize > maxSizeTotal) { 12702 setErrorMessage(errorMessages.sizeExceeded); 12703 } 12704 12705 if (emptyFile) { 12706 setErrorMessage(errorMessages.minSizeValidation); 12707 } 12708 12709 if (myDropzone.files.length > maxNumberOfFiles) { 12710 setErrorMessage(errorMessages.limitExceeded); 12711 } 12712 12713 }); 12714 12715 function getTotalFilesSize() { 12716 var sumFilesSize = 0; 12717 emptyFile = false; 12718 $.each(myDropzone.files, function (k, v) { 12719 if (v.size == 0) { 12720 emptyFile = true; 12721 } 12722 sumFilesSize += v.size; 12723 }); 12724 return sumFilesSize; 12725 } 12726 } 12727 }); 12728 12729 $(".form-file-upload-details", $dragDropForm).first().addClass("hidden"); 12730 12731 function disableForm() { 12732 $(":input", $dragDropForm).prop("disabled", true) 12733 } 12734 12735 function enableForm() { 12736 $(":input", $dragDropForm).prop("disabled", false); 12737 } 12738 12739 function setErrorMessage(error) { 12740 $errorSelector.text(error).addClass("text-danger"); 12741 } 12742 12743 function cleanErrorMessage() { 12744 $errorSelector.text("").removeClass("text-danger"); 12745 } 12746 } 12747 } 12748 } 12749 // if uploading is not required 12750 else if ($thisRadio.val() == "no" && $thisRadio.prop("checked") == true) { 12751 $("form[class*='form_cpaform']").validator().on('submit', function (e) { 12752 if (e.isDefaultPrevented()) { 12753 hideSuccessModal(); 12754 $('.with-errors').show(); 12755 12756 if ($(".has-error").not(".form__container").length != 0) { 12757 $("html, body").animate({ 12758 scrollTop: $(".has-error").offset().top - 50 12759 }, 500); 12760 e.preventDefault(); 12761 return false; 12762 } 12763 12764 } else { 12765 e.preventDefault(); 12766 12767 if ($(".has-error").not(".form__container").length != 0) { 12768 $("html, body").animate({ 12769 scrollTop: $(".has-error").offset().top - 50 12770 }, 500); 12771 return false; 12772 } 12773 12774 radioValueDisplay(); 12775 dropdownValueDisplay(); 12776 12777 verifyReCaptchaStatus().then(function () { 12778 var dateTime = new Date().toString(); 12779 var dateTimeSerialized = "dateTime=" + encodeURI(dateTime) + "&"; 12780 var formData = dateTimeSerialized + concatenateDropdown + $("form[class*='form_cpaform']").serialize(); 12781 $('.with-errors').hide(); 12782 // Display Success message immediately 12783 // Success message for Optout request type only 12784 if (formData.indexOf("requesttype=opt_out") >= 0 && formData.indexOf("requesttype=know") < 0 && formData.indexOf("requesttype=delete") < 0 && formData.indexOf("requesttype=request_correct") < 0) { 12785 showSuccessModal('#form__success-modal-optout-only'); 12786 // Success message for any combination of request type with Optout 12787 } else if ((formData.indexOf("requesttype=opt_out") >= 0) && (formData.indexOf("requesttype=know") >= 0 || formData.indexOf("requesttype=delete") >= 0 || formData.indexOf("requesttype=request_correct") >= 0)) { 12788 showSuccessModal('#form__success-modal-with-optout'); 12789 // Success message for any combination of request type without Optout 12790 } else if ((formData.indexOf("requesttype=opt_out") < 0) && (formData.indexOf("requesttype=know") >= 0 || formData.indexOf("requesttype=delete") >= 0 || formData.indexOf("requesttype=request_correct") >= 0)) { 12791 showSuccessModal('#form__success-modal-without-optout'); 12792 } 12793 reloadPageAfterClosingSuccessModal(); 12794 12795 $.ajax({ 12796 type: 'POST', 12797 url: '/gmfdyn/snowservlet', 12798 data: formData, 12799 success: function (response) { }, 12800 error: function (data, errorThrown) { } 12801 }); 12802 }).catch(function () { 12803 showReCaptchaValidation(); 12804 }); 12805 } 12806 }); 12807 } 12808 }); 12809 } 12810 12811 $(":checkbox", $formContainer).change(concatenateCheckboxValues).change(validateCheckbox); 12812 12813 $('.nav-tabs li').on('click touchend', function (e) { 12814 $activeContainerTab = getActiveTab(); 12815 var noActiveTabs = $(".nav-tabs li").not(".active").find("a").map(function () { 12816 return $(this).data("target"); 12817 }).get(); 12818 $.each(noActiveTabs, function (elem, val) { 12819 var $tabForm = $("div" + val).find("form"); 12820 if ($tabForm.attr("class").indexOf("form_cpaform") > 0) { 12821 $(".eHidden", $tabForm).hide(); 12822 cDisablingHiddenFields($tabForm); 12823 cResetForm($tabForm); 12824 } 12825 }); 12826 }); 12827}); 12828 12829function radioValueDisplay() { 12830 $(".form_input_radio").each(function () { 12831 var thisRadioValue = $(this); 12832 // remove underscore from radio value 12833 thisRadioValue.val(thisRadioValue.val().replace(/_/g, " ")); 12834 }); 12835} 12836 12837function dropdownValueDisplay() { 12838 var selectDropdown = $(".form-group-dropdown:hidden select", $formContainer).map(function () { 12839 return $(this).attr("name"); 12840 }); 12841 for (var i = 0; i < selectDropdown.length; i++) { 12842 concatenateDropdown += selectDropdown[i] + "=&"; 12843 } 12844} 12845 12846function reloadPageAfterClosingSuccessModal() { 12847 $('#form__success-modal-optout-only, #form__success-modal-with-optout, #form__success-modal-without-optout', "div.tab-pane.active").on('hidden.bs.modal', function (e) { 12848 e.preventDefault(); 12849 location.reload(true); 12850 }); 12851} 12852 12853function showSuccessModal(showModal) {
12854 $formModal = $(showModal, "div.tab-pane.active"), 12855 $emailResultContainer = $(".sendemailresult", $formModal), 12856 $emailErrorContainer = $(".sendemailerror", $formModal), 12857 $emailResultContainer.show(); 12858 $emailErrorContainer.hide(); 12859 $(showModal, "div.tab-pane.active").modal('show'); 12860} 12861 12862function hideSuccessModal() { 12863 $('#form__success-modal-optout-only, #form__success-modal-with-optout, #form__success-modal-without-optout', "div.tab-pane.active").modal('hide'); 12864} 12865 12866function concatenateCheckboxValues() { 12867 var checkTarget = $(this), 12868 checkboxesContainer = checkTarget.parents(".checkboxes-list"), 12869 currentHiddenField = checkboxesContainer.find("input:hidden"), 12870 textInputHidden = $(':checkbox:checked', checkboxesContainer).map(function () { 12871 return $(this).next("label").text(); 12872 }).get().join(', '); 12873 currentHiddenField.val(textInputHidden); 12874} 12875 12876function validateCheckbox() { 12877 var checkTarget = $(this), 12878 checkboxesContainer = checkTarget.parents('.checkboxes-l
12878ist'); 12879 12880 if ($('input[type=checkbox]:checked', checkboxesContainer).length > 0) { 12881 $('input[type=checkbox]', checkboxesContainer).removeAttr('required'); 12882 } else { 12883 $('input[type=checkbox]', checkboxesContainer).prop('required', true); 12884 $('input[value=norequired]', checkboxesContainer).prop('required', false).removeAttr('required'); 12885 } 12886} 12887 12888function cDisablingHiddenFields($selectorInContext) { 12889 $(":input.vHid", $selectorInContext).removeAttr("required"); 12890} 12891 12892function cEnablingHiddenFields($selectorInContext) { 12893 $(":input.vHid", $selectorInContext).attr("required", "required"); 12894} 12895 12896function cResetForm($selectorInContext) { 12897 $(":input:not(:checkbox):not(:radio):not(:button)", $selectorInContext).val(""); 12898 $("input.form_input_dropdown", $selectorInContext).removeAttr("value"); 12899 $(".form-dropdown-toggle span.option", $selectorInContext).text("Select"); 12900 $(".radioButtonFunc,.iradio_square-blue", $selectorInContext).removeClass("checked"); 12901 $(":radio,:checkbox", $selectorInContext).prop("checked", false); 12902 // Commented out due to missing dependents form inputValue when we select and deselect parent checkbox multiple times.
12903 //$(".checkboxes-list :hidden",$selectorInContext).val(""); 12904} 12905 12906function getActiveTab() { 12907 return $("div.tab-pane.active"); 12908} 12909 12910function isRequestTypeOptOutChecked() { 12911 // hide personal infomation fields when only opt out request selected 12912 if ($("#form_input_checkbox_requesttype_opt_out").is(":checked") && $("#form_input_checkbox_requesttype_know").is(":not(:checked)") && $("#form_input_checkbox_requesttype_delete").is(":not(:checked)") && $("#form_input_checkbox_requesttype_request_correct").is(":not(:checked)")) { 12913 return true; 12914 } 12915} 12916 12917// Hides the 2nd children elements of a 1st child element 12918 12919function hideChildElements($inputElement) { 12920 var inputType = $inputElement.data("input-type") ? $inputElement.data("input-type") : ""; 12921 var opSelected; 12922 12923 switch (inputType) { 12924 case "select": 12925 opSelected = $("select option:selected.dependants", $inputElement) 12926 .map(function () { 12927 return $(this).data("dependants-list"); 12928 }) 12929 .get().join(','); 12930 break; 12931 case "radio": 12932 opSelected = $(":radio:checked.dependants", $inputElement) 12933 .map(function () { 12934 return $(this).data("dependants-list"); 12935 }) 12936 .get().join(','); 12937 break; 12938 case "checkbox": 12939 opSelected = $(":checkbox:checked.dependants", $inputElement) 12940 .map(function () { 12941 return $(this).data("dependants-list"); 12942 }) 12943 .get().join(','); 12944 break; 12945 } 12946 12947 if (inputType == "select" || inputType == "checkbox" || inputType == "radio") { 12948 if (opSelected != "") { 12949 $(opSelected).hide(); 12950 } 12951 } else { 12952 $inputElement.hide(); 12953 } 12954 12955 cDisablingHiddenFields($inputElement); 12956 cResetForm($inputElement); 12957} 12958 12959// v2: render explicit widgets once the API is loaded 12960var onloadCallback = function() { 12961 $(".recaptcha[data-version='v2']").each(function() { 12962 var key = $(this).data("sitekey"); 12963 var recaptchaID = $(this).find(".g-recaptcha").attr("id"); 12964 grecaptcha.render(recaptchaID, { 12965 sitekey: key, 12966 theme: "light", 12967 callback: verifyCaptchaV2 12968 }); 12969 }); 12970}; 12971 12972// v2: called by the widget on successful checkbox completion 12973var verifyCaptchaV2 = function() { 12974 $("#hiddenRecaptcha").val("true"); 12975 hideReCaptchaValidation(); 12976}; 12977 12978var hideReCaptchaValidation = function() { 12979 $(".recaptcha").removeClass("has-error"); 12980 $(".recaptcha .help-block").hide(); 12981}; 12982 12983var showReCaptchaValidation = function() { 12984 $(".recaptcha").addClass("has-error"); 12985 $(".recaptcha .help-block").show(); 12986}; 12987 12988function recaptchaExpired() { 12989 $("#hiddenRecaptcha").val(""); 12990 $("form").validator("validate"); 12991} 12992 12993// Always returns a Promise regardless of version â callers never need to branch 12994function verifyReCaptchaStatus() { 12995 var $recaptcha = $(".recaptcha"); 12996 var version = $recaptcha.data("version") || "v2"; 12997 12998 if (version === "v2") { 12999 var response = grecaptcha.getResponse(); 13000 if (response.length === 0) { 13001 showReCaptchaValidation(); 13002 $("#form_group_catpcha").addClass("has-error"); 13003 return Promise.reject(false); 13004 } 13005 $("#hiddenRecaptcha").val("true"); 13006 $("#form_group_catpcha").removeClass("has-error"); 13007 hideReCaptchaValidation(); 13008 return Promise.resolve(true); 13009 } 13010 13011 // v3 path 13012 var siteKey = $recaptcha.data("sitekey"); 13013 return new Promise(function(resolve, reject) { 13014 grecaptcha.ready(function() { 13015 grecaptcha.execute(siteKey, { action: "submit" }).then(function(token) { 13016 $("#g-recaptcha-response").val(token); 13017 resolve(true); 13018 }).catch(function() { 13019 reject(false); 13020 }); 13021 }); 13022 }); 13023} 13024
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.