How to use cleanseError method in Cypress

Best JavaScript code snippet using cypress

epp_registration.js

Source:epp_registration.js Github

copy

Full Screen

1if (typeof(epp) == "undefined") 2 epp = {};3 var pp, th;4epp.registration = {5 selState:"",6 countriesList:[],7 stateEnabledList:[],8 trillEnabledList:[],9 init: function() {10 vmf.scEvent =true;11 th = epp.registration; //Storing epp.registration object12 pp = th.pp;13 th.cmm.events(); //Bind all events in registration pages14 th.cmm.getStateEnabledList();15 //code for ominature tracking of log in page loading16 //callBack.addsc({'f':'riaLinkmy','args':[epp.globalVar.pageName + ' : epp']})17 },18 placeErrors:function(error, element){ //placing error message on validation of forms19 if(element.next('.tooltip').length > 0) {20 element.next('.tooltip').after(error);21 } else if(element.is('input[type=checkbox]')) {22 element.next('*').after(error);23 } else {24 element.after(error);25 }26 },27 loadBasicProfile:function(){ //Loading profile when no prepopulation required28 vmf.ajax.post(epp.globalVar.loadNewProfileDetails, null, function(jData){29 if(typeof jData!="object") var jData = vmf.json.txtToObj(jData);30 if(jData!=null){31 var email = $('#txt_email'), sal=$('#sel_salutation'), country = $('#country'), cList=[];32 var pf = jData.ProfileJSON;33 email.val(pf.emailAddress);34 sal.find('option').not(':eq(0)').remove();35 for(var key in pf.salutationList){36 sal.append('<option value="'+pf.salutationList[key][1]+'">'+pf.salutationList[key][0]+'</option>');37 }38 cList=[];39 for(var key in pf.countryList){40 cList.push('<option value="'+pf.countryList[key][1]+'">'+pf.countryList[key][0]+'</option>');41 }42 country.find('option').not(':eq(0)').remove();43 country.append(cList.join(''));44 th.stateEnabledList = pf.stateEnabledCountries;45 if(pf.selectedCountry != null && pf.selectedCountry.length && th.checkStateEnable(pf.selectedCountry, th.stateEnabledList)){46 $('#country').parent().next('.ctrlHolder').removeClass('hidden');47 th.selState = pf.selectedState;48 $('#country').val(pf.selectedCountry).trigger('change');49 }50 //When short profile, hiding login information section.51 if(pf.shortProfile) {52 $('#txt_verify_email').val(pf.emailAddress);53 $('#loginInfo').hide();54 }55 }56 th.validateRegForm();57 },function(){th.cmm.genericError()},function(){vmf.loading.hide()},null,function(){vmf.loading.show({"overlay":true});});58 },59 loadProfile:function(){//Loading profile with prepopulation of data if user already filled60 vmf.ajax.post(epp.globalVar.loadEditProfileDetails, null, function(jData){61 if(typeof jData !="object") jData=vmf.json.txtToObj(jData);62 if(jData!=null && jData.ProfileJSONEdit!=null){63 var em = $('#eppRegForm').find('input,select'), cList=[], stateEnabled = false;64 var pf = jData.ProfileJSONEdit;65 em.each(function(){66 var $id = $(this).attr('id');67 if($id == 'txt_email' && pf.emailAddress != null && pf.emailAddress.length){68 $(this).val(pf.emailAddress);69 }else if($id == 'txt_verify_email' && pf.verifyEmailAddress != null && pf.verifyEmailAddress.length){70 $(this).val(pf.verifyEmailAddress);71 }else if($id == 'sel_salutation' && pf.salutationList != null && pf.salutationList.length){72 $(this).find('option').not(':eq(0)').remove();73 for(var key in pf.salutationList){74 $(this).append('<option value="'+pf.salutationList[key][1]+'">'+pf.salutationList[key][0]+'</option>');75 }76 if(pf.salutation != null && pf.salutation.length) $(this).val(pf.salutation);77 }else if($id == 'txt_firstName' && pf.firstName != null && pf.firstName.length){78 $(this).val(pf.firstName)79 }else if($id == 'txt_lastName' && pf.lastName != null && pf.lastName.length){80 $(this).val(pf.lastName);81 }else if (pf.customerAddress != null ){ 82 if($id == 'txt_company' && pf.customerAddress.companyName != null && pf.customerAddress.companyName.length){83 $(this).val(pf.customerAddress.companyName);84 }else if($id == 'txt_address1' && pf.customerAddress.addressLine1 != null && pf.customerAddress.addressLine1.length){85 $(this).val(pf.customerAddress.addressLine1);86 }else if($id == 'txt_address2' && pf.customerAddress.addressLine2 != null && pf.customerAddress.addressLine2.length){87 $(this).val(pf.customerAddress.addressLine2);88 }else if($id == 'txt_city' && pf.customerAddress.city != null && pf.customerAddress.city.length){89 $(this).val(pf.customerAddress.city);90 }else if($id == 'txt_zip_postal_code' && pf.customerAddress.zipCode != null && pf.customerAddress.zipCode.length){91 $(this).val(pf.customerAddress.zipCode);92 }else if($id == 'country' && pf.countryList != null && pf.countryList.length){93 cList=[];94 for(var key in pf.countryList){95 cList.push('<option value="'+pf.countryList[key][1]+'">'+pf.countryList[key][0]+'</option>');96 }97 $(this).find('option').not(':eq(0)').remove();98 $(this).append(cList.join(''));99 th.stateEnabledList = pf.stateEnabledCountries;100 if(pf.selectedCountry.length && th.checkStateEnable(pf.selectedCountry, th.stateEnabledList)){101 $(this).parent().next('.ctrlHolder').removeClass('hidden');102 th.selState = pf.selectedState;103 }104 $(this).val(pf.selectedCountry).trigger('change');105 }else if($id == 'txt_busPhone' && pf.customerAddress.phone != null && pf.customerAddress.phone.length){106 $(this).val(pf.customerAddress.phone);107 }108 }109 });110 //When short profile, hiding login information section.111 if(pf.shortProfile) { $('#loginInfo').hide() };112 }113 th.validateRegForm();114 },function(){th.cmm.genericError()},function(){vmf.loading.hide();},null,function(){vmf.loading.show({"overlay":true});})115 },116 checkStateEnable:function(val, eList){ //Checking if country is state enabled or not117 var enableList = eList;118 return($.inArray(val,enableList) == -1)?false:true;119 },120 validateRegForm: function() { // Validation of epp registration form.121 $.validator.addMethod("duplicate", function(val, element) {122 if($(element).is(':hidden')) return true;123 var ret=false;124 $.ajaxSetup({async:false});125 vmf.ajax.post(epp.globalVar.checkDuplicate,{"email":$.trim(val)}, function(jData){126 if(typeof jData!="object") jData = vmf.json.txtToObj(jData);127 if(jData != null){ret=!jData.registeredUser;}128 },function(){alert(epp.globalVar.genericError)},function(){$("#duplicate_img").hide()},null,function(){$(element).siblings('label.error').hide(); $("#duplicate_img").show()},false);129 $.ajaxSetup({async:true});130 return ret;131 },epp.globalVar.existingUser);132 133 $.validator.addMethod("vppRegistered", function(val, element) {134 var cName=$.trim(val), $this=$(element);135 if (cName.length){136 vmf.ajax.post(epp.globalVar.companyExistUrl,{"cName":cName},function(res){137 if(typeof res!="object") res=vmf.json.txtToObj(res); 138 (res.status) ? $this.siblings("div.note").html(epp.globalVar.vppRegisteredMsg).show() : $this.siblings("div.note").hide();139 },function(){th.cmm.genericError()},function(){$("#loading_img").hide()},null,function(){140 $this.siblings('label.error').hide();141 $("#loading_img").show();142 },false);143 } else {144 $this.siblings("div.note").hide();145 }146 return true; //Always returning true as there is no need to stop execution147 },epp.globalVar.vppRegisteredMsg);148 149 $.validator.addMethod("customEmail", function(val, element) {150 var emailPattern = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9-]+\.)+[a-zA-Z0-9.]+$/;151 return (emailPattern.test(val));152 },epp.globalVar.enterValidEmail);153 154 $.validator.addMethod("equalToNoCase", function (value, element, param) {155 return this.optional(element) || 156 (value.toLowerCase() == $(param).val().toLowerCase());157 });158 $('#eppRegForm').validate({159 errorPlacement : function(error, element) {160 th.placeErrors(error, element);161 element.closest('.ctrlHolder').addClass('error');162 },163 rules : {164 regEmailAddress : {165 required : "#txt_email:visible",166 minlength : 6,167 email : true,168 duplicate : true,169 customEmail:true170 },171 regVerifyEmailAddress : {172 required : "#txt_verify_email:visible",173 equalToNoCase : '#txt_email'174 },175 regFirstName : {176 //text177 required : true178 },179 regLastName : {180 //text181 required : true182 },183 regCompanyName : {184 required : true,185 vppRegistered: true186 },187 regAddressLine1 : {188 //text189 required : true,190 minlength : 5191 },192 regCity : {193 //select194 required : true195 },196 regZipCode : {197 //alphanumeric198 required : true,199 zipFormat:true200 },201 country : {202 //select203 required : true204 },205 state : {206 //select207 required : {208 depends: function(element){209 return th.checkStateEnable($("#country").val(), th.stateEnabledList);210 }211 }212 },213 regPhone : {214 mformat : true,215 required : false216 }217 218 },219 messages : {220 regEmailAddress : {221 required : epp.globalVar.enterEmail,222 minlength : epp.globalVar.emailMinLength,223 email : epp.globalVar.enterValidEmail,224 duplicate : epp.globalVar.existingUser225 },226 regVerifyEmailAddress : {227 required : epp.globalVar.emailMatch,228 equalToNoCase : epp.globalVar.emailMatch229 },230 regFirstName : {231 //text232 required : epp.globalVar.required233 },234 regLastName : {235 //text236 required : epp.globalVar.required237 },238 regCompanyName : {239 required : epp.globalVar.required,240 vppRegistered:epp.globalVar.vppRegisteredMsg241 },242 regAddressLine1 : {243 //text244 required : epp.globalVar.required,245 minlength : epp.globalVar.AddMinLength246 },247 regCity : {248 //select249 required : epp.globalVar.required250 },251 regZipCode : {252 //text253 required : epp.globalVar.required,254 zipFormat: epp.globalVar.enterValidZip255 },256 country : {257 //select258 required : epp.globalVar.required259 },260 state : {261 //select262 required : epp.globalVar.required263 },264 regPhone : {265 mformat : epp.globalVar.enterValidPhone266 }267 268 },269 onfocusout : function(element) {270 this.element(element);271 if($(element).hasClass('error')) $(element).closest('.ctrlHolder').addClass('error');272 },273 success : function(em) {274 $(em).closest('.ctrlHolder').removeClass('error');275 return false;276 },277 invalidHandler: function(form, validator) {278 var errors = validator.numberOfInvalids();279 if (errors) {280 //resize code goes here281 $('#eppRegForm .errorDashBoard').show();282 }283 },284 submitHandler : function(form) {285 //submit handler code286 if($(form).find('.errorDashBoard').is(':visible')) $(form).find('.errorDashBoard').hide();287 /*th.checkStateEnable($('#country').val(), th.trillEnabledList)?th.validateTrillium(form):th.submitForm(form);Enhancement BUG-00039854*/288 th.validateTrillium(form);289 return false;290 }291 }); 292 },293 validateTrillium:function(form){ //Posting to Trillium services to get address validation.294 var formData={295 "email": $("#txt_email").val(),296 "verifyEmail":$("#txt_verify_email").val(),297 "salutation": $("#sel_salutation").val(),298 "salutationName": $("#sel_salutation option:selected").text(),299 "fName": $("#txt_firstName").val(),300 "lName": $("#txt_lastName").val(),301 "cName": $("#txt_company").val(),302 "add1": $("#txt_address1").val(),303 "add2": $("#txt_address2").val(),304 "city": $("#txt_city").val(),305 "zip": $("#txt_zip_postal_code").val(),306 "cCode": $("#country").val(),307 "countryName": $("#country option:selected").text(),308 "state": $("#state_province").val(),309 "stateName": $("#state_province option:selected").text(),310 "phone": $("#txt_busPhone").val()311 };312 //if(th.checkStateEnable($("#country").val(), th.trillEnabledList)){ Enhancement BUG-00039854313 vmf.ajax.post(epp.globalVar.trillinium, formData, function(jData){314 if(typeof jData!="object") jData=vmf.json.txtToObj(jData);315 if(jData != null && jData.AddressValidationJSON != null){316 var trF = $('#trilliumForm'), ad = jData.AddressValidationJSON, suggestedAdd, originalAdd;317 if(ad.hasCleanseError) {318 $("#txt_zip_postal_code").next('label').text(ad.cleanseError).show();319 } else if(ad.hasSuggested && ad.suggestedAddress[0] != null && (ad.suggestedAddress[0] != "null" )){320 vmf.modal.show('trilliumModal');321 trF.find('label[for="address_1"]').html('<span class="addL">'+ ad.suggestedAddress[0] + '</span><br/><span class="addL">' + ad.suggestedAddress[1]+'</span>');322 trF.find('label[for="address_2"]').html('<span class="addTitle">'+ epp.globalVar.originalAdd + '</span><br/><span class="addL">' + ad.originalAddress[0] + '</span><br/><span class="addL">' + ad.originalAddress[1]+'</span>')323 } else{324 th.submitForm(form);325 }326 } else {327 th.cmm.genericError();328 }329 },function(){th.cmm.genericError()},function(){vmf.loading.hide();},null,function(){vmf.loading.show({"overlay":true});});330 /*}else {331 th.submitForm(form);332 }*/333 },334 submitForm:function(form){335 form.submit();336 },337 //cmn object is for common code across all pages338 cmm:{339 events: function(){340 //Event registration of country selection to show states341 $('#country').live('change',function() {342 if($(this).val().length && th.checkStateEnable($(this).val(), th.stateEnabledList)) {343 $(this).closest('.ctrlHolder').next('.ctrlHolder').removeClass('hidden');344 vmf.ajax.post(epp.globalVar.getStatesForcountry, {"countryCode" : $(this).val()}, th.cmm.showStates, th.cmm.genericError,function(){vmf.loading.hide();},null,function(){vmf.loading.show();});345 } else {346 if($('#state_province').is(':visible'))347 $('#state_province option:eq(0)').attr('selected','selected').closest('.ctrlHolder').addClass('hidden');348 }349 if($(this).closest("section#ltSec").length) pp.adjustHt(($('#state_province').is(':visible'))?true:false);350 /*if($('#txt_busPhone').val().length && $(this).val().length){351 if($(this).val() == 'US' || $(this).val() == 'CA') $('#txt_busPhone').attr('maxlength',10).focusout();352 else $('#txt_busPhone').attr('maxlength',20).focusout();353 }*/354 });355 //To continue after trillium address validation356 $('#btnTrill').live('click',function(){357 var bSuggested = false, add = $('#trilliumForm').find('input:checked');358 if(add.attr('id') == 'address_1') bSuggested = true;359 //Affiliate trillium code below360 if ($('#trilliumForm').data("program")){361 if (bSuggested){362 pp.affData.affId=pp.affData.affId1;363 pp.buildAffiliates(true)364 } else{365 pp.affData.affId=pp.affData.affId2;366 pp.buildAffiliates();367 }368 vmf.modal.hide();369 }else {370 //if(bSuggested) { $('#selectedAddress').val("Y"); } else {$('#selectedAddress').val("N"); }371 $('#selectedAddress').val((bSuggested)?"suggested":"N");372 $('#trilliumForm').submit();373 }374 });375 376 $("form select,form input").keypress(function (e) {377 var enterKey = 13;378 if(e.which == enterKey) $(this).closest('form').submit();379 });380 $('#btnRegCancel').live('click',function(){381 location.replace(epp.globalVar.returnUrl); 382 });383 //To close modal window384 $('#btnCloseTrill').live('click',function(){385 vmf.modal.hide('trilliumModal');386 });387 $.validator.addMethod("mformat", function(val, element) {388 return th.cmm.validateBusPhone($.trim(val));389 },epp.globalVar.enterValidPhone); 390 /*Zip format*/391 $.validator.addMethod("zipFormat", function(val, element) {392 var postalCodeRegex = /^[-\sa-zA-Z0-9]+$/;393 return postalCodeRegex.test(val);394 },epp.globalVar.enterValidZip);395 /*Allow only Alpha nuemeric*/396 $.validator.addMethod("alphanumeric", function(value, element) {397 return this.optional(element) || /^[a-zA-Z0-9]+$/.test(value);398 }); 399 },400 validateBusPhone:function(num){401 var reg = new RegExp('^[0-9\\.\\+\\-\\(\\)\\ \\s]*$');402 return reg.test(num);403 /*if(reg.test(num)){404 if($('#country').val() == 'US' || $('#country').val() == 'CA'){405 if(num.length > 10) return false; else return true;406 }else{407 return true;408 }409 }else{410 return false;411 }*/412 },413 getStateEnabledList:function(){414 vmf.ajax.post(epp.globalVar.stateEnabledListURL, null, function(jData){415 if(typeof jData != "object") jData=vmf.json.txtToObj(jData);416 if(jData != null){417 var eData = jData.StateEnabledJSON;418 th.countriesList = eData.countryList;419 th.stateEnabledList = eData.stateEnabledCountries;420 th.trillEnabledList = eData.trilliniumEnabledCountries;421 if ($("#eppLocation").length) th.cmm.getCountries('eppLocation');422 if ($("#vppLocation").length) th.cmm.getCountries('vppLocation');423 424 th.cmm.getCountries('country');425 }426 if(epp.globalVar.pageName == "registration") {427 location.search.indexOf("pre=1")!=-1?th.loadProfile():th.loadBasicProfile();428 }429 },function(){th.cmm.genericError();});430 },431 getCountries:function(con){432 var cList=[];433 for(var key in th.countriesList){434 cList.push('<option value="'+th.countriesList[key][1]+'">'+th.countriesList[key][0]+'</option>');435 }436 $('#'+con).find('option').not(':eq(0)').remove();437 $('#'+con).append(cList.join(''));438 },439 showStates:function(jData){//Loading States information based country selection440 if(typeof jData !="object") jData=vmf.json.txtToObj(jData);441 if(jData != null){442 var selC = $('#country').val(), selSt = $('#state_province'), oList=[], st = jData.StatesList;443 selSt.attr('disabled',true);444 for(var key in st) {445 oList.push('<option value="'+st[key][1]+'">'+st[key][0]+'</option>');446 }447 selSt.find('option').not(':eq(0)').remove().end().end().append(oList.join('')).attr('disabled','');448 selSt.find('option:eq(0)').attr('selected','selected');449 if(th.selState != null && th.selState.length) selSt.val(th.selState);450 } else {451 th.cmm.genericError();452 }453 },454 showLoading: function(ref){455 ref.html("<div class=\"loading_small\">Loading...</div>").show();456 },457 genericError: function(){458 alert(epp.globalVar.errorMessage);459 }460 },461 //Purchasing Program(pp - EPP & VPP) code Start462 pp:{463 sections:{464 "vpp":{"sec":"#progInfo, #progInfo #vpp_intro, #optionalInfo #vppPartner,#progInfo .options .option, #progHead, #btnPanel","enrollNo":1,"optional":"#optionalInfo, #affiliate, #vppPartner", "progType":"VPP"},465 "vpp_epp":{"sec":"#progInfo, #progInfo #vppepp_intro, #optionalInfo #vppPartner,#optionalInfo #eppPartner,#progInfo .options .option,#progHead, #btnPanel","enrollNo":3,"optional":"#optionalInfo, #affiliate, #vppPartner, #eppPartner, #eppAlternate","progType":"VPP & EPP"},466 "epp":{"sec":"#progInfo, #progInfo #epp_intro, #optionalInfo #eppPartner, #eppMsg, #progInfo .vppNumber, #btnPanel","enrollNo":2,"optional":"#optionalInfo, #eppPartner, #eppAlternate", "progType":"EPP"},467 "all":{"sec":"#progInfo, #progInfo #vpp_intro, #progInfo #vppepp_intro, #progInfo #epp_intro, #eppAlternate, #optionalInfo #affiliate, #optionalInfo #vppPartner,#optionalInfo #eppPartner, #optionalInfo, #progInfo .options .option, #progHead, #eppMsg,#vppMsg"}468 }, //map vpp, epp and vpp_epp elements469 addEPPArr:[], //Maintain Add EPP Partner details in this array470 addVPPArr:[], //Maintain Add VPP Partner details in this array471 addAffArr:[], //Maintain Add Affiliate details in this array472 map:{},473 cTab:0,474 affData:[],475 $del:$("<div class=\"remImg\"><a href=\"javascript:void(0)\" class=\"remove\">Remove</a></div>"), //creating delete image in myAffiliates476 addVppOrEpp:null,477 vppValidated:false, // Maintain state to disaply option info478 vppNum:null,479 init:function(){480 vmf.scEvent =true;481 th=epp.registration;482 pp=th.pp;483 th.cmm.getStateEnabledList();484 pp.map={485 "vpBtn":{"url": epp.globalVar.vppSearchPartnerUrl,"ref":$("#vppPartner .column-wrapper")},486 "epBtn":{"url": epp.globalVar.eppSearchPartnerUrl,"ref":$("#eppPartner .column-wrapper")},487 "btnAddVppPartner":{"arr":"pp.addVPPArr"},488 "btnAddEppPartner":{"arr":"pp.addEPPArr"}489 };490 pp.validateProgForm();491 pp.validateFOForm();492 pp.validateAflForm();493 pp.validateVppForm();494 pp.validateEppForm();495 pp.clearFields();496 pp.bindPPEvents();497 th.cmm.events();498 var psValue = "-999";499 if(epp.globalVar != undefined && epp.globalVar.preselectvalue != undefined) psValue = epp.globalVar.preselectvalue;500 if(location.search.indexOf("pre=1")!=-1||psValue.indexOf("1")!=-1){ //This condition has to be changed later501 pp.getData();502 }503 if(epp.globalVar.existingVPPCustomer) {504 $("#vpp,#vpp_epp").addClass('hidden');505 $("#epp").removeClass('hidden').trigger('click');506 } else {507 $("#vpp,#vpp_epp").removeClass('hidden');508 $("#epp").addClass('hidden');509 if(epp.globalVar.partnerProgram != null && epp.globalVar.partnerProgram == '1'){510 $("#vpp_epp").addClass('hidden');511 $("#vpp").trigger('click');512 }else if(epp.globalVar.partnerProgram != null && epp.globalVar.partnerProgram == '2'){513 $("#vpp").addClass('hidden');514 $("#vpp_epp").trigger('click');515 }516 }517 myvmware.hoverContent.bindEvents($('#vpp.tooltiptext'), 'defaultfunc');518 //code for ominature tracking of enrollment519 callBack.addsc({'f':'riaLinkmy','args':[epp.globalVar.pageName]})520 },521 getData:function(){522 vmf.ajax.post(epp.globalVar.loadEditProgramProfileDetails,null,pp.prePopulate,function(){th.cmm.genericError();},function(){vmf.loading.hide();},null,function(){vmf.loading.show();});523 },524 prePopulate: function(data){525 if(typeof data!="object") data=vmf.json.txtToObj(data);526 if(data.RegistrationJSON.enrolType==0 && data.RegistrationJSON.multipleVPP){ //If multipleVPP true then show error message and return527 $("#eppAlternate,#optionalInfo,#continue").addClass("hidden");528 $("#progInfo .eppAlert").removeClass("hidden");529 return;530 }531 pp.cTab=data.RegistrationJSON.enrolType;532 switch (pp.cTab){533 case "1": $("#vpp.program").trigger('click'); break;534 case "2": $("#epp.program").trigger('click'); break;535 case "3": $("#vpp_epp.program").trigger('click'); break;536 }537 if(pp.cTab == 0) th.cmm.getCountries('eppLocation');538 539 if(data.RegistrationJSON.affiliates && data.RegistrationJSON.affiliates.length>0){540 //pp.addAffArr=data.RegistrationJSON.affiliates;541 $.each(data.RegistrationJSON.affiliates, function(i,v){542 pp.affData={543 "cName": v.cName,544 "add1": v.add1,545 "add2": v.add2,546 "city": v.city,547 "zip": v.zip,548 "cCode": v.cCode,549 "state": v.state,550 "affId":v.affId,551 "countryName": v.cName552 };553 pp.buildAffiliates();554 });555 $("#affiliate fieldset").removeClass("closed").addClass("open");556 }557 if(data.RegistrationJSON.eppPartner && data.RegistrationJSON.eppPartner.length>0){558 //pp.addEPPArr=data.RegistrationJSON.eppPartner;559 $.each(data.RegistrationJSON.eppPartner, function(i,v){560 pp.buildPartner(v,$("#eppPartner section:eq(1)"));561 });562 $("#eppPartner fieldset").removeClass("closed").addClass("open");563 }564 if(data.RegistrationJSON.vppPartner && data.RegistrationJSON.vppPartner.length>0){565 //pp.addVPPArr=data.RegistrationJSON.vppPartner;566 $.each(data.RegistrationJSON.vppPartner, function(i,v){567 pp.buildPartner(v,$("#vppPartner section:eq(1)"));568 });569 $("#vppPartner fieldset").removeClass("closed").addClass("open");570 }571 if(data.RegistrationJSON.vppNumber && $.trim(data.RegistrationJSON.vppNumber).length>0) {$('#progInfoForm .vppNumber').show(); pp.vppNum=data.RegistrationJSON.vppNumber; $("#vppTxt").val(data.RegistrationJSON.vppNumber);}572 if(data.RegistrationJSON.memType ==1 || data.RegistrationJSON.memType == '1') $("input#mem_2:radio").attr("checked","checked").next('label').find('span.desc').show();573 else if (data.RegistrationJSON.memType ==0) $("input#mem_1:radio").attr("checked","checked").next('label').find('span.desc').show();574 if($.trim(data.RegistrationJSON.altFirstName).length>0) $("#txt_firstName").val(data.RegistrationJSON.altFirstName);575 if($.trim(data.RegistrationJSON.altLastName).length>0) $("#txt_lastName").val(data.RegistrationJSON.altLastName);576 if($.trim(data.RegistrationJSON.altEmail).length>0) $("#txt_email").val(data.RegistrationJSON.altEmail);577 if($.trim(data.RegistrationJSON.altPhone).length>0) $("#txt_busPhone").val(data.RegistrationJSON.altPhone);578 if(data.RegistrationJSON.affSetting==0 || data.RegistrationJSON.affSetting=="0"579 || data.RegistrationJSON.affSetting == "ALLOW_AFTER_APPROVAL")580 { 581 $("input#aff_1:radio").attr("checked","checked");582 }583 else if(data.RegistrationJSON.affSetting==1 || data.RegistrationJSON.affSetting=="1" 584 || data.RegistrationJSON.affSetting == "NEVER_ALLOW" ) {585 $("input#aff_2:radio").attr("checked","checked");586 }587 pp.flipOptional(1);588 if(data.RegistrationJSON.memType == '1' && (data.RegistrationJSON.enrolType == '1' || data.RegistrationJSON.enrolType == '3')) $('#affiliate').hide();589 },590 failPopulate: function(data){591 592 },593 clearFields:function(){594 $("#vppTxt,#txt_firstName,#txt_lastName,#txt_email,#txt_busPhone,.filter-content input.pInput,.filter-content select.selLocation").val('');595 //$("input#aff_1:radio").attr("checked","checked");596 $("input[name=membership]").removeAttr("checked");597 $("#affiliate").hide();598 $("#myAffiliates,ul.addedItems,ul.license_folders_id").html('');599 $(".message_container").show();600 $("#affiliate fieldset, #eppPartner fieldset, #vppPartner fieldset").removeClass('open').addClass('closed');601 pp.resetAffiliateForm();602 },603 resetAffiliateForm:function(){604 $("#txt_company,#txt_address1,#txt_address2,#txt_city,#txt_zip_postal_code,#country").val('');605 $("#country").trigger('change'); //This is to hide state dropdown606 },607 showOptionalInfo:function(){608 if($("#mem_1").is(":checked")){609 pp.flipOptional(1);610 } else if ($("#mem_2").is(":checked") && pp.vppValidated){611 pp.flipOptional(1);612 $("#affiliate").hide();613 } else {614 pp.flipOptional(0);615 // $('#progInfoForm').find('.vppNumber,.desc').hide();616 }617 },618 bindPPEvents: function(){619 //Tab activity620 $(".program", $("#selProg")).bind('click', function(e) {//Tab functionality621 if ($(this).hasClass('disabled') || $(this).hasClass('active')) return;622 e.preventDefault();623 $(this).siblings().removeClass('active').end().addClass('active'); //highlight secected program624 $("#prodDetails").show(); //show details section625 $(pp.sections.all.sec).hide(); // hide all internal section626 $(pp.sections[$(this).attr("id")].sec).show(); // show required sections627 //$("#progInfo .options span.desc").hide();628 //Style VPP number for EPP only state629 $("#progInfo .options").removeClass("epp_only vpp_only vpp_epp_only").addClass($(this).attr("id") + "_only");630 631 //$("#affiliate .message_container").show();632 pp.cTab = pp.sections[$(this).attr("id")].enrollNo;633 //$("#input#mem_2:radio, input:radio#mem_1").removeAttr('checked');634 //pp.clearFields();635 //$("input[name=membership]").removeAttr("checked");636 //$(".actionSection .warningctrls").addClass("disabled").find("input:checkbox").removeAttr('checked').attr("disabled","disabled");637 //Reset all forms to remove error messages638 $.each($("form"),function(i,e){639 if($(e).data('validator')) $(e).data('validator').resetForm();640 });641 //pp.flipOptional(0); // By default hide optionalInfo642 if(epp.globalVar.existingVPPCustomer ==0 && pp.checkDataInForms()) {643 $('#mem_1').trigger('click').attr('checked',false).next('label').find('.desc').hide();644 }645 pp.showOptionalInfo();646 });647 $(".remove", $("section .remImg")).live('click', function() {//Remove an affiliate648 var $this=$(this), li=$(this).closest('li'), ref=$(this).closest('.column-wrapper');649 if(!li.siblings().length) ref.find("section .message_container").show();650 if(li.data("id")){651 if (ref.find("input:radio[id='"+li.data("id")+"']").length>0) ref.find("input:radio[id='"+li.data("id")+"']").removeAttr("disabled");652 }653 li.remove();654 });655 $("a.profile-minimize-button", $("#prodDetails")).bind('click', function(e) {656 $(this).closest('fieldset').toggleClass('open closed');657 e.preventDefault();658 });659 $(".partnerList input:radio").live('click', function() {660 var ref = $(this).closest('.column');661 if(ref.find('input:checkbox').attr("checked"))662 pp.activateBtn(true, ref);663 else664 pp.activateBtn(false, ref);665 });666 $(".actionSection input:checkbox").bind('click', function() {667 var ref = $(this).closest('.column');668 if($(this).attr("checked")) {669 if(ref.find('input:radio:checked').length)670 pp.activateBtn(true, ref);671 else672 pp.activateBtn(false, ref)673 } else {674 pp.activateBtn(false, ref);675 }676 });677 $(".actionSection button").bind('click', function() {678 if($(this).hasClass("disabled")) return;679 var ref = $(this).closest('.column'), selRow;680 selrow = ref.find("input:radio:checked");681 var dt={"pId":selrow.attr("id"),"pName":selrow.val(),"cCode":selrow.attr("cCode"),"ppID":selrow.attr("ppID"),"cName":selrow.attr("cName"),"pKey":selrow.attr("pKey")}682 pp.buildPartner(dt,ref.next("section"));683 //vmf.json.txtToObj(pp.map[$(this).attr('id')]["arr"]).push(dt);684 $(this).addClass("disabled");685 selrow.attr("disabled","disabled").removeAttr("checked");686 });687 $('input:radio',$("#progInfo .option")).bind("click",function(){688 ($(this).attr('id') == 'mem_2')? $('#progInfoForm .vppNumber').show():$('#progInfoForm .vppNumber').hide();689 $(this).next('label').find('span.desc').show();690 //pp.clearFields();691 if($(this).attr('id') == 'mem_1'){692 pp.flipOptional(1);693 $("#affiliate").show();694 $("#mem_2").next('label').find('span.desc').hide();695 }else{696 pp.flipOptional(0);697 $("#affiliate").hide();698 $("#mem_1").next('label').find('span.desc').hide();699 }700 $("#vppMsg").hide(); //Hide Confirmation Message701 });702 $(".validateVPP a",$("#progInfo")).bind('click',function(e){703 $('#progInfoForm').submit();704 });705 $("#continue").bind('click',function(){706 if(pp.validateSubmit()){707 var postData={};708 postData.affiliates=pp.getSelectedids($("ul#myAffiliates li"));709 postData.eppPartner=pp.getSelectedids($(".addedItems li",$("#eppPartner")));710 postData.vppPartner=pp.getSelectedids($(".addedItems li",$("#vppPartner")));711 postData.vppNumber=($("#vppTxt").length) ? pp.vppNum : $("#vppNum").text();712 713 if(postData.vppNumber != null){714 postData.vppNumber =$.trim(postData.vppNumber);715 }716 717 postData.altFirstName=$("#txt_firstName").val();718 postData.altLastName=$("#txt_lastName").val();719 postData.altEmail=$("#txt_email").val();720 postData.altPhone=$("#txt_busPhone").val();721 postData.enrolType=pp.cTab;722 postData.memType=$("input:radio[name='membership']:checked").val();723 postData.affSetting=$("input:radio[name='aff']:checked").val();724 vmf.ajax.post(epp.globalVar.regPurchaseProgUrl,postData,function(data){725 if(typeof data!="object") data=vmf.json.txtToObj(data);726 if(data.success) {727 location.replace(epp.globalVar.gotoReviewAndSubmitURL); 728 }729 else th.cmm.genericError();730 },function(){th.cmm.genericError();},function(){vmf.loading.hide();},null,function(){vmf.loading.show();})731 }732 });733 $("#submitRegistration").bind('click',function(){734 $('#eppSubmitForm').submit();735 /*vmf.ajax.post(epp.globalVar.submitRegistration, null, function(data){736 if(typeof data!="object") data=vmf.json.txtToObj(data);737 if(data.success) location.replace(epp.globalVar.redirectToEnrollOptions);738 //alert("success");739 else th.cmm.genericError();740 })741 */742 });743 },744 checkDataInForms: function(){745 if(!$('#vppTxt').val().length746 && !$('#affiliateForm input').val().length747 && !$('#affiliateForm select').val().length748 && !$('#vppPartnersForm input').val().length749 && !$('#vppPartnersForm select').val().length750 && !$('#eppPartnersForm input').val().length751 && !$('#eppPartnersForm select').val().length752 && !$('#myAffiliates li').length 753 && !$('#vppPartnersForm .addedItems').length 754 && !$('#eppPartnersForm .addedItems').length) return true; else return false;755 },756 flipOptional: function(flag){757 var activetab=$("#selProg .program.active");758 if(activetab.length){759 if (flag){760 $(pp.sections[activetab.attr("id")].optional).show();761 $('#continue').removeAttr('disabled').removeClass('disabled'); 762 } else {763 $(pp.sections[activetab.attr("id")].optional).hide();764 $('#continue').attr('disabled','disabled').addClass('disabled'); 765 }766 }767 },768 validateSubmit: function(){769 switch(parseInt(pp.cTab,10)){770 case 1 : return $("#progInfoForm").valid()771 case 2 : return $("#progInfoForm").valid() && $("#altFunOwnerForm").valid()772 case 3 : return $("#progInfoForm").valid() && $("#altFunOwnerForm").valid()773 case 0 : return $("#altFunOwnerForm").valid()774 }775 //return (pp.cTab =1 ) ? ($("#progInfoForm").valid() && $("#altFunOwnerForm").valid()) : $("#progInfoForm").valid();776 },777 getSelectedids: function(ref){778 var ep = [];779 $.each(ref,function(i,p){780 ep.push($(p).data("id"));781 });782 return ep.join(',');783 },784 buildPartner: function(json,ref){785 var liRef=ref.find("ul.addedItems li"), fl=false;786 if(liRef.length){787 $.each(liRef,function(n,curLi){788 if($(curLi).data("pKey")==json.pKey){789 $(curLi).data("id",json.pId).find(".pCountry").html(json.cName);790 fl=true;791 return false;792 }793 });794 if(fl) return;795 }796 var $liObj = $("<li class=\"clearfix\"></li>"), data;797 data = "<div class=\"flowleft partnerInfo\"><span>" + json.pName + "</span><span class=\"pCountry\">" + json.cName +"</span></div>";798 $liObj.append(pp.$del.clone()).append(data).data("id",json.pId).data("pKey",json.pKey);799 ref.find(".message_container").hide().end().find("ul").append($liObj);800 },801 validateVPP:function(){802 var vpp=$.trim($("input#vppTxt").val());803 vmf.ajax.post(epp.globalVar.vppValiateUrl,{"vppNumber":vpp},function(data){804 if(typeof data!="object") data=vmf.json.txtToObj(data);805 if(data!=null && data.ValidateVppJSON!=null){806 data=data.ValidateVppJSON;807 if(data.status){808 $("#vppMsg").html(epp.globalVar.validVpp).removeClass('failure').addClass("success").css("display","inline-block").find("#vppNumber").text(vpp).end().find("#progType").text(pp.sections[$(".program.active").attr("id")].progType); //We have to remove inline css later809 pp.flipOptional(1);810 $("#affiliate").hide();811 pp.vppNum = vpp;812 pp.vppValidated=true;813 } else{814 $("input#vppTxt").val('').focus();815 $("#vppMsg").html(data.errorMsg).addClass('failure').removeClass("success").css("display","inline-block"); //We have to remove inline css later816 pp.flipOptional(0);817 pp.vppValidated=false;818 }819 } else {820 th.cmm.genericError();821 pp.vppValidated=false;822 }823 },function(){th.cmm.genericError()},function(){vmf.loading.hide();},null,function(){vmf.loading.show();});824 },825 activateBtn: function(flag,ref){826 (flag)? ref.find('button').removeClass('disabled').removeAttr("disabled"):ref.find('button').addClass('disabled').attr("disabled","disabled");827 },828 enableAddPartner: function(flag,ref){829 (flag)? ref.find("div.actionSection .warningctrls").removeClass('disabled').find("input:checkbox").removeAttr("disabled"):ref.find("div.actionSection .warningctrls").addClass('disabled').find("input:checkbox").attr("disabled","disabled").removeAttr('checked');830 },831 findPartners:function(btn){832 var offset = $(btn).closest('div.filter-content'), btnId = $(btn).attr("id"), url, pData, ref; url = pp.map[btnId].url, ref = pp.map[btnId].ref833 pData = {834 "partner" : $.trim(offset.find("input.pInput").val()),835 "country" : offset.find("select.selLocation").val()836 };837 ref.find('.partnerList ul').show();838 ref.find('.partnerList .message_container').addClass('hidden');839 if(!ref.find("div.actionSection .warningctrls").hasClass('disabled')) pp.enableAddPartner(false,ref);840 pp.activateBtn(false,ref.find('.warningctrls'));841 vmf.ajax.post(url, pData, pp.pSuccess(btnId, ref), pp.pFailure,null,null,th.cmm.showLoading(ref.find(".partnerList ul")));842 },843 pSuccess: function(btnId,refObj){844 return function(data){845 var json=(typeof data!="object")?vmf.json.txtToObj(data):data,liObj=[],exist_part=[];846 if(json!=null && json.partners != null){847 if(json.partners.length>0){848 var exist_partners=refObj.find('.addedItems li');849 if(exist_partners.length>0){850 $.each(exist_partners,function(index,value){851 exist_part.push($(value).data('id'));852 });853 }854 refObj.find(".partnerList .message_container").addClass('hidden');855 refObj.find("span.pNum").html("("+json.partners.length+")");856 $.each(json.partners,function(i,v){857 if($.inArray(v.pId,exist_part)!=-1)858 liObj.push("<li><input type=\"radio\" id='"+v.pId+"' name="+btnId+" value='"+v.pName+"' cCode='"+v.cCode+"' cName='"+v.cName + "' ppID='"+v.ppID+"' pKey='"+v.pKey+"' disabled=\"disabled\"><label for='"+v.pId+"'>"+v.pName+"</label></li>");859 else liObj.push("<li><input type=\"radio\" id='"+v.pId+"' name="+btnId+" value='"+v.pName+"' cCode='"+v.cCode+"' cName='"+v.cName + "'ppID='"+v.ppID+"' pKey='"+v.pKey+"' ><label for='"+v.pId+"'>"+v.pName+"</label></li>");860 });861 refObj.find(".partnerList ul").html(liObj.join('')).show().end().find("div.actionSection .warningctrls").removeClass('disabled').find("input:checkbox").removeAttr("disabled");862 pp.enableAddPartner(true,refObj);863 } else{864 refObj.find(".partnerList ul").hide();865 refObj.find(".partnerList .message_container").html(epp.globalVar.noPartnerResults).removeClass('hidden');866 refObj.find("span.pNum").html("");867 pp.enableAddPartner(false,refObj);868 }869 } else {870 refObj.find(".partnerList ul").hide();871 refObj.find(".partnerList .message_container").html(epp.globalVar.errorMessage).removeClass('hidden');872 refObj.find("span.pNum").html("");873 pp.enableAddPartner(false,refObj);874 }875 }876 },877 pFailure: function(){878 alert(epp.globalVar.errorMessage);879 },880 validateProgForm:function() {881 $('#progInfoForm').validate({882 errorPlacement : function(error, element) {883 $(element).siblings(":last").after(error);884 },885 invalidHandler: function(form, validator) {886 if (!validator.numberOfInvalids())887 return;888 $('html, body').animate({889 scrollTop: $(validator.errorList[0].element).offset().top890 }, 2000);891 },892 rules : {893 vppTxt : {894 required : function(element){return ($("#mem_2").is(':visible'))?$("#mem_2").is(':checked'):true},895 vformat : true896 }897 },898 messages : {899 vppTxt : {900 required : epp.globalVar.required,901 vformat : epp.globalVar.vppFormat902 }903 },904 onfocusout : function(element) {905 $("#vppMsg").hide();906 this.element(element);907 },908 success : function(em) {909 $("#vppMsg").hide(); //Hide Confirmation Message910 return false;911 },912 submitHandler : function(form) {913 pp.validateVPP();914 return false;915 }916 });917 $.validator.addMethod("vformat", function(vpp, element) {918 return (this.optional(element) || (vpp.match(/^[vV][0-9]{8}$/)));919 });920 }, 921 validateFOForm:function() {922 $.validator.addMethod("duplicate", function(val, element) {923 var curEmail = "";924 if(epp.globalVar.userEmailAddress != null) {925 curEmail = epp.globalVar.userEmailAddress.toLowerCase();926 }927 var newEmail = val.toLowerCase();928 if(newEmail == curEmail) {929 return false;930 } else {931 return true;932 }933 }, epp.globalVar.existingUser);934 935 $.validator.addMethod("customEmail", function(val, element) {936 var emailPattern = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9-]+\.)+[a-zA-Z0-9.]+$/;937 return (emailPattern.test(val));938 },epp.globalVar.enterValidEmail);939 940 $('#altFunOwnerForm').validate({941 errorPlacement : function(error, element) {942 th.placeErrors(error, element);943 },944 invalidHandler: function(form, validator) {945 if (!validator.numberOfInvalids())946 return;947 $('html, body').animate({948 scrollTop: $(validator.errorList[0].element).offset().top949 }, 2000);950 },951 rules : {952 altOwnerEmail : {953 required : true,954 minlength : 6,955 email : true,956 duplicate : true,957 customEmail : true958 },959 altOwnerFirstName : {960 //text961 required : true962 },963 altOwnerLastName : {964 //text965 required : true966 },967 altOwnerPhone:{968 required:false,969 mformat:true970 }971 },972 messages : {973 altOwnerEmail : {974 required : epp.globalVar.enterEmail,975 minlength : epp.globalVar.emailMinLength,976 email : epp.globalVar.enterValidEmail,977 duplicate : epp.globalVar.existingUser978 },979 altOwnerFirstName : {980 //text981 required : epp.globalVar.required982 },983 altOwnerLastName : {984 //text985 required : epp.globalVar.required986 },987 altOwnerPhone : {988 mformat : epp.globalVar.enterValidPhone989 }990 },991 onfocusout : function(element) {992 this.element(element);993 },994 success : function(em) {995 return false;996 },997 submitHandler : function(form) {998 //submit handler code999 return false;1000 }1001 });1002 }, 1003 validateAflForm:function() {1004 $.validator.addMethod("chkduplicate", function(val, element) {1005 var ret=true;1006 if($("#affiliate .company").length>0){1007 $.each($("#affiliate .company"),function(i,v){1008 if ($.trim(val).toLowerCase() == $.trim($(v).html()).toLowerCase()){1009 ret =false;1010 }1011 });1012 }1013 return ret;1014 },epp.globalVar.duplicateCompanyAdded);1015 $.validator.addMethod("chkExist", function(val, element) {1016 var ret=true;1017 vmf.ajax.post(epp.globalVar.affiliateExistUrl,{"cName":$.trim(val)},function(d){1018 if(typeof d !="object") d=vmf.json.txtToObj(d);1019 if(d.status) ret=false;1020 },function(){th.cmn.genericError()},function(){vmf.loading.hide()},null,function(){vmf.loading.show()},false);1021 return ret;1022 },epp.globalVar.duplicateCompanyExist);1023 1024 $('#affiliateForm').validate({1025 errorPlacement : function(error, element) {1026 th.placeErrors(error, element);1027 },1028 rules : {1029 txt_company : {1030 required : true,1031 chkduplicate:true,1032 chkExist:true1033 },1034 txt_address1 : {1035 //text1036 required : true,1037 minlength : 51038 },1039 txt_city : {1040 //select1041 required : true1042 },1043 txt_zip_postal_code : {1044 //text1045 required : true,1046 zipFormat : true1047 },1048 country : {1049 //select1050 required : true1051 },1052 state_province : {1053 //select1054 required : {1055 depends: function(element){1056 return th.checkStateEnable($("#country").val(), th.stateEnabledList);1057 }1058 }1059 }1060 },1061 messages : {1062 txt_email : {1063 required : epp.globalVar.enterEmail,1064 minlength : epp.globalVar.emailMinLength,1065 email : epp.globalVar.enterValidEmail,1066 remote : epp.globalVar.existingUser1067 },1068 txt_verify_email : {1069 required : epp.globalVar.enterEmail,1070 equalTo : epp.globalVar.emailMatch1071 },1072 txt_firstName : {1073 //text1074 required : epp.globalVar.required1075 },1076 txt_lastName : {1077 //text1078 required : epp.globalVar.required1079 },1080 txt_company : {1081 required : epp.globalVar.required,1082 chkduplicate: epp.globalVar.duplicateCompanyAdded,1083 chkExist: epp.globalVar.duplicateCompanyExist1084 },1085 txt_address1 : {1086 //text1087 required : epp.globalVar.required,1088 minlength : epp.globalVar.AddMinLength1089 },1090 txt_city : {1091 //select1092 required : epp.globalVar.required1093 },1094 txt_zip_postal_code : {1095 //text1096 required : epp.globalVar.required,1097 zipFormat: epp.globalVar.enterValidZip1098 },1099 country : {1100 //select1101 required : epp.globalVar.required1102 },1103 state_province : {1104 //select1105 required : epp.globalVar.required1106 }1107 },1108 onfocusout : function(element) {1109 this.element(element);1110 },1111 success : function(em) {1112 return false;1113 },1114 submitHandler : function(form) {1115 pp.checkAffiliates();1116 return false;1117 }1118 });1119 }, 1120 validateVppForm:function() {1121 // Validating partner search form of VPP1122 $('#vppPartnersForm').validate({1123 errorPlacement : function(error, element) {1124 th.placeErrors(error, element);1125 },1126 rules : {1127 vppPartnerName : {1128 required : true,1129 minlength : 31130 },1131 vppLocation : {1132 required : true1133 }1134 },1135 messages : {1136 vppPartnerName : {1137 required : epp.globalVar.required,1138 minlength : epp.globalVar.firstNameMinLength1139 },1140 vppLocation : {1141 required : epp.globalVar.required1142 }1143 },1144 onfocusout : function(element) {1145 this.element(element);1146 },1147 success : function(em) {1148 return false;1149 },1150 submitHandler : function(form) {1151 //submit handler code1152 pp.addVppOrEpp = 'add vpp partners'1153 pp.findPartners($('#vpBtn'));1154 return false;1155 }1156 });1157 }, 1158 validateEppForm:function() {1159 // Validating partner search form of VPP1160 $('#eppPartnersForm').validate({1161 errorPlacement : function(error, element) {1162 th.placeErrors(error, element);1163 },1164 rules : {1165 eppPartnerName : {1166 required : true,1167 minlength : 31168 },1169 eppLocation : {1170 required : true1171 }1172 },1173 messages : {1174 eppPartnerName : {1175 required : epp.globalVar.required,1176 minlength : epp.globalVar.firstNameMinLength1177 },1178 eppLocation : {1179 required : epp.globalVar.required1180 }1181 },1182 onfocusout : function(element) {1183 this.element(element);1184 },1185 success : function(em) {1186 return false;1187 },1188 submitHandler : function(form) {1189 //submit handler code1190 pp.addVppOrEpp = 'add epp partners'1191 pp.findPartners($('#epBtn'));1192 return false;1193 }1194 });1195 },1196 checkAffiliates:function(){1197 pp.affData={1198 "cName": $("#txt_company").val(),1199 "add1": $("#txt_address1").val(),1200 "add2": $("#txt_address2").val(),1201 "city": $("#txt_city").val(),1202 "zip": $("#txt_zip_postal_code").val(),1203 "cCode": $("#country").val(),1204 "state": $("#state_province").val(),1205 "stateName": $("#state_province option:selected").text(),1206 "countryName": $("#country option:selected").text()1207 };1208 vmf.ajax.post(epp.globalVar.trilliumUrl,pp.affData,function(data){1209 if(typeof data!= "object") data = vmf.json.txtToObj(data);1210 if(data!=null){1211 pp.affData.affId=data.affId;1212 if(data.AddressValidationJSON != null && data.AddressValidationJSON.hasCleanseError) {1213 $("#txt_zip_postal_code").next('label').text(data.AddressValidationJSON.cleanseError).show();1214 }else if(data.AddressValidationJSON!= null && data.AddressValidationJSON.hasSuggested){1215 var ad = data.AddressValidationJSON, trF = $('#trilliumForm');1216 vmf.modal.show('trilliumModal');1217 trF.find('label[for="address_1"]').html(ad.suggestedAddress[0] + '<br/>' + ad.suggestedAddress[1])1218 trF.find('label[for="address_2"]').html('<strong>' + epp.globalVar.originalAdd + '</strong><br/>' + ad.originalAddress[0] + '<br/>' + ad.originalAddress[1]);1219 trF.data("program",pp.cTab);1220 pp.affData.sugAdd1=ad.suggestedAddress[0];1221 pp.affData.sugAdd2=ad.suggestedAddress[1];1222 pp.affData.affId1=ad.suggestedAddress[2];1223 pp.affData.affId2=ad.originalAddress[2];1224 $($("div.afferr"),$("#affiliate")).addClass("vhidden");1225 } else if (data.AddressValidationJSON!= null && !data.AddressValidationJSON.hasSuggested){1226 //pp.addAffArr.push(pp.affData);1227 pp.affData.affId=data.AddressValidationJSON.affId;1228 pp.buildAffiliates();1229 $($("div.afferr"),$("#affiliate")).addClass("vhidden");1230 } else {1231 $($("div.afferr"),$("#affiliate")).html(data.error).removeClass("vhidden");1232 }1233 } else {1234 th.cmm.genericError();1235 }1236 },function(){th.cmm.genericError()},function(){vmf.loading.hide();},null,function(){vmf.loading.show();});1237 },1238 buildAffiliates: function(flg){1239 var $myaff=$("#myAffiliates"),$liObj=$("<li class=\"clearfix\"></li>"),myArr=[], stateVal, address2Val;1240 $("#affiliate .message_container").hide();1241 myArr.push("<div class=\"flowleft\"><span class=\"company\">"+pp.affData.cName+"</span>");1242 if(pp.affData.state != null)stateVal=pp.affData.state; else stateVal='';1243 if(pp.affData.add2 != null)address2Val=pp.affData.add2; else address2Val='';1244 if(flg){ // From Trillium Suggested address1245 myArr.push("<span>"+pp.affData.sugAdd1+"</span><span>"+pp.affData.sugAdd2+"</span>");1246 } else {1247 myArr.push("<span>"+pp.affData.add1+"</span>");1248 if (address2Val != null && address2Val != '') {1249 myArr.push("<span>"+pp.affData.add2+"</span>");1250 }1251 myArr.push("<span>"+pp.affData.city+", "+ stateVal+" "+pp.affData.zip+"</span>");1252 myArr.push("<span>"+pp.affData.countryName+"</span></div>");1253 }1254 $liObj.append(pp.$del.clone()).append(myArr.join('')).data("id",pp.affData.affId);1255 $myaff.append($liObj);1256 pp.affData={};1257 pp.resetAffiliateForm()1258 },1259 adjustHt : function(flg){1260 if(flg){ 1261 $('#ltSec, #rtSec').removeClass('htThreeNinefive').addClass('htFourFourZero');1262 $('#ltSec .affilliate, #rtSec .scroll').addClass("htFourTwoZero").removeClass('htThreeSevenfive');1263 } else {1264 $('#ltSec, #rtSec').addClass('htThreeNinefive').removeClass('htFourFourZero');1265 $('#ltSec .affilliate, #rtSec .scroll').removeClass("htFourTwoZero").addClass('htThreeSevenfive');1266 }1267 },1268 review:{1269 init: function(){1270 vmf.scEvent=true;1271 $("#editProfile").bind('click',function(){1272 if(epp.globalVar.fromPartner == 'Y' && epp.globalVar.shortProfile == 'Y'){1273 location.replace(epp.globalVar.editPartnerProfileURL+"&pre=1");1274 }else{1275 location.replace(epp.globalVar.editProfileURL+"&pre=1");1276 }1277 });1278 $("#editProgram").bind('click',function(){1279 vmf.ajax.post(epp.globalVar.loadEditProgramProfileDetails, null, function(data){1280 if(data.RegistrationJSON.enrolType == 0){1281 //TODO replace the url with correct jsp1282 location.replace(epp.globalVar.redirectToEppEnrollOptions+"&pre=1");1283 }else{1284 location.replace(epp.globalVar.redirectToEnrollOptions+"&pre=1");1285 }1286 })1287 });1288 $("#chk_tt_uw").bind('click', function() {1289 var $btn = $("#submitRegistration");1290 ($(this).attr("checked"))?$btn.removeClass('disabled').attr('disabled',''):$btn.addClass('disabled').attr('disabled','true');1291 });1292 $("#submitRegistration").bind('click',function(){1293 $('#eppSubmitForm').submit();1294 });1295 //BUG-000419491296 $('#recaptcha_response_field').live('keypress',function(e){1297 if(e.which == 13){1298 if($("#chk_tt_uw").attr('checked') && !$("#submitRegistration").attr('disabled')){1299 $('#eppSubmitForm').submit();1300 }1301 else return false;1302 } 1303 });1304 $('#btnRegCancel').live('click',function(){1305 location.replace(epp.globalVar.returnUrl); 1306 });1307 //Ominature capture for review page1308 callBack.addsc({'f':'riaLinkmy','args':[epp.globalVar.pageName + ' : review']})1309 }1310 },1311 confirm:{1312 init: function(){1313 vmf.scEvent=true;1314 var dt = {emailAddress : epp.globalVar.emailAddress}1315 var enableEPPWidgetUrl = (location.protocol + '//'+location.hostname + epp.globalVar.enableEPPWidgetAjaxUrl);1316 if(epp.globalVar.enableEPPWidgetAjaxUrl.length && epp.globalVar.enrollType != "1"){1317 vmf.ajax.post(enableEPPWidgetUrl,dt,function(jData){1318 if(jData != null){ 1319 1320 }1321 });1322 }1323 if(parseInt(epp.globalVar.enrollmentType) == 0) callBack.addsc({'f':'riaLinkmy','args':[epp.globalVar.pageName + ' : epp-bolt-on submit']})1324 else if(parseInt(epp.globalVar.enrollmentType) == 1) callBack.addsc({'f':'riaLinkmy','args':[epp.globalVar.pageName + ' : vpp form submit']})1325 else if(parseInt(epp.globalVar.enrollmentType) == 2) callBack.addsc({'f':'riaLinkmy','args':[epp.globalVar.pageName + ' : epp form submit']})1326 else if(parseInt(epp.globalVar.enrollmentType) == 3) callBack.addsc({'f':'riaLinkmy','args':[epp.globalVar.pageName + ' : vpp-epp form submit']})1327 }1328 }1329 }...

Full Screen

Full Screen

ns.addresses.js

Source:ns.addresses.js Github

copy

Full Screen

...487 refThis.viewModel.cleanseInProgress(true);488 refThis.viewModel.retryCleanseTriggered(false);489 refThis.viewModel.lists.suggestions.removeAll();490 refThis.viewModel.cleanseErrorOccurred(false);491 refThis.viewModel.cleanseError('');492 $.ajax({493 url: refThis.settings.scrubAddressAjaxLink,494 data: { fromAddress: _.getAddressModel.apply(refThis) },495 success: function (results) {496 try {497 if (results.Status == consts.cleanseResult.Success) {498 refThis.viewModel.lists.suggestions.removeAll();499 for (var i = 0; i < results.ValidAddresses.length; i++) {500 var item = ko.mapping.fromJS({501 address: $.extend(true, {},502 {503 AddressID: null,504 Attention: '',505 FirstName: '',506 LastName: '',507 Address1: '',508 Address2: '',509 Address3: '',510 PostalCode: '',511 City: '',512 County: '',513 StateProvince: '',514 StateProvinceID: '',515 Country: '',516 CountryCode: '',517 CountryID: 0,518 ScrubbedGuid: ''519 }, refThis.settings.address, results.ValidAddresses[i])520 });521 if (results.ValidAddresses.length == 1) {522 var model = ko.mapping.toJS(item.address);523 clearSubscribers();524 refThis.cleanseWindow.jqmHide();525 refThis.viewModel.showingCleanseWindow(false);526 if (_.isFunction(successCallback))527 successCallback(model);528 }529 else {530 refThis.viewModel.lists.suggestions.push(item);531 }532 }533 } else {534 refThis.viewModel.cleanseErrorOccurred(true);535 refThis.viewModel.cleanseError(results.Message);536 }537 } catch (ex) { }538 },539 error: function (detail, status, ex) {540 try {541 refThis.viewModel.cleanseErrorOccurred(true);542 refThis.viewModel.cleanseError(refThis.settings.termTranslations.commError);543 } catch (ex) { }544 },545 complete: function () {546 refThis.viewModel.cleanseInProgress(false);547 }548 });549 });550 this.viewModel.retryCleanse.apply(refThis.viewModel);551 this.cleanseWindow.jqmShow();552 },553 getAddress: function (successCallback, failCallback) {554 if (!$(this.settings.templateDiv).find('form').valid()) {555 failCallback();556 return;...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...284 return bundles;285};286// @ts-ignore - webpack.StatsError is unique to webpack 5287// TODO: Remove this when we update to webpack 5.288function cleanseError(err) {289 var msg = typeof err === 'string' ? err : err.message;290 return msg.replace(/\n\s*at.*/g, '').replace(/From previous event:\n?/g, '');291}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const {CypressError} = require('cypress/lib/errors');2const error = new CypressError('Error message');3const error = new CypressError('Error message', {foo: 'bar'});4CypressError.cleanseError(error);5const {CypressError} = require('cypress/lib/errors');6const error = new CypressError('Error message');7const error = new CypressError('Error message', {foo: 'bar'});8CypressError.cleanseError(error);9const {CypressError} = require('cypress/lib/errors');10const error = new CypressError('Error message');11const error = new CypressError('Error message', {foo: 'bar'});12CypressError.cleanseError(error);13const {CypressError} = require('cypress/lib/errors');14const error = new CypressError('Error message');15const error = new CypressError('Error message', {foo: 'bar'});16CypressError.cleanseError(error);17const {CypressError} = require('cypress/lib/errors');18const error = new CypressError('Error message');19const error = new CypressError('Error message', {foo: 'bar'});20CypressError.cleanseError(error);21const {CypressError} = require('cypress/lib/errors');22const error = new CypressError('Error message');23const error = new CypressError('Error message', {foo: 'bar'});24CypressError.cleanseError(error);25const {CypressError} = require('cypress/lib/errors');26const error = new CypressError('Error message');27const error = new CypressError('Error message', {foo: 'bar'});28CypressError.cleanseError(error);29const {CypressError} = require('cypress/lib/errors');30const error = new CypressError('Error message');31const error = new CypressError('Error message', {

Full Screen

Using AI Code Generation

copy

Full Screen

1import {CypressError} from 'cypress/types/cy';2const error = new CypressError('some error message');3const cleanError = CypressError.cleanseError(error);4console.log(cleanError.message);5Cypress.on('uncaught:exception', (err, runnable) => {6 CypressError.cleanseError = (error) => {7 }8 return false;9});

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful