Files
Last update 2 months 4 days
by
Arnaud-Apu-Fanovard
CountdownClock.js.téléchargement$(document).ready(function(){styleChangeforMobileViewInShipping(),setModalFocus("#shippingInstructionsModal","#lnkShippingRestrictionsTooltip")});function changeButtonWidth(e){const t=$("a#lnkEdit"),n=$("input#btnSubmit"),s=$("input#btnSubmitShippingOptions"),o=$("a#lnkBack"),i=$("a#lnkContinue");e.matches?(t.css({width:"100%"}),n.css("width","100%"),s.css("width","100%"),o.css({width:"100%","margin-bottom":"8px"}),i.css("width","100%")):(t.css({width:"auto"}),n.css("width","auto"),s.css("width","auto"),i.css("width","auto"),o.css({width:"auto","margin-bottom":"0px"}))}function styleChangeforMobileViewInShipping(){const e=window.matchMedia("(max-width: 767px)");changeButtonWidth(e),e.addEventListener("change",changeButtonWidth)}var isCart=window.location.href.toLowerCase().indexOf("/cart")>-1;$(isCart?function(){$(document).ajaxComplete(function(){try{ClockCounter()}catch{}})}:function(){try{ClockCounter()}catch{}});function VerifyAndUpdateMultiMsg(){$.ajax({type:"POST",url:"/Cart/Cart/VerifyAndUpdateMultiMsg",cache:!1,success:function(){location.reload()},error:function(){$("div[id$=clockdiv]").hide(),$("#helpTooltip").addClass("hidden")}})}function ShowProductShipsFreeModal(e,t){var n,s,o,i,a,r=e.getAttribute("data-header"),c=e.getAttribute("data-body");$("#"+t+"Label").text(r),$("#"+t+"Body").html(c),n=$("#"+t),s=n.find('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),a=$(e),o=s.first(),i=s.last(),$("#"+t).modal("show"),n.on("focusin",function(e){var t=$(e.target);s.css("outline","none"),t.is(s)&&t.css("outline","2px solid black")}),n.on("keydown",function(e){e.key==="Tab"&&n.hasClass("in")&&(document.activeElement===i[0]&&!e.shiftKey?(e.preventDefault(),o.focus()):document.activeElement===o[0]&&e.shiftKey&&(e.preventDefault(),i.focus()))}),$("#"+t).appendTo("body"),n.on("hidden.bs.modal",function(){$(".modal.in").length>0&&$("body").addClass("modal-open"),a.focus()})}function ClockCounter(){String.format||(String.format=function(e){var t=Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,n){return typeof t[n]!="undefined"?t[n]:e})}),$("#js-atc div:first").addClass("pull-left");var r=$("input[id$=hidClockCounterStartTime]").val(),s=$("input[id$=hidClockCounterEndTime]").val(),o=$("input[id$=hidClockCart]").val(),_=$("input[id$=hidShowCounter]").val(),i=$("input[id$=hidTimeRemainInMilliseconds]").val(),y=$("input[id$=hidOrderNextHoursToShipToday]").val(),l=$("input[id$=hidOrderNextMinutesToShipToday]").val(),b=$("input[id$=hidShipmentLeavesWarehouseInHours]").val(),v=$("input[id$=hidShipmentLeavesWarehouseInMinutes]").val(),g=$("input[id$=hidOrderNowForFasterDelivery]").val(),w=$("input[id$=hidDisplayStartingIcons]").val(),u=$("<div/>").html(y).text(),h=$("<div/>").html(l).text(),m=$("<div/>").html(b).text(),E=$("<div/>").html(v).text(),p=$("<div/>").html(g).text(),e=document.getElementById("clockdiv"),t=document.getElementById("helpTooltip"),r=new Date(r),s=new Date(s),c=(new Date).getTime(),j=parseFloat(c)+parseFloat(i),a=new Date(j),n=$("input[id$=hidShipCutoffMsgType]").val(),d=new Date($("input[id$=hidDisplayClockStartTime]").val()),O=$("input[id$=hidOrderNowToShipToday]").val(),x=$("<div/>").html(O).text();_==1&&f("clockdiv",i);function C(e){var t=e,o=Math.floor(t/1e3%60),i=Math.floor(t/1e3/60%60),n=Math.floor(t/1e3/(60*60)%24),s=Math.floor(t/(1e3*60*60*24));return s>0&&(n=n+s*24),{total:t,hours:n,minutes:i,seconds:o}}function f(s,i){var b,r=document.getElementById(s),g=r.querySelector(".hours"),l=r.querySelector(".minutes"),f=r.querySelector(".seconds");function v(){var s,o,r,v,j=new Date,y=a-j;i=y,i<0&&($("div[id$=clockdiv]").hide(),$("div[id$=clockCounterBrd]").length==1&&$("div[id$=clockCounterBrd]").hide()),s=C(i),g.innerHTML=s.hours<10?"0"+s.hours:s.hours,l.innerHTML=s.minutes<10?"0"+s.minutes:s.minutes,f.innerHTML=s.seconds<10?"0"+s.seconds:s.seconds,s.total<=0&&clearInterval(b),s.hours==0?r=l.innerHTML+":"+f.innerHTML:r=g.innerHTML+":"+l.innerHTML+":"+f.innerHTML,o="",w==1&&(o="<i class='fa fa-lg fa-clock hidden-sm'></i><i class='fa fa-lg fa-truck hidden-sm'></i>"),n=="display"?(e.innerHTML=o+String.format(x,r),t.className=t.className.replace(/\bhidden\b/g,"")):n=="warehouse"?(e.innerHTML=o+String.format(m,r),t.className=t.className.replace(/\bhidden\b/g,"")):n=="ordernow"?e.innerHTML=o+p:s.hours==0?(e.innerHTML=o+String.format(h,r),t.className=t.className.replace(/\bhidden\b/g,"")):(e.innerHTML=o+String.format(u,r),t.className=t.className.replace(/\bhidden\b/g,"")),(s.hours==0&&s.minutes==0&&s.seconds==0||new Date(c)>=a||isNaN(s.hours)||isNaN(s.minutes)||isNaN(s.seconds))&&($("div[id$=clockdiv]").hide(),n!="off"&&VerifyAndUpdateMultiMsg()),v=d.getTime()-j,v=v-1e3,v>=0&&v<=1e3&&(n="display"),i-=1e3}v(),b=setInterval(v,1e3),typeof o!="undefined"&&o.toLowerCase()=="cart"?$(".liCounterClock").css({"background-color":"transparent",border:"none"}):(e.style.width="953px",e.style.textAlign="center",e.style.marginTop="5px")}}