Files
Last update 4 months 1 week
by
Arnaud-Apu-Fanovard
CustomerPartNumber.js.téléchargement$(document).ready(function(){CpnReadySteps()});function CpnReadySteps(){$(".uli-hcpns").hide();try{BindCustPartNum2($(".cust-part-add-btn"),$(".cust-part-ddl"),$(".cust-part-num-input"))}catch{}}function IsValid(e){return typeof e!="undefined"&&e}function IsPositiveInteger(e){return/^\d+$/.test(e)}function BindCustPartNum2(e,t,n){var s=$('input[name$="ControllerUrl"]').first().val();IsValid(s)&&s.trim()&&s.toLowerCase()!=="nonmvc"&&(e.on("click",function(e){e.preventDefault(),SaveCustPartNumSteps(this,s,$(this).parents(".cust-part-add-grp").find(".cust-part-num-input").val())}),s.toLowerCase()!=="pdp"&&n.on("blur",function(){SaveCustPartNumSteps(this,s,$(this).val())})),t.on("change",function(){if(this.value>"1")SaveCustPartNumSteps(this,s,$(this).find(":selected").text());else if(this.value<"1")SaveCustPartNumSteps(this,s,"");else{var e=$(this).closest(".formSaveCustomerPartNumber"),t=$(e).find(".cust-part-ddl"),n=$(e).find(".cust-part-add-btn"),o=$(e).find(".cust-part-num-input");t.off(),n.off(),o.off(),ShowHideCustPartNumInput(this),BindCustPartNum2(n,t,o)}})}function ShowHideCustPartNumInput(e){var n,s=$(e).closest(".formSaveCustomerPartNumber"),o=$(s).find(".cust-part-add-grp"),t=$(s).find(".cust-part-num-input");$(e).val()==="1"?(t.val()!==""&&t.val(""),o.show()):(o.hide(),$(e).val()>"1"?(n=$(e).find(":selected").text(),t.val()!==n&&t.val(n)):t.val()!==""&&t.val(""))}function SaveCustPartNumSteps(e,t,n){if(IsValidCustPartNum(n)){var s=$(e).closest(".formSaveCustomerPartNumber"),o=$(s).find(".cust-part-ddl"),i=$(s).find(".cust-part-add-btn");o.off(),i.off();try{SaveCustPartNum2(e,t,n)}catch{}}}function SaveCustPartNum2(e,t,n){var o,i,a,r,c,s=$(e).closest(".formSaveCustomerPartNumber");IsValid(t)&&t.trim()&&t.toLowerCase()!=="nonmvc"?(i=$(s).find('input[name$="CartHeaderIdForCustPartNum"]').val(),o=$(s).find('input[name$="ProductIdEncForCustPartNum"]').val(),a=$("input[name=__RequestVerificationToken]").val(),r=$(s).find('input[name$="CustomerPartNumber"]').attr("id").split("_"),c=r[1],IsValid(o)&&o.trim()&&(SpinnerOpen(),$.ajax({url:"/Product/Product/SaveCustomerPartNumber2",type:"POST",data:{__RequestVerificationToken:a,productIdEncForCustPartNum:o,customerPartNumber:encodeURIComponent(n),calledFrom:t,itemId:i,cartItemRowId:c}}).done(function(e){if(IsValid(e)){$(s).html($(e)[0].innerHTML);var t=$(s).find(".cust-part-ddl"),n=$(s).find(".cust-part-add-btn"),o=$(s).find(".cust-part-num-input");ShowHideCustPartNumInput(t),BindCustPartNum2(n,t,o)}}).always(function(){SpinnerClose()}))):(ShowHideCustPartNumInput(e),$('input[id$="btnUpdateTop"]').trigger("click"))}function IsValidCustPartNum(e){var t=new RegExp("^[\x00-)+-\xFF]*$");return t.test(e)}function SpinnerOpen(){$("#colorbox").css("display")!=="block"&&$("a#lnkloader").trigger("click")}function SpinnerClose(){$("#colorbox").css("display")==="block"&&$.colorbox.close()}