687 lines
225 KiB
JavaScript
687 lines
225 KiB
JavaScript
|
|
/**
|
||
|
|
* Owl Carousel v2.3.4
|
||
|
|
* Copyright 2013-2018 David Deutsch
|
||
|
|
* Licensed under: SEE LICENSE IN https://github.com/OwlCarousel2/OwlCarousel2/blob/master/LICENSE
|
||
|
|
*/
|
||
|
|
!function(a,b,c,d){function e(b,c){this.settings=null,this.options=a.extend({},e.Defaults,c),this.$element=a(b),this._handlers={},this._plugins={},this._supress={},this._current=null,this._speed=null,this._coordinates=[],this._breakpoint=null,this._width=null,this._items=[],this._clones=[],this._mergers=[],this._widths=[],this._invalidated={},this._pipe=[],this._drag={time:null,target:null,pointer:null,stage:{start:null,current:null},direction:null},this._states={current:{},tags:{initializing:["busy"],animating:["busy"],dragging:["interacting"]}},a.each(["onResize","onThrottledResize"],a.proxy(function(b,c){this._handlers[c]=a.proxy(this[c],this)},this)),a.each(e.Plugins,a.proxy(function(a,b){this._plugins[a.charAt(0).toLowerCase()+a.slice(1)]=new b(this)},this)),a.each(e.Workers,a.proxy(function(b,c){this._pipe.push({filter:c.filter,run:a.proxy(c.run,this)})},this)),this.setup(),this.initialize()}e.Defaults={items:3,loop:!1,center:!1,rewind:!1,checkVisibility:!0,mouseDrag:!0,touchDrag:!0,pullDrag:!0,freeDrag:!1,margin:0,stagePadding:0,merge:!1,mergeFit:!0,autoWidth:!1,startPosition:0,rtl:!1,smartSpeed:250,fluidSpeed:!1,dragEndSpeed:!1,responsive:{},responsiveRefreshRate:200,responsiveBaseElement:b,fallbackEasing:"swing",slideTransition:"",info:!1,nestedItemSelector:!1,itemElement:"div",stageElement:"div",refreshClass:"owl-refresh",loadedClass:"owl-loaded",loadingClass:"owl-loading",rtlClass:"owl-rtl",responsiveClass:"owl-responsive",dragClass:"owl-drag",itemClass:"owl-item",stageClass:"owl-stage",stageOuterClass:"owl-stage-outer",grabClass:"owl-grab"},e.Width={Default:"default",Inner:"inner",Outer:"outer"},e.Type={Event:"event",State:"state"},e.Plugins={},e.Workers=[{filter:["width","settings"],run:function(){this._width=this.$element.width()}},{filter:["width","items","settings"],run:function(a){a.current=this._items&&this._items[this.relative(this._current)]}},{filter:["items","settings"],run:function(){this.$stage.children(".cloned").remove()}},{filter:["width","items","settings"],run:function(a){var b=this.settings.margin||"",c=!this.settings.autoWidth,d=this.settings.rtl,e={width:"auto","margin-left":d?b:"","margin-right":d?"":b};!c&&this.$stage.children().css(e),a.css=e}},{filter:["width","items","settings"],run:function(a){var b=(this.width()/this.settings.items).toFixed(3)-this.settings.margin,c=null,d=this._items.length,e=!this.settings.autoWidth,f=[];for(a.items={merge:!1,width:b};d--;)c=this._mergers[d],c=this.settings.mergeFit&&Math.min(c,this.settings.items)||c,a.items.merge=c>1||a.items.merge,f[d]=e?b*c:this._items[d].width();this._widths=f}},{filter:["items","settings"],run:function(){var b=[],c=this._items,d=this.settings,e=Math.max(2*d.items,4),f=2*Math.ceil(c.length/2),g=d.loop&&c.length?d.rewind?e:Math.max(e,f):0,h="",i="";for(g/=2;g>0;)b.push(this.normalize(b.length/2,!0)),h+=c[b[b.length-1]][0].outerHTML,b.push(this.normalize(c.length-1-(b.length-1)/2,!0)),i=c[b[b.length-1]][0].outerHTML+i,g-=1;this._clones=b,a(h).addClass("cloned").appendTo(this.$stage),a(i).addClass("cloned").prependTo(this.$stage)}},{filter:["width","items","settings"],run:function(){for(var a=this.settings.rtl?1:-1,b=this._clones.length+this._items.length,c=-1,d=0,e=0,f=[];++c<b;)d=f[c-1]||0,e=this._widths[this.relative(c)]+this.settings.margin,f.push(d+e*a);this._coordinates=f}},{filter:["width","items","settings"],run:function(){var a=this.settings.stagePadding,b=this._coordinates,c={width:Math.ceil(Math.abs(b[b.length-1]))+2*a,"padding-left":a||"","padding-right":a||""};this.$stage.css(c)}},{filter:["width","items","settings"],run:function(a){var b=this._coordinates.length,c=!this.settings.autoWidth,d=this.$stage.children();if(c&&a.items.merge)for(;b--;)a.css.width=this._widths[this.relative(b)],d.eq(b).css(a.css);else c&&(a.css.width=a.items.width,d.css(a.css))}},{filter:["items"],run:function(){this._coordinates.length<1&&this.$stage.removeAttr("style")}},{filter:["width","items","settings"],run:function(a){a.current=a.current?this.$stage.children().index(a.current):0,a.current=Math.max(this.minimum(),Math.min(this.maximum
|
||
|
|
animateIn:!1},e.prototype.swap=function(){if(1===this.core.settings.items&&a.support.animation&&a.support.transition){this.core.speed(0);var b,c=a.proxy(this.clear,this),d=this.core.$stage.children().eq(this.previous),e=this.core.$stage.children().eq(this.next),f=this.core.settings.animateIn,g=this.core.settings.animateOut;this.core.current()!==this.previous&&(g&&(b=this.core.coordinates(this.previous)-this.core.coordinates(this.next),d.one(a.support.animation.end,c).css({left:b+"px"}).addClass("animated owl-animated-out").addClass(g)),f&&e.one(a.support.animation.end,c).addClass("animated owl-animated-in").addClass(f))}},e.prototype.clear=function(b){a(b.target).css({left:""}).removeClass("animated owl-animated-out owl-animated-in").removeClass(this.core.settings.animateIn).removeClass(this.core.settings.animateOut),this.core.onTransitionEnd()},e.prototype.destroy=function(){var a,b;for(a in this.handlers)this.core.$element.off(a,this.handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},a.fn.owlCarousel.Constructor.Plugins.Animate=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){var e=function(b){this._core=b,this._call=null,this._time=0,this._timeout=0,this._paused=!0,this._handlers={"changed.owl.carousel":a.proxy(function(a){a.namespace&&"settings"===a.property.name?this._core.settings.autoplay?this.play():this.stop():a.namespace&&"position"===a.property.name&&this._paused&&(this._time=0)},this),"initialized.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.autoplay&&this.play()},this),"play.owl.autoplay":a.proxy(function(a,b,c){a.namespace&&this.play(b,c)},this),"stop.owl.autoplay":a.proxy(function(a){a.namespace&&this.stop()},this),"mouseover.owl.autoplay":a.proxy(function(){this._core.settings.autoplayHoverPause&&this._core.is("rotating")&&this.pause()},this),"mouseleave.owl.autoplay":a.proxy(function(){this._core.settings.autoplayHoverPause&&this._core.is("rotating")&&this.play()},this),"touchstart.owl.core":a.proxy(function(){this._core.settings.autoplayHoverPause&&this._core.is("rotating")&&this.pause()},this),"touchend.owl.core":a.proxy(function(){this._core.settings.autoplayHoverPause&&this.play()},this)},this._core.$element.on(this._handlers),this._core.options=a.extend({},e.Defaults,this._core.options)};e.Defaults={autoplay:!1,autoplayTimeout:5e3,autoplayHoverPause:!1,autoplaySpeed:!1},e.prototype._next=function(d){this._call=b.setTimeout(a.proxy(this._next,this,d),this._timeout*(Math.round(this.read()/this._timeout)+1)-this.read()),this._core.is("interacting")||c.hidden||this._core.next(d||this._core.settings.autoplaySpeed)},e.prototype.read=function(){return(new Date).getTime()-this._time},e.prototype.play=function(c,d){var e;this._core.is("rotating")||this._core.enter("rotating"),c=c||this._core.settings.autoplayTimeout,e=Math.min(this._time%(this._timeout||c),c),this._paused?(this._time=this.read(),this._paused=!1):b.clearTimeout(this._call),this._time+=this.read()%c-e,this._timeout=c,this._call=b.setTimeout(a.proxy(this._next,this,d),c-e)},e.prototype.stop=function(){this._core.is("rotating")&&(this._time=0,this._paused=!0,b.clearTimeout(this._call),this._core.leave("rotating"))},e.prototype.pause=function(){this._core.is("rotating")&&!this._paused&&(this._time=this.read(),this._paused=!0,b.clearTimeout(this._call))},e.prototype.destroy=function(){var a,b;this.stop();for(a in this._handlers)this._core.$element.off(a,this._handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},a.fn.owlCarousel.Constructor.Plugins.autoplay=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){"use strict";var e=function(b){this._core=b,this._initialized=!1,this._pages=[],this._controls={},this._templates=[],this.$element=this._core.$element,this._overrides={next:this._core.next,prev:this._core.prev,to:this._core.to},this._handlers={"prepared.owl.carousel":a.proxy(function(b){b.namespace&&this._core.settings.dotsData&&this._templates.push('<div class="'+this._core.settings.dotClass+'">'+a
|
||
|
|
|
||
|
|
/* ========================================================== */
|
||
|
|
|
||
|
|
/*! owl.carousel2.thumbs - v0.1.8 | (c) 2016 @gijsroge | MIT license | https://github.com/gijsroge/OwlCarousel2-Thumbs */
|
||
|
|
!function(a,b,c,d){"use strict";var e=function(b){this.owl=b,this._thumbcontent=[],this._identifier=0,this.owl_currentitem=this.owl.options.startPosition,this.$element=this.owl.$element,this._handlers={"prepared.owl.carousel":a.proxy(function(b){if(!b.namespace||!this.owl.options.thumbs||this.owl.options.thumbImage||this.owl.options.thumbsPrerendered||this.owl.options.thumbImage){if(b.namespace&&this.owl.options.thumbs&&this.owl.options.thumbImage){var c=a(b.content).find("img");this._thumbcontent.push(c)}}else a(b.content).find("[data-thumb]").attr("data-thumb")!==d&&this._thumbcontent.push(a(b.content).find("[data-thumb]").attr("data-thumb"))},this),"initialized.owl.carousel":a.proxy(function(a){a.namespace&&this.owl.options.thumbs&&(this.render(),this.listen(),this._identifier=this.owl.$element.data("slider-id"),this.setActive())},this),"changed.owl.carousel":a.proxy(function(a){a.namespace&&"position"===a.property.name&&this.owl.options.thumbs&&(this._identifier=this.owl.$element.data("slider-id"),this.setActive())},this)},this.owl.options=a.extend({},e.Defaults,this.owl.options),this.owl.$element.on(this._handlers)};e.Defaults={thumbs:!0,thumbImage:!1,thumbContainerClass:"owl-thumbs",thumbItemClass:"owl-thumb-item",moveThumbsInside:!1},e.prototype.listen=function(){var b=this.owl.options;b.thumbsPrerendered&&(this._thumbcontent._thumbcontainer=a("."+b.thumbContainerClass)),a(this._thumbcontent._thumbcontainer).on("click",this._thumbcontent._thumbcontainer.children(),a.proxy(function(c){this._identifier=a(c.target).closest("."+b.thumbContainerClass).data("slider-id");var d=a(c.target).parent().is(this._thumbcontent._thumbcontainer)?a(c.target).index():a(c.target).closest("."+b.thumbItemClass).index();b.thumbsPrerendered?a("[data-slider-id="+this._identifier+"]").trigger("to.owl.carousel",[d,b.dotsSpeed,!0]):this.owl.to(d,b.dotsSpeed),c.preventDefault()},this))},e.prototype.render=function(){var b=this.owl.options;b.thumbsPrerendered?(this._thumbcontent._thumbcontainer=a("."+b.thumbContainerClass),b.moveThumbsInside&&this._thumbcontent._thumbcontainer.appendTo(this.$element)):this._thumbcontent._thumbcontainer=a("<div>").addClass(b.thumbContainerClass).appendTo(this.$element);var c;if(b.thumbImage)for(c=0;c<this._thumbcontent.length;++c)this._thumbcontent._thumbcontainer.append("<button class="+b.thumbItemClass+'><img src="'+this._thumbcontent[c].attr("src")+'" alt="'+this._thumbcontent[c].attr("alt")+'" /></button>');else for(c=0;c<this._thumbcontent.length;++c)this._thumbcontent._thumbcontainer.append("<button class="+b.thumbItemClass+">"+this._thumbcontent[c]+"</button>")},e.prototype.setActive=function(){this.owl_currentitem=this.owl._current-this.owl._clones.length/2,this.owl_currentitem===this.owl._items.length&&(this.owl_currentitem=0);var b=this.owl.options,c=b.thumbsPrerendered?a("."+b.thumbContainerClass+'[data-slider-id="'+this._identifier+'"]'):this._thumbcontent._thumbcontainer;c.children().filter(".active").removeClass("active"),c.children().eq(this.owl_currentitem).addClass("active")},e.prototype.destroy=function(){var a,b;for(a in this._handlers)this.owl.$element.off(a,this._handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},a.fn.owlCarousel.Constructor.Plugins.Thumbs=e}(window.Zepto||window.jQuery,window,document);
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
*
|
||
|
|
* Animate On Scroll
|
||
|
|
*
|
||
|
|
**/
|
||
|
|
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.AOS=t():e.AOS=t()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var i=n[o]={exports:{},id:o,loaded:!1};return e[o].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="dist/",t(0)}([function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},r=n(1),a=(o(r),n(6)),u=o(a),c=n(7),f=o(c),s=n(8),d=o(s),l=n(9),p=o(l),m=n(10),b=o(m),v=n(11),y=o(v),g=n(14),h=o(g),w=[],k=!1,x=document.all&&!window.atob,j={offset:120,delay:0,easing:"ease",duration:400,disable:!1,once:!1,startEvent:"DOMContentLoaded",throttleDelay:99,debounceDelay:50,disableMutationObserver:!1},O=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(e&&(k=!0),k)return w=(0,y.default)(w,j),(0,b.default)(w,j.once),w},_=function(){w=(0,h.default)(),O()},S=function(){w.forEach(function(e,t){e.node.removeAttribute("data-aos"),e.node.removeAttribute("data-aos-easing"),e.node.removeAttribute("data-aos-duration"),e.node.removeAttribute("data-aos-delay")})},z=function(e){return e===!0||"mobile"===e&&p.default.mobile()||"phone"===e&&p.default.phone()||"tablet"===e&&p.default.tablet()||"function"==typeof e&&e()===!0},A=function(e){return j=i(j,e),w=(0,h.default)(),z(j.disable)||x?S():(document.querySelector("body").setAttribute("data-aos-easing",j.easing),document.querySelector("body").setAttribute("data-aos-duration",j.duration),document.querySelector("body").setAttribute("data-aos-delay",j.delay),"DOMContentLoaded"===j.startEvent&&["complete","interactive"].indexOf(document.readyState)>-1?O(!0):"load"===j.startEvent?window.addEventListener(j.startEvent,function(){O(!0)}):document.addEventListener(j.startEvent,function(){O(!0)}),window.addEventListener("resize",(0,f.default)(O,j.debounceDelay,!0)),window.addEventListener("orientationchange",(0,f.default)(O,j.debounceDelay,!0)),window.addEventListener("scroll",(0,u.default)(function(){(0,b.default)(w,j.once)},j.throttleDelay)),j.disableMutationObserver||(0,d.default)("[data-aos]",_),w)};e.exports={init:A,refresh:O,refreshHard:_}},function(e,t){},,,,,function(e,t){(function(t){"use strict";function n(e,t,n){function o(t){var n=b,o=v;return b=v=void 0,k=t,g=e.apply(o,n)}function r(e){return k=e,h=setTimeout(s,t),_?o(e):g}function a(e){var n=e-w,o=e-k,i=t-n;return S?j(i,y-o):i}function c(e){var n=e-w,o=e-k;return void 0===w||n>=t||n<0||S&&o>=y}function s(){var e=O();return c(e)?d(e):void(h=setTimeout(s,a(e)))}function d(e){return h=void 0,z&&b?o(e):(b=v=void 0,g)}function l(){void 0!==h&&clearTimeout(h),k=0,b=w=v=h=void 0}function p(){return void 0===h?g:d(O())}function m(){var e=O(),n=c(e);if(b=arguments,v=this,w=e,n){if(void 0===h)return r(w);if(S)return h=setTimeout(s,t),o(w)}return void 0===h&&(h=setTimeout(s,t)),g}var b,v,y,g,h,w,k=0,_=!1,S=!1,z=!0;if("function"!=typeof e)throw new TypeError(f);return t=u(t)||0,i(n)&&(_=!!n.leading,S="maxWait"in n,y=S?x(u(n.maxWait)||0,t):y,z="trailing"in n?!!n.trailing:z),m.cancel=l,m.flush=p,m}function o(e,t,o){var r=!0,a=!0;if("function"!=typeof e)throw new TypeError(f);return i(o)&&(r="leading"in o?!!o.leading:r,a="trailing"in o?!!o.trailing:a),n(e,t,{leading:r,maxWait:t,trailing:a})}function i(e){var t="undefined"==typeof e?"undefined":c(e);return!!e&&("object"==t||"function"==t)}function r(e){return!!e&&"object"==("undefined"==typeof e?"undefined":c(e))}function a(e){return"symbol"==("undefined"==typeof e?"undefined":c(e))||r(e)&&k.call(e)==d}function u(e){if("number"==typeof e)return e;if(a(e))return s;if(i(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=i(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(l,"");var n=m.test(e);return n||b.test(e)?v(e.slice(2),n?2:8):p.test(e)?s:+e}var c="function"==typeof Symbol&&"symbol"==typeof S
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
*
|
||
|
|
* vanilla-lazyload@13.0.1
|
||
|
|
*
|
||
|
|
**/
|
||
|
|
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).LazyLoad=e()}(this,(function(){"use strict";function t(){return(t=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}var e="undefined"!=typeof window,n=e&&!("onscroll"in window)||"undefined"!=typeof navigator&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),r=e&&"IntersectionObserver"in window,a=e&&"classList"in document.createElement("p"),o={elements_selector:"img",container:n||e?document:null,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",data_poster:"poster",class_loading:"loading",class_loaded:"loaded",class_error:"error",load_delay:0,auto_unobserve:!0,callback_enter:null,callback_exit:null,callback_reveal:null,callback_loaded:null,callback_error:null,callback_finish:null,use_native:!1},i=function(t,e){var n,r=new t(e);try{n=new CustomEvent("LazyLoad::Initialized",{detail:{instance:r}})}catch(t){(n=document.createEvent("CustomEvent")).initCustomEvent("LazyLoad::Initialized",!1,!1,{instance:r})}window.dispatchEvent(n)},s=function(t,e){return t.getAttribute("data-"+e)},c=function(t,e,n){var r="data-"+e;null!==n?t.setAttribute(r,n):t.removeAttribute(r)},l=function(t){return"true"===s(t,"was-processed")},u=function(t,e){return c(t,"ll-timeout",e)},d=function(t){return s(t,"ll-timeout")},f=function(t){for(var e,n=[],r=0;e=t.children[r];r+=1)"SOURCE"===e.tagName&&n.push(e);return n},_=function(t,e,n){n&&t.setAttribute(e,n)},v=function(t,e){_(t,"sizes",s(t,e.data_sizes)),_(t,"srcset",s(t,e.data_srcset)),_(t,"src",s(t,e.data_src))},g={IMG:function(t,e){var n=t.parentNode;n&&"PICTURE"===n.tagName&&f(n).forEach((function(t){v(t,e)}));v(t,e)},IFRAME:function(t,e){_(t,"src",s(t,e.data_src))},VIDEO:function(t,e){f(t).forEach((function(t){_(t,"src",s(t,e.data_src))})),_(t,"poster",s(t,e.data_poster)),_(t,"src",s(t,e.data_src)),t.load()}},h=function(t,e){var n,r,a=e._settings,o=t.tagName,i=g[o];if(i)return i(t,a),e.loadingCount+=1,void(e._elements=(n=e._elements,r=t,n.filter((function(t){return t!==r}))));!function(t,e){var n=s(t,e.data_src),r=s(t,e.data_bg);n&&(t.style.backgroundImage='url("'.concat(n,'")')),r&&(t.style.backgroundImage=r)}(t,a)},m=function(t,e){a?t.classList.add(e):t.className+=(t.className?" ":"")+e},b=function(t,e){a?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\s+)"+e+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},p=function(t,e,n,r){t&&(void 0===r?void 0===n?t(e):t(e,n):t(e,n,r))},y=function(t,e,n){t.addEventListener(e,n)},E=function(t,e,n){t.removeEventListener(e,n)},w=function(t,e,n){E(t,"load",e),E(t,"loadeddata",e),E(t,"error",n)},I=function(t,e,n){var r=n._settings,a=e?r.class_loaded:r.class_error,o=e?r.callback_loaded:r.callback_error,i=t.target;b(i,r.class_loading),m(i,a),p(o,i,n),n.loadingCount-=1,0===n._elements.length&&0===n.loadingCount&&p(r.callback_finish,n)},k=function(t,e){var n=function n(a){I(a,!0,e),w(t,n,r)},r=function r(a){I(a,!1,e),w(t,n,r)};!function(t,e,n){y(t,"load",e),y(t,"loadeddata",e),y(t,"error",n)}(t,n,r)},A=["IMG","IFRAME","VIDEO"],L=function(t,e){var n=e._observer;z(t,e),n&&e._settings.auto_unobserve&&n.unobserve(t)},z=function(t,e,n){var r=e._settings;!n&&l(t)||(A.indexOf(t.tagName)>-1&&(k(t,e),m(t,r.class_loading)),h(t,e),function(t){c(t,"was-processed","true")}(t),p(r.callback_reveal,t,e))},O=function(t){var e=d(t);e&&(clearTimeout(e),u(t,null))},N=function(t,e,n){var r=n._settings;p(r.callback_enter,t,e,n),r.load_delay?function(t,e){var n=e._settings.load_delay,r=d(t);r||(r=setTimeout((function(){L(t,e),O(t)}),n),u(t,r))}(t,n):L(t,n)},C=function(t){return!!r&&(t._observer=new IntersectionObserver((function(e){e.forEach((function(e){return function(t){return t.isIntersecting||t.intersectionRatio>0}(e)?N(e.target,e,t):function(t,e,n){var r=n._settings;p(r.callback_exit,t,e,n),r.load_delay&&O(t)}(e.target,e,
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Fancybox
|
||
|
|
**/
|
||
|
|
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).window=t.window||{})}(this,(function(t){"use strict";const e=(t,e=1e4)=>(t=parseFloat(t+"")||0,Math.round((t+Number.EPSILON)*e)/e),i=function(t){if(!(t&&t instanceof Element&&t.offsetParent))return!1;const e=t.scrollHeight>t.clientHeight,i=window.getComputedStyle(t).overflowY,n=-1!==i.indexOf("hidden"),s=-1!==i.indexOf("visible");return e&&!n&&!s},n=function(t,e=void 0){return!(!t||t===document.body||e&&t===e)&&(i(t)?t:n(t.parentElement,e))},s=function(t){var e=(new DOMParser).parseFromString(t,"text/html").body;if(e.childElementCount>1){for(var i=document.createElement("div");e.firstChild;)i.appendChild(e.firstChild);return i}return e.firstChild},o=t=>`${t||""}`.split(" ").filter((t=>!!t)),a=(t,e,i)=>{o(e).forEach((e=>{t&&t.classList.toggle(e,i||!1)}))};class r{constructor(t){Object.defineProperty(this,"pageX",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pageY",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"clientX",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"clientY",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"time",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"nativePointer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.nativePointer=t,this.pageX=t.pageX,this.pageY=t.pageY,this.clientX=t.clientX,this.clientY=t.clientY,this.id=self.Touch&&t instanceof Touch?t.identifier:-1,this.time=Date.now()}}const l={passive:!1};class c{constructor(t,{start:e=(()=>!0),move:i=(()=>{}),end:n=(()=>{})}){Object.defineProperty(this,"element",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"startCallback",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"moveCallback",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"endCallback",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"currentPointers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"startPointers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),this.element=t,this.startCallback=e,this.moveCallback=i,this.endCallback=n;for(const t of["onPointerStart","onTouchStart","onMove","onTouchEnd","onPointerEnd","onWindowBlur"])this[t]=this[t].bind(this);this.element.addEventListener("mousedown",this.onPointerStart,l),this.element.addEventListener("touchstart",this.onTouchStart,l),this.element.addEventListener("touchmove",this.onMove,l),this.element.addEventListener("touchend",this.onTouchEnd),this.element.addEventListener("touchcancel",this.onTouchEnd)}onPointerStart(t){if(!t.buttons||0!==t.button)return;const e=new r(t);this.currentPointers.some((t=>t.id===e.id))||this.triggerPointerStart(e,t)&&(window.addEventListener("mousemove",this.onMove),window.addEventListener("mouseup",this.onPointerEnd),window.addEventListener("blur",this.onWindowBlur))}onTouchStart(t){for(const e of Array.from(t.changedTouches||[]))this.triggerPointerStart(new r(e),t);window.addEventListener("blur",this.onWindowBlur)}onMove(t){const e=this.currentPointers.slice(),i="changedTouches"in t?Array.from(t.changedTouches||[]).map((t=>new r(t))):[new r(t)],n=[];for(const t of i){const e=this.currentPointers.findIndex((e=>e.id===t.id));e<0||(n.push(t),this.currentPointers[e]=t)}n.length&&this.moveCallback(t,this.currentPointers.slice(),e)}onPointerEnd(t){t.buttons>0&&0!==t.button||(this.triggerPointerEnd(t,new r(t)),window.removeEventListener("mousemove",this.onMove),window.removeEventListener("mouseup",this.onPointerEnd),window.removeEventListener("blur",this.onWindowBlur))}onTouchEnd(t){for(const e of Array.from(t.changedTouches||[]))this.tr
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// Product Like: Add / Remove
|
||
|
|
function addFavoriteProduct(productId) {
|
||
|
|
if (check_user != '') {
|
||
|
|
Hura.Ajax.post('user', {
|
||
|
|
action_type: 'like',
|
||
|
|
item_type : 'product',
|
||
|
|
item_id: productId
|
||
|
|
}).then(function(response){
|
||
|
|
|
||
|
|
$('.success-form .content-text').html('Thêm sản phẩm ưa thích thành công !');
|
||
|
|
|
||
|
|
$(".success-form").show();
|
||
|
|
|
||
|
|
setTimeout(function(){
|
||
|
|
$(".success-form").fadeOut();
|
||
|
|
}, 1100);
|
||
|
|
|
||
|
|
setTimeout(function(){
|
||
|
|
$('.success-form .content-text').html('Thêm sản phẩm vào giỏ hàng thành công !');
|
||
|
|
}, 1500);
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
} else {
|
||
|
|
Fancybox.show([{ src: "#js-popup-customer-like"}]);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
function removeFavoriteProduct(productId) {
|
||
|
|
Hura.Ajax.post('user', {
|
||
|
|
action_type: 'remove-like',
|
||
|
|
item_type : 'product',
|
||
|
|
item_id: productId
|
||
|
|
}).then(function(response){
|
||
|
|
if (response.status != 'success') {
|
||
|
|
alert('- Có lỗi xảy ra. Vui lòng tải lại trang và thử lại')
|
||
|
|
}
|
||
|
|
|
||
|
|
location.reload();
|
||
|
|
});
|
||
|
|
}
|
||
|
|
//
|
||
|
|
|
||
|
|
function calculatePriceOff(price, normal_price) {
|
||
|
|
var percent = 0;
|
||
|
|
|
||
|
|
if (normal_price > price && price > 0) {
|
||
|
|
percent = Math.ceil(100 - price * 100 / normal_price);
|
||
|
|
}
|
||
|
|
|
||
|
|
return percent;
|
||
|
|
}
|
||
|
|
|
||
|
|
function formatArticleTime(article_time) {
|
||
|
|
if (article_time.includes('Hôm nay')) {
|
||
|
|
var time = new Date();
|
||
|
|
var day = (time.getDate() <= 9) ? '0' + time.getDate() : time.getDate();
|
||
|
|
var month = (time.getMonth()+1 <= 9) ? '0' + (time.getMonth()+1) : (time.getMonth()+1);
|
||
|
|
var year = time.getFullYear();
|
||
|
|
|
||
|
|
var html = day +'.'+ month;
|
||
|
|
} else {
|
||
|
|
var day_month = article_time.substring(0,5).replaceAll('-','.');
|
||
|
|
var year = article_time.substring(6,10);
|
||
|
|
var html = day_month;
|
||
|
|
}
|
||
|
|
return html + '\n'+ year;
|
||
|
|
}
|
||
|
|
|
||
|
|
function alertInput(errorArray, color) {
|
||
|
|
errorArray.forEach(function(input){
|
||
|
|
input.style.borderColor = color;
|
||
|
|
})
|
||
|
|
}
|
||
|
|
|
||
|
|
function countDownToNextDay(holder) {
|
||
|
|
const today = new Date();
|
||
|
|
const tomorrow = new Date(today);
|
||
|
|
tomorrow.setDate(tomorrow.getDate() + 1);
|
||
|
|
tomorrow.setHours(0,0,0,0); // set hour
|
||
|
|
|
||
|
|
var countDownDate = tomorrow.setDate(tomorrow.getDate() + 1);
|
||
|
|
|
||
|
|
var x = setInterval(function() {
|
||
|
|
var now = new Date().getTime();
|
||
|
|
var distance = countDownDate - now;
|
||
|
|
|
||
|
|
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
|
||
|
|
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
||
|
|
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
|
||
|
|
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
|
||
|
|
|
||
|
|
if(hours <=9) {
|
||
|
|
hours = "<b>0" + hours + "</b>";
|
||
|
|
} else {
|
||
|
|
hours = '<b>' + hours.toString().substr(0,1) + hours.toString().substr(1) + '</b>'
|
||
|
|
}
|
||
|
|
if(minutes <=9) {
|
||
|
|
minutes = "<b>0" + minutes + "</b>";
|
||
|
|
} else {
|
||
|
|
minutes = '<b>' + minutes.toString().substr(0,1) + minutes.toString().substr(1) + '</b>'
|
||
|
|
}
|
||
|
|
if(seconds <=9) {
|
||
|
|
seconds = "<b>0" + seconds + "</b>";
|
||
|
|
} else {
|
||
|
|
seconds = '<b>' + seconds.toString().substr(0,1) + seconds.toString().substr(1) + '</b>'
|
||
|
|
}
|
||
|
|
var html = hours + minutes + seconds;
|
||
|
|
|
||
|
|
$(holder).html(html);
|
||
|
|
|
||
|
|
}, 1000);
|
||
|
|
}
|
||
|
|
|
||
|
|
function checkContentHeight(height) {
|
||
|
|
$(".js-static-content").each(function(){
|
||
|
|
var $row = $(this);
|
||
|
|
var $row_height = $row.height();
|
||
|
|
|
||
|
|
if ($row_height > height) {
|
||
|
|
$row.css("max-height", height);
|
||
|
|
$row.addClass("bg-content");
|
||
|
|
$(".js-showmore-button").css("display","block");
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
$(".js-showmore-button").click(function(){
|
||
|
|
$(this).parents(".js-static-container").find(".js-static-content").css("max-height","unset");
|
||
|
|
$(this).parents(".js-static-container").find(".js-static-content").removeClass("bg-content");
|
||
|
|
$(this).parents(".js-static-container").find(".js-showless-button").css({"display": "block", "margin-top": "15px"});
|
||
|
|
$(this).hide();
|
||
|
|
|
||
|
|
$('html, body').animate({
|
||
|
|
scrollTop: $(this).parents(".js-static-container").find(".js-static-content").offset().top - 160
|
||
|
|
},500);
|
||
|
|
});
|
||
|
|
|
||
|
|
$(".js-showless-button").click(function(){
|
||
|
|
$(this).parents(".js-static-container").find(".js-static-content").css("max-height",height);
|
||
|
|
$(this).parents(".js-static-container").find(".js-static-content").addClass("bg-content");
|
||
|
|
$(this).parents(".js-static-container").find(".js-showmore-button").css("display","block");
|
||
|
|
$(this).hide();
|
||
|
|
|
||
|
|
$('html, body').animate({
|
||
|
|
scrollTop: $(this).parents(".js-static-container").find(".js-static-content").offset().top - 160
|
||
|
|
},800);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
function tooltip(){
|
||
|
|
var w_tooltip = $("#tooltip").width();
|
||
|
|
var h_tooltip = 0;
|
||
|
|
var pad = 10;
|
||
|
|
var x_mouse = 0;
|
||
|
|
var y_mouse = 0;
|
||
|
|
var wrap_left = 0;
|
||
|
|
var wrap_right = 0;
|
||
|
|
var wrap_top = 0;
|
||
|
|
var wrap_bottom = 0;
|
||
|
|
|
||
|
|
$(".p-item .p-img").mousemove(function(e){
|
||
|
|
content_tooltip = $(this).parents(".p-item").find(".p-tooltip");
|
||
|
|
if(content_tooltip.length == 0){
|
||
|
|
return;
|
||
|
|
$("#tooltip").hide();
|
||
|
|
}
|
||
|
|
|
||
|
|
$("#tooltip").html(content_tooltip.html());
|
||
|
|
|
||
|
|
wrap_left = 0;
|
||
|
|
wrap_top = $(window).scrollTop();
|
||
|
|
wrap_bottom = $(window).height();
|
||
|
|
wrap_right = $(window).width();
|
||
|
|
x_mouse = e.pageX;
|
||
|
|
y_mouse = e.pageY;
|
||
|
|
h_tooltip = $("#tooltip").height();
|
||
|
|
|
||
|
|
if(x_mouse + w_tooltip > wrap_right) $("#tooltip").css("left",x_mouse - w_tooltip - pad);
|
||
|
|
else $("#tooltip").css("left",x_mouse + pad);
|
||
|
|
|
||
|
|
if(y_mouse - h_tooltip < wrap_top) $("#tooltip").css("top",wrap_top);
|
||
|
|
else $("#tooltip").css("top",y_mouse - h_tooltip - pad);
|
||
|
|
|
||
|
|
$("#tooltip").show();
|
||
|
|
});
|
||
|
|
|
||
|
|
$(".p-item .p-img").mouseout(function(){
|
||
|
|
$("#tooltip").hide();
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
function showCartSummary(display_node) {
|
||
|
|
var $status_container = $(display_node);
|
||
|
|
$status_container.html('...');
|
||
|
|
Hura.Cart.getSummary().then(summary => {
|
||
|
|
$status_container.html(summary.total_item);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
function check_login(error_holder){
|
||
|
|
var error = "";
|
||
|
|
var email = document.getElementById('js-login-email').value;
|
||
|
|
if (email.length < 6) error += "- Mời bạn nhập địa chỉ email<br>";
|
||
|
|
|
||
|
|
var password = document.getElementById('js-login-pass').value;
|
||
|
|
if (password.length == 0 ) error += "- Bạn cần nhập mật khẩu <br>";
|
||
|
|
|
||
|
|
if (error != "") {
|
||
|
|
$(error_holder).html(error);
|
||
|
|
return false;
|
||
|
|
} else {
|
||
|
|
Hura.User.login(email, password).then(function (data) {
|
||
|
|
//console.log(data);
|
||
|
|
if (data.status == 'error') {
|
||
|
|
$(error_holder).html(data.message);
|
||
|
|
} else if (GetURLParameter('return_url')) {
|
||
|
|
location.href = GetURLParameter('return_url').replaceAll(';amp;','&').replaceAll(';equals;','=')
|
||
|
|
} else {
|
||
|
|
|
||
|
|
location.href = '/taikhoan'
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
function check_field_registor(error_holder) {
|
||
|
|
var ERROR_NOTE = error_holder;
|
||
|
|
var number_regex1 = /^[0]\d{9}$/i;
|
||
|
|
var number_regex2 = /^[0]\d{10}$/i;
|
||
|
|
var error = "";
|
||
|
|
var errorInput = [];
|
||
|
|
|
||
|
|
var email = document.getElementById("email");
|
||
|
|
if(email.value.length < 4) {
|
||
|
|
errorInput = [...errorInput, email];
|
||
|
|
error += "- Bạn chưa nhập email<br>";
|
||
|
|
|
||
|
|
} else if(validateEmail(email.value)==false){
|
||
|
|
errorInput = [...errorInput, email];
|
||
|
|
error += "- Email không hợp lệ <br>";
|
||
|
|
}
|
||
|
|
|
||
|
|
var password = document.getElementById('password');
|
||
|
|
if(password.value.length < 6) {
|
||
|
|
errorInput = [...errorInput, password];
|
||
|
|
error += "- Mật khẩu yếu<br>";
|
||
|
|
}
|
||
|
|
|
||
|
|
var pass1 = document.getElementById("password1");
|
||
|
|
if (pass1.value != password.value) {
|
||
|
|
errorInput = [...errorInput, pass1];
|
||
|
|
error += '- Mật khẩu không trùng khớp. Vui lòng nhập lại <br>';
|
||
|
|
}
|
||
|
|
|
||
|
|
var full_name = document.getElementById('full_name');
|
||
|
|
if(full_name.value.length < 2) {
|
||
|
|
errorInput = [...errorInput, full_name];
|
||
|
|
error += "- Tên quá ngắn<br>";
|
||
|
|
|
||
|
|
} else if(full_name.value.indexOf('<script') > -1) {
|
||
|
|
errorInput = [...errorInput, full_name];
|
||
|
|
error += "- Họ tên chứa các ký tự không hợp lệ, bạn vui lòng kiểm tra lại<br>";
|
||
|
|
}
|
||
|
|
|
||
|
|
var mobile = document.getElementById('tel');
|
||
|
|
if(mobile.value.length < 4) {
|
||
|
|
errorInput = [...errorInput, mobile];
|
||
|
|
error += "- Bạn chưa nhập SĐT<br>";
|
||
|
|
|
||
|
|
} else if(number_regex1.test(mobile.value) == false && number_regex2.test(mobile.value) == false){
|
||
|
|
errorInput = [...errorInput, mobile];
|
||
|
|
error += "- Số điện thoại chưa chính xác<br>";
|
||
|
|
}
|
||
|
|
|
||
|
|
var address = document.getElementById('address');
|
||
|
|
if(address.value.length < 5){
|
||
|
|
errorInput = [...errorInput, address];
|
||
|
|
error += "- Địa chỉ quá ngắn<br>";
|
||
|
|
|
||
|
|
} else if(address.value.indexOf('<script') > -1) {
|
||
|
|
errorInput = [...errorInput, address];
|
||
|
|
error += "- Địa chỉ chứa các ký tự không hợp lệ, bạn vui lòng kiểm tra lại<br>";
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
var province = $("#ship_to_province option:checked").val();
|
||
|
|
var district = $("#js-district-holder option:checked").val();
|
||
|
|
var sex = $('input[type="radio"]:checked').val()
|
||
|
|
|
||
|
|
var setDefault = [email, password, full_name, mobile, address, pass1]
|
||
|
|
|
||
|
|
alertInput(setDefault, '#d9d9d9');
|
||
|
|
|
||
|
|
if (error != "") {
|
||
|
|
$(ERROR_NOTE).html(error);
|
||
|
|
|
||
|
|
alertInput(errorInput, 'red');
|
||
|
|
|
||
|
|
return false;
|
||
|
|
} else {
|
||
|
|
|
||
|
|
var registerParams = {
|
||
|
|
action_type: "register",
|
||
|
|
info : {
|
||
|
|
email : email.value,
|
||
|
|
name : full_name.value,
|
||
|
|
tel : mobile.value,
|
||
|
|
mobile : mobile.value,
|
||
|
|
sex : 'male',
|
||
|
|
birthday : '',
|
||
|
|
password : password.value,
|
||
|
|
address : address.value,
|
||
|
|
province : province,
|
||
|
|
district : district
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
Hura.Ajax.post('customer', registerParams).then(function (data) {
|
||
|
|
console.log(data);
|
||
|
|
if(data.status == 'error' && data.message == 'Email exist' ){
|
||
|
|
|
||
|
|
$(ERROR_NOTE).html('Email đã được sử dụng <br> Vui lòng đăng ký lại ! ');
|
||
|
|
|
||
|
|
} else {
|
||
|
|
$(ERROR_NOTE).html('Bạn đã đăng ký thành công ! ');
|
||
|
|
|
||
|
|
$('.customer-page button[type=button]').html("Đang xử lý ... !").css({"background":"#ccc", "border-color":"transparent", "pointer-events":"none"});
|
||
|
|
|
||
|
|
location.href="/dang-nhap";
|
||
|
|
}
|
||
|
|
})
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
function check_user_captcha(captcha){
|
||
|
|
$('#check_captcha').html("... đang kiểm tra");
|
||
|
|
|
||
|
|
var params = {
|
||
|
|
captcha: captcha
|
||
|
|
};
|
||
|
|
|
||
|
|
Hura.Ajax.post('check-captcha', params).then(function (data) {
|
||
|
|
console.log(data);
|
||
|
|
$('#check_captcha').html(data);
|
||
|
|
})
|
||
|
|
}
|
||
|
|
|
||
|
|
function subscribe_newsletter(a, error_holder){
|
||
|
|
var number_regex1 = /^[0]\d{9}$/i;
|
||
|
|
var number_regex2 = /^[0]\d{10}$/i;
|
||
|
|
var NOTIFY = error_holder;
|
||
|
|
var error = "";
|
||
|
|
var email = $(a).val();
|
||
|
|
|
||
|
|
if(email.length < 4) {
|
||
|
|
error += "- Bạn chưa nhập email <br>";
|
||
|
|
} else if(validateEmail(email)==false){
|
||
|
|
error += "- Email không hợp lệ <br>";
|
||
|
|
}
|
||
|
|
|
||
|
|
if(error != "") {
|
||
|
|
$(NOTIFY).html(error).show();
|
||
|
|
$(a).css('border','2px solid #FA5252');
|
||
|
|
|
||
|
|
return false;
|
||
|
|
} else {
|
||
|
|
var params = {
|
||
|
|
action : 'customer',
|
||
|
|
action_type: 'register-newsletter',
|
||
|
|
info : {
|
||
|
|
full_name: 'Khách hàng nhận bản tin',
|
||
|
|
email: email
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
Hura.Ajax.post('customer', params).then(function (data) {
|
||
|
|
|
||
|
|
if(data.status == 'success') {
|
||
|
|
$(NOTIFY).html("- Quý khách đã đăng ký thành công").show();
|
||
|
|
$(a).css('border','unset');
|
||
|
|
$(a).val("");
|
||
|
|
|
||
|
|
setTimeout(function(){
|
||
|
|
$(NOTIFY).html("").hide();
|
||
|
|
},2000);
|
||
|
|
|
||
|
|
} else if(data.message == 'Email exist'){
|
||
|
|
$(NOTIFY).html("- Email này đã tồn tại").show();
|
||
|
|
$(a).css('border','2px solid #FA5252');
|
||
|
|
} else {
|
||
|
|
|
||
|
|
$(NOTIFY).html("- Lỗi xảy ra, vui lòng thử lại").show();
|
||
|
|
$(a).css('border','2px solid #FA5252');
|
||
|
|
}
|
||
|
|
})
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
function show_datetime_from_unix(int){
|
||
|
|
var date = new Date(int*1000);
|
||
|
|
return date;
|
||
|
|
}
|
||
|
|
|
||
|
|
function toTimestamp(strDate){
|
||
|
|
var datum = Date.parse(strDate);
|
||
|
|
return datum/1000;
|
||
|
|
}
|
||
|
|
|
||
|
|
function formatDate(a){
|
||
|
|
var a = new Date(parseInt(a)*1000);
|
||
|
|
|
||
|
|
var year = a.getFullYear();
|
||
|
|
var month = ((a.getMonth()+1) <= 9) ? '0' + (a.getMonth()+1) : a.getMonth()+1;
|
||
|
|
var date = (a.getDate() <= 10) ? '0' + a.getDate() : a.getDate();
|
||
|
|
var hour = (a.getHours() <= 10) ? '0' + a.getHours() : a.getHours();
|
||
|
|
var min = (a.getMinutes() <= 10) ? '0' + a.getMinutes() : a.getMinutes();
|
||
|
|
var sec = (a.getSeconds() <= 10) ? '0' + a.getSeconds() : a.getSeconds();
|
||
|
|
var text = (hour < 12) ? 'am' : 'pm';
|
||
|
|
var time = `Ngày ${date}-${month}-${year}, ${hour}:${min} ${text}`;
|
||
|
|
return time;
|
||
|
|
}
|
||
|
|
|
||
|
|
function GetURLParameter(sParam){
|
||
|
|
var sPageURL = window.location.search.substring(1);
|
||
|
|
var sURLVariables = sPageURL.split('&');
|
||
|
|
for (var i = 0; i < sURLVariables.length; i++)
|
||
|
|
{
|
||
|
|
var sParameterName = sURLVariables[i].split('=');
|
||
|
|
if (sParameterName[0] == sParam)
|
||
|
|
{
|
||
|
|
return sParameterName[1];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
function validateEmail(sEmail) {
|
||
|
|
var filter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
|
||
|
|
if (filter.test(sEmail)) {
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
function validatePhoneNumber(a){
|
||
|
|
var number_regex1 = /^[0]\d{9}$/i;
|
||
|
|
var number_regex2 = /^[0]\d{10}$/i;
|
||
|
|
|
||
|
|
if(number_regex1.test(a) == false && number_regex2.test(a) == false) return false;
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
function formatCurrency(a) {
|
||
|
|
var b = parseFloat(a).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1.").toString();
|
||
|
|
var len = b.length;
|
||
|
|
b = b.substring(0, len - 3);
|
||
|
|
return b;
|
||
|
|
}
|
||
|
|
|
||
|
|
function isOnScreen(elem) {
|
||
|
|
// if the element doesn't exist, abort
|
||
|
|
if( elem.length == 0 ) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
var $window = jQuery(window)
|
||
|
|
var viewport_top = $window.scrollTop()
|
||
|
|
var viewport_height = $window.height()
|
||
|
|
var viewport_bottom = viewport_top + viewport_height
|
||
|
|
var $elem = jQuery(elem)
|
||
|
|
var top = $elem.offset().top
|
||
|
|
var height = $elem.height()
|
||
|
|
var bottom = top + height
|
||
|
|
|
||
|
|
return (top >= viewport_top && top < viewport_bottom) ||
|
||
|
|
(bottom > viewport_top && bottom <= viewport_bottom) ||
|
||
|
|
(height > viewport_height && top <= viewport_top && bottom >= viewport_bottom)
|
||
|
|
}
|
||
|
|
|
||
|
|
function strToNumber(str) {
|
||
|
|
str += ''; //convert to str incase it's already a number
|
||
|
|
while(str.indexOf(".") > 0){
|
||
|
|
str = str.replace('.','');
|
||
|
|
}
|
||
|
|
var result = parseFloat(str);
|
||
|
|
return isNaN(result) ? 0 : result;
|
||
|
|
}
|
||
|
|
|
||
|
|
function writeStringToPrice(str){
|
||
|
|
str = (str+'').replace(/\./g, "");
|
||
|
|
var first_group = str.substr(0,str.length % 3);
|
||
|
|
var remain_group = str.replace(first_group,"");
|
||
|
|
var num_group = remain_group.length/3;
|
||
|
|
var result = "", group_of_three;
|
||
|
|
|
||
|
|
for(var i=0;i < num_group;i++){
|
||
|
|
group_of_three = remain_group.substr(i*3,3);
|
||
|
|
result += group_of_three;
|
||
|
|
if(i !== (num_group-1)) result += ".";
|
||
|
|
}
|
||
|
|
|
||
|
|
if(first_group.length > 0) {
|
||
|
|
return (result !== "") ? first_group + "." + result : first_group;
|
||
|
|
}
|
||
|
|
|
||
|
|
return result;
|
||
|
|
}
|
||
|
|
|
||
|
|
function loaiTrungLap(array, key) {
|
||
|
|
let check = {};
|
||
|
|
let res = [];
|
||
|
|
for(let i=0; i<array.length; i++) {
|
||
|
|
if(!check[array[i][key]]){
|
||
|
|
check[array[i][key]] = true;
|
||
|
|
res.push(array[i]);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return res;
|
||
|
|
}
|
||
|
|
|
||
|
|
// search
|
||
|
|
function _run_search() {
|
||
|
|
$('#js-global-search').keyup(debounce(function(){
|
||
|
|
inputString = $(this).val();
|
||
|
|
search(inputString);
|
||
|
|
},200));
|
||
|
|
|
||
|
|
$("#js-global-search").keydown(function(e){
|
||
|
|
var inputString = $("#js-global-search").val();
|
||
|
|
if(e.keyCode == 13 && inputString == ''){
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
$('body').click(function(){
|
||
|
|
$("#js-search-holder").hide();
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
function search(inputString){
|
||
|
|
var button = $('form[action="/tim"]').find('button');
|
||
|
|
|
||
|
|
var params = {
|
||
|
|
action_type : "search",
|
||
|
|
limit : 10,
|
||
|
|
q : inputString
|
||
|
|
}
|
||
|
|
|
||
|
|
Hura.Ajax.get('search', params).then(function (data) {
|
||
|
|
if (inputString.trim() != '') {
|
||
|
|
if (data != '') {
|
||
|
|
var html = Hura.Template.parse(instant_search_result_template, data.list);
|
||
|
|
Hura.Template.render('#js-search-holder', html);
|
||
|
|
|
||
|
|
button.attr('type','submit');
|
||
|
|
|
||
|
|
} else {
|
||
|
|
$('#js-search-holder').html('<p style="text-align: center;margin: 15px;">Không tìm thấy kết quả của <b>"'+inputString+'"</b></p>');
|
||
|
|
button.attr('type','button');
|
||
|
|
}
|
||
|
|
|
||
|
|
$("#js-search-holder").show();
|
||
|
|
} else {
|
||
|
|
$("#js-search-holder").hide();
|
||
|
|
}
|
||
|
|
})
|
||
|
|
}
|
||
|
|
|
||
|
|
function debounce(func, wait, immediate) {
|
||
|
|
var timeout;
|
||
|
|
return function() {
|
||
|
|
var context = this, args = arguments;
|
||
|
|
var later = function() {
|
||
|
|
timeout = null;
|
||
|
|
if (!immediate) func.apply(context, args);
|
||
|
|
};
|
||
|
|
var callNow = immediate && !timeout;
|
||
|
|
clearTimeout(timeout);
|
||
|
|
timeout = setTimeout(later, wait);
|
||
|
|
if (callNow) func.apply(context, args);
|
||
|
|
};
|
||
|
|
};
|
||
|
|
// end search
|
||
|
|
|
||
|
|
function _getPathName(){
|
||
|
|
var pathname = location.pathname;
|
||
|
|
|
||
|
|
if(pathname == '/tim') {
|
||
|
|
if ( GetURLParameter('q') ) {
|
||
|
|
pathname = '/tim?q=' + GetURLParameter('q')
|
||
|
|
} else {
|
||
|
|
pathname = '/tim?q='
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
$('.js-pathName').attr('href', pathname);
|
||
|
|
$('.js-select-path').val(pathname);
|
||
|
|
}
|
||
|
|
|
||
|
|
function show_hide_pass(pa) {
|
||
|
|
var x = $(pa).parents('.item').find('.input-pass').attr('type');
|
||
|
|
|
||
|
|
if (x === "password") {
|
||
|
|
$(pa).parents('.item').find('.input-pass').attr('type','text');
|
||
|
|
} else {
|
||
|
|
$(pa).parents('.item').find('.input-pass').attr('type','password');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
function addProductToCart(product_id, quantity ,redirect) {
|
||
|
|
var product_prop = {
|
||
|
|
quantity: quantity,
|
||
|
|
buyer_note : ''
|
||
|
|
};
|
||
|
|
|
||
|
|
Hura.Cart.Product.add(product_id, 0, product_prop).then(function(response){
|
||
|
|
if (redirect == '/cart') {
|
||
|
|
location.href = redirect;
|
||
|
|
} else {
|
||
|
|
// showCartSummary(".js-cart-count");
|
||
|
|
|
||
|
|
$('.js-cart-count').html(response.length);
|
||
|
|
|
||
|
|
$(".success-form").show();
|
||
|
|
|
||
|
|
setTimeout(function(){
|
||
|
|
$(".success-form").fadeOut();
|
||
|
|
}, 1000);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
//
|
||
|
|
function animateValue(id, end, duration) {
|
||
|
|
var start = 0;
|
||
|
|
if (start === end) return;
|
||
|
|
var range = end - start;
|
||
|
|
var current = start;
|
||
|
|
var increment = end > start? 1 : -1;
|
||
|
|
var stepTime = Math.abs(Math.floor(duration / range));
|
||
|
|
var obj = id;
|
||
|
|
var timer = setInterval(function() {
|
||
|
|
current += increment;
|
||
|
|
obj.innerHTML = current;
|
||
|
|
if (current == end) {
|
||
|
|
clearInterval(timer);
|
||
|
|
}
|
||
|
|
}, stepTime);
|
||
|
|
}
|