www.lightcourse.com/public/static/home/new/js/jquery.simpler-sidebar.min.js

189 lines
5.0 KiB
JavaScript

/*!
* simpler-sidebar - A simple side nav in jQuery
* @version v2.2.4
* @license MIT AND GPL-2.0
*/
!(function (n) {
"function" == typeof define && define.amd
? define(["jquery"], n)
: "object" == typeof module && module.exports
? (module.exports = function (o, t) {
return (
void 0 === t &&
(t =
"undefined" != typeof window
? require("jquery")
: require("jquery")(o)),
n(t),
t
);
})
: n(jQuery);
})(function (n) {
n.fn.simplerSidebar = function (o) {
var t = n.extend(
!0,
{
attr: "simplersidebar",
top: 0,
gap: 64,
zIndex: 3e3,
sidebar: { width: 768 },
animation: { duration: 500, easing: "swing" },
events: {
on: {
animation: {
open: function () {},
close: function () {},
both: function () {},
},
},
callbacks: {
animation: {
open: function () {},
close: function () {},
both: function () {},
freezePage: !0,
},
},
},
mask: {
display: !0,
css: {
backgroundColor: "black",
opacity: 0.5,
filter: "Alpha(opacity=50)",
},
},
},
o
);
return this.each(function () {
var o,
e,
i,
a = "data-" + t.attr,
c = "opened" === t.init ? "opened" : "closed",
s = t.overflow ? t.overflow : n("html").css("overflow"),
l = t.overflow ? t.overflow : n("body").css("overflow"),
d = "left" === t.align ? "left" : "right",
r = t.animation.duration,
f = t.animation.easing,
u = {},
p = !0 === t.events.callbacks.animation.freezePage,
m = function () {
n("body, html").css("overflow", "hidden");
},
b = function () {
n("html").css("overflow", s), n("body").css("overflow", l);
},
h = n(this),
w = function (n) {
return n < t.sidebar.width + t.gap ? n - t.gap : t.sidebar.width;
},
v = function () {
return h.attr(a);
},
k = function (n) {
h.attr(a, n);
},
y = n("<div>").attr(a, "mask"),
g = function () {
y.fadeIn(r);
},
x = function () {
y.fadeOut(r);
},
z = n(t.selectors.trigger),
I = t.selectors.quitter ? t.selectors.quitter : "a",
q = n(window).width(),
j = {
on: {
animation: {
open: function () {
g(), k("opened"), t.events.on.animation.open();
},
close: function () {
x(), k("closed"), t.events.on.animation.close();
},
both: function () {
t.events.on.animation.both();
},
},
},
callbacks: {
animation: {
open: function () {
p && m(), t.events.callbacks.animation.open();
},
close: function () {
p && b(), t.events.callbacks.animation.close();
},
both: function () {
t.events.callbacks.animation.both();
},
},
},
},
P = function () {
var n = function () {
j.callbacks.animation.open(), j.callbacks.animation.both();
};
(u[d] = 0),
h.animate(u, r, f, n),
j.on.animation.open(),
j.on.animation.both();
},
A = function () {
var n = function () {
j.callbacks.animation.close(), j.callbacks.animation.both();
};
(u[d] = -h.width()),
h.animate(u, r, f, n),
j.on.animation.close(),
j.on.animation.both();
};
(o = {
position: "fixed",
top: parseInt(t.top),
bottom: 0,
width: w(q),
zIndex: t.zIndex,
}),
(o[d] = "closed" === c ? -w(q) : 0),
p && "opened" === c && m(),
h.css(o).attr(a, c),
(e = {
position: "fixed",
top: parseInt(t.top),
right: 0,
bottom: 0,
left: 0,
zIndex: t.zIndex - 1,
display: "none",
}),
(e.display = "opened" === c ? "block" : "none"),
(i = n.extend(!0, e, t.mask.css)),
t.mask.display &&
(function () {
y.appendTo("body").css(i);
})(),
z.click(function () {
switch (v()) {
case "opened":
A();
break;
case "closed":
P();
}
}),
y.click(A),
h.on("click", I, A),
n(window).resize(function () {
var o = n(window).width();
h.css("width", w(o)), "closed" === v() && h.css(d, -h.width());
});
});
};
});