delivery-date.onrender.com
Open in
urlscan Pro
216.24.57.253
Public Scan
Submitted URL: http://delivery-date.onrender.com/datepicker/app_cart_date.js?shop=personalised-cookies.myshopify.com&sm_au=iVVfkHqSQFM57qnqqQ2QvK...
Effective URL: https://delivery-date.onrender.com/datepicker/app_cart_date.js?shop=personalised-cookies.myshopify.com&sm_au=iVVfkHqSQFM57qnqqQ2QvK...
Submission: On July 19 via manual from AU — Scanned from DE
Effective URL: https://delivery-date.onrender.com/datepicker/app_cart_date.js?shop=personalised-cookies.myshopify.com&sm_au=iVVfkHqSQFM57qnqqQ2QvK...
Submission: On July 19 via manual from AU — Scanned from DE
Form analysis
0 forms found in the DOMText Content
function sbtDeliveryDate($){ /*! * Datepicker v1.0.9 * https://fengyuanchen.github.io/datepicker * * Copyright 2014-present Chen Fengyuan * Released under the MIT license * * Date: 2019-09-21T06:57:34.100Z */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],e):e((t=t||self).jQuery)}(this,function(D){"use strict";function a(t,e){for(var i=0;i<e.length;i++){var a=e[i];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}D=D&&D.hasOwnProperty("default")?D.default:D;var s={autoShow:!1,autoHide:!1,autoPick:!1,inline:!1,container:null,trigger:null,language:"",format:"mm/dd/yyyy",date:null,startDate:null,endDate:null,startView:0,weekStart:0,yearFirst:!1,yearSuffix:"",days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],daysMin:["Su","Mo","Tu","We","Th","Fr","Sa"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],itemTag:"li",mutedClass:"muted",pickedClass:"picked",disabledClass:"disabled",highlightedClass:"highlighted",template:'<div class="datepicker-container"><div class="datepicker-panel" data-view="years picker"><ul><li data-view="years prev">‹</li><li data-view="years current"></li><li data-view="years next">›</li></ul><ul data-view="years"></ul></div><div class="datepicker-panel" data-view="months picker"><ul><li data-view="year prev">‹</li><li data-view="year current"></li><li data-view="year next">›</li></ul><ul data-view="months"></ul></div><div class="datepicker-panel" data-view="days picker"><ul><li data-view="month prev">‹</li><li data-view="month current"></li><li data-view="month next">›</li></ul><ul data-view="week"></ul><ul data-view="days"></ul></div></div>',offset:10,zIndex:1e3,filter:null,show:null,hide:null,pick:null},t="undefined"!=typeof window,e=t?window:{},i=t&&"ontouchstart"in e.document.documentElement,c="datepicker",n="click.".concat(c),r="focus.".concat(c),h="hide.".concat(c),o="keyup.".concat(c),l="pick.".concat(c),d="resize.".concat(c),u="scroll.".concat(c),p="show.".concat(c),f="touchstart.".concat(c),g="".concat(c,"-hide"),y={},m=0,v=1,w=2,k=Object.prototype.toString;function b(t){return"string"==typeof t}var C=Number.isNaN||e.isNaN;function $(t){return"number"==typeof t&&!C(t)}function x(t){return void 0===t}function F(t){return"date"===function(t){return k.call(t).slice(8,-1).toLowerCase()}(t)&&!C(t.getTime())}function M(a,s){for(var t=arguments.length,n=new Array(2<t?t-2:0),e=2;e<t;e++)n[e-2]=arguments[e];return function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return a.apply(s,n.concat(e))}}function Y(t){return'[data-view="'.concat(t,'"]')}function G(t,e){return[31,function(t){return t%4==0&&t%100!=0||t%400==0}(t)?29:28,31,30,31,30,31,31,30,31,30,31][e]}function V(t,e,i){return Math.min(i,G(t,e))}var T=/(y|m|d)+/g;function I(t,e){var i=1<arguments.length&&void 0!==e?e:1,a=String(Math.abs(t)),s=a.length,n="";for(t<0&&(n+="-");s<i;)s+=1,n+="0";return n+a}var S=/\d+/g,P={show:function(){this.built||this.build(),this.shown||this.trigger(p).isDefaultPrevented()||(this.shown=!0,this.$picker.removeClass(g).on(n,D.proxy(this.click,this)),this.showView(this.options.startView),this.inline||(this.$scrollParent.on(u,D.proxy(this.place,this)),D(window).on(d,this.onResize=M(this.place,this)),D(document).on(n,this.onGlobalClick=M(this.globalClick,this)),D(document).on(o,this.onGlobalKeyup=M(this.globalKeyup,this)),i&&D(document).on(f,this.onTouchStart=M(this.touchstart,this)),this.place()))},hide:function(){this.shown&&(this.trigger(h).isDefaultPrevented()||(this.shown=!1,this.$picker.addClass(g).off(n,this.click),this.inline||(this.$scrollParent.off(u,this.place),D(window).off(d,this.onResize),D(document).off(n,this.onGlobalClick),D(document).off(o,this.onGlobalKeyup),i&&D(document).off(f,this.onTouchStart))))},toggle:function(){this.shown?this.hide():this.show()},update:function(){var t=this.getValue();t!==this.oldValue&&(this.setDate(t,!0),this.oldValue=t)},pick:function(t){var e=this.$element,i=this.date;this.trigger(l,{view:t||"",date:i}).isDefaultPrevented()||(i=this.formatDate(this.date),this.setValue(i),this.isInput&&(e.trigger("input"),e.trigger("change")))},reset:function(){this.setDate(this.initialDate,!0),this.setValue(this.initialValue),this.shown&&this.showView(this.options.startView)},getMonthName:function(t,e){var i=this.options,a=i.monthsShort,s=i.months;return D.isNumeric(t)?t=Number(t):x(e)&&(e=t),!0===e&&(s=a),s[$(t)?t:this.date.getMonth()]},getDayName:function(t,e,i){var a=this.options,s=a.days;return D.isNumeric(t)?t=Number(t):(x(i)&&(i=e),x(e)&&(e=t)),i?s=a.daysMin:e&&(s=a.daysShort),s[$(t)?t:this.date.getDay()]},getDate:function(t){var e=this.date;return t?this.formatDate(e):new Date(e)},setDate:function(t,e){var i=this.options.filter;if(F(t)||b(t)){if(t=this.parseDate(t),D.isFunction(i)&&!1===i.call(this.$element,t,"day"))return;this.date=t,this.viewDate=new Date(t),e||this.pick(),this.built&&this.render()}},setStartDate:function(t){F(t)||b(t)?this.startDate=this.parseDate(t):this.startDate=null,this.built&&this.render()},setEndDate:function(t){F(t)||b(t)?this.endDate=this.parseDate(t):this.endDate=null,this.built&&this.render()},parseDate:function(a){var s=this.format,t=[];return F(a)||(b(a)&&(t=a.match(S)||[]),F(a=a?new Date(a):new Date)||(a=new Date),t.length===s.parts.length&&(D.each(t,function(t,e){var i=parseInt(e,10);switch(s.parts[t]){case"yy":a.setFullYear(2e3+i);break;case"yyyy":a.setFullYear(2===e.length?2e3+i:i);break;case"mm":case"m":a.setMonth(i-1)}}),D.each(t,function(t,e){var i=parseInt(e,10);switch(s.parts[t]){case"dd":case"d":a.setDate(i)}}))),new Date(a.getFullYear(),a.getMonth(),a.getDate())},formatDate:function(t){var e=this.format,i="";if(F(t)){var a=t.getFullYear(),s=t.getMonth(),n=t.getDate(),r={d:n,dd:I(n,2),m:s+1,mm:I(s+1,2),yy:String(a).substring(2),yyyy:I(a,4)};i=e.source,D.each(e.parts,function(t,e){i=i.replace(e,r[e])})}return i},destroy:function(){this.unbind(),this.unbuild(),this.$element.removeData(c)}},N={click:function(t){var e=D(t.target),i=this.options,a=this.date,s=this.viewDate,n=this.format;if(t.stopPropagation(),t.preventDefault(),!e.hasClass("disabled")){var r=e.data("view"),h=s.getFullYear(),o=s.getMonth(),l=s.getDate();switch(r){case"years prev":case"years next":h="years prev"===r?h-10:h+10,s.setFullYear(h),s.setDate(V(h,o,l)),this.renderYears();break;case"year prev":case"year next":h="year prev"===r?h-1:h+1,s.setFullYear(h),s.setDate(V(h,o,l)),this.renderMonths();break;case"year current":n.hasYear&&this.showView(w);break;case"year picked":n.hasMonth?this.showView(v):(e.siblings(".".concat(i.pickedClass)).removeClass(i.pickedClass).data("view","year"),this.hideView()),this.pick("year");break;case"year":h=parseInt(e.text(),10),a.setDate(V(h,o,l)),a.setFullYear(h),s.setDate(V(h,o,l)),s.setFullYear(h),n.hasMonth?this.showView(v):(e.addClass(i.pickedClass).data("view","year picked").siblings(".".concat(i.pickedClass)).removeClass(i.pickedClass).data("view","year"),this.hideView()),this.pick("year");break;case"month prev":case"month next":(o="month prev"===r?o-1:o+1)<0?(h-=1,o+=12):11<o&&(h+=1,o-=12),s.setFullYear(h),s.setDate(V(h,o,l)),s.setMonth(o),this.renderDays();break;case"month current":n.hasMonth&&this.showView(v);break;case"month picked":n.hasDay?this.showView(m):(e.siblings(".".concat(i.pickedClass)).removeClass(i.pickedClass).data("view","month"),this.hideView()),this.pick("month");break;case"month":o=D.inArray(e.text(),i.monthsShort),a.setFullYear(h),a.setDate(V(h,o,l)),a.setMonth(o),s.setFullYear(h),s.setDate(V(h,o,l)),s.setMonth(o),n.hasDay?this.showView(m):(e.addClass(i.pickedClass).data("view","month picked").siblings(".".concat(i.pickedClass)).removeClass(i.pickedClass).data("view","month"),this.hideView()),this.pick("month");break;case"day prev":case"day next":case"day":"day prev"===r?o-=1:"day next"===r&&(o+=1),l=parseInt(e.text(),10),a.setDate(1),a.setFullYear(h),a.setMonth(o),a.setDate(l),s.setDate(1),s.setFullYear(h),s.setMonth(o),s.setDate(l),this.renderDays(),"day"===r&&this.hideView(),this.pick("day");break;case"day picked":this.hideView(),this.pick("day")}}},globalClick:function(t){for(var e=t.target,i=this.element,a=this.$trigger[0],s=!0;e!==document;){if(e===a||e===i){s=!1;break}e=e.parentNode}s&&this.hide()},keyup:function(){this.update()},globalKeyup:function(t){var e=t.target,i=t.key,a=t.keyCode;this.isInput&&e!==this.element&&this.shown&&("Tab"===i||9===a)&&this.hide()},touchstart:function(t){var e=t.target;this.isInput&&e!==this.element&&!D.contains(this.$picker[0],e)&&(this.hide(),this.element.blur())}},j={render:function(){this.renderYears(),this.renderMonths(),this.renderDays()},renderWeek:function(){var i=this,a=[],t=this.options,e=t.weekStart,s=t.daysMin;e=parseInt(e,10)%7,s=s.slice(e).concat(s.slice(0,e)),D.each(s,function(t,e){a.push(i.createItem({text:e}))}),this.$week.html(a.join(""))},renderYears:function(){var t,e=this.options,i=this.startDate,a=this.endDate,s=e.disabledClass,n=e.filter,r=e.yearSuffix,h=this.viewDate.getFullYear(),o=(new Date).getFullYear(),l=this.date.getFullYear(),c=[],d=!1,u=!1;for(t=-5;t<=6;t+=1){var p=new Date(h+t,1,1),f=!1;i&&(f=p.getFullYear()<i.getFullYear(),-5===t&&(d=f)),!f&&a&&(f=p.getFullYear()>a.getFullYear(),6===t&&(u=f)),!f&&n&&(f=!1===n.call(this.$element,p,"year"));var g=h+t===l,y=g?"year picked":"year";c.push(this.createItem({picked:g,disabled:f,text:h+t,view:f?"year disabled":y,highlighted:p.getFullYear()===o}))}this.$yearsPrev.toggleClass(s,d),this.$yearsNext.toggleClass(s,u),this.$yearsCurrent.toggleClass(s,!0).html("".concat(h+-5+r," - ").concat(h+6).concat(r)),this.$years.html(c.join(""))},renderMonths:function(){var t,e=this.options,i=this.startDate,a=this.endDate,s=this.viewDate,n=e.disabledClass||"",r=e.monthsShort,h=D.isFunction(e.filter)&&e.filter,o=s.getFullYear(),l=new Date,c=l.getFullYear(),d=l.getMonth(),u=this.date.getFullYear(),p=this.date.getMonth(),f=[],g=!1,y=!1;for(t=0;t<=11;t+=1){var m=new Date(o,t,1),v=!1;i&&(v=(g=m.getFullYear()===i.getFullYear())&&m.getMonth()<i.getMonth()),!v&&a&&(v=(y=m.getFullYear()===a.getFullYear())&&m.getMonth()>a.getMonth()),!v&&h&&(v=!1===h.call(this.$element,m,"month"));var w=o===u&&t===p,k=w?"month picked":"month";f.push(this.createItem({disabled:v,picked:w,highlighted:o===c&&m.getMonth()===d,index:t,text:r[t],view:v?"month disabled":k}))}this.$yearPrev.toggleClass(n,g),this.$yearNext.toggleClass(n,y),this.$yearCurrent.toggleClass(n,g&&y).html(o+e.yearSuffix||""),this.$months.html(f.join(""))},renderDays:function(){var t,e,i,a=this.$element,s=this.options,n=this.startDate,r=this.endDate,h=this.viewDate,o=this.date,l=s.disabledClass,c=s.filter,d=s.months,u=s.weekStart,p=s.yearSuffix,f=h.getFullYear(),g=h.getMonth(),y=new Date,m=y.getFullYear(),v=y.getMonth(),w=y.getDate(),k=o.getFullYear(),D=o.getMonth(),b=o.getDate(),C=[],$=f,x=g,F=!1;0===g?($-=1,x=11):x-=1,t=G($,x);var M=new Date(f,g,1);for((i=M.getDay()-parseInt(u,10)%7)<=0&&(i+=7),n&&(F=M.getTime()<=n.getTime()),e=t-(i-1);e<=t;e+=1){var Y=new Date($,x,e),V=!1;n&&(V=Y.getTime()<n.getTime()),!V&&c&&(V=!1===c.call(a,Y,"day")),C.push(this.createItem({disabled:V,highlighted:$===m&&x===v&&Y.getDate()===w,muted:!0,picked:$===k&&x===D&&e===b,text:e,view:"day prev"}))}var T=[],I=f,S=g,P=!1;11===g?(I+=1,S=0):S+=1,t=G(f,g),i=42-(C.length+t);var N=new Date(f,g,t);for(r&&(P=N.getTime()>=r.getTime()),e=1;e<=i;e+=1){var j=new Date(I,S,e),q=I===k&&S===D&&e===b,A=!1;r&&(A=j.getTime()>r.getTime()),!A&&c&&(A=!1===c.call(a,j,"day")),T.push(this.createItem({disabled:A,picked:q,highlighted:I===m&&S===v&&j.getDate()===w,muted:!0,text:e,view:"day next"}))}var O=[];for(e=1;e<=t;e+=1){var W=new Date(f,g,e),z=!1;n&&(z=W.getTime()<n.getTime()),!z&&r&&(z=W.getTime()>r.getTime()),!z&&c&&(z=!1===c.call(a,W,"day"));var J=f===k&&g===D&&e===b,E=J?"day picked":"day";O.push(this.createItem({disabled:z,picked:J,highlighted:f===m&&g===v&&W.getDate()===w,text:e,view:z?"day disabled":E}))}this.$monthPrev.toggleClass(l,F),this.$monthNext.toggleClass(l,P),this.$monthCurrent.toggleClass(l,F&&P).html(s.yearFirst?"".concat(f+p," ").concat(d[g]):"".concat(d[g]," ").concat(f).concat(p)),this.$days.html(C.join("")+O.join("")+T.join(""))}},q="".concat(c,"-top-left"),A="".concat(c,"-top-right"),O="".concat(c,"-bottom-left"),W="".concat(c,"-bottom-right"),z=[q,A,O,W].join(" "),J=function(){function i(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,i),this.$element=D(t),this.element=t,this.options=D.extend({},s,y[e.language],D.isPlainObject(e)&&e),this.$scrollParent=function(t,e){var i=1<arguments.length&&void 0!==e&&e,a=D(t),s=a.css("position"),n="absolute"===s,r=i?/auto|scroll|hidden/:/auto|scroll/,h=a.parents().filter(function(t,e){var i=D(e);return(!n||"static"!==i.css("position"))&&r.test(i.css("overflow")+i.css("overflow-y")+i.css("overflow-x"))}).eq(0);return"fixed"!==s&&h.length?h:D(t.ownerDocument||document)}(t,!0),this.built=!1,this.shown=!1,this.isInput=!1,this.inline=!1,this.initialValue="",this.initialDate=null,this.startDate=null,this.endDate=null,this.init()}return function(t,e,i){e&&a(t.prototype,e),i&&a(t,i)}(i,[{key:"init",value:function(){var t=this.$element,e=this.options,i=e.startDate,a=e.endDate,s=e.date;this.$trigger=D(e.trigger),this.isInput=t.is("input")||t.is("textarea"),this.inline=e.inline&&(e.container||!this.isInput),this.format=function(i){var t=String(i).toLowerCase(),e=t.match(T);if(!e||0===e.length)throw new Error("Invalid date format.");return i={source:t,parts:e},D.each(e,function(t,e){switch(e){case"dd":case"d":i.hasDay=!0;break;case"mm":case"m":i.hasMonth=!0;break;case"yyyy":case"yy":i.hasYear=!0}}),i}(e.format);var n=this.getValue();this.initialValue=n,this.oldValue=n,s=this.parseDate(s||n),i&&(i=this.parseDate(i),s.getTime()<i.getTime()&&(s=new Date(i)),this.startDate=i),a&&(a=this.parseDate(a),i&&a.getTime()<i.getTime()&&(a=new Date(i)),s.getTime()>a.getTime()&&(s=new Date(a)),this.endDate=a),this.date=s,this.viewDate=new Date(s),this.initialDate=new Date(this.date),this.bind(),(e.autoShow||this.inline)&&this.show(),e.autoPick&&this.pick()}},{key:"build",value:function(){if(!this.built){this.built=!0;var t=this.$element,e=this.options,i=D(e.template);this.$picker=i,this.$week=i.find(Y("week")),this.$yearsPicker=i.find(Y("years picker")),this.$yearsPrev=i.find(Y("years prev")),this.$yearsNext=i.find(Y("years next")),this.$yearsCurrent=i.find(Y("years current")),this.$years=i.find(Y("years")),this.$monthsPicker=i.find(Y("months picker")),this.$yearPrev=i.find(Y("year prev")),this.$yearNext=i.find(Y("year next")),this.$yearCurrent=i.find(Y("year current")),this.$months=i.find(Y("months")),this.$daysPicker=i.find(Y("days picker")),this.$monthPrev=i.find(Y("month prev")),this.$monthNext=i.find(Y("month next")),this.$monthCurrent=i.find(Y("month current")),this.$days=i.find(Y("days")),this.inline?D(e.container||t).append(i.addClass("".concat(c,"-inline"))):(D(document.body).append(i.addClass("".concat(c,"-dropdown"))),i.addClass(g).css({zIndex:parseInt(e.zIndex,10)})),this.renderWeek()}}},{key:"unbuild",value:function(){this.built&&(this.built=!1,this.$picker.remove())}},{key:"bind",value:function(){var t=this.options,e=this.$element;D.isFunction(t.show)&&e.on(p,t.show),D.isFunction(t.hide)&&e.on(h,t.hide),D.isFunction(t.pick)&&e.on(l,t.pick),this.isInput&&e.on(o,D.proxy(this.keyup,this)),this.inline||(t.trigger?this.$trigger.on(n,D.proxy(this.toggle,this)):this.isInput?e.on(r,D.proxy(this.show,this)):e.on(n,D.proxy(this.show,this)))}},{key:"unbind",value:function(){var t=this.$element,e=this.options;D.isFunction(e.show)&&t.off(p,e.show),D.isFunction(e.hide)&&t.off(h,e.hide),D.isFunction(e.pick)&&t.off(l,e.pick),this.isInput&&t.off(o,this.keyup),this.inline||(e.trigger?this.$trigger.off(n,this.toggle):this.isInput?t.off(r,this.show):t.off(n,this.show))}},{key:"showView",value:function(t){var e=this.$yearsPicker,i=this.$monthsPicker,a=this.$daysPicker,s=this.format;if(s.hasYear||s.hasMonth||s.hasDay)switch(Number(t)){case w:i.addClass(g),a.addClass(g),s.hasYear?(this.renderYears(),e.removeClass(g),this.place()):this.showView(m);break;case v:e.addClass(g),a.addClass(g),s.hasMonth?(this.renderMonths(),i.removeClass(g),this.place()):this.showView(w);break;default:e.addClass(g),i.addClass(g),s.hasDay?(this.renderDays(),a.removeClass(g),this.place()):this.showView(v)}}},{key:"hideView",value:function(){!this.inline&&this.options.autoHide&&this.hide()}},{key:"place",value:function(){if(!this.inline){var t=this.$element,e=this.options,i=this.$picker,a=D(document).outerWidth(),s=D(document).outerHeight(),n=t.outerWidth(),r=t.outerHeight(),h=i.width(),o=i.height(),l=t.offset(),c=l.left,d=l.top,u=parseFloat(e.offset),p=q;C(u)&&(u=10),o<d&&s<d+r+o?(d-=o+u,p=O):d+=r+u,a<c+h&&(c+=n-h,p=p.replace("left","right")),i.removeClass(z).addClass(p).css({top:d,left:c})}}},{key:"trigger",value:function(t,e){var i=D.Event(t,e);return this.$element.trigger(i),i}},{key:"createItem",value:function(t){var e=this.options,i=e.itemTag,a={text:"",view:"",muted:!1,picked:!1,disabled:!1,highlighted:!1},s=[];return D.extend(a,t),a.muted&&s.push(e.mutedClass),a.highlighted&&s.push(e.highlightedClass),a.picked&&s.push(e.pickedClass),a.disabled&&s.push(e.disabledClass),"<".concat(i,' class="').concat(s.join(" "),'" data-view="').concat(a.view,'">').concat(a.text,"</").concat(i,">")}},{key:"getValue",value:function(){var t=this.$element;return this.isInput?t.val():t.text()}},{key:"setValue",value:function(t){var e=0<arguments.length&&void 0!==t?t:"",i=this.$element;this.isInput?i.val(e):this.inline&&!this.options.container||i.text(e)}}],[{key:"setDefaults",value:function(t){var e=0<arguments.length&&void 0!==t?t:{};D.extend(s,y[e.language],D.isPlainObject(e)&&e)}}]),i}();if(D.extend&&D.extend(J.prototype,j,N,P),D.fn){var E=D.fn.datepicker;D.fn.datepicker=function(h){for(var t=arguments.length,o=new Array(1<t?t-1:0),e=1;e<t;e++)o[e-1]=arguments[e];var l;return this.each(function(t,e){var i=D(e),a="destroy"===h,s=i.data(c);if(!s){if(a)return;var n=D.extend({},i.data(),D.isPlainObject(h)&&h);s=new J(e,n),i.data(c,s)}if(b(h)){var r=s[h];D.isFunction(r)&&(l=r.apply(s,o),a&&i.removeData(c))}}),x(l)?this:l},D.fn.datepicker.Constructor=J,D.fn.datepicker.languages=y,D.fn.datepicker.setDefaults=J.setDefaults,D.fn.datepicker.noConflict=function(){return D.fn.datepicker=E,this}}}); !function(a){"use strict";function b(a,c){if(!(this instanceof b)){var d=new b(a,c);return d.open(),d}this.id=b.id++,this.setup(a,c),this.chainCallbacks(b._callbackChain)}function c(a,b){var c={};for(var d in a)d in b&&(c[d]=a[d],delete a[d]);return c}function d(a,b){var c={},d=new RegExp("^"+b+"([A-Z])(.*)");for(var e in a){var f=e.match(d);if(f){var g=(f[1]+f[2].replace(/([A-Z])/g,"-$1")).toLowerCase();c[g]=a[e]}}return c}if("undefined"==typeof a)return void("console"in window&&window.console.info("Too much lightness, Featherlight needs jQuery."));if(a.fn.jquery.match(/-ajax/))return void("console"in window&&window.console.info("Featherlight needs regular jQuery, not the slim version."));var e=[],f=function(b){return e=a.grep(e,function(a){return a!==b&&a.$instance.closest("body").length>0})},g={allow:1,allowfullscreen:1,frameborder:1,height:1,longdesc:1,marginheight:1,marginwidth:1,mozallowfullscreen:1,name:1,referrerpolicy:1,sandbox:1,scrolling:1,src:1,srcdoc:1,style:1,webkitallowfullscreen:1,width:1},h={keyup:"onKeyUp",resize:"onResize"},i=function(c){a.each(b.opened().reverse(),function(){return c.isDefaultPrevented()||!1!==this[h[c.type]](c)?void 0:(c.preventDefault(),c.stopPropagation(),!1)})},j=function(c){if(c!==b._globalHandlerInstalled){b._globalHandlerInstalled=c;var d=a.map(h,function(a,c){return c+"."+b.prototype.namespace}).join(" ");a(window)[c?"on":"off"](d,i)}};b.prototype={constructor:b,namespace:"featherlight",targetAttr:"data-featherlight",variant:null,resetCss:!1,background:null,openTrigger:"click",closeTrigger:"click",filter:null,root:"body",openSpeed:250,closeSpeed:250,closeOnClick:"background",closeOnEsc:!0,closeIcon:"✕",loading:"",persist:!1,otherClose:null,beforeOpen:a.noop,beforeContent:a.noop,beforeClose:a.noop,afterOpen:a.noop,afterContent:a.noop,afterClose:a.noop,onKeyUp:a.noop,onResize:a.noop,type:null,contentFilters:["jquery","image","html","ajax","iframe","text"],setup:function(b,c){"object"!=typeof b||b instanceof a!=!1||c||(c=b,b=void 0);var d=a.extend(this,c,{target:b}),e=d.resetCss?d.namespace+"-reset":d.namespace,f=a(d.background||['<div class="'+e+"-loading "+e+'">','<div class="'+e+'-content">','<button class="'+e+"-close-icon "+d.namespace+'-close" aria-label="Close">',d.closeIcon,"</button>",'<div class="'+d.namespace+'-inner">'+d.loading+"</div>","</div>","</div>"].join("")),g="."+d.namespace+"-close"+(d.otherClose?","+d.otherClose:"");return d.$instance=f.clone().addClass(d.variant),d.$instance.on(d.closeTrigger+"."+d.namespace,function(b){if(!b.isDefaultPrevented()){var c=a(b.target);("background"===d.closeOnClick&&c.is("."+d.namespace)||"anywhere"===d.closeOnClick||c.closest(g).length)&&(d.close(b),b.preventDefault())}}),this},getContent:function(){if(this.persist!==!1&&this.$content)return this.$content;var b=this,c=this.constructor.contentFilters,d=function(a){return b.$currentTarget&&b.$currentTarget.attr(a)},e=d(b.targetAttr),f=b.target||e||"",g=c[b.type];if(!g&&f in c&&(g=c[f],f=b.target&&e),f=f||d("href")||"",!g)for(var h in c)b[h]&&(g=c[h],f=b[h]);if(!g){var i=f;if(f=null,a.each(b.contentFilters,function(){return g=c[this],g.test&&(f=g.test(i)),!f&&g.regex&&i.match&&i.match(g.regex)&&(f=i),!f}),!f)return"console"in window&&window.console.error("Featherlight: no content filter found "+(i?' for "'+i+'"':" (no target specified)")),!1}return g.process.call(b,f)},setContent:function(b){return this.$instance.removeClass(this.namespace+"-loading"),this.$instance.toggleClass(this.namespace+"-iframe",b.is("iframe")),this.$instance.find("."+this.namespace+"-inner").not(b).slice(1).remove().end().replaceWith(a.contains(this.$instance[0],b[0])?"":b),this.$content=b.addClass(this.namespace+"-inner"),this},open:function(b){var c=this;if(c.$instance.hide().appendTo(c.root),!(b&&b.isDefaultPrevented()||c.beforeOpen(b)===!1)){b&&b.preventDefault();var d=c.getContent();if(d)return e.push(c),j(!0),c.$instance.fadeIn(c.openSpeed),c.beforeContent(b),a.when(d).always(function(a){c.setContent(a),c.afterContent(b)}).then(c.$instance.promise()).done(function(){c.afterOpen(b)})}return c.$instance.detach(),a.Deferred().reject().promise()},close:function(b){var c=this,d=a.Deferred();return c.beforeClose(b)===!1?d.reject():(0===f(c).length&&j(!1),c.$instance.fadeOut(c.closeSpeed,function(){c.$instance.detach(),c.afterClose(b),d.resolve()})),d.promise()},resize:function(a,b){if(a&&b){this.$content.css("width","").css("height","");var c=Math.max(a/(this.$content.parent().width()-1),b/(this.$content.parent().height()-1));c>1&&(c=b/Math.floor(b/c),this.$content.css("width",""+a/c+"px").css("height",""+b/c+"px"))}},chainCallbacks:function(b){for(var c in b)this[c]=a.proxy(b[c],this,a.proxy(this[c],this))}},a.extend(b,{id:0,autoBind:"[data-featherlight]",defaults:b.prototype,contentFilters:{jquery:{regex:/^[#.]\w/,test:function(b){return b instanceof a&&b},process:function(b){return this.persist!==!1?a(b):a(b).clone(!0)}},image:{regex:/\.(png|jpg|jpeg|gif|tiff?|bmp|svg)(\?\S*)?$/i,process:function(b){var c=this,d=a.Deferred(),e=new Image,f=a('<img src="'+b+'" alt="" class="'+c.namespace+'-image" />');return e.onload=function(){f.naturalWidth=e.width,f.naturalHeight=e.height,d.resolve(f)},e.onerror=function(){d.reject(f)},e.src=b,d.promise()}},html:{regex:/^\s*<[\w!][^<]*>/,process:function(b){return a(b)}},ajax:{regex:/./,process:function(b){var c=a.Deferred(),d=a("<div></div>").load(b,function(a,b){"error"!==b&&c.resolve(d.contents()),c.fail()});return c.promise()}},iframe:{process:function(b){var e=new a.Deferred,f=a("<iframe/>"),h=d(this,"iframe"),i=c(h,g);return f.hide().attr("src",b).attr(i).css(h).on("load",function(){e.resolve(f.show())}).appendTo(this.$instance.find("."+this.namespace+"-content")),e.promise()}},text:{process:function(b){return a("<div>",{text:b})}}},functionAttributes:["beforeOpen","afterOpen","beforeContent","afterContent","beforeClose","afterClose"],readElementConfig:function(b,c){var d=this,e=new RegExp("^data-"+c+"-(.*)"),f={};return b&&b.attributes&&a.each(b.attributes,function(){var b=this.name.match(e);if(b){var c=this.value,g=a.camelCase(b[1]);if(a.inArray(g,d.functionAttributes)>=0)c=new Function(c);else try{c=JSON.parse(c)}catch(h){}f[g]=c}}),f},extend:function(b,c){var d=function(){this.constructor=b};return d.prototype=this.prototype,b.prototype=new d,b.__super__=this.prototype,a.extend(b,this,c),b.defaults=b.prototype,b},attach:function(b,c,d){var e=this;"object"!=typeof c||c instanceof a!=!1||d||(d=c,c=void 0),d=a.extend({},d);var f,g=d.namespace||e.defaults.namespace,h=a.extend({},e.defaults,e.readElementConfig(b[0],g),d),i=function(g){var i=a(g.currentTarget),j=a.extend({$source:b,$currentTarget:i},e.readElementConfig(b[0],h.namespace),e.readElementConfig(g.currentTarget,h.namespace),d),k=f||i.data("featherlight-persisted")||new e(c,j);"shared"===k.persist?f=k:k.persist!==!1&&i.data("featherlight-persisted",k),j.$currentTarget.blur&&j.$currentTarget.blur(),k.open(g)};return b.on(h.openTrigger+"."+h.namespace,h.filter,i),{filter:h.filter,handler:i}},current:function(){var a=this.opened();return a[a.length-1]||null},opened:function(){var b=this;return f(),a.grep(e,function(a){return a instanceof b})},close:function(a){var b=this.current();return b?b.close(a):void 0},_onReady:function(){var b=this;if(b.autoBind){var c=a(b.autoBind);c.each(function(){b.attach(a(this))}),a(document).on("click",b.autoBind,function(d){if(!d.isDefaultPrevented()){var e=a(d.currentTarget),f=c.length;if(c=c.add(e),f!==c.length){var g=b.attach(e);(!g.filter||a(d.target).parentsUntil(e,g.filter).length>0)&&g.handler(d)}}})}},_callbackChain:{onKeyUp:function(b,c){return 27===c.keyCode?(this.closeOnEsc&&a.featherlight.close(c),!1):b(c)},beforeOpen:function(b,c){return a(document.documentElement).addClass("with-featherlight"),this._previouslyActive=document.activeElement,this._$previouslyTabbable=a("a, input, select, textarea, iframe, button, iframe, [contentEditable=true]").not("[tabindex]").not(this.$instance.find("button")),this._$previouslyWithTabIndex=a("[tabindex]").not('[tabindex="-1"]'),this._previousWithTabIndices=this._$previouslyWithTabIndex.map(function(b,c){return a(c).attr("tabindex")}),this._$previouslyWithTabIndex.add(this._$previouslyTabbable).attr("tabindex",-1),document.activeElement.blur&&document.activeElement.blur(),b(c)},afterClose:function(c,d){var e=c(d),f=this;return this._$previouslyTabbable.removeAttr("tabindex"),this._$previouslyWithTabIndex.each(function(b,c){a(c).attr("tabindex",f._previousWithTabIndices[b])}),this._previouslyActive.focus(),0===b.opened().length&&a(document.documentElement).removeClass("with-featherlight"),e},onResize:function(a,b){return this.resize(this.$content.naturalWidth,this.$content.naturalHeight),a(b)},afterContent:function(a,b){var c=a(b);return this.$instance.find("[autofocus]:not([disabled])").focus(),this.onResize(b),c}}}),a.featherlight=b,a.fn.featherlight=function(a,c){return b.attach(this,a,c),this},a(document).ready(function(){b._onReady()})}(jQuery); var str = __st.pageurl var rest = str.substring(0, str.lastIndexOf("/") + 1); var template = str.substring(str.lastIndexOf("/") + 1, str.length); var shop_name = Shopify.shop; var base_url = "https://delivery-date.onrender.com"; // var base_url = "https://6c4d8a332b12.ngrok.io"; var cart_form_selector = $("[name='checkout']").last().closest("form"); if(cart_form_selector.length == 0){ var cart_form_selector = $("form[action^='/cart']"); } if(shop_name == "farmyard-frozen.myshopify.com"){ if(window.matchMedia("(max-width: 767px)").matches){ // The viewport is less than 768 pixels wide var cart_form_selector = $("div[data-view='mobile'] form[action^='/cart']"); } else{ // The viewport is at least 768 pixels wide var cart_form_selector = $("div[data-view='desktop'] form[action^='/cart']"); } } // console.log(cart_form_selector.length) // var cart_form_selector = $( "form[action^='/cart']",'form[action$="/cart"]', 'form[action="/cart"]', 'form[action^="/cart?"]') // String.prototype.toDate = function(format) { // format = format || "dmy"; // var separator = this.match(/[^0-9]/)[0]; // var components = this.split(separator); // var day, month, year; // for (var key in format) { // var fmt_value = format[key]; // var value = components[key]; // switch (fmt_value) { // case "d": // day = parseInt(value); // break; // case "m": // month = parseInt(value)-1; // break; // case "y": // year = parseInt(value); // } // } // return new Date(year, month, day); // }; // if (typeof template !== 'undefined' && template != "cart" && (shop_name != "simple-succers.myshopify.com" || shop_name != "bud-floral-and-home.myshopify.com" || shop_name != 'julie-gilbert.myshopify.com')) { // console.log("All checkouts will be through cart page for date selection") // $(document).on('click',"[name='checkout']",function(e){ // e.preventDefault(); // window.location = "/cart"; // }) // } if (typeof template !== 'undefined' && template === "cart") { var urll = base_url+'/configuration_delivery_date.json?shop='+ shop_name; $.ajax({ crossOrigin: true, url: urll, success: function(data) { var setting = data["settings"] if (setting.status == true){ console.log("SBT Delivery Date Setting enabled") $('head').append('<link type="text/css" href="'+base_url+'/datepicker/datepicker.css" rel="stylesheet">'); var style = '' var required_html; if(setting.date_selection_required == true){ var required_html = "required"; } else{ var required_html = ""; } if(setting.date_select_lable != ""){ var label_delivery_date_selector = setting.date_select_lable; } else{ var label_delivery_date_selector = ""; } if(setting.date_font_color != ""){ var font_color = 'color:'+setting.date_font_color; } else{ var font_color = ""; } var margintop = setting.date_padding_top if(margintop != null){ style += 'padding-top:'+margintop+'px;' display_block = true } var marginbottom = setting.date_padding_bottom if(marginbottom != null){ style += 'padding-bottom:'+marginbottom+'px;' display_block = true } var marginleft = setting.date_padding_left if(marginleft != null){ style += 'padding-left:'+marginleft+'px;' } var marginright = setting.date_padding_right if(marginright != null){ style += 'padding-right:'+marginright+'px;' } var custom_css = setting.custom_css if(custom_css != null){ $('head').append('<style type="text/css">'+custom_css+'</style>'); } var required_timeslot_html; if(setting.timeslot_required == true){ var required_timeslot_html = "required='true'"; } else{ var required_timeslot_html = ""; } if(setting.date_select_msg != ""){ var label_date_select_msg = "<span class='cart_date_message' style='display:block;"+font_color+"'>"+setting.date_select_msg+"</span>"; } else{ var label_date_select_msg = ""; } function generate_options(timeslots){ $(document).find('#sbt_timeslot').empty(); $(document).find('#sbt_timeslot').append($('<option value="" label="'+setting.timeslot_select_lable+'"></option>')) $.each(timeslots, function(i, p) { $(document).find('#sbt_timeslot').append($('<option></option>').val(p).html(p)); }); } if(setting.timeslot_select_lable != ""){ var label_timeslot_select_lable = "<span clas='cart_date_message' style='display:block;"+font_color+"'>"+setting.timeslot_select_lable+"</span>"; } else{ var label_timeslot_select_lable = ""; } if(setting.disable_timeslot == true){ var timeslot_html = '<div class="sbt_timeslot_wrapper_div" style="max-width:max-content; clear:both;'+style+'">\ <span class="sbt_timeslot_heading">'+label_timeslot_select_lable+'</span><div class="timeslot_wrap" style="width:250px"><select id="sbt_timeslot" name="attributes[Delivery Time]" '+required_timeslot_html+' style="border:1px solid"><option value="">'+setting.timeslot_select_lable+'</option></select></div>\ </div>'; } else{ var timeslot_html = ""; } var delivery_date_selector_input = '<div class="sbt_date_wrapper">\ <input id="sbt_datepicker" type="text" name="attributes[Delivery Date]" autocomplete="off" '+required_html+' readonly>\ <img class="sbt_datepicker_icon" src="'+base_url+'/datepicker/calendar-icon.png">\ </div>' var delivery_date_selector = '<div class="sbt_delivery_date_wrapper_div" style="max-width:max-content; clear:both;'+style+'">\ <span class="sbt_delivery_date_heading">'+label_delivery_date_selector+'</span>'+delivery_date_selector_input+'\ '+label_date_select_msg+'\ </div>'+timeslot_html+'' if ($("#sbt_delivery_date_wrapper").length) { $("#sbt_delivery_date_wrapper").append(delivery_date_selector); } else { if ($(cart_form_selector).find("table").length) { $(cart_form_selector).find("table:first").after('<div id="sbt_delivery_date_wrapper">'+delivery_date_selector+'</div>'); } else if ($(cart_form_selector).find(".cart-total").length){ $(cart_form_selector).find(".cart-total").prepend('<div id="sbt_delivery_date_wrapper">'+delivery_date_selector+'</div>'); } else if(($(cart_form_selector).find("[name='note']").length)){ if(($(cart_form_selector).find(".cart__note").length)){ $(cart_form_selector).find(".cart__note").parent().closest('div').prepend('<div id="sbt_delivery_date_wrapper">'+delivery_date_selector+'</div>'); } else if(($(cart_form_selector).find(".cart-notes-container").length)){ $(cart_form_selector).find(".cart-notes-container").parent().closest('div').prepend('<div id="sbt_delivery_date_wrapper">'+delivery_date_selector+'</div>'); } else if(($(cart_form_selector).find(".cart-recap__note").length)){ $(cart_form_selector).find(".cart-recap__note").before('<div id="sbt_delivery_date_wrapper">'+delivery_date_selector+'</div>'); } else{ $(cart_form_selector).find("[name='note']").parent().closest('div').prepend('<div id="sbt_delivery_date_wrapper">'+delivery_date_selector+'</div>'); } } else if(($(cart_form_selector).find(".container").length)){ $(cart_form_selector).find(".container").append('<div id="sbt_delivery_date_wrapper">'+delivery_date_selector+'</div>'); } else{ $(cart_form_selector).append('<div id="sbt_delivery_date_wrapper">'+delivery_date_selector+'</div>'); } } if(setting.date_format != ""){ var required_date_format = setting.date_format } else{ var required_date_format = 'dd/mm/yyyy'; } var disable_sunday = setting.disable_sunday var disable_monday = setting.disable_monday var disable_tuesday = setting.disable_tuesday var disable_wednesday = setting.disable_wednesday var disable_thursday = setting.disable_thursday var disable_friday = setting.disable_friday var disable_saturday = setting.disable_saturday var array_of_week = [ setting.disable_sunday? 1 : 0, setting.disable_monday? 1 : 0, setting.disable_tuesday? 1 : 0, setting.disable_wednesday? 1 : 0, setting.disable_thursday? 1 : 0, setting.disable_friday? 1 : 0, setting.disable_saturday? 1 : 0 ] // alert(JSON.stringify(array_of_week)); var start_after_days = setting.cutoffdays || 0 if((setting.maximum_day == '') || (setting.maximum_day == 0)){ var maximum_date = 365 }else{ var maximum_date = setting.maximum_day } // this.getMoment().add(15, 'days'); // checkoutPicker.setMaxDate(maxDate.toDate()) var somedatestart = new Date(); somedatestart.setDate(somedatestart.getDate() + start_after_days) var somedateend = new Date(); somedateend.setDate(somedateend.getDate() + maximum_date) // var disabled_dates = [] // console.log(setting.disabled_dates) var disabled_dates = setting.disabled_dates; // var disabled_dates = ["8/9/2020"];//dates to disable var now = Date.now(); var dp_configuration = { format: required_date_format, autoHide: true, zIndex: 2048, startDate : somedatestart, endDate : somedateend, filter: function(date) { // console.log($.type(date)) // console.log(disabled_dates) // var d = new Date(date); // $thisDate = d.toLocaleString().split(',')[0]; // console.log($thisDate) $thisDate = ((date.getDate() > 9) ? date.getDate() : ('0' + date.getDate()))+'/'+((date.getMonth() > 8) ? (date.getMonth() + 1) : ('0' + (date.getMonth() + 1))) + '/' + date.getFullYear() if ($.inArray($thisDate, disabled_dates) != -1) { return false; } if(disable_sunday){ if (date.getDay() === 0) {return false; return false; // Disable all Sundays, but till leave months/years, whose first day is a Sunday, enabled. } } if(disable_monday){ if (date.getDay() === 1) {return false; return false; // Disable all Sundays, but till leave months/years, whose first day is a Sunday, enabled. } } if(disable_tuesday){ if (date.getDay() === 2) {return false; return false; // Disable all Sundays, but till leave months/years, whose first day is a Sunday, enabled. } } if(disable_wednesday){ if (date.getDay() === 3) {return false; return false; // Disable all Sundays, but till leave months/years, whose first day is a Sunday, enabled. } } if(disable_thursday){ if (date.getDay() === 4) {return false; return false; // Disable all Sundays, but till leave months/years, whose first day is a Sunday, enabled. } } if(disable_friday){ if (date.getDay() === 5) {return false; return false; // Disable all Sundays, but till leave months/years, whose first day is a Sunday, enabled. } } if(disable_saturday){ if (date.getDay() === 6) {return false; return false; // Disable all Sundays, but till leave months/years, whose first day is a Sunday, enabled. } } } } $(document).find('#sbt_datepicker').datepicker(dp_configuration); $(document).on('click',".sbt_datepicker_icon,#sbt_datepicker",function(e){ e.preventDefault(); $(document).find('#sbt_datepicker').datepicker('show'); }) // Validation start if(setting.date_selection_required == true && setting.disable_checkout_btn_if_required == true ){ if($(document).find('#sbt_datepicker').val()==""){ $(cart_form_selector).find("[name='checkout']").prop('disabled', true); $(cart_form_selector).find(".additional-checkout-button--paypal",".additional_checkout_buttons",".additional-checkout-buttons",".dynamic-checkout__content").hide(); $(cart_form_selector).find(".additional-checkout-button--paypal",".additional_checkout_buttons",".additional-checkout-buttons",".dynamic-checkout__content").addClass('hide').css('opacity',0); $(cart_form_selector).find(".additional-checkout-buttons").hide(); } } $(document).on('click',"[name='checkout']",function(e){ // $(document).on('submit',"form[action^='/cart']",function(e){ console.log("checkout button clicked") if(setting.date_selection_required == true){ if($(document).find('#sbt_datepicker').val()==""){ e.preventDefault(); e.stopImmediatePropagation(); e.stopPropagation(); var date_validation_msg = setting.date_validation_msg if((date_validation_msg != null) && (date_validation_msg != "")) { var date_validation_msg_val = setting.date_validation_msg } else{ var date_validation_msg_val = 'Please select date.' } $(document).find('#sbt_datepicker').removeClass('invalid').addClass('invalid'); $(document).find('#sbt_delivery_date_wrapper .sbt_datepicker_validation').remove(); $(document).find('#sbt_delivery_date_wrapper').find('.sbt_delivery_date_wrapper_div').append('<span class="sbt_datepicker_validation" style="color:red">'+date_validation_msg_val+'</span>'); // $('html, body').animate({ // scrollTop: $(document).find('#sbt_datepicker').offset().top+200 // }, 2000); } else{ // e.preventDefault(); // alert("valid h") } } if(setting.timeslot_required == true){ if($(document).find('#sbt_timeslot').val()==""){ e.preventDefault(); e.stopImmediatePropagation(); e.stopPropagation(); var timeslot_validation_msg = setting.timeslot_validation_msg if((timeslot_validation_msg != null) && (timeslot_validation_msg != "")) { var timeslot_validation_msg_val = setting.timeslot_validation_msg } else{ var timeslot_validation_msg_val = 'Please select time slot.' } $(document).find('#sbt_timeslot').removeClass('invalid').addClass('invalid'); $(document).find('.sbt_timeslot_wrapper_div .sbt_timeslot_validation').remove(); $(document).find('#sbt_delivery_date_wrapper').find('.sbt_timeslot_wrapper_div').append('<span class="sbt_timeslot_validation" style="color:red">'+timeslot_validation_msg_val+'</span>'); // $('html, body').animate({ // scrollTop: $(document).find('#sbt_datepicker').offset().top+200 // }, 2000); } else{ // e.preventDefault(); // alert("valid h") // $.ajax({ // type: 'POST', // url: '/cart/update.js', // data: 'attributes[Delivery Date]='+$(document).find('#sbt_datepicker').val(), // dataType: 'json' // }); } } }); // Validation end if(setting.timeslot_type == "all_day"){ generate_options(setting.default_timeslot) } else{ // if (e.date.getDay() === 0) } $(document).find('#sbt_datepicker').on('pick.datepicker', function (e) { $(document).find('#sbt_delivery_date_wrapper .sbt_datepicker_validation').remove(); $(document).find('#sbt_datepicker').removeClass('invalid'); console.log(e.date) console.log($(document).find('#sbt_datepicker').val()) console.log($(document).find('#sbt_datepicker').datepicker('getDate', true)) $(document).find('#sbt_datepicker').val($(document).find('#sbt_datepicker').datepicker('getDate', true)) var date_update = $(document).find('#sbt_datepicker').datepicker('getDate', true) $(document).find('#sbt_datepicker').val(date_update) $(document).find('.tbtDeliveryDateVal').val(date_update) if(setting.allow_save_date_time_on_select == true ){ $.ajax({ type: 'POST', url: '/cart/update.js', data: 'attributes[Delivery Date]='+date_update, dataType: 'json' }); } // if (e.date < new Date()) { // e.preventDefault(); // Prevent to pick the date // } // if(setting.date_selection_required == true && setting.disable_checkout_btn_if_required == true ){ $(cart_form_selector).find("[name='checkout']").prop('disabled', false); $(cart_form_selector).find(".additional-checkout-button--paypal",".additional_checkout_buttons",".additional-checkout-buttons",".dynamic-checkout__content").show(); $(cart_form_selector).find(".additional-checkout-button--paypal",".additional_checkout_buttons",".additional-checkout-buttons",".dynamic-checkout__content").removeClass('hide').css('opacity',1); $(cart_form_selector).find(".additional-checkout-buttons").show(); $(window).trigger('resize'); // } if(setting.timeslot_type == "all_day"){ generate_options(setting.default_timeslot) } else{ if (e.date.getDay() === 0){ generate_options(setting.sunday_timeslot) } if (e.date.getDay() === 1){ generate_options(setting.monday_timeslot) } if (e.date.getDay() === 2){ generate_options(setting.tuesday_timeslot) } if (e.date.getDay() === 3){ generate_options(setting.wednesday_timeslot) } if (e.date.getDay() === 4){ generate_options(setting.thursday_timeslot) } if (e.date.getDay() === 5){ generate_options(setting.friday_timeslot) } if (e.date.getDay() === 6){ generate_options(setting.saturday_timeslot) } } }); $(document).find('#sbt_timeslot').on('change', function() { var selected_val = $(this).find(":selected").val(); if(selected_val!=''){ $(document).find('#sbt_timeslot').removeClass('invalid') $(document).find('.sbt_timeslot_wrapper_div .sbt_timeslot_validation').remove(); if(setting.allow_save_date_time_on_select == true ){ $.ajax({ type: 'POST', url: '/cart/update.js', data: 'attributes[Delivery Time]='+selected_val, dataType: 'json' }); } } else{ if(setting.allow_save_date_time_on_select == true ){ $.ajax({ type: 'POST', url: '/cart/update.js', data: 'attributes[Delivery Time]='+selected_val, dataType: 'json' }); } } }); // check if already exists $.getJSON('/cart.js', function(cart) { // now have access to Shopify cart object if(setting.allow_prefill == true){ if(cart.attributes !== null && cart.attributes !== undefined){ var deliver_date_exists_in_cart = cart.attributes.hasOwnProperty("Delivery Date"); var deliver_time_exists_in_cart = cart.attributes.hasOwnProperty("Delivery Time"); if(deliver_date_exists_in_cart){ $(document).find('#sbt_datepicker').val(cart.attributes["Delivery Date"]) $(document).find('#sbt_timeslot').val(cart.attributes["Delivery Time"]) $(document).find('#sbt_datepicker').trigger('click'); // console.log($(document).find('#sbt_datepicker').datepicker('getDate', true)) } if(deliver_time_exists_in_cart){ $(document).find('#sbt_timeslot').val(cart.attributes["Delivery Time"]) } // alert('There are now ' + JSON.stringify(cart.attributes) + ' items in the cart.'); } } }); // check if already exists // ///////////////////////////////////////////// } else{ console.log("Setting disabled") // alert("ena1") } } }) // ajax call end } // if cart page // your jQuery code } function loadjQuery(url, success) { var script = document.createElement('script'); script.src = url; var head = document.getElementsByTagName('head')[0], done = false; head.appendChild(script); // Attach handlers for all browsers script.onload = script.onreadystatechange = function() { if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) { done = true; success(); script.onload = script.onreadystatechange = null; head.removeChild(script); } }; } if (typeof jQuery == 'undefined') { console.log("jQuery not found") loadjQuery('http://code.jquery.com/jquery-latest.min.js', function() { // sbtDeliveryDate(); jQuery(function($) { // code goes here console.log("jQuery loaded dynamically.") sbtDeliveryDate($); }); }); } else { // if(window.jQuery.fn.jquery == '2.2.3'){ // console.log("jQuery found with version 2.2.3") // loadjQuery('http://code.jquery.com/jquery-latest.min.js', function() // { // // sbtDeliveryDate(); // jQuery(function($) { // // code goes here // console.log("jQuery loaded dynamically.") // sbtDeliveryDate($); // }); // }); // } // else{ // console.log("jQuery already found") // jQuery(function($) { // // code goes here // sbtDeliveryDate($); // }); // } console.log("jQuery lib already detected") jQuery(function($) { // code goes here sbtDeliveryDate($); }); }