!(function(){ /** * @class * @param {jQuery} container DOM node with .refresh button * @requiresDOM .refresh, .playAudio, .cq_captchakey, .captchaVal, .captchaVarTime, .cq_captcha, .audioCaptcha * @TODO move to some nested namespace (twytrebowicz) * @TODO refactor with new registration (twytrebowicz) */ portalGGA.Captcha = function Captcha(container,playCaptchaURL){ this.container = container; this.hours = "0"; this.captchaStartTime = 0; this.playCaptchaURL = playCaptchaURL; this.container.find('.refresh').on('click.captcha', $.proxy( this.refresh, this ) ); this.container.find('.playAudio').on('click.captcha', $.proxy( this.playAudio,this ) ); this.refresh(); }; /** * [refresh description] * @TODO return something (twytrebowicz) */ portalGGA.Captcha.prototype.refresh = function refresh() { this.container.find('.audioCaptcha').text(""); this.container.find('.captchaVal').val(""); this.container.find('.cq_captcha').val(""); var d = new Date(); this.hours = d.getTime(); var captchakey = ("" + Math.random()).substring(3, 8); var image = this.container.find('.cq_captchaimg'); var urlParam = image.attr('src'); //image.attr('src',urlParam.split("?")[0] + "?id=" + captchakey+"&hours="+this.hours); this.container.find('.cq_captchakey').val(captchakey); captchaStartTime = new Date().getTime(); this.container.find('.captchaVarTime').val(captchaStartTime); } /** * [captchaTimer description] * @TODO return something (twytrebowicz) */ portalGGA.Captcha.prototype.captchaTimer = function captchaTimer() { var now = new Date().getTime(); if ((now - this.captchaStartTime) > 60000) { this.refresh(); } var captchatimer = document.getElementById("cq_captchatimer"); var width = Math.floor((60000 - (now - captchaStartTime)) / 60000 * 64); captchatimer.innerHTML = "
"; window.setTimeout(this.captchaTimer(), 1500); } /** * [playAudio description] * @TODO return something (twytrebowicz) */ portalGGA.Captcha.prototype.playAudio = function playAudio(){ var captchakey = this.container.find('.cq_captchakey').val(); var playAction = this.playCaptchaURL; this.setEmbed( playAction+'?captchakey='+captchakey+'&hours='+this.hours+'&time='+new Date().getTime()); } /** * [setEmbed description] * @TODO return something (twytrebowicz) */ portalGGA.Captcha.prototype.setEmbed = function setEmbed( dir) { var agt=navigator.userAgent.toLowerCase(); var element = this.container.find('.audioCaptcha'); if (agt.indexOf("firefox")!=-1) { element.html(""); } else if(agt.indexOf("chrome")!=-1) element.html(''); else { element.html(""); } } /** * [getMimeType description] * @TODO return something (twytrebowicz) */ portalGGA.Captcha.prototype.getMimeType = function getMimeType(){ var mimeType = "application/x-mplayer2"; //default var agt=navigator.userAgent.toLowerCase(); if (navigator.mimeTypes && agt.indexOf("windows")==-1) { //non-IE, no-Windows var plugin=navigator.mimeTypes["audio/mpeg"].enabledPlugin; if (plugin) mimeType="audio/mpeg" //Mac/Safari & Linux/FFox }//end no-Windows return mimeType } }()); !(function($, redirect, session, localStorage, NeedPlayerVerification, CommunicationPreferences,NotificationPreferences,GetNotificationPref) { /** * @classDesc Model of registration form * @class * @requires portalGGA.models.Player * @requires portalGGA.Captcha * @TODO: email validation, veryfication, phone, ssn split/join */ portalGGA.models.RegistrationForm = Backbone.Model.extend( /** @lends portalGGA.models.RegistrationForm.prototype */ { /** * Enclose Player model, for better namespacing attributes. * @author Tomek.Wytrebowicz@gtech.com * */ constructor: function RegistrationFormModel() { Backbone.Model.apply(this, arguments); this.registration || (this.registration = new portalGGA.models.Player()); this.attributes.registration = this.registration.attributes; //this.checkEmailAvailabilityModel = new portalGGA.models.player.CheckEmailAvailability(); $('.panel-title a').on('click', function(e) { e.preventDefault(); }); $('#addAnotherQuestion').on('click', function() { var lastInstance = $(this).parent().parent().prev(); var container = $("#securityQuestionsGroup").children('div').length, maxCount = 3; if (container <= maxCount) { cloneinstance = lastInstance.clone(); setTimeout(function() { cloneinstance.addClass('in'); }, 1000); cloneinstance.find('input').attr('name', cloneinstance.find('input').attr('name').replace(/\d/, (container))).val(""); cloneinstance.find('.form-group').removeClass("has-success has-feedback"); cloneinstance.find('.form-control-feedback').detach(); cloneinstance.find('select').attr('name', cloneinstance.find('select').attr('name').replace(/\d/, (container))).val(""); cloneinstance.find('select').removeAttr('required'); cloneinstance.find('select').attr("securityquestionrequired", 'true'); cloneinstance.find('select').attr("id", "registrationPasswordHintQuestions" + container); cloneinstance.find('input').attr("id", "registrationPasswordHintAns" + container); if (container == 3) { cloneinstance.find('#security-question2').attr("id", "security-question" + container); cloneinstance.find('#security-answer2').attr("id", "security-answer" + container); cloneinstance.find('#registrationPasswordHintQuestions2-error').remove(); cloneinstance.find('#registrationPasswordHintAns2-error').remove(); } cloneinstance.find('#registrationPasswordHintAns-error').remove(); cloneinstance.find('#registrationPasswordHintQuestions' + container).parent().parent().removeClass('has-error'); cloneinstance.find('#registrationPasswordHintAns' + container).parent().parent().removeClass('has-error'); cloneinstance.find('button').removeClass('hide'); cloneinstance.find('#security-question').attr("id", "security-question" + container); cloneinstance.find('#security-answer').attr("id", "security-answer" + container); cloneinstance.find('label').map(function() { $(this).text($(this).text().replace(/\d/, container)); }); cloneinstance.find('.required').removeClass('required'); cloneinstance.insertAfter(lastInstance); } if (container == maxCount) { $(this).closest('.form-group').removeClass('in').addClass('out'); } $('[data-action="delete"]').on('click', function() { el = $(this); el.closest('.question').removeClass('in').addClass('out'); /*el('#securityQuestionsGroups').find('label').map(function() { $(this).text($(this).text().replace(/\d/,container)); });*/ setTimeout(function() { el.closest('.question').remove(); }, 100); if (container == maxCount - 1) { $('#security-question' + maxCount).attr("id", "security-question" + container).text($('#security-question' + container).text().replace(/\d/, container)); $('#security-answer' + maxCount).attr("id", "security-answer" + container).text($('#security-answer' + container).text().replace(/\d/, container)); $('#registrationPasswordHintQuestions' + maxCount).attr("name", "registration[personalInfo][passwordHints][" + container + "][securityQuestion][question]"); $('#registrationPasswordHintAns' + maxCount).attr("name", "registration[personalInfo][passwordHints][" + container + "][securityAnswer][answer]"); $('#registrationPasswordHintQuestions' + maxCount).attr("for", "registrationPasswordHintQuestions" + container); $('#registrationPasswordHintAns' + maxCount).attr("for", "registrationPasswordHintAns" + container); $('#registrationPasswordHintQuestions' + maxCount).attr("id", "registrationPasswordHintQuestions" + container); $('#registrationPasswordHintAns' + maxCount).attr("id", "registrationPasswordHintAns" + container); $('#registrationPasswordHintQuestions3-error').attr("for", "registrationPasswordHintQuestions" + container); $('#registrationPasswordHintAns3-error').attr("for", "registrationPasswordHintAns" + container); $('#registrationPasswordHintQuestions3-error').attr("id", "registrationPasswordHintQuestions" + container + "-error"); $('#registrationPasswordHintAns3-error').attr("id", "registrationPasswordHintAns" + container + "-error"); $('#addAnotherQuestion').closest('.form-group').removeClass('out').addClass('in'); } if (container == maxCount) { var count = container - 1; $('#security-question' + maxCount).attr("id", "security-question" + count).text($('#security-question' + count).text().replace(/\d/, count)); $('#security-answer' + maxCount).attr("id", "security-answer" + count).text($('#security-answer' + count).text().replace(/\d/, count)); $('#registrationPasswordHintQuestions' + maxCount).attr("name", "registration[personalInfo][passwordHints][" + count + "][securityQuestion][question]"); $('#registrationPasswordHintAns' + maxCount).attr("name", "registration[personalInfo][passwordHints][" + count + "][securityAnswer][answer]"); $('#registrationPasswordHintQuestions' + maxCount).attr("for", "registrationPasswordHintQuestions" + count); $('#registrationPasswordHintAns' + maxCount).attr("for", "registrationPasswordHintAns" + count); $('#registrationPasswordHintQuestions' + maxCount).attr("id", "registrationPasswordHintQuestions" + count); $('#registrationPasswordHintAns' + maxCount).attr("id", "registrationPasswordHintAns" + count); $('#registrationPasswordHintQuestions3-error').attr("for", "registrationPasswordHintQuestions" + count); $('#registrationPasswordHintAns3-error').attr("for", "registrationPasswordHintAns" + count); $('#registrationPasswordHintQuestions3-error').attr("id", "registrationPasswordHintQuestions" + count + "-error"); $('#registrationPasswordHintAns3-error').attr("id", "registrationPasswordHintAns" + count + "-error"); $('#addAnotherQuestion').closest('.form-group').removeClass('out').addClass('in'); } }); }); $('.registration-secQuestion option:nth-child(1)').attr('hidden', 'hidden'); $('.registration-secQuestion option:nth-child(2)').attr('selected', 'selected'); }, /** * Extend Backbone's set to allow setting nested models directly with json. * @see Backbone.Model.prototype.set */ set: function set(key, value, options) { if (_.isObject(key) || key == null) { attrs = key; options = value; } else { attrs = {}; attrs[key] = value; } if (attrs.registration && !attrs.registration instanceof Backbone.Model === false) { attrs.registration = this.registration.set(attrs.registration).attributes; } return Backbone.Model.prototype.set.apply(this, arguments); } }); /** * @class * @classDesc View of registration form. * Could work as a subcomponent of card registration, or as a standalone form. * @requires portalGGA.models.Player * @requires portalGGA.models.player.PersonalInfo * @requires portalGGA.Captcha * @requires portalGGA.utils.globalErrorNotifier * @requires jQuery.validation * @author Tomek.Wytrebowicz@gtech.com * @TODO: email validation, veryfication, phone, ssn split */ portalGGA.views.Registration = Backbone.View.extend( /** @lends portalGGA.views.Registration.prototype */ { /** steps counter */ currentStep: 0, /** {Boolean} is transition in progress? */ transitionInProgress: false, /** {jQuery} collection of all step containers */ steps: null, /** {jQuery} container for billing address*/ billing: null, isChecked: false, isMobile: { Android: function() { return navigator.userAgent.match(/Android/i); }, BlackBerry: function() { return navigator.userAgent.match(/BlackBerry/i); }, iOS: function() { return /iPhone|iPad|iPod/i.test(navigator.userAgent); }, Opera: function() { return /Opera Mini/i.test(navigator.userAgent); }, Windows: function() { return /IEMobile/i.test(navigator.userAgent); }, any: function() { return (this.Android() || this.BlackBerry() || this.iOS() || this.Opera() || this.Windows()); } }, events: { "click span.nextStep": "changeStep", "submit #candidateForm": "changeStep", "click button.prevStep": function prevStep(e) { return this.changeStep(e, -1); }, "click button[type=reset]": "reset", "click #acceptterms": function checked(e) { if ($('#acceptterms').is(':checked')) this.isChecked = true; else this.isChecked = false; }, "click #prevAddedNumber": "usePhoneChecked", "click .billingSameAsMailing": "toggleBillingSameAsMailing", "click .showConfirmation": "showConfirmation", "submit #confirmRegistration": "save", "change .acceptsRewards": "changeAcceptsRewards", "click #registrationCancel": "cancel", "click #autologinBox": "autoLoginOption", "change #birthday_year": function changed(e) { this.getDays(e); }, "change #birthday_month": function changed(e) { this.getDays(e); // this.getDob(); }, "click .deselect-all-form": "deselectCheckbox", "blur #email": "checkEmailAvailability" }, checkEmailAvailability: function checkEmailAvailability() { var self = this; var email = $('#email').val(); var checkEmailAvailabilityModel = new portalGGA.models.player.CheckEmailAvailability(); email = $.trim(email); if (email && email != null && email != undefined && email != "") { checkEmailAvailabilityModel.fetch({ data: { type: "email", value: email } }).then( function(response) { if (response.available) {} else { $("#errorModal").html(handleEmailAvailability()).find(".modal").modal(); } }, function(failure) {}); } }, /** * Change step. Perform validation and crosfades. * @author Tomek.Wytrebowicz@gtech.com * @param {Event} event not used * @param {Number} direction * @return {portalGGA.views.Registration} self * * @TODO: move card toggle to registrationwith WC (twytrebowicz) */ changeStep: function changeStep(event, direction) { // $(event.target).button("loading"); // console.log(handleEmailAvailability) var self = this; if (self.transitionInProgress) { return this; } portalGGA.utils.globalErrorNotifier.clear(); direction = direction || +1; $('.panel-title a').on('click', function(e) { e.preventDefault(); }); if ((self.$('#candidateForm').valid() && $('#confirmRegistration').valid())) { if (self.isChecked == false) { return false; } $('#registrationForm_step1').addClass('hide'); $('#registrationForm_step2').removeClass('hide'); $('#userName').html("Hi "+ $('#registrationFirstName').val()+", Welcome to the VIP Club!"); $('#registrationStep1').hide(); ga('send', 'event', 'VIP Club Registration', 'Sign In', 'Sign In'); // $('[href="#registrationStep1"]').closest('.panel-heading').removeClass('active').addClass('complete'); // $('#registrationForm_step1').find('.panel-heading').find('a').append(''); $('#registrationStep2').show(); // $('[href="#registrationStep2"]').closest('.panel-heading').addClass('active'); // $('#registrationForm_step2 #userName')[0].scrollIntoView(); setTimeout(function() { $("#topNav").get(0).scrollIntoView() // $("#registrationStep2").get(0).scrollIntoView(); }, 500); $('[href="#registrationStep1"]').one('click', function(e) { e.preventDefault(); $(' #registrationStep2').collapse('hide'); $(' #registrationStep1').collapse('show'); $('.panel-heading').removeClass('active').addClass('complete'); $('[href="#registrationStep1"]').closest('.panel-heading').removeClass('complete').addClass('active').find('span').remove(); }); if ($('#candidateForm').find('.has-error').length != 0) { for (var i = 0; i < $('#candidateForm').find('.has-error').find('input').length; i++) { var inputid = "#" + $('#candidateForm').find('.has-error').find('input')[i].getAttribute('id').replace(/(:|\.|\[|\])/g, "\\$1"); $(inputid).focusout(); } for (var i = 0; i < $('#candidateForm').find('.has-error').find('select').length; i++) { var inputid = "#" + $('#candidateForm').find('.has-error').find('select')[i].getAttribute('id').replace(/(:|\.|\[|\])/g, "\\$1"); $(inputid).focusout(); } } } else { var errors = $('#candidateForm').find('.error'); _.each(errors, function(error) { if (error.innerHTML != "") { error.focus(); return; } }); } return this; }, /** * Creates model if not given, bind auto tabs,.. * @param {Object} options * @param {String} options.successRedirectURL Where to redirect on successful registration? * @param {String} options.captchaPlayURL CAPTCHA */ constructor: function RegistrationFormView(options) { Backbone.View.apply(this, arguments); this.options = options; _.bindAll(this, "reset"); this.notificationsMap = { 'CSH5_INFO' : ['CSH5_INFO', 'GAME_CSH5','EMAIL'], 'P6_INFO' : ['P6_INFO', 'GAME_P6','EMAIL'], 'P4_INFO' : ['P4_INFO', 'GAME_P4','EMAIL'], 'P3_INFO' : ['P3_INFO', 'GAME_P3','EMAIL'], 'C4L_INFO' : ['C4L_INFO', 'GAME_C4L','EMAIL'], 'PB_INFO' : ['PB_INFO', 'GAME_PB','EMAIL'], 'MM_INFO' : ['MM_INFO', 'GAME_MM','EMAIL'], 'FASTPLAY_INFO' : ['FASTPLAY_INFO', 'GAME_FP','EMAIL'], 'FIVECARDCASH_INFO' : ['FIVECARDCASH_INFO', 'GAME_FIVE_CARD','EMAIL'], 'KENO_INFO' : ['KENO_INFO', 'GAME_QUICK_DRAW','EMAIL'], 'INSTANT_GAME_INFO' : ['INSTANT_GAME_INFO', 'GAME_INSTANT_GAME_INFO','EMAIL'], 'MDR_INFO' : ['MDR_INFO', 'GAME_MDR_INFO','EMAIL'], 'COLLECT_N_WIN_INFO' : ['COLLECT_N_WIN_INFO', 'GAME_COLLECT_N_WIN_INFO','EMAIL'], 'OPTIN_INFO' : ['OPTIN_INFO', 'GAME_OPTIN_INFO','EMAIL'], 'LBZ_INFO' : ['LBZ_INFO', 'GAME_LBZ_INFO','EMAIL'], 'INSTANT_PRICE_1_INFO' : ['INSTANT_PRICE_1_INFO', 'INSTANT_GAME_PRICE_1','EMAIL'], 'INSTANT_PRICE_2_INFO' : ['INSTANT_PRICE_2_INFO', 'INSTANT_GAME_PRICE_2','EMAIL'], 'INSTANT_PRICE_3_INFO' : ['INSTANT_PRICE_3_INFO', 'INSTANT_GAME_PRICE_3','EMAIL'], 'INSTANT_PRICE_5_INFO' : ['INSTANT_PRICE_5_INFO', 'INSTANT_GAME_PRICE_5','EMAIL'], 'INSTANT_PRICE_10_INFO' : ['INSTANT_PRICE_10_INFO', 'INSTANT_GAME_PRICE_10','EMAIL'], 'INSTANT_PRICE_20_INFO' : ['INSTANT_PRICE_20_INFO', 'INSTANT_GAME_PRICE_20','EMAIL'], 'INSTANT_PRICE_25_INFO' : ['INSTANT_PRICE_25_INFO', 'INSTANT_GAME_PRICE_25','EMAIL'], 'INSTANT_PRICE_30_INFO' : ['INSTANT_PRICE_30_INFO', 'INSTANT_GAME_PRICE_30','EMAIL'], 'DRAW_GAMES_INFO' : ['DRAW_GAMES_INFO', 'DRAW_GAME_INFO','EMAIL'], 'GAMES_INFO' : ['GAMES_INFO','GAME_INFO','EMAIL'], 'JACKPOT_ALERT_INFO' : ['JACKPOT_ALERT_INFO',"JACKPOT_ALERT_GAME_INFO",'EMAIL'], 'JACKPOT_PB_INFO' : ['JACKPOT_PB_INFO','JACKPOT_PB_GAME_INFO','EMAIL'], 'JACKPOT_MM_INFO' : ['JACKPOT_MM_INFO','JACKPOT_MM_GAME_INFO','EMAIL'], 'JACKPOT_CSH5_INFO' : ['JACKPOT_CSH5_INFO','JACKPOT_CSH5_GAME_INFO','EMAIL'], 'JACKPOT_P6_INFO' : ['JACKPOT_P6_INFO','JACKPOT_P6_GAME_INFO','EMAIL'], 'JACKPOT_CSH5' : ['JACKPOT_CSH5', 'JACKPOT_CASH5_PUSH','PUSH_CLIENT'], 'JACKPOT_MM' : ['JACKPOT_MM', 'JACKPOT_MM','PUSH_CLIENT'], 'JACKPOT_P6' : ['JACKPOT_P6', 'JACKPOT_P6','PUSH_CLIENT'], 'JACKPOT_PB' : ['JACKPOT_PB', 'JACKPOT_PB','PUSH_CLIENT'], 'RESULTS_CSH5' : ['RESULTS_CSH5', 'RESULT_C5','PUSH_CLIENT'], 'RESULTS_MM' : ['RESULTS_MM', 'RESULT_MM','PUSH_CLIENT'], 'RESULTS_P3' : ['RESULTS_P3', 'RESULT_P3','PUSH_CLIENT'], 'RESULTS_P4' : ['RESULTS_P4', 'RESULT_P4','PUSH_CLIENT'], 'RESULTS_P6' : ['RESULTS_P6', 'RESULT_P6','PUSH_CLIENT'], 'RESULTS_C4L' : ['RESULTS_C4L', 'RESULT_C4','PUSH_CLIENT'], 'RESULTS_PB' : ['RESULTS_PB', 'RESULT_PB','PUSH_CLIENT'], 'RESULTS_FIVECARDCASH' : ['RESULTS_FIVECARDCASH', 'RESULT_5C','PUSH_CLIENT'], 'PROMO_MESSAGE' : ['PROMO_MESSAGE', 'PROMOTION_MSG','PUSH_CLIENT'], 'JackpotAlert' : ['JackpotAlert', 'JACKPOT_ALERT_PUSH','PUSH_CLIENT'], 'DailyWinningNumbers' : ['DailyWinningNumbers', 'DailyWinningNumbers_INFO','EMAIL'], 'SecondChanceOptIn' : ['SecondChanceOptIn', 'optinDrawingsAlerts','EMAIL'], 'NewsEvent' : ['NewsEvent', 'eventNewsletterAlerts','EMAIL'], 'ParticipateOnlineSurveys' : ['ParticipateOnlineSurveys', 'participateOnlineSurveys','EMAIL'], 'JACKPOT_CSH5_TEXT' : ['JACKPOT_CSH5_TEXT', 'JACKPOT_CSH5_GAME_TEXT','SMS'], 'PROMO_MESSAGE_TEXT' : ['PROMO_MESSAGE_TEXT', 'PROMO_MESSAGE_GAME_TEXT','SMS'], 'SecondChanceOptIn_TEXT' : ['SecondChanceOptIn_TEXT', 'SecondChanceOptIn_GAME_TEXT','SMS'], 'JACKPOT_PB_TEXT' : ['JACKPOT_PB_TEXT', 'JACKPOT_PB_GAME_TEXT','SMS'], 'JACKPOT_P6_TEXT' : ['JACKPOT_P6_TEXT', 'JACKPOT_P6_GAME_TEXT','SMS'], 'JACKPOT_MM_TEXT' : ['JACKPOT_MM_TEXT', 'JACKPOT_MM_GAME_TEXT','SMS'], 'ParticipateOnlineSurveys_TEXT' : ['ParticipateOnlineSurveys_TEXT', 'ParticipateOnlineSurveys_GAME_TEXT','SMS'], 'JACKPOT_ALERT_TEXT' : ['JACKPOT_ALERT_TEXT', 'JACKPOT_ALERT_GAME_TEXT','SMS'], 'MDR_TEXT' : ['MDR_TEXT', 'GAME_MDR_TEXT','SMS'], 'COLLECT_N_WIN_TEXT' : ['COLLECT_N_WIN_TEXT', 'GAME_COLLECT_N_WIN_TEXT','SMS'], 'OPTIN_TEXT' : ['OPTIN_TEXT', 'GAME_OPTIN_TEXT','SMS'], 'LBZ_TEXT' : ['LBZ_TEXT', 'GAME_LBZ_TEXT','SMS'], 'SecondChanceOptIn_PUSH': ['SecondChanceOptIn_PUSH','SecondChanceOptIn_GAME_PUSH','PUSH_CLIENT'], 'NewsEvent_PUSH' : ['NewsEvent_PUSH','NewsEvent_GAME_PUSH','PUSH_CLIENT'], 'ParticipateOnlineSurveys_PUSH' : ['ParticipateOnlineSurveys_PUSH','ParticipateOnlineSurveys_GAME_PUSH','PUSH_CLIENT'] }; this.steps = this.$('.registrationStep'); this.toggleBillingSameAsMailing(null, true); this.isAutoLoginEnabled = options.isAutoLoginEnabled; this.model || (this.model = new portalGGA.models.RegistrationForm()); this.communicationPreferencesModel = new CommunicationPreferences(); this.getNotificationPrefCollection = new portalGGA.models.GetNotificationPreferences(); this.notificationsCollection = new portalGGA.models.player.NotificationPreferences(); this.birthdayMonth = 0; this.birthdayYear = 0; //Bind datepicker var self = this; this.optinModel = new portalGGA.models.MobileCarrier(); this.handleSelectAll(); this.bindPhoneNumber(); this.handleInputChange(); $('.text-checkbox').on('click',function(){ $('#textAccordionTrigger').trigger('click'); }); $('#emailCheckbox').on('click',function(){ $('#emailAccordian').trigger('click'); }); $('#geoLocationOptin').hide(); session.willBeReady.then(function bindSessionData(session) { if (portalGGA.utils.session.isAuthenticated()) redirect.send(self.options.successRedirectURL); }); if (!this.isMobile.any()) { portalGGA.utils.forms.automaticTab(this.$('input.autoTab-ssn')); portalGGA.utils.forms.automaticTab(this.$('input.autoTab-phonesHome')); portalGGA.utils.forms.automaticTab(this.$('input.autoTab-phonesMobile')); portalGGA.utils.forms.automaticTab(this.$('input.autoTab-homePostalCode')); portalGGA.utils.forms.automaticTab(this.$('input.autoTab-billingPostalCode')); } if (this.isAutoLoginEnabled && sessionStorage.getItem('quickcheckout')) { $('.autologinBoxDiv').hide(); $('#autoLogin').val('true'); } $("#GAME_INFO").prop("checked",true); $("#optinDrawingsAlerts").prop("checked",true); $('.emailsection').trigger('click'); $('#emailAccordian').trigger('click'); $('.gameupdateoffer').trigger('click'); jQuery.validator.setDefaults({ highlight: function(element, errorClass, validClass) { if (element.type === "radio" || element.type === "checkbox") { this.findByName(element.name).addClass(errorClass).removeClass(validClass); } else if ($(element).parent().hasClass('input-inline') || $(element).parent().hasClass('input-group')) { $(element).closest('.form-group').addClass('has-error'); $(element).closest('.form-group').attr('tabindex', '0'); } else { $(element).closest('.form-group').removeClass('has-success has-feedback').addClass('has-error has-feedback').find('span').remove(); $(element).closest('.form-row').find('span').remove(); $(element).parent().find('span.glyphicon').remove(); $(element).parent().find('.error').attr("tabindex","0") //$('').insertAfter(element); } }, unhighlight: function(element, errorClass, validClass) { if (element.type === "radio" || element.type === "checkbox") { this.findByName(element.name).removeClass(errorClass).addClass(validClass); } else if ($(element).parent().hasClass('input-inline') || $(element).parent().hasClass('input-group')) { $(element).closest('.form-group').removeClass('has-error'); } else { $(element).closest('.form-group').removeClass('has-error has-feedback').find('span').remove(); $(element).closest('.form-group').find('.error').remove(); /* $(element).closest('.form-group').removeClass('has-error has-feedback').addClass('has-success has-feedback').find('span').remove(); $(element).parent().find('span.glyphicon').remove(); $('').insertAfter(element); */ } }, errorPlacement: function(error, element) { if (element.parent('.input-group').length || element.prop('type') === 'checkbox' || element.prop('type') === 'radio') { error.insertAfter(element.parent()); } else if ($(element).parent().hasClass('input-inline') || $(element).parent().hasClass('input-group')) { $(element).closest('.form-group').find('>div').append(error); } else { error.insertAfter(element); } } }); jQuery.validator.addMethod('DOB', function(value, element, param) { $(element).attr('data-dobvalidate', "true"); var validate_day = JSON.parse($('#birthday_day').attr('data-dobvalidate')); var validate_month = JSON.parse($('#birthday_month').attr('data-dobvalidate')); var validate_year = JSON.parse($('#birthday_year').attr('data-dobvalidate')); if (validate_day && validate_month && validate_year) { var day = $('#birthday_day').val(); var month = $('#birthday_month').val(); var year = $('#birthday_year').val(); var date = new Date(year, month - 1, day); return this.optional(element) || !/Invalid|NaN/.test(date); } else { return true; } }, 'Please enter a valid date of birth'); jQuery.validator.addMethod('DOB18', function(value, element, param) { $(element).attr('data-dobvalidate', "true"); var validate_day = JSON.parse($('#birthday_day').attr('data-dobvalidate')); var validate_month = JSON.parse($('#birthday_month').attr('data-dobvalidate')); var validate_year = JSON.parse($('#birthday_year').attr('data-dobvalidate')); var birthday = $('#birthday_day').val(); var birthmonth = $('#birthday_month').val(); var birthyear = $('#birthday_year').val(); var today = new Date(); var nowyear = today.getFullYear(); var nowmonth = today.getMonth(); var nowday = today.getDate(); var age = nowyear - birthyear; var age_month = nowmonth - birthmonth; var age_day = nowday - birthday; var isValid = false; if (validate_day && validate_month && validate_year) { var isNinteen = false; if (age_month < 0 || (age_month == 0 && age_day < 0)) { if (age == 19) { isNinteen = true; } age = parseInt(age) - 1; } if (false == isNinteen && (age == 18 && age_month < 0 && age_day < 0) || age < 18) { isValid = false; } else { isValid = true; } } else { isValid = true; } return this.optional(element) || isValid; }, 'Age should be at least 18 years'); jQuery.validator.addMethod('DOBRequired', function(value, element, param) { var isValid = false; $(element).attr('data-dobvalidate', "true"); var validate_day = JSON.parse($('#birthday_day').attr('data-dobvalidate')); var validate_month = JSON.parse($('#birthday_month').attr('data-dobvalidate')); var validate_year = JSON.parse($('#birthday_year').attr('data-dobvalidate')); if (validate_day && validate_month && validate_year) { if ($('#birthday_day').val() == "") isValid = false; else if ($('#birthday_month').val() == "") isValid = false; else if ($('#birthday_year').val() == "") isValid = false; else isValid = true; } else { isValid = true; } //CQ.I18n.getMessage("jquery.validate.plugin.DOB" return this.optional(element) || isValid; }, 'Please enter Date of Birth'); jQuery.validator.addMethod('HomePhone', function(value, element, param) { $(element).attr('data-PHONEValidate', "true"); var validate_first = JSON.parse($('#registration\\[personalInfo\\]\\[phones\\]\\[HOME\\]\\[number\\]\\[1\\]').attr('data-PHONEValidate')); var validate_second = JSON.parse($('#registration\\[personalInfo\\]\\[phones\\]\\[HOME\\]\\[number\\]\\[2\\]').attr('data-PHONEValidate')); var validate_third = JSON.parse($('#registration\\[personalInfo\\]\\[phones\\]\\[HOME\\]\\[number\\]\\[3\\]').attr('data-PHONEValidate')); if (validate_first && validate_second && validate_third) { if ($(element).val().length == $(element).prop('maxlength')) { this.settings.messages.HOMEPhone = CQ.I18n.get("jquery.validate.plugin.phoneRequired"); var homephone = $('input[name="registration[personalInfo][phones][HOME][number][1]"]').val() + $('input[name="registration[personalInfo][phones][HOME][number][2]"]').val() + $('input[name="registration[personalInfo][phones][HOME][number][3]"]').val(); return this.optional(element) || homephone.length > 0 && homephone.length == 10; } else { this.settings.messages.HOMEPhone = ($(element).val().length < $(element).prop('maxlength')) ? CQ.I18n.getMessage("jquery.validate.plugin.phoneMinlength") : CQ.I18n.getMessage("jquery.validate.plugin.phoneMaxlength"); return false; } } else { return this.optional(element) || true; } }, function(params, element) { return CQ.I18n.get(this.settings.messages.HOMEPhone) }); jQuery.validator.addMethod('homenumbers', function(value, element, param) { $(element).attr('data-PHONEValidate', "true"); var validate_first = JSON.parse($('#registration\\[personalInfo\\]\\[phones\\]\\[HOME\\]\\[number\\]\\[1\\]').attr('data-PHONEValidate')); var validate_second = JSON.parse($('#registration\\[personalInfo\\]\\[phones\\]\\[HOME\\]\\[number\\]\\[2\\]').attr('data-PHONEValidate')); var validate_third = JSON.parse($('#registration\\[personalInfo\\]\\[phones\\]\\[HOME\\]\\[number\\]\\[3\\]').attr('data-PHONEValidate')); if (validate_first && validate_second && validate_third) { var homephone = $('input[name="registration[personalInfo][phones][HOME][number][1]"]').val() + $('input[name="registration[personalInfo][phones][HOME][number][2]"]').val() + $('input[name="registration[personalInfo][phones][HOME][number][3]"]').val(); return this.optional(element) || !isNaN(homephone); } else { return this.optional(element) || true; } }, CQ.I18n.getMessage("jquery.validate.plugin.homenumbers")); jQuery.validator.addMethod('MobilePhone', function(value, element) { $(element).attr('data-MOBILEValidate', "true"); var validate_mnumber1 = JSON.parse($('#mnumber1').attr('data-MOBILEValidate')); var validate_mnumber2 = JSON.parse($('#mnumber2').attr('data-MOBILEValidate')); var validate_mnumber3 = JSON.parse($('#mnumber3').attr('data-MOBILEValidate')); if (validate_mnumber1 && validate_mnumber2 && validate_mnumber3) { if (value != "") { if ($(element).val().length == $(element).prop('maxlength')) { this.settings.messages.MobilePhone = CQ.I18n.get("jquery.validate.plugin.phoneRequired"); var mobile = $('input[name="registration[personalInfo][phones][MOBILE][number][1]"]').val() + $('input[name="registration[personalInfo][phones][MOBILE][number][2]"]').val() + $('input[name="registration[personalInfo][phones][MOBILE][number][3]"]').val(); return this.optional(element) || mobile.length > 0 && mobile.length == 10 && !isNaN(mobile); } else { this.settings.messages.MobilePhone = ($(element).val().length < $(element).prop('maxlength')) ? CQ.I18n.getMessage("jquery.validate.plugin.phoneMinlength") : CQ.I18n.getMessage("jquery.validate.plugin.phoneMaxlength"); return false; } } else { return true; } } else { return true; } }, function(params, element) { return CQ.I18n.get(this.settings.messages.MobilePhone) }); jQuery.validator.addMethod('mobilenumbers', function(value, element) { $(element).attr('data-MOBILEValidate', "true"); var validate_mnumber1 = JSON.parse($('#mnumber1').attr('data-MOBILEValidate')); var validate_mnumber2 = JSON.parse($('#mnumber2').attr('data-MOBILEValidate')); var validate_mnumber3 = JSON.parse($('#mnumber3').attr('data-MOBILEValidate')); if (validate_mnumber1 && validate_mnumber2 && validate_mnumber3) { var mobile = $('input[name="registration[personalInfo][phones][MOBILE][number][1]"]').val() + $('input[name="registration[personalInfo][phones][MOBILE][number][2]"]').val() + $('input[name="registration[personalInfo][phones][MOBILE][number][3]"]').val(); return this.optional(element) || !isNaN(mobile); } else { return this.optional(element) || true; } }, CQ.I18n.getMessage("jquery.validate.plugin.mobileNumber")); jQuery.validator.addMethod("mobileRequired", function(value, element) { $(element).attr('data-MOBILEValidate', "true"); var validate_mnumber1 = JSON.parse($('#mnumber1').attr('data-MOBILEValidate')); var validate_mnumber2 = JSON.parse($('#mnumber2').attr('data-MOBILEValidate')); var validate_mnumber3 = JSON.parse($('#mnumber3').attr('data-MOBILEValidate')); if (validate_mnumber1 && validate_mnumber2 && validate_mnumber3) { if (value != "") { return value.indexOf(" ") < 0 && value != ""; } else return true; } else { return true; } }, CQ.I18n.getMessage("jquery.validate.plugin.mobileNumber")); this.captcha = new portalGGA.Captcha(this.$('.captchaBlock'), this.options.captchaPlayURL); this.$('#candidateForm').validate({ rules: { "registration[personalInfo][addresses][MAILING][city]": { required: true, maxlength: 50, minlength: 3 }, "registration[personalInfo][addresses][MAILING][address1]": { required: true, maxlength: 50, minlength: 5 }, "registration[nonpublicPersonalInfo][dateOfBirth][0]": { required: true, DOB18: true, DOB: true, DOBRequired: true, }, "registration[nonpublicPersonalInfo][dateOfBirth][1]": { required: true, DOB18: true, DOB: true, DOBRequired: true, }, "registration[nonpublicPersonalInfo][dateOfBirth][2]": { required: true, DOB: true, DOB18: true, DOBRequired: true, }, "registration[personalInfo][phones][HOME][number][1]": { required: true, homenumbers: true, HomePhone: true }, "registration[personalInfo][phones][HOME][number][2]": { required: true, homenumbers: true, HomePhone: true }, "registration[personalInfo][phones][HOME][number][3]": { required: true, homenumbers: true, HomePhone: true }, "registration[personalInfo][phones][MOBILE][number][1]": { //mobilenumbers: true, mobileRequired: true, //minlength: 3, //maxlength: 3, MobilePhone: true }, "registration[personalInfo][phones][MOBILE][number][2]": { // mobilenumbers: true, mobileRequired: true, //minlength: 3, //maxlength: 3, MobilePhone: true }, "registration[personalInfo][phones][MOBILE][number][3]": { //mobilenumbers: true, mobileRequired: true, // minlength: 4, // maxlength: 4, MobilePhone: true } }, groups: { SSN: "registration[nonpublicPersonalInfo][socialSecurityNumber][0] " + "registration[nonpublicPersonalInfo][socialSecurityNumber][1] " + "registration[nonpublicPersonalInfo][socialSecurityNumber][2]", HomePhone: "registration[personalInfo][phones][HOME][number][1] " + "registration[personalInfo][phones][HOME][number][2] " + "registration[personalInfo][phones][HOME][number][3]", MobilePhone: "registration[personalInfo][phones][MOBILE][number][1] " + "registration[personalInfo][phones][MOBILE][number][2] " + "registration[personalInfo][phones][MOBILE][number][3]", DOB: "registration[nonpublicPersonalInfo][dateOfBirth][0] " + "registration[nonpublicPersonalInfo][dateOfBirth][1] " + "registration[nonpublicPersonalInfo][dateOfBirth][2]", DOBRequired: "registration[nonpublicPersonalInfo][dateOfBirth][0] " + "registration[nonpublicPersonalInfo][dateOfBirth][1] " + "registration[nonpublicPersonalInfo][dateOfBirth][2]", DOB18: "registration[nonpublicPersonalInfo][dateOfBirth][0] " + "registration[nonpublicPersonalInfo][dateOfBirth][1] " + "registration[nonpublicPersonalInfo][dateOfBirth][2]", homenumbers: "registration[personalInfo][phones][HOME][number][1] " + "registration[personalInfo][phones][HOME][number][2] " + "registration[personalInfo][phones][HOME][number][3]", mobilenumbers: "registration[personalInfo][phones][MOBILE][number][1] " + "registration[personalInfo][phones][MOBILE][number][2] " + "registration[personalInfo][phones][MOBILE][number][3]", mobileRequired: "personalInfo[phones][MOBILE][number][1] " + "personalInfo[phones][MOBILE][number][2] " + "personalInfo[phones][MOBILE][number][3]" }, messages: { DOB: CQ.I18n.getMessage("jquery.validate.plugin.DOB"), HomePhone: CQ.I18n.getMessage("jquery.validate.plugin.homePhone"), MobilePhone: CQ.I18n.getMessage("jquery.validate.plugin.MobilePhone"), "registration[nonpublicPersonalInfo][dateOfBirth][0]": { required: CQ.I18n.getMessage("jquery.validate.plugin.dateofBirthRequired"), DOB: CQ.I18n.getMessage("jquery.validate.plugin.DOB"), DOBRequired: CQ.I18n.getMessage("jquery.validate.plugin.dobRequired"), DOB18: CQ.I18n.getMessage("jquery.validate.plugin.dob18") }, "registration[nonpublicPersonalInfo][dateOfBirth][1]": { required: CQ.I18n.getMessage("jquery.validate.plugin.dateofBirthRequired"), DOB: CQ.I18n.getMessage("jquery.validate.plugin.DOB"), DOBRequired: CQ.I18n.getMessage("jquery.validate.plugin.dobRequired"), DOB18: CQ.I18n.getMessage("jquery.validate.plugin.dob18") }, "registration[nonpublicPersonalInfo][dateOfBirth][2]": { required: CQ.I18n.getMessage("jquery.validate.plugin.dateofBirthRequired"), DOB: CQ.I18n.getMessage("jquery.validate.plugin.DOB"), DOBRequired: CQ.I18n.getMessage("jquery.validate.plugin.dobRequired"), DOB18: CQ.I18n.getMessage("jquery.validate.plugin.dob18") }, "registration[personalInfo][phones][HOME][number][1]": { required: CQ.I18n.getMessage("jquery.validate.plugin.phoneRequired"), homenumbers: CQ.I18n.getMessage("jquery.validate.plugin.homenumbers"), minlength: CQ.I18n.getMessage("jquery.validate.plugin.phoneMinlength"), maxlength: CQ.I18n.getMessage("jquery.validate.plugin.phoneMaxlength") // HomePhone: "Please enter phone number" }, "registration[personalInfo][phones][HOME][number][2]": { required: CQ.I18n.getMessage("jquery.validate.plugin.phoneRequired"), homenumbers: CQ.I18n.getMessage("jquery.validate.plugin.homenumbers"), minlength: CQ.I18n.getMessage("jquery.validate.plugin.phoneMinlength"), maxlength: CQ.I18n.getMessage("jquery.validate.plugin.phoneMaxlength") //HomePhone: "Please enter phone number" }, "registration[personalInfo][phones][HOME][number][3]": { required: CQ.I18n.getMessage("jquery.validate.plugin.phoneRequired"), homenumbers: CQ.I18n.getMessage("jquery.validate.plugin.homenumbers"), minlength: CQ.I18n.getMessage("jquery.validate.plugin.phoneMinlength"), maxlength: CQ.I18n.getMessage("jquery.validate.plugin.phoneMaxlength") //HomePhone: "Please enter phone number" }, "registration[personalInfo][phones][MOBILE][number][1]": { mobilenumbers: CQ.I18n.getMessage("jquery.validate.plugin.mobileNumber"), minlength: CQ.I18n.getMessage("jquery.validate.plugin.phoneMinlength"), maxlength: CQ.I18n.getMessage("jquery.validate.plugin.phoneMaxlength"), mobileRequired: CQ.I18n.getMessage("jquery.validate.plugin.mobileNumber") }, "registration[personalInfo][phones][MOBILE][number][2]": { mobilenumbers: CQ.I18n.getMessage("jquery.validate.plugin.mobileNumber"), minlength: CQ.I18n.getMessage("jquery.validate.plugin.phoneMinlength"), maxlength: CQ.I18n.getMessage("jquery.validate.plugin.phoneMaxlength"), mobileRequired: CQ.I18n.getMessage("jquery.validate.plugin.mobileNumber") }, "registration[personalInfo][phones][MOBILE][number][3]": { mobilenumbers: CQ.I18n.getMessage("jquery.validate.plugin.mobileNumber"), minlength: CQ.I18n.getMessage("jquery.validate.plugin.phoneMinlength"), maxlength: CQ.I18n.getMessage("jquery.validate.plugin.phoneMaxlength"), mobileRequired: CQ.I18n.getMessage("jquery.validate.plugin.mobileNumber") }, "registration[personalInfo][addresses][MAILING][city]": { required: CQ.I18n.getMessage("jquery.validate.plugin.cityRequired"), maxlength: CQ.I18n.getMessage("jquery.validate.plugin.cityMaxlength"), minlength: CQ.I18n.getMessage("jquery.validate.plugin.cityMinlength") }, "registration[personalInfo][addresses][MAILING][address1]": { required: CQ.I18n.getMessage("jquery.validate.plugin.streetAddressRequired"), maxlength: CQ.I18n.getMessage("jquery.validate.plugin.streetAddressmaxlength"), minlength: CQ.I18n.getMessage("jquery.validate.plugin.streetAddressminlength") } }, errorPlacement: function(error, element) { if (element.parent('.input-group').length || element.prop('type') === 'checkbox' || element.prop('type') === 'radio') { error.insertAfter(element.parent()); } else if ($(element).parent().hasClass('input-inline') || $(element).parent().hasClass('input-group')) { $(element).closest('.form-group').find('>div').append(error); } else if (element.attr("id") == "birthday_month" || element.attr("id") == "birthday_day" || element.attr("id") == "birthday_year") { //error.insertAfter("#birthday_year"); $(element).closest('.form-group').append(error); } else if (element.attr("id") == "registration[personalInfo][phones][HOME][number][1]" || element.attr("id") == "registration[personalInfo][phones][HOME][number][2]" || element.attr("id") == "registration[personalInfo][phones][HOME][number][3]") { $(element).closest('.form-group').append(error); } else if (element.attr("id") == "mnumber1" || element.attr("id") == "mnumber2" || element.attr("id") == "mnumber3") { $(element).closest('.form-group').append(error); } else { error.insertAfter(element); } } }); this.checkDeselect(); }, checkDeselect: function checkDeselect(){ var self=this; $('.outeremail').on('change',function(e){ if ( !$(this).prop('checked') ) { $(".outerdrawgame").prop("checked",false); $(".emailsection").prop("checked",false); $(".scratchoffOuter").prop("checked",false); } }); $('.outerdrawgame').on('change',function(e){ if ( !$(this).prop('checked') ) { $(".emailsection").prop("checked",false); } }); $('.scratchoffOuter').on('change',function(e){ if ( !$(this).prop('checked') ) { $(".scratchoffsec").prop("checked",false); } }); $('.jackpotOuter').on('change',function(e){ if ( !$(this).prop('checked') ) { $(".emailjackpot").prop("checked",false); } }); $('.textJckptOuter').on('change',function(e){ if ( !$(this).prop('checked') ) { $(".textJckpt").prop("checked",false); } }); $('.emailsweepsouter').on('change',function(e){ if ( !$(this).prop('checked') ) { $(".emailsweeps").prop("checked",false); } }); $('.textpromotionOuter').on('change',function(e){ if ( !$(this).prop('checked') ) { $(".textpromotions").prop("checked",false); } }); }, /** * Serializes `this.$el` using {@link portalGGA.utils.forms.serializeJSON} * @author Tomek.Wytrebowicz@gtech.com * @return {Object} * @see portalGGA.utils.forms.serializeJSON */ serialize: function() { return portalGGA.utils.forms.serializeJSON.apply(this.$el); }, /** * Set the value to the acceptsRewards checkbox. */ changeAcceptsRewards: function changeAcceptsRewards() { if (this.$('.acceptsRewards').prop('checked')) { this.$('.acceptsRewards').val("true"); } else { this.$('.acceptsRewards').val("false"); } }, bindPhoneNumber: function bindPhoneNumber(){ var self =this; $('.phone-required').on('keyup change', function(e) { // self.check_mobile_num(); }); // self.check_mobile_num(); }, check_mobile_num: function check_mobile_num() { $('.message-preferences .phone-required').each(function(){ if ($(this).val().length < parseInt($(this).attr("maxlength"))) { $(this).removeClass('mob-is-filled'); //return false; } else { $(this).addClass('mob-is-filled'); } }); var reqPLen = $('.phone-required').length; var filledPLen = $('.phone-required.mob-is-filled').length; }, handleInputChange: function handleInputChange(){ var self= this; $('.is-required').on('keyup change', function(e) { // self.check_required_inputs(); }); //self.check_required_inputs(); }, handleSelectAll: function handleSelectAll() { var self= this; // select all action $('.deselect-all__trigger').change(function() { if ( $(this).prop('checked') ) { $('input:checkbox').not('.deselect-all__trigger').prop({ indeterminate: false, checked: false }); $('.deselect-all .input-tel').val(''); $('.deselect-all .panel-collapse.in').removeClass('in'); $('.emailCheckbox').prop('checked',false); $('.text-checkbox').prop('checked',false); $("#emailAccordian").addClass("collapsed"); $("#textAccordionTrigger").addClass("collapsed"); $('#registrationForm_step2 .form-group--btn').html('LET ME IN'); } }); $('.select-all-group__trigger').change(function() { if ( $(this).prop('checked') ) { $(this).parent().parent().find('input').prop('checked', true); } else { $(this).parent().parent().find('input').prop('checked', false); } }); $('.select-all-group__section').each(function(){ $(this).find('input:checkbox').change(function() { $('.deselect-all__trigger').prop('checked', false); var boxesInGroup = $(this).parentsUntil('.select-all-group__section').find('input:checkbox').not('.select-all-group__trigger').not('.select-all-group__parent-input').length; var boxesInGroupChecked = $(this).parentsUntil('.select-all-group__section').find('input[type=checkbox]:checked').not('.select-all-group__trigger').not('.select-all-group__parent-input').length; console.log('boxesInGrouP:' +boxesInGroup+ ' boxesInGroupChecked:'+boxesInGroupChecked); if ( $(this).not('.select-all-group__parent-input').prop('checked') ) { $(this).parents('.select-all-group__section').find('.select-all-group__parent-input').prop('checked', true); $('.select-all-group__section-game-updates-box').prop('checked', true); } else { if ( $(this).hasClass('select-all-group__parent-input') ) { } else { if ( boxesInGroup > boxesInGroupChecked ) { $(this).parents('.select-all-group__section').find('.select-all-group__trigger').prop('checked', false); } else { //alert('all checked'); $(this).parents('.select-all-group__section').find('.select-all-group__trigger').prop('checked', true); } } } }); }); $('.phone-required').on('keyup change', function(e) { self.check_mobile_num(); }); self.check_mobile_num(); }, /** * Set the value to the acceptsRewards checkbox. */ deselectCheckbox: function deselectCheckbox() { $('.select-all-group').find('input[type="checkbox"]').prop('checked', false); }, autoLoginOption: function autoLoginOption() { if ($('#autologinBox').is(':checked')) { $('#autoLogin').val('true'); } else { $('#autoLogin').val('false'); } }, usePhoneChecked: function usePhoneChecked() { var data = portalGGA.utils.forms.serializeJSON.apply(this.$('#candidateForm')); var mobObj = data.registration.personalInfo.phones.HOME.number; if ($('#prevAddedNumber').is(':checked')) { if ($('input[id="registration[personalInfo][phones][HOME][number][1]"]').valid() && $('input[id="registration[personalInfo][phones][HOME][number][2]"]').valid() && $('input[id="registration[personalInfo][phones][HOME][number][3]"]').valid()) { $('#mnumber1').val(mobObj[1]); $('#mnumber2').val(mobObj[2]); $('#mnumber3').val(mobObj[3]); } else { $('#prevAddedNumber').attr("checked", false); } } else { // $('#mnumber1').parent().find('label').addClass("required"); $('#mnumber1').val(''); $('#mnumber2').val(''); $('#mnumber3').val(''); } }, daysInMonth: function daysInMonth(month, year) { var noOfDays; if (month == 0 || month == 2 || month == 4 || month == 6 || month == 7 || month == 9 || month == 11) { noOfDays = 31; } else if (month == 3 || month == 5 || month == 8 || month == 10) { noOfDays = 30; } else { noOfDays = (year % 4 == 0) ? 29 : 28; } /*var isLeap = ((year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0)); return [31, (isLeap ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];*/ return noOfDays; }, getDays: function getDays() { var selectmonth = document.getElementById("birthday_month").value; var selectday = document.getElementById("birthday_day").value; var selectyear = document.getElementById("birthday_year").value; var noOfDays = this.daysInMonth(selectmonth, selectyear); var birthDay = $("#birthday_day option:selected").text(); var selOptions = $('#birthday_day').text(""); for (var numberCount = 0; numberCount <= noOfDays; numberCount++) { if (numberCount == 0) { (selOptions).append(""); } else { if (birthDay == numberCount) { (selOptions).append(""); } else(selOptions).append(""); } } if (birthDay != null && birthDay != "") { $("#birthday_day option[text=" + birthDay + "]").attr("selected", "selected"); } else { $("#birthday_day option[text=DD]").attr("selected", "selected"); } }, getDob: function getDob() { document.getElementById("birthday").value = 'dob'; }, /** * Reset both forms, redirect to home. */ reset: function reset(e) { this.$('form').each(function resetForm() { this.reset(); }); redirect.send(this.options.successRedirectURL, { message: { code: 'registration.success', type: 'alert-success' } }); }, cancel: function cancel(e) { this.$('form').each(function resetForm() { this.reset(); }); redirect.send("/en-us/signup.html", {}); }, /** * Prefill form with given data. * @author Tomek.Wytrebowicz@gtech.com * @param {Object} data [description] * @see portalGGA.utils.forms.deserializeJSON */ prefill: function(data) { this.model.registration.set(data); var regData = { registration: data }; splitInputs(regData); portalGGA.utils.forms.deserializeJSON(this.$('#candidateForm input, #candidateForm select'), regData); }, /** * Toggles billing addres form. * @param {event} e * @param {Boolean} noAnimation if true, no crosfade will happen * @return {portalGGA.views.Registration} self */ toggleBillingSameAsMailing: function(e, noAnimation) { var container = this.$('.billingAddress'), checked = !!this.$('.billingSameAsMailing').attr('checked'); if (noAnimation) { container.toggle(!checked); } else { if (checked) { container.fadeOut(); } else { container.fadeIn(); } } return this; }, /** * Fill confirmation form with data, refresh captcha * @see portalGGA.Captcha.refresh */ showConfirmation: function showConfirmation() { var self = this; var data = portalGGA.utils.forms.serializeJSON.apply(this.$('#candidateForm')); if (data.registration.billingSameAsMailing) { data.registration.personalInfo.addresses.BILLING = data.registration.personalInfo.addresses.MAILING; } portalGGA.utils.forms.deserializeJSON(this.$('#confirmRegistration input, #confirmRegistration select'), data); if ((self.$('#candidateForm').valid() && $('#confirmRegistration').valid())) { this.saveRegistration(); } else { var errors = $('#candidateForm').find('.error'); _.each(errors, function(error) { if (error.innerHTML != "") { error.focus(); if($(error).attr('id').indexOf("homenumbers")!= -1) $('.autoTab-phonesHome').focus(); if($(error).attr('id').indexOf("mobile")!= -1) $('#mnumber1').focus(); // if (error.innerHTML == "Please enter Date of Birth") /// $('#birthday_month').focus(); return; } }); } }, /** * Save communication preferences, show messages. * @author Tomek.Wytrebowicz@gtech.com * @author santoshreddy.mogulla@gtech.com * @param {Event} e * @return {jQuery.Promise} [description] */ savePreferences: function savePreferences() { var self = this, button = this.$('[type=submit]'); button.button('loading'); var disabled = this.$(':input:disabled').removeAttr('disabled'); var fields = $("input[name='preferredChannel']").serializeArray(); disabled.attr('disabled','disabled'); _.each(self.notificationsMap, function(currentTypeFromMap){ var notificationFromBackend = self.getNotificationPrefCollection.get(currentTypeFromMap[0]); if(notificationFromBackend){ if($('#'+ currentTypeFromMap[1]).prop("checked")){ _.each(notificationFromBackend.get("channels"), function(currentChannel){ if(currentTypeFromMap[2] ==currentChannel.type) currentChannel.enabled = true; else currentChannel.enabled = false; }); } else { _.each(notificationFromBackend.get("channels"), function(currentChannel){ currentChannel.enabled = false; }); } } if(notificationFromBackend) { self.getNotificationPrefCollection.add(notificationFromBackend, {'merge': true}); } }); $.ajaxSetup({ headers: {'Authorization' :'Password '+ $('#confirm_password').val(), 'Content-Type': 'application/json' } }); self.getNotificationPrefCollection.url = self.getNotificationPrefCollection.url+"?username="+$('#email').val(); return self.getNotificationPrefCollection.save( null,{silent:true,patch:true, type:"PUT"}) .done(function success(response) { if(!self.fromMyAccount) { self.model.set('counter', 3); $("#modalMyPreferences").modal('hide'); } var html = handlePreferencesSuccessResponseTemplate (); $("#successPreferencesModal").html(html); $("#successPreferencesModal").find(".modal").modal(); button.button('reset'); return response; }) .fail(function failure(reason) { }); }, /* * @param {Event} [event] event to prevent */ saveRegistration: function saveRegistration() { var self =this; var form = this.$('#confirmRegistration'); var disabled = form.find(':input:disabled').removeAttr('disabled'); var data = portalGGA.utils.forms.serializeJSON.apply(form); var promotionCode = $('#registrationPromoCode').val(); // data = filterPasswordHints(data); disabled.attr('disabled', 'disabled'); portalGGA.utils.globalErrorNotifier.clear(); concatSplittedInputs(data); this.model.set(data); this.model.registration.profile.set('acceptsRewards', false); this.model.registration.profile.set('userName', data.registration.personalInfo.emails.PERSONAL.address); if($("#textMobile").prop("checked")){ this.model.attributes.registration.profile.acceptsPromotionalSms = true; } if (this.$('#registrationPromoCode').length > 0) { (this.$('#registrationPromoCode').val()) ? this.model.registration.set("promotions", [{ "type": "REGISTRATION_PROMO", id: this.$('#registrationPromoCode').val() }]): this.model.registration.set("promotions", null); } if (this.$('#registrationCardType').length > 0) { (this.$('#registrationCardType').val()) ? this.model.registration.set("playerCard", { "type": this.$('#registrationCardType').val(), id: "0" }): this.model.registration.set("playerCard", null); } if (portalGGA.utils.getCookie(portalGGA.variables['tracking_campaign_id'])) { this.model.registration.profile.set("affiliateId", portalGGA.utils.getCookie(portalGGA.variables['tracking_campaign_id'])) } this.model.url = form.attr('action'); var self = this; if (data.cellular == 'YES') { this.model.attributes.registration.optIntoGeoCompliance = true; this.model.attributes.registration.personalInfo.phones.MOBILE.provider = this.model.attributes.mobilecarrier; } else { this.model.attributes.registration.optIntoGeoCompliance = false; } if ($('#autoLogin').val()) { this.model.attributes.autoLogin = $('#autoLogin').val(); } else { this.model.attributes.autoLogin = "false"; } delete this.model.attributes.mobileCountryCode; delete this.model.attributes.mnumber1; delete this.model.attributes.mnumber2; delete this.model.attributes.mnumber3; delete this.model.attributes.mobilecarrier; delete this.model.attributes.prevAddedNumber; delete this.model.attributes.cellular; delete this.model.attributes.opting; delete this.model.attributes.mtandcs; delete this.model.attributes.registration.personalInfo.addresses.BILLING; var button = this.$('.showConfirmation'); button.button('loading'); return this.model.save() .pipe( function rejectInCaseOfErrors(response) { console.info('rejectInCaseOfErrors', this, arguments); button.button('reset'); return response.errors && response.errors.length > 0 ? $.Deferred().reject(response) : response; }, function putFailureToErrors(response) { console.warn('putFailureToErrors', this, arguments); button.button('reset'); try { response = $.parseJSON(response.responseText); } catch (error) { response = { errors: [{ code: error.toString() }] }; } response.errors = response.errors || { code: "unknown" }; return response; }) .done(function success(response) { ga('send', 'event', 'VIP Club Registration', 'Profile','Profile'); gtag('event', 'conversion', {'allow_custom_scripts': true,'send_to': 'DC-6198115/vip_c0/njl_s000+standard'}); $(document.body).prepend(''); fbq('track', 'VIP_Club_SignUp'); snaptr('track', 'SIGN_UP'); button.button('reset'); $.ajaxSetup({ headers: {'Authorization' :'Password '+ $('#confirm_password').val(), 'Content-Type': 'application/json' } }); self.getNotificationPrefCollection.fetch({ data: {'username': $('#email').val() }, headers: {'Authorization' : $('#confirm_password').val()}, beforeSend: function(xhr){ xhr.setRequestHeader('Authorization','Password '+ $('#confirm_password').val()); }}) .done(function success(response) { if (response) { self.getNotificationPrefCollection.on("sync", self.savePreferences(), self); // self.savePreferences(); } }) $('#registrationForm_step2').hide(); $('#registrationStep3').removeClass("hide"); ga('send', 'event', 'VIP Club Registration', 'Confirmation','Confirmation'); $("#topNav").get(0).scrollIntoView(); }) .fail(function handleError(response) { console.warn('handleError', this, arguments); var msg; var message; button.button('reset'); if (response && response.errors) { for (var errorsLength = 0; errorsLength < response.errors.length; errorsLength++) { msg = response.errors[errorsLength].code; if (msg == "EMAIL_ALREADY_REGISTERED") { message = CQ.I18n.getMessage(msg); portalGGA.utils.globalErrorNotifier.show(message, "alert-danger"); } else { portalGGA.utils.globalErrorNotifier.show(msg, "alert-danger"); } } $("#topNav").get(0).scrollIntoView(); } }); /** * Filter Passwor Hints - remove sequrity questions with empty answers * @param {Object} data form data * @return {Object} filtered form data */ function filterPasswordHints(data) { if (data.registration && data.registration.personalInfo && data.registration.personalInfo.passwordHints) { var passwordHints = data.registration.personalInfo.passwordHints.filter(function(passwordHint) { return passwordHint.securityAnswer && passwordHint.securityAnswer.answer; }) } data.registration.personalInfo.passwordHints = passwordHints; return data; } } }); /** * Cancatenate phones, ssn numbers, dob, emails, zip codes; * @param {Object} registrationForm data * @requires portalGGA.models.player.PersonalInfo * @see splitInputs * @private * @memberOf portalGGA.views.Registration */ function concatSplittedInputs(data) { portalGGA.models.player.PersonalInfo.reparsePhones(data.registration.personalInfo.phones); data.registration.nonpublicPersonalInfo.socialSecurityNumber = data.registration.nonpublicPersonalInfo.socialSecurityNumber.join(''); var month = data.registration.nonpublicPersonalInfo.dateOfBirth[0]; var date = data.registration.nonpublicPersonalInfo.dateOfBirth[1]; var year = data.registration.nonpublicPersonalInfo.dateOfBirth[2]; var birthDate = new Date(year, month, date); var monthArr=new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); var dateString = date+" "+monthArr[month]+" "+year+" "+"12:00:00 GMT"; var now_utc = Date.UTC(birthDate.getUTCFullYear(), birthDate.getUTCMonth(), birthDate.getUTCDate(),birthDate.getUTCHours(), birthDate.getUTCMinutes(), birthDate.getUTCSeconds()); data.registration.nonpublicPersonalInfo.dateOfBirth =Date.parse(dateString); //new Date(now_utc).getTime(); var emails = data.registration.personalInfo.emails; for (type in emails) { emails[type].type = type; emails[type].verified = false; } portalGGA.models.player.PersonalInfo.zipJoin(data.registration.personalInfo.addresses); } /** * Cancatenate phones, ssn numbers, and zip codes; * @param {Object} registrationForm data * @see concatSplittedInputs * @todo implement if needed ssn, dob, mails * @todo get phone prefix from dialog * @private * @memberOf portalGGA.views.Registration * @see portalGGA.models.player.PersonalInfo.parsePhones * @see portalGGA.models.player.PersonalInfo.zipSplit */ function splitInputs(data) { portalGGA.models.player.PersonalInfo.parsePhones(data.registration.personalInfo.phones); if (data.registration.nonpublicPersonalInfo.socialSecurityNumber) { data.registration.nonpublicPersonalInfo.socialSecurityNumber = data.registration.nonpublicPersonalInfo.socialSecurityNumber .match(/(\d{0,3})(\d{0,2})(\d{0,4})(\d*)/) .splice(1); } portalGGA.models.player.PersonalInfo.zipSplit(data.registration.personalInfo.addresses); } }(jQuery, portalGGA.utils.redirect, portalGGA.utils.session, portalGGA.utils.localStorage, portalGGA.views.NeedPlayerVerification, portalGGA.models.player.CommunicationPreferences,portalGGA.models.player.NotificationPreferences,portalGGA.models.GetNotificationPreferences));