Skip to content

Instantly share code, notes, and snippets.

@nakamuraagatha
Created December 11, 2016 02:33
Show Gist options
  • Save nakamuraagatha/cfc91c820ccd96d2a5b0f05f7b2a6697 to your computer and use it in GitHub Desktop.
Save nakamuraagatha/cfc91c820ccd96d2a5b0f05f7b2a6697 to your computer and use it in GitHub Desktop.
! function(t) {
function e(o) {
if (i[o]) return i[o].exports;
var r = i[o] = {
exports: {},
id: o,
loaded: !1
};
return t[o].call(r.exports, r, r.exports, e), r.loaded = !0, r.exports
}
var i = {};
return e.m = t, e.c = i, e.p = "", e(0)
}({
0: function(t, e, i) {
t.exports = i(80)
},
80: function(t, e, i) {
"use strict";
function o(t) {
if (jQuery(".cart-item .nav-dropdown").length) jQuery(".cart-item").addClass("current-dropdown cart-active"), jQuery(".shop-container").click(function() {
jQuery(".cart-item").removeClass("current-dropdown cart-active")
}), jQuery(".cart-item").hover(function() {
jQuery(".cart-active").removeClass("cart-active")
}), setTimeout(function() {
jQuery(".cart-active").removeClass("current-dropdown")
}, t);
else {
var e = jQuery.magnificPopup.open ? 0 : 300;
e && jQuery.magnificPopup.close(), setTimeout(function() {
jQuery(".cart-item .off-canvas-toggle").click()
}, e)
}
}
i(81), i(82), i(83);
var r = !1;
/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) || (r = jQuery(".has-image-zoom .slide").easyZoom({
loadingNotice: ""
})), jQuery("table.my_account_orders").wrap('<div class="touch-scroll-table"/>'), jQuery("a.woocommerce-review-link").click(function(t) {
jQuery.scrollTo(".reviews_tab", {
duration: 300,
offset: -150
})
}), jQuery(".single_add_to_cart_button").click(function(t) {
jQuery(this).addClass("loading")
});
var s = jQuery(".product-thumbnails .first img").attr("data-src") ? jQuery(".product-thumbnails .first img").attr("data-src") : jQuery(".product-thumbnails .first img").attr("src");
jQuery("form.variations_form").on("show_variation", function(t, e) {
if (e.image_src) {
if (jQuery(".product-gallery-slider .slide.first img, .product-thumbnails .first img").attr("src", e.image_src).attr("srcset", ""), jQuery(".product-gallery-slider").data("flickity") && jQuery(".product-gallery-slider").flickity("select", 0), r && r.length) {
var i = r.filter(".has-image-zoom .slide.first").data("easyZoom");
i.swap(jQuery(".has-image-zoom .slide.first img").attr("src"), jQuery(".has-image-zoom .slide.first a").attr("href"))
}
} else jQuery(".product-thumbnails .first img").attr("src", s)
}), jQuery(document).ready(function() {
jQuery(".has-lightbox .product-gallery-slider").each(function() {
jQuery(this).magnificPopup({
delegate: "a",
type: "image",
tLoading: '<div class="loading-spin centered dark"></div>',
closeBtnInside: !1,
gallery: {
enabled: !0,
navigateByImgClick: !0,
preload: [0, 1],
arrowMarkup: '<button class="mfp-arrow mfp-arrow-%dir%" title="%title%"><i class="icon-angle-%dir%"></i></button>'
},
image: {
tError: '<a href="%url%">The image #%curr%</a> could not be loaded.',
verticalFit: !1
}
})
})
}), jQuery(".zoom-button").click(function(t) {
jQuery(".product-gallery-slider").find(".is-selected a").click(), t.preventDefault()
}), jQuery(".product-gallery-slider").on("cellSelect", function() {
var t = jQuery(this).find(".is-selected").outerHeight();
t && jQuery(this).find(".flickity-viewport").css("height", t)
}), jQuery("body").on("added_to_cart", function() {
o("5000")
}), jQuery("body").on("updated_cart_totals", function() {
Flatsome.attach(jQuery(".cart-wrapper"))
}), jQuery(document).ready(function() {
jQuery("span.added-to-cart").length && o("5000")
})
},
81: function(t, e, i) {
var o;
/*!
* @name EasyZoom
* @author Matt Hinchliffe <>
* @modified Tuesday, September 6th, 2016
* @version 2.4.0
*/
! function(r) {
"use strict";
function s(t, e) {
this.$target = r(t), this.opts = r.extend({}, d, e, this.$target.data()), void 0 === this.isOpen && this._init()
}
var a, n, c, l, h, u, d = {
loadingNotice: "Loading image",
errorNotice: "The image could not be loaded",
errorDuration: 2500,
linkAttribute: "href",
preventClicks: !0,
beforeShow: r.noop,
beforeHide: r.noop,
onShow: r.noop,
onHide: r.noop,
onMove: r.noop
};
s.prototype._init = function() {
this.$link = this.$target.find("a"), this.$image = this.$target.find("img"), this.$flyout = r('<div class="easyzoom-flyout" />'), this.$notice = r('<div class="easyzoom-notice" />'), this.$target.on({
"mousemove.easyzoom touchmove.easyzoom": r.proxy(this._onMove, this),
"mouseleave.easyzoom touchend.easyzoom": r.proxy(this._onLeave, this),
"mouseenter.easyzoom touchstart.easyzoom": r.proxy(this._onEnter, this)
}), this.opts.preventClicks && this.$target.on("click.easyzoom", function(t) {
t.preventDefault()
})
}, s.prototype.show = function(t, e) {
var i, o, r, s, h = this;
if (this.opts.beforeShow.call(this) !== !1) {
if (!this.isReady) return this._loadImage(this.$link.attr(this.opts.linkAttribute), function() {
(h.isMouseOver || !e) && h.show(t)
});
this.$target.append(this.$flyout), i = this.$target.width(), o = this.$target.height(), r = this.$flyout.width(), s = this.$flyout.height(), a = this.$zoom.width() - r, n = this.$zoom.height() - s, 0 > a && (a = 0), 0 > n && (n = 0), c = a / i, l = n / o, this.isOpen = !0, this.opts.onShow.call(this), t && this._move(t)
}
}, s.prototype._onEnter = function(t) {
var e = t.originalEvent.touches;
this.isMouseOver = !0, e && 1 != e.length || (t.preventDefault(), this.show(t, !0))
}, s.prototype._onMove = function(t) {
this.isOpen && (t.preventDefault(), this._move(t))
}, s.prototype._onLeave = function() {
this.isMouseOver = !1, this.isOpen && this.hide()
}, s.prototype._onLoad = function(t) {
t.currentTarget.width && (this.isReady = !0, this.$notice.detach(), this.$flyout.html(this.$zoom), this.$target.removeClass("is-loading").addClass("is-ready"), t.data.call && t.data())
}, s.prototype._onError = function() {
var t = this;
this.$notice.text(this.opts.errorNotice), this.$target.removeClass("is-loading").addClass("is-error"), this.detachNotice = setTimeout(function() {
t.$notice.detach(), t.detachNotice = null
}, this.opts.errorDuration)
}, s.prototype._loadImage = function(t, e) {
var i = new Image;
this.$target.addClass("is-loading").append(this.$notice.text(this.opts.loadingNotice)), this.$zoom = r(i).on("error", r.proxy(this._onError, this)).on("load", e, r.proxy(this._onLoad, this)), i.style.position = "absolute", i.src = t
}, s.prototype._move = function(t) {
if (0 === t.type.indexOf("touch")) {
var e = t.touches || t.originalEvent.touches;
h = e[0].pageX, u = e[0].pageY
} else h = t.pageX || h, u = t.pageY || u;
var i = this.$target.offset(),
o = u - i.top,
r = h - i.left,
s = Math.ceil(o * l),
d = Math.ceil(r * c);
if (0 > d || 0 > s || d > a || s > n) this.hide();
else {
var p = -1 * s,
y = -1 * d;
this.$zoom.css({
top: p,
left: y
}), this.opts.onMove.call(this, p, y)
}
}, s.prototype.hide = function() {
this.isOpen && this.opts.beforeHide.call(this) !== !1 && (this.$flyout.detach(), this.isOpen = !1, this.opts.onHide.call(this))
}, s.prototype.swap = function(t, e, i) {
this.hide(), this.isReady = !1, this.detachNotice && clearTimeout(this.detachNotice), this.$notice.parent().length && this.$notice.detach(), this.$target.removeClass("is-loading is-ready is-error"), this.$image.attr({
src: t,
srcset: r.isArray(i) ? i.join() : i
}), this.$link.attr(this.opts.linkAttribute, e)
}, s.prototype.teardown = function() {
this.hide(), this.$target.off(".easyzoom").removeClass("is-loading is-ready is-error"), this.detachNotice && clearTimeout(this.detachNotice), delete this.$link, delete this.$zoom, delete this.$image, delete this.$notice, delete this.$flyout, delete this.isOpen, delete this.isReady
}, r.fn.easyZoom = function(t) {
return this.each(function() {
var e = r.data(this, "easyZoom");
e ? void 0 === e.isOpen && e._init() : r.data(this, "easyZoom", new s(this, t))
})
}, o = function() {
return s
}.call(e, i, e, t), !(void 0 !== o && (t.exports = o))
}(jQuery)
},
82: function(t, e) {
"use strict";
Flatsome.plugin("addQty", function(t, e) {
var i = jQuery(t);
i.on("click", ".plus, .minus", function() {
var t = jQuery(this),
e = t.closest(".quantity").find(".qty"),
i = parseFloat(e.val()),
o = parseFloat(e.attr("max")),
r = parseFloat(e.attr("min")),
s = e.attr("step");
i && "" !== i && "NaN" !== i || (i = 0), "" !== o && "NaN" !== o || (o = ""), "" !== r && "NaN" !== r || (r = 0), "any" !== s && "" !== s && void 0 !== s && "NaN" !== parseFloat(s) || (s = 1), t.is(".plus") ? o && (o === i || i > o) ? e.val(o) : e.val(i + parseFloat(s)) : r && (r === i || i < r) ? e.val(r) : i > 0 && e.val(i - parseFloat(s)), e.trigger("change")
})
})
},
83: function(t, e) {
"use strict";
Flatsome.behavior("add-qty", {
attach: function(t) {
jQuery(".quantity", t).addQty()
}
})
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment