$(function () { $('header .dropdown').hover(function () { $(this).find('.dropdown-menu').stop(true, true).delay(200).fadeIn(500); }, function () { $(this).find('.dropdown-menu').stop(true, true).delay(200).fadeOut(500); }); if ($(window).width() <= 992) { $('.product-slider').slick({ arrows: false, dots: true, autoplay: true, infinite: true, speed: 300, slidesToShow: 1, slidesToScroll: 1, draggable: false }); } if ($(window).width() > 768) { $('.product-slider').slick({ arrows: false, dots: true, autoplay: true, infinite: true, speed: 300, slidesToShow: 4, slidesToScroll: 1, draggable: false }); $('.js-heading-2').height($('.js-heading-1').height()); } }); (function (root, factory) { if (typeof define === 'function' && define.amd) { define(factory); } else if (typeof exports === 'object') { module.exports = factory(); } else { root.resLoader = factory(root); } }(this, function () { var isFunc = function (f) { return typeof f === 'function'; } function resLoader(config) { this.option = { resourceType: 'image', baseUrl: '', resources: [], onStart: null, onProgress: null, onComplete: null } if (config) { for (i in config) { this.option[i] = config[i]; } } else { return; } this.status = 0; this.total = this.option.resources.length || 0; this.currentIndex = 0; }; resLoader.prototype.start = function () { this.status = 1; var _this = this; var baseUrl = this.option.baseUrl; for (var i = 0, l = this.option.resources.length; i < l; i++) { var r = this.option.resources[i], url = ''; if (r.indexOf('http://') === 0 || r.indexOf('https://') === 0) { url = r; } else { url = baseUrl + r; } var image = new Image(); image.onload = function () { _this.loaded(); }; image.onerror = function () { _this.loaded(); }; image.src = url; } if (isFunc(this.option.onStart)) { this.option.onStart(this.total); } } resLoader.prototype.loaded = function () { if (isFunc(this.option.onProgress)) { this.option.onProgress(++this.currentIndex, this.total); } if (this.currentIndex === this.total) { if (isFunc(this.option.onComplete)) { this.option.onComplete(this.total); } } } return resLoader; }));