1/* Common event handlers and such for every non-ring page */ 2 3/* This contains everything from component.js - with the cart stuff abstracted to hjCart.js, login to myAccount.js */ 4 5 6HJCONTAINER.components.sharedSecom = function(con) { 7 con.sharedSecomInit = function() { 8 // Common event handlers and init work for all non-ringConfigurator pages 9 // * Automatically invoked for every instance of hjMasterInit * 10 // turn off all ajax caching 11 $.ajaxSetup({ 12 cache:false 13 }); 14 15 // TODO - con.relativePath should be on config object, be ref as con.rel etc 16 con.relativePath = $("#relativePathValue").text(); 17 con.schoolUrlPrefix = $("#schoolUrlPrefixValue").text(); 18 19 // Event handlers for cart 20 con.cartInit(); 21 22 // setup school search instances 23 con.schoolSearchSetupInstances(); 24 25 $("#logo > a").on("click", con.debugSubmission); 26 27 $('.videoLink').click( con.bindVideoClick ); 28 29 /* school home page fix */ 30 $(".ringHero.single").parent().addClass("tight"); 31 $(".gradProductsHero.single").parent().addClass("tight"); 32 33 /* checkout validaiton fix */ 34 $("input.error").parent().addClass("error"); 35 $("select.error").parent().parent().addClass("error"); 36 37 $("input.error").focus(function(){ 38 $(this).parent().removeClass("error"); 39 $(this).removeClass("error"); 40 41 }); 42 43 $("select.error").focus(function(){ 44 $(this).parent().parent().removeClass("error"); 45 $(this).removeClass("error"); 46 }); 47 48 /* browse product banner resizing */ 49 var $browseli = $("#browseProductBanner li").length; 50 var $browseBanner = $("#browseProductBanner"); 51 52 if($browseli > 3) { 53 $browseBanner.addClass('four'); 54 } else if($browseli > 2) { 55 $browseBanner.addClass('three'); 56 } else if($browseli > 1){ 57 $browseBanner.addClass('two'); 58 } else if($browseli > 0){ 59 $browseBanner.addClass('one'); 60 } 61 62 /* format phone and fax number */ 63 $(".phoneFax").text(function(i, text) { 64 text = text.replace(/(\d{3})(\d{3})(\d{4})/, "$1.$2.$3"); 65 return text; 66 }); 67 68 /* PLUG INS */ 69 $( ".datepicker" ).datepicker(); 70 71 /* LOGIN MODAL */ 72 $("#navPreLogin").click(function(){ 73 con.modalPreLoginRequest(); 74 }); 75 $("#saveForLaterButton").click(function(){ 76 con.modalPreLoginRequest(); 77 }); 78 $("#designStartedLoginLink").click(function(){ 79 con.modalPreLoginRequest(); 80 }); 81 82 (function() { 83 function maybeHide() { 84 setTimeout(function() { 85 if(!inBar && !inModal) 86 $("#gradProdDropdown").hide(); 87 }, 200); 88 } 89 90 var inBar = false; 91 var inModal = false; 92 $("#gradProdDropdown").hover(function() { 93 inModal = true; 94 }, function() { 95 inModal = false; 96 maybeHide(); 97 }); 98 99 $("#navGradProd").hover(function() { 100 inBar = true; 101 $("#gradProdDropdown").show(); 102 var off = $(this).offset(); 103 off.left -= 125; 104 off.top += 50; 105 $("#gradProdDropdown").offset(off); 106 }, function() { 107 inBar = false; 108 maybeHide(); 109 }); 110 })(); 111 112 /* ADDS SELECTED VALUE TO SELECT BUTTON ///// FIX THIS */ 113 $(".btn-group ul a").click(function( e ){ 114 e.preventDefault(); 115 116 var text = $(this).text(); 117 118 $(this).closest('.btn-group').children('a.view').text(text); 119 120 }); 121 122 /* PACKAGE DETAIL MODAL */ 123 /* CHECKOUT-BILLING-INFO // AUTO SELECTS CORRECT RADIO WHEN TEXT BOX IS SELECTED */ 124 $("#otherAmountVal").click(function() { 125 $("#otherAmount").prop("checked",true); 126 }); 127 128 $("#editEmail").click(function() { 129 $("#prevEmail").hide(); 130 $("#newEmail").show(); 131 }); 132 133 /* FAQ question toggle */ 134 $(".question a").click(function() { 135 136 if($(this).parent().hasClass("open") == true) { 137 $(this).parent().removeClass("open"); 138 } else { 139 $(this).parent().addClass("open"); 140 } 141 142 }); 143 144 $(".question.open a").click(function() { 145 $(this).parent().removeClass("open"); 146 }); 147 148 if( $('#submitFW').length > 0 ) { 149 $('#submitFW').click(function(e) { 150 e.preventDefault(); 151 var el = $(this); 152 con.submitForgotPassword( el ); 153 }); 154 } 155 156 $(".trimVar").on("change", function() {$(this).val(con.trimVar($(this).val()));}) 157 158 $("#ringSizerOrderForm").click( con.getRingSizerOrderForm ); 159 }; 160 con.trimVar = function (val) { 161 trimmedVal = val.toString().trim(); 162 163 // replace all smart quotes 164 trimmedVal = trimmedVal.replace(/[\u2018\u2019\u201A\u201B\u2032\u2035]/g, "'"); 165 trimmedVal = trimmedVal.replace(/[\u201C\u201D\u201E\u201F\u2033\u2036]/g, '"'); 166 167 return trimmedVal; 168 } 169 con.buildURL = function( root, addition ) { 170 var n = ( root || "" ).indexOf(";jsessionid"); 171 172 if ( n < 0 ) { 173 return root + addition; 174 } else { 175 return root.replace(";jsessionid", ( addition + ";jsessionid" ) ); 176 } 177 }; 178 con.submitForgotPassword = function( el ) { 179 var _this = el; 180 var form = el.closest('form'); 181 var errorsCont = form.find('.errors'); 182 var msgsCont = form.find('.msgs'); 183 var email = $('#emailAddress'); 184 var errors = con.validateEmail(email.val()); 185 186 if( errors != null ) { 187 errorsCont.html( errors ).show(); 188 email.addClass('inputError'); 189 } else { 190 errorsCont.html('').hide(); 191 email.removeClass('inputError'); 192 } 193 194 msgsCont.html('<div class="loadingGif"></div>'); 195 196 var url = con.relativePath + '/forgotpassword'; 197 var data = form.serialize(); 198 199 $.ajax({ 200 url: url, 201 data: data, 202 type: 'POST', 203 success: function( data ) { 204 205 if( data.success == false ) { 206 msgsCont.html(''); 207 208 if( data.messages.global ) { 209 errorsCont.html( data.messages.global ).show(); 210 } 211 } else { 212 if( data.onSuccessEvent ) { 213 window.location = con.relativePath + '/' + data.onSuccessEvent.redirect; 214 } else { 215 window.location = con.relativePath + '/login'; 216 } 217 } 218 219 }, 220 error: function( data ) { 221 console.log( data ); 222 } 223 }); 224 225 }; 226 con.validateEmail = function( email ) { 227 var errors = null; 228 229 if( email === null ) { 230 errors = "Email Address can not be empty."; 231 } else if( !con.isEmailAddress( email ) ) { 232 errors = "Please enter a valid email address."; 233 } 234 return errors; 235 }; 236 con.isEmailAddress = function( email ) { 237 email = _.trim(email); 238 return /^([\w!.%+\-])+@([\w\-])+(?:\.[\w\-]+)+$/.test(email); 239 }; 240 241 // Refs #2163 Add phone number validation 242 con.validatePhone = function( phone ) { 243 var errors = null; 244 245 if( phone === null || phone.trim().length < 1) { 246 errors = "Phone number can not be empty."; 247 } else if( !con.isPhoneNumber( phone ) ) { 248 errors = "Please enter a valid phone number."; 249 } 250 return errors; 251 }; 252 con.isPhoneNumber = function( phone ) { 253 phone = phone.replace(/\s/g, ''); 254 return /^[\+]?([1][-.]?)?[\(]?[0-9]{3}[\)]?[-.]?[0-9]{3}[-.]?[0-9]{4}$/.test(phone); 255 }; 256 257 con.debugSubmission = function(e) { 258 if(!e.shiftKey) 259 return; 260 261 e.preventDefault(); 262
263 var modal = $('<div class="modal"><p>What happened?</p><textarea style="width:670px;height:150px;"></textarea><p>Your Name</p><input type="text"/><a class="hjbtn green"><span>Submit</span></a></div>'); 264 modal.modal(); 265 modal.find("textarea").focus(); 266 modal.find("a").on("click", function() { 267 var input = {url:window.location.href, 268 reason: modal.find("textarea").val(), 269 loggedBy: modal.find("input").val() 270 }; 271 272 try{ 273 input.facts = window.isaac.modelRegistry.get("ringFormModel").getFacts(); 274 }catch(e){} 275 276 modal.find("span").html("Submitting..."); 277 $.ajax({type: 'POST', 278 url: "/" + window.location.pathname.split("/")[1] + "/qaHelper", 279 data: JSON.stringify(input), 280 contentType: "application/json", 281 complete: function(data) { 282 modal.html('<p>' + data.responseText + '</p><a class="hjbtn green"><span>Close</span></a>'); 283 modal.find("a").on("click", function() { 284 modal.modal("hide"); 285 modal.remove(); 286 }); 287 } 288 }); 289 }); 290 291 return false; 292 }; 293 294 con.getRingSizerOrderForm = function() { 295 var modalContainer = $('#modalContainer'); 296 var modalContent; 297 $.ajax({ 298 url: con.relativePath + '/modals/ringSizerOrderForm.jsp', 299 type: 'GET', 300 success: function( data ) { 301 modalContent = data; 302 modalContainer.html( modalContent ).addClass('ringSizeOrderForm'); 303 304 modalContainer.find("button.submit").on("click", function() { 305 var temp = {}; 306 var formValid = true; 307 _.each($(this).closest("form").serializeArray(), function(item) { 308 if ((item.name == "schoolName") && (item.value == null || item.value == "") && formValid) { 309 alert("School must not be blank."); 310 formValid = false; 311 } 312 if ((item.name == "studentFirstName") && (item.value == null || item.value == "") && formValid) { 313 alert("Student First Name must not be blank."); 314 formValid = false; 315 } 316 if ((item.name == "studentLastName") && (item.value == null || item.value == "") && formValid) { 317 alert("Student Last Name must not be blank."); 318 formValid = false; 319 } 320 if ((item.name == "addressLine1") && (item.value == null || item.value == "") && formValid) { 321 alert("The first line of the Address must not be blank."); 322 formValid = false; 323 } 324 if ((item.name == "city") && (item.value == null || item.value == "") && formValid) { 325 alert("City must not be blank."); 326 formValid = false; 327 } 328 if ((item.name == "state") && (item.value == null || item.value == "") && formValid) { 329 alert("Please select a state."); 330 formValid = false; 331 } 332 if ((item.name == "zip") && (item.value == null || item.value == "") && formValid) { 333 alert("Please enter a valid zip code."); 334 formValid = false; 335 } 336 if ((item.name == "email") && (item.value != null) && (item.value != "") && formValid) { 337 var atpos = item.value.indexOf("@"); 338 var dotpos = item.value.indexOf("."); 339 if (atpos<1 || dotpos<atpos+2 || dotpos+2>=item.value.length) { 340 alert("The email address entered is not valid."); 341 formValid = false; 342 } 343 } 344 temp[item.name] = item.value; 345 }); 346 347 if (!formValid) return false; 348 349 $.ajax({ 350 url: con.relativePath + "/requestRingSizer", 351 type: "POST", 352 contentType:"application/json", 353 data: JSON.stringify(temp) 354 }); 355 $(this).closest(".modal").modal("hide"); 356 return false; 357 }); 358 359 launchModal(modalContainer, 'show', "ringSizeOrderFormModal"); 360 361 $("#checkoutButton").click(function(e) { 362 e.preventDefault(); 363 var form = $('#ringSizerForm'); 364 form.submit(); 365 }); 366 367 $("#checkoutButton2").click(function(e) { 368 e.preventDefault(); 369 var form = $('#ringSizerForm'); 370 form.submit(); 371 }); 372 373 }, 374 error: function( data ) { 375 console.log( data ); 376 console.log('error in con.getRingSizerOrderForm ajax send '); 377 } 378 }); 379 }; 380 con.showRingGallery = function() { 381 var ringGalleryAns = $('.ringGalleryInfo'); 382 383 if( ringGalleryAns.is(':visible') ) { 384 ringGalleryAns.hide(); 385 } else { 386 ringGalleryAns.show(); 387 } 388 }; 389 390 con.maybeHideRingGallery = function() { 391 // hide ring gallery if flash is not enabled 392 var model = isaac.modelRegistry.get("ringFormModel"); 393 if(!model.getFlashEnabled() || !model.getCompleted()) { 394 $("#ringGallery").attr("checked", false); 395 $("#ringGallery").parent().hide(); 396 } 397 }; 398 399 con.registerSaveRing = function( action, subAction) { 400 401 $('#modalContainer').html('Loading'); 402 403 $.ajax({ 404 url: con.relativePath + '/modals/registerSavedRings.jsp', 405 type: 'GET', 406 async: false, 407 success: function( data ) { 408 $('#modalContainer').html( data ); 409 410 con.maybeHideRingGallery(); 411 412 $('#whatRingGallery').click( con.showRingGallery ); 413 414 $('#loginModal').click(function(e){ 415 e.preventDefault(); 416 con.showLoginSaveRing( action, subAction); 417 }); 418 419 $('.registerBtn').on( 'click' , function( e ) { 420 e.preventDefault(); 421 var el = this; 422 423 if( action ) { 424 nextStep = action; 425 } else { 426 nextStep = "saveRing"; 427 } 428
429 con.submitRegisterSaveRing( el , nextStep, subAction); 430 431 }); 432 }, 433 error: function( data ) { 434 console.log( data ); 435 } 436 }); 437 438 }; 439 440 con.removeSavedRing = function( id, inMyAccount ) { 441 $.ajax({ 442 url: con.relativePath + '/rings/delete/' + id, 443 type: 'POST', 444 success: function( data ) { 445 if(inMyAccount) { 446 window.location.reload(); 447 } 448 else { 449 $('#stepHolder').removeAttr('ringid'); 450 $('.saveRing').find('span').html('Save Ring'); 451 } 452 }, 453 error: function( data ) { 454 console.log( data ); 455 } 456 }); 457 }; 458 459 con.submitRegisterSaveRing = function( el , action, subAction ) { 460 var _this = $( el ); 461 var form = _this.closest('form'); 462 var url = con.relativePath + "/register"; 463 464 var email = form.find('.emailAddress').val(); 465 var errors = con.validateEmail( email ); 466 467 if( errors !== null ) { 468 form.find('.errors').html( errors ).show(); 469 form.find('.emailAddress').addClass('inputError'); 470 } else { 471 form.find('.errors').html('').hide(); 472 form.find('.emailAddress').removeClass('inputError'); 473 474 var formData = form.serialize(); 475 var registerErrors = ""; 476 477 $.ajax({ 478 url: url, 479 type: 'POST', 480 data: formData, 481 async: false, 482 success: function( data ) { 483 484 if( data.success === false ) { 485 grecaptcha.reset(); 486 487 if( data.messages.password ) { 488 if(typeof data.messages.password == 'string') { 489 registerErrors = "Password: " + data.messages.password; 490 } else { 491 for(var i = 0;i<data.messages.password.length;i++ ) { 492 registerErrors += 'Password: ' + data.messages.password[i] + '<br />'; 493 } 494 } 495 } else if( data.messages.confirmPassword ) { 496 registerErrors += data.messages.confirmPassword + '<br />'; 497 } else if( data.messages.captcha ) { 498 registerErrors += data.messages.captcha; 499 } else { 500 registerErrors += data.messages.global; 501 } 502 503 form.find('.errors').html( registerErrors ).show(); 504 505 } else { 506 507 var showInGallery = ( $('#ringGallery').is(":checked")) ? true : false; 508 509 if( action ) { 510 switch(action) { 511 case "saveRing": 512 con.updateHeaderLinksOnLogin(); 513 break; 514 515 case "viewRings": 516 window.location = con.relativePath + "/myaccount/savedRings"; 517 break; 518 519 case "addRingToGallery": 520 con.updateHeaderLinksOnLogin(); 521 con.updateGalleryTextOnceRingAdded(); 522 break; 523 524 case "changeSchoolSaveRing": 525 con.updateHeaderLinksOnLogin(); 526 break; 527 528 case "sharing": 529 con.updateHeaderLinksOnLogin(); 530 break; 531 532 default: 533 window.location = con.relativePath + "/myaccount"; 534 break; 535 } 536 537 } 538 539 } 540 }, 541 error: function( data ) { 542 console.log( data ); 543 } 544 }); 545 } 546 }; 547 con.showLoginSaveRing = function(action, subAction) { 548 $.ajax({ 549 url: con.relativePath + '/modals/loginSaveRing.jsp', 550 type: 'GET', 551 async: false, 552 success: function( data ) { 553 $('#modalContainer').html( data ).addClass('loginContainer'); 554 555 con.maybeHideRingGallery(); 556 557 $('#whatRingGallery').click( function() { 558 con.showRingGallery(); 559 }); 560 $('#modalRegister').on('click', function( e ) { 561 e.preventDefault(); 562 con.registerSaveRing(action, subAction); 563 }); 564 565 $('.loginBtn').on( 'click' , function( e ) { 566 e.preventDefault(); 567 var el = this; 568 var nextStep; 569 570 if( action ) { 571 nextStep = action; 572 } else { 573 nextStep = "saveRing"; 574 } 575 576 con.standaloneLogin( el , nextStep , subAction); 577 }); 578 579 $('#saveRingFacebookLoginButton').click(function(e) { 580 console.log('fb login clicked from showLoginSaveRing'); 581 var cookieAction = action + '-' + subAction; 582 var model = isaac.modelRegistry.get("ringFormModel"); 583 var facts = JSON.stringify(model.getFacts()); 584 $.cookie("herffJonesPostFacebookLoginAction", cookieAction, { expires: 999, path: '/' }); 585 $.cookie("herffJonesPostFacebookLoginAction-ringFacts", facts, { expires: 999, path: '/' }); 586 587 var returnStep = model.getCurrentStep(); 588 $.cookie("herffJonesPostFacebookLoginAction-ringReturnStep", returnStep, { expires: 999, path: '/' }); 589 590 window.location = con.relativePath + '/social/facebook/signin?sRedirect=' + con.relativePath + '/rings/home'; 591 }); 592 593 launchModal($('#modalContainer'), 'show', "rings/loginSvedRing"); 594 595 }, 596 error: function( data ) { 597 console.log( data ); 598 } 599 }); 600 }; 601 602 con.shareRing = function( subAction , data ) { 603 // THESE NEED TO BE UPDATED WITH THE HERFF JONES ACCOUNT CREDENTIALS // 604 var url = "http://" + window.location.host + "/secom/ringconfig/ringdetail/" + data.id; // we should NOT be building urls like this 605 var appId = "c35e3e92-6c16-47d1-bc8f-5fe22798c561"; 606 var accessKey = "08bce3e267e882265029e2c76870b90c" 607 608 var twitterTitle = "I just designed my High School Class Ring. It was fun and it tells a little about me. :) Let me know what you think."; 609 610 switch( subAction ) { 611 case "facebook": 612 window.open( "http://rest.sharethis.com/share/sharer.php?destination=facebook&url=" + url + "&title=Herff Jones Class Ring&pub_key=" + appId + "&access_key=" + accessKey, "_blank" ,"location=0, menubar=0, height=360, width=680" ); 613 break; 614 case "twitter": 615 window.open( "http://rest.sharethis.com/share/sharer.php?destination=twitter&url=" + url + "&title=" + twitterTitle + "&pub_key=" + appId + "&access_key=" + accessKey, "_blank" , "location=0, menubar=0, height=360, width=680" ); 616 break; 617 case "email": 618 con.getShareEmail( url ); 619 break; 620 default: 621 break; 622 } 623 624 }; 625 con.fbLogin = function() { 626 var url = con.relativePath + '/social/facebook/signin?sRedirect=' + con.relativePath + '/myaccount'; 627 window.location = url; 628 }; 629 con.postFacebookLoginRingSpecifics = function() {
630 // *********** POST FACEBOOK LOGIN SPECIFICS FOR RING CONFIGURATOR ******************** 631 632 if ($.cookie("herffJonesPostFacebookLoginAction")) { 633 var split = ($.cookie("herffJonesPostFacebookLoginAction")).split('-'); 634 var action = split[0]; 635 var subAction = split[1]; 636 console.log('action after facebook login cookie present. Action is ' + action); 637 638 // Grab original form value 639 var showInGallery = false; 640 641 switch(action) { 642 case "saveRing": 643 console.log('^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ con.postFacebookLoginRingSpecifics ^^^^^^^^^^^^^^^^^^^^^^'); 644 break; 645 646 case "viewRings": 647 window.location = con.relativePath + "/myaccount/savedRings"; 648 break; 649 650 case "ringGallery": 651 con.saveRingLikeToBackend($.cookie("herffJonesPostFacebookLoginAction-ringIdToSave")); 652 $.cookie("herffJonesPostFacebookLoginAction-ringIdToSave", null, { expires: 999, path: '/' }); 653 break; 654 655 case "addRingToGallery": 656 con.updateGalleryTextOnceRingAdded(); 657 break; 658 659 case "changeSchoolSaveRing": 660 break; 661 662 case "sharing": 663 break; 664 665 default: 666 window.location = con.relativePath + "/myaccount"; 667 break; 668 } 669 670 $.cookie("herffJonesPostFacebookLoginAction", null, { expires: 999, path: '/' }); 671 672 } 673 }; 674 con.bindVideoClick = function( e ) { 675 e.preventDefault(); 676 var videoId = $(this).attr('data-id'); 677 678 $("#videoModal .videoContainer").append($('<div id="youtubeReplace"></div>')); 679 680 var videoIframe = '<iframe width="100%" height="390" src="https://www.youtube.com/embed/'+videoId+'?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>'; 681 $("#youtubeReplace").html(videoIframe); 682 683 $("#videoModal").on("hidden", function() { 684 $("#videoModal .videoContainer").empty(); 685 }); 686 $("#videoModal").removeClass("hide"); 687 launchModal($('#videoModal'), "show", videoId); 688 689 }; 690 691 con.showHideFlash = function(show) { 692 try{ 693 window.isaac.modelRegistry.get("ringFormModel").setShortHide(!show); 694 }catch(e){} 695 }; 696 697 isBannedWord = function(word, bannedWords) { 698 isBanned = false; 699 try { 700 word = word.toString().toUpperCase(); 701 bwUpper = bannedWords.toString().toUpperCase(); 702 bws = bwUpper.split(','); 703 for (i=0, len=bws.length; i < len; i++) { 704 bannedWord = bws[i].replace(/^\s+/,""); 705 bannedWordRegEx = new RegExp("\\b" + bannedWord + "\\b","gi"); 706 707 if (word === bannedWord || word.search(bannedWordRegEx) >= 0) { 708 isBanned = true; 709 break; 710 } 711 } 712 } catch(e) {} 713 return isBanned; 714 }; 715}; 716 717 718HJCONTAINER.components.sharedMenuLoginHelpers = function(con) { 719 // adds the pre-login modal 720 con.loginModalHelper = function(url, handlers) { 721 con.loginModalHandlers = handlers; 722 $.ajax({ 723 url : url, 724 type : "GET", 725 success : function(data) { 726 launchModal($('#loginRegHolder').html(data), "show", "preLoginModal"); 727 // ie7 fixes 728 $("#loginRegHolder").css("z-index", 4125); 729 $(".modal-backdrop.in").css("z-index", 4124); 730 con.loginModalSetupHandlers(con.loginModalHandlers); 731 }, 732 error: function( data ) { 733 // TO DO: redirect to standalone login page 734 } 735 }); 736 }; 737 con.modalPreLoginRequest = function() { 738 var url = $("#loginRegHolder").attr("preLoginURL"); 739 var handlers = "preLogin"; 740 con.loginModalHelper(url, handlers); 741 742 }; 743 con.modalPreDppLoginRequest = function() { 744 var url = $("#loginRegHolder").attr("dppPreLoginURL"); 745 var handlers = "preLogin"; 746 con.loginModalHelper(url, handlers); 747 }; 748 // switches modal contents to login form 749 con.modalLoginRequest = function() { 750 var url = $("#loginRegHolder").attr("loginURL"); 751 var handlers = "login"; 752 con.loginModalHelper(url, handlers); 753 754 }; 755 // switches modal contents to register form 756 con.modalRegRequest = function() { 757 var url = $("#loginRegHolder").attr("regURL"); 758 var handlers = "reg"; 759 con.loginModalHelper(url, handlers); 760 761 }; 762 con.loginModalSetupHandlers = function(handlersToSetup) { 763 $(document).ready(function() { 764 switch (handlersToSetup) { 765 case 'preLogin': 766 $("#modalLogin").click(con.modalLoginRequest); 767 $("#modalReg").click(con.modalRegRequest); 768 $('#facebookLogin').click(con.fbLogin); 769 break; 770 case 'login': 771 $('#loginform .loginBtn').off('click'); 772 $('#loginform').on("click", ".loginBtn", function(e) { 773 e.preventDefault(); 774 con.standaloneLogin($(this),"home"); 775 }); 776 $("#modalReg").off('click'); 777 $("#modalReg").click(con.modalRegRequest); 778 break;
779 case 'reg': 780 $('#registerForm .registerBtn').off('click'); 781 $('#registerForm').on("click", ".registerBtn", con.submitRegisterForm); 782 $("#modalLogin").off('click'); 783 $("#modalLogin").click(con.modalLoginRequest); 784 break; 785 } 786 }); 787 }; 788 789}; 790 791 792HJCONTAINER.components.imageZoom = function(con) { 793 con.hjImgZoom = function() { 794 /* The zoom functionality will not work as is with the new responsive designs. 795 Removing zoom functionality for now. 796 var native_width = 0; 797 var native_height = 0; 798 799 $('.magnify').mouseleave(function() { 800 var large = $('.magnify').find('.large'); 801 var largeImg = $('.largeImg'); 802 large.hide(); 803 largeImg.hide(); 804 }); 805 806 $(".magnify").mousemove(function(e) { 807 var small = $('.magnify').find('.small'); 808 var large = $('.magnify').find('.large'); 809 var largeImg = $('.largeImg'); 810 811 if(!native_width && !native_height) { 812 var src = small.attr('src'); 813 // assign background image to large 814 largeImg.css({ 815 background: '#FFF url(\"' + src + '\") no-repeat' 816 }); 817 var image_object = new Image(); 818 image_object.src = src; 819 native_width = image_object.width; 820 native_height = image_object.height; 821 } else { 822 var magnify_offset = $(this).offset(); 823 824 var mx = e.pageX - magnify_offset.left; 825 var my = e.pageY - magnify_offset.top; 826 var smx = e.pageX - small.offset().left; 827 var smy = e.pageY - small.offset().top; 828 829 if(mx < $(this).width() && my < $(this).height() && mx > 0 && my > 0) { 830 large.show(); 831 largeImg.show(); 832 833 // listen for mobile clicks outside 834 var bodyWatch = function() { 835 var $mag = $(".magnify"); 836 var off = $mag.offset(); 837 if(off && ((event.pageX < off.left) || 838 (event.pageX > (off.left + $mag.width())) || 839 (event.pageY < off.top) || 840 (event.pageY > (off.top + $mag.height())) )){ 841 large.hide(); 842 largeImg.hide(); 843 $("#container").off("click", bodyWatch); 844 } 845 }; 846 847 $("#container").on("click", bodyWatch); 848 } else { 849 large.hide(); 850 largeImg.hide(); 851 } 852 853 if(large.is(":visible")) { 854 var rx = Math.round(smx/small.width()*native_width - large.width()/2)*-1 + largeImg.width()/2; 855 var ry = Math.round(smy/small.height()*native_height - large.height()/2)*-1 + largeImg.height()/2; 856 857 if( $(this).attr('ismodal') ) { 858 859 var modalOffset = $('.magnify').closest('.modal').offset(); 860 var modalLeft = modalOffset.left; 861 var modalTop = modalOffset.top; 862 863 rx += 65; 864 ry += 85; 865 866 } 867 868 var bgp = rx + "px " + ry + "px"; 869 870 //Time to move the magnifying glass with the mouse 871 var px = mx - large.width()/2; 872 var py = my - large.height()/2; 873 874 large.css({left: px, top: py }); 875 largeImg.css({backgroundPosition: bgp}); 876 } 877 } 878 });*/ 879 }; 880 con.imageSwap = function( e ) { 881 e.preventDefault(); 882 883 var _this = $(this); 884 var _thisA = _this.find('a'); 885 var mainImg = $('.magnify'); 886 var collageView = $('#collageView'); 887 888 if( !_thisA.hasClass('selected') ) { 889 890 891 if( _thisA.hasClass('collageHold')) { 892 mainImg.hide(); 893 collageView.show(); 894 895 $('#thumbnails').find('.selected').removeClass('selected'); 896 _thisA.addClass('selected'); 897 898 } else { 899 900 if(!mainImg.is(':visible')) { 901 mainImg.show(); 902 collageView.hide(); 903 } 904 905 // Set selected flag 906 $('#thumbnails').find('.selected').removeClass('selected'); 907 _thisA.addClass('selected'); 908 909 // Sanitize the rendition logic to allow zoom to work properly. 910 var tinyUrl = _this.find('img').attr('src'); 911 var fullUrl = tinyUrl.replace("68x60_thumb", "692x834_full"); 912 913 // Update image and reinitalize zoom 914 mainImg.find('img').attr('src', fullUrl); 915 con.hjImgZoom(); 916 } 917 918 } 919 }; 920 con.toggleProductImages = function(images) { 921 var data; 922 923 if ( images.length > 0 ) { 924 $('#thumbnails').empty(); 925 } 926 927 if ( $('#thumbnails').hasClass("cgt") ) { 928 $('.magnify').hide(); 929 $('#collageView').show(); 930 $('#collageView').empty(); 931 932 $('#thumbnails').append("<li class='img'><a class='collageHold selected' href='#'></a></li>"); 933
934 var dataCollage1 = ("<img class='collage cap' src='" + images[0].smallThumb + "' />"); 935 var dataCollage2 = ("<img class='collage gown' src='" + images[1].smallThumb + "' />"); 936 var dataCollage3 = ("<img class='collage tassel' src='" + images[2].smallThumb + "' />"); 937 $('#thumbnails .collageHold').append(dataCollage1).append(dataCollage2).append(dataCollage3); 938 $('#collageView').append(dataCollage1).append(dataCollage2).append(dataCollage3); 939 940 for( var i = 0;i < images.length;i++ ) { 941 var dataSingle = ("<li class='img'><a class='singleHold' href='#'><img src='" + images[i].smallThumb + "' /></a></li>"); 942 $('#thumbnails').append(dataSingle); 943 } 944 945 } else { 946 947 for( var i = 0;i < images.length;i++ ) { 948 949 if( i == 0 ) { 950 data = ("<li class='img'><a href='#' class='selected'><img src='" + images[i].smallThumb + "' /></a></li>"); 951 } else { 952 data = ("<li class='img'><a href='#'><img src='" + images[i].smallThumb + "' /></a></li>"); 953 } 954 955 $('#thumbnails').append(data); 956 } 957 if (images[0].title == "Snell Roundhand" || images[0].title == "Unicorn" || images[0].title == "Century Gothic" || images[0].title == "Ballet Harmony") { 958 $('.secondaryHold').find('img').attr('src',images[0].fullZoom); 959 } else { 960 $('.primaryHold').find('img').attr('src',images[0].fullZoom); 961 con.toggleAlECarteProductImages(images); 962 } 963 964 } 965 966 con.hjImgZoom(); 967 con.bindImageSwap(); 968 969 }; 970 // The a la carte / specialty item modal renders its own image markup 971 // (.alECarteMainImg plus an .alECarteThumbnails strip) rather than the shared 972 // primaryHold/#thumbnails structure, so it has to be refreshed separately or it 973 // keeps showing the previously selected option's images - a unit's gown stayed 974 // the Option A color after switching to Option B. 975 con.toggleAlECarteProductImages = function(images) { 976 var mainImg = $('.alECarteMainImg'); 977 978 if ( mainImg.length === 0 || images == null || images.length === 0 ) { 979 return; 980 } 981 982 mainImg.attr('src', images[0].fullZoom); 983 984 var container = mainImg.closest('.images'); 985 var thumbnails = container.find('.alECarteThumbnails'); 986 var newThumbnails = $("<ul class='thumbnails alECarteThumbnails'></ul>"); 987 var thumbCount = 0; 988 989 for( var i = 0;i < images.length;i++ ) { 990 991 if( !images[i].smallThumb ) { 992 continue; 993 } 994 995 var isFirst = ( thumbCount === 0 ); 996 997 var thumbLink = $("<a href='#'></a>") 998 .addClass('alECarteThumb' + (isFirst ? ' selected' : '')) 999 .attr('data-fullzoom', images[i].fullZoom) 1000 .append($("<img />").attr('src', images[i].smallThumb).attr('alt', images[i].title || '')); 1001 1002 newThumbnails.append($("<li></li>").addClass('img' + (isFirst ? ' first' : '')).append(thumbLink)); 1003 thumbCount++; 1004 } 1005 1006 // Match the JSP, which only renders the strip when there is more than one image 1007 if ( thumbCount > 1 ) { 1008 if ( thumbnails.length > 0 ) { 1009 thumbnails.replaceWith(newThumbnails); 1010 } else { 1011 mainImg.after(newThumbnails); 1012 } 1013 container.addClass('has-thumbs'); 1014 } else { 1015 thumbnails.remove(); 1016 container.removeClass('has-thumbs'); 1017 } 1018 }; 1019 con.bindImageSwap = function() { 1020 var img = $('#thumbnails').find('.img'); 1021 $('#thumbnails').find('.img').click( con.imageSwap ); 1022 }; 1023}; 1024 1025 1026HJCONTAINER.components.designYourRing = function(con) { 1027 con.designYourRingInit = function() { 1028 $(".designGender").on("click", function(event){ 1029 con.designYourRingGender = $(event.target).parent().index() ? "Female" : "Male"; 1030 (con.designYourRingMakeGradCallback())(); 1031 }); 1032 1033 con.designYourRingHookupGo(); 1034 }; 1035 1036 con.designYourRingHookupGo = function() { 1037 $(".designRingGradPop button").on("click", con.designYourRingMaybeGo); 1038 $(".designRingGradPop input").keyup(function(event){ 1039 if(event.keyCode == 13) 1040 con.designYourRingMaybeGo(); 1041 }); 1042 $("#designRingCheckout").on("click", con.designPackageRing()); 1043 }; 1044 1045 con.designPackageRing = function() { 1046 return function(event) { 1047 window.location = schoolUrlPrefix + "/rings/list?promoId=P2"; 1048 return false; 1049 } 1050 } 1051 1052 con.designYourRingMakePackageCallback = function(gender) { 1053 return function(event) { 1054 con.designYourRingGender = gender; 1055 1056 // A ring inside a fine paper package is always a P2 ring. 1057 // If this ever changes, we'll need more information from the package which is not supplied at this time 1058 // Therefore, hard coding this to P2 for the time being. 1059 con.promoId = "P2"; 1060 1061 con.genderOnLeft = true; 1062 con.designYourRingRedirect = "/secom/rings/collections?gender=" + gender; 1063 (con.designYourRingMakeGradCallback(true))(event); 1064 return false;
1065 }; 1066 }; 1067 1068 1069 con.designYourRingMakeGenderCallback = function(left) { 1070 return function(event){ 1071 $("body").on("click", con.designYourRingPopClick); 1072 con.promoId = $(event.target).closest(".imageWithSubtitles").attr("data-info"); 1073 con.promoAvailable = $(event.target).closest(".imageWithSubtitles").attr("data-promotion"); 1074 con.promoModalText = $(event.target).closest(".imageWithSubtitles").attr("data-modaltext"); 1075 con.promoInitialGradYear = $(event.target).closest(".imageWithSubtitles").attr("data-initialgradyear"); 1076 1077 if (con.promoAvailable == "Seniors" && con.promoId.length) { 1078 if (con.promoModalText && con.promoModalText.length) { 1079 $("#gradYearAreaText").text(con.promoModalText); 1080 } 1081 $(".designRingGradPop input").val(con.promoInitialGradYear); 1082 $(".designRingGradPop input").attr("readonly",true); 1083 $(".designRingGradPop").css("width","193px"); 1084 } 1085 if (!con.promoId) { 1086 $("#gradYearAreaText").text("When do you Graduate?"); 1087 $(".designRingGradPop input").attr("readonly",false); 1088 } 1089 1090 con.genderOnLeft = left; 1091 var offset = $(this).offset(); 1092 offset.top += $(this).outerHeight(); 1093 1094 var inModal = $(this).closest(".modal"); 1095 if(inModal.length) // in a modal? 1096 $(".designRingGenderPop").appendTo(inModal); 1097 $(".designRingGenderPop").show().offset(offset); 1098 return false; 1099 }; 1100 }; 1101 1102 1103 con.designYourRingMakeGradCallback = function(bottomAlign) { 1104 return function(event) { 1105 $("body").on("click", con.designYourRingPopClick); 1106 var nextTo = $(".designRingGenderPop:visible"); 1107 if(!nextTo.length) 1108 nextTo = $(event.target); 1109 var offset = nextTo.offset(); 1110 1111 var pop = $(".designRingGradPop"); 1112 if(con.genderOnLeft) 1113 offset.left -= pop.outerWidth(); 1114 else 1115 offset.left += nextTo.outerWidth(); 1116 if(bottomAlign) 1117 offset.top -= nextTo.outerHeight(); 1118 1119 var inModal = $(this).closest(".modal"); 1120 if(inModal.length) // in a modal? 1121 pop.appendTo(inModal); 1122 pop.show().offset(offset); 1123 pop.find("input").focus(); 1124 return false; 1125 }; 1126 }; 1127 1128 con.designYourRingMaybeGo = function() { 1129 var pop = $(".designRingGradPop"); 1130 var year = pop.find("input").val(); 1131
1132 var validYears = $("#container").attr("data-validgradyears"); 1133 validYears = validYears ? validYears.split(",") : []; 1134 1135 var browseMode = $("#container").attr("data-browseMode") == "true"; 1136 1137 // This can not be removed until browse mode is removed from the senior side. 1138 // However note, if browse mode is removed from the senior side, this needs to be changed 1139 // to reflect if a pricelist is offline or not. 1140 // Additionally, be careful because a ring price list may be offline, 1141 // But if a fine paper package has a ring in it, it needs to launch the P2 ring configuration. 1142 var pricelistAvailable = $("#container").attr("data-pricelistAvailable") == "true"; 1143 1144 var why = null; 1145 var sub = ""; 1146 var title = ""; 1147 1148 year = parseInt(year, 10); 1149 if((year > 999) && (year < 10000)) { // 1-3 digits 1150 con.designYourRingHideGenderGradModals(); 1151 1152 var showModalWarning = false; 1153 if(!$("#designRingBrowseModeWarningModal").length) { 1154 if(_.indexOf(validYears, year.toString()) == -1) { 1155 showModalWarning = true; 1156 } else if(!con.promoId) { 1157 // If this isn't a ring promotion 1158 if( browseMode ) { 1159 showModalWarning = true; 1160 } 1161 else if (!pricelistAvailable) { 1162 showModalWarning = true; 1163 } 1164 } 1165 } 1166 1167 if (showModalWarning) { 1168 title = ""; 1169 why = "Your custom class ring is only moments away"; 1170 sub = "Contact your Herff Jones Sales Representative below with any questions at all.<br />Happy designing!"; 1171 $("#designRingWarningModal").find(".continue").html("<span>Design your ring now</span>"); 1172 $("#designRingWarningModal").find(".continue").addClass("noPriceList"); 1173 $("#designRingWarningModal").find(".hjbtn.blue").filter('a[data-dismiss="modal"]').css("display","none"); 1174 } 1175 1176 1177 var loc = "/secom/rings/collections?gender=" + con.designYourRingGender + "&gradYear=" + year; 1178 1179 if(con.promoId) 1180 loc += "&promoId=" + con.promoId + "&promoMode=true"; 1181 1182 if(pop.attr("ringid")) 1183 loc = "home?ringId=" + pop.attr("ringid") + "&gender=" + con.designYourRingGender + "&gradYear=" + year; 1184 1185 if(con.designYourRingRedirect) 1186 loc = con.designYourRingRedirect + "&gradYear=" + year; 1187 1188 if(why) { 1189 var modal = $("#designRingWarningModal"); 1190 modal.find(".modal-header .title").html(title); 1191 modal.find(".why").html(why); 1192 modal.find(".sub").html(sub); 1193 modal.find(".continue").attr("href", loc); 1194 launchModal(modal, "show", "ringLandings/warning/" + title); 1195 } 1196 else { 1197 var browseModeWarning = $("#designRingBrowseModeWarningModal"); 1198 if(browseModeWarning.length) { 1199 browseModeWarning.find('a[data-control="browseModeWarningContinue"]').attr("href", loc); 1200 launchModal($("#designRingBrowseModeWarningModal"), "show", "ringLandings/warning/browseMode"); 1201 } 1202 else 1203 window.location = loc; 1204 } 1205 } else { 1206 pop.addClass("expanded"); 1207 } 1208 }; 1209 con.designYourRingHideGenderGradModals = function() { 1210 $(".designRingGenderPop, .designRingGradPop").hide(); 1211 $("body").off("click", con.designYourRingPopClick); 1212 }; 1213 con.designYourRingPopClick = function(event) { 1214 if(!$(event.target).closest(".designRingGenderPop, .designRingGradPop").length) 1215 con.designYourRingHideGenderGradModals(); 1216 }; 1217 1218 con.designYourRingInit(); // just call it 1219};
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.