Skip to content
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.

Commit

Permalink
v1.5.4
Browse files Browse the repository at this point in the history
- Nuevo componente `.wjs-accordion`
  • Loading branch information
danieIabel committed Oct 17, 2018
1 parent 34cfd89 commit d95e0d4
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 109 deletions.
3 changes: 2 additions & 1 deletion dist/css/whale.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Whale v1.5.2
* Whale v1.5.4
* Copyright 2017-2018 zkreations
* Developed by Daniel Abel M. (instagram.com/danie.abel)
* Licensed under MIT (github.com/zkreations/whale/blob/master/LICENSE)
Expand Down Expand Up @@ -2791,6 +2791,7 @@ textarea {

.wjs-menu,
.wjs-spoiler,
.wjs-accordion,
.wjs-tab {
display: none !important;
}
Expand Down
4 changes: 2 additions & 2 deletions dist/css/whale.min.css

Large diffs are not rendered by default.

250 changes: 146 additions & 104 deletions dist/js/whale.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,102 +6,141 @@
*/
var whale = function() {
"use strict";
function e(t, a) {
return e.addElements(t, a);
function e(t, n) {
return e.addElements(t, n)
}
function t(e, t) {
for (var a = 0, n = e.length; a < n && !1 !== t.call(e[a], a, e[a]); a++) ;
return e;
}
function a(e) {
return e.trim();
for (var n = 0, a = e.length; a > n && !1 !== t.call(e[n], n, e[n]); n++);
return e
}
function n(e) {
return (" " + (e.getAttribute("class") || "") + " ").replace(/[\t\r\n\f]/g, " ");
return e.trim()
}
function a(e) {
return (" " + (e.getAttribute("class") || "") + " ").replace(/[\t\r\n\f]/g, " ")
}
function l(e, t) {
return -1 < n(e).indexOf(t);
function s(e, t) {
return -1 < a(e).indexOf(t)
}
function s(e, s) {
var c = n(e);
t(s.split(" "), function(t, n) {
n = a(n), l(e, n) || (c += n + " ");
}), e.setAttribute("class", a(c));
function c(e, c) {
var l = a(e);
t(c.split(" "), function(t, a) {
a = n(a), s(e, a) || (l += a + " ")
}), e.setAttribute("class", n(l))
}
function c(e, l) {
t(l.split(" "), function(t, l) {
e.setAttribute("class", a(n(e).replace(" " + a(l) + " ", " ")));
});
function l(e, s) {
t(s.split(" "), function(t, s) {
e.setAttribute("class", n(a(e).replace(" " + n(s) + " ", " ")))
})
}
function i(e, a) {
t(a.split(" "), function(t, a) {
(l(e, a) ? c : s)(e, a);
});
function i(e, n) {
t(n.split(" "), function(t, n) {
(s(e, n) ? l : c)(e, n)
})
}
return e.extend = function(e) {
var t, a, n, l = 1, s = arguments.length;
for (l === s && (e = this, l--); l < s; l++) if (null != (t = arguments[l])) for (n in t) (a = t[n]) !== e[n] && (e[n] = a);
return e;
}, t([ s, c, i ], function(e, a) {
a.collection = function(e, n) {
var t, n, a, s, c = 1,
l = arguments.length;
for (c === l && (e = this, c--); l > c; c++)
if (null != (t = arguments[c]))
for (a in t) n = t[a], s = e[a], n !== s && (e[a] = n);
return e
}, t([c, l, i], function(e, n) {
n.collection = function(e, a) {
t(e, function(e, t) {
a(t, n);
});
};
}), e.components = {}, e.addElements = function(t, a) {
var n;
if (a) e.components[t] = a; else for (n in t) e.components[n] = t[n];
return this;
n(t, a)
})
}
}), e.components = {}, e.addElements = function(t, n) {
var a;
if (n) e.components[t] = n;
else
for (a in t) e.components[a] = t[a];
return this
}, e.extend({
trim: a,
trim: n,
forEach: t,
hasClass: l,
addClass: s,
removeClass: c,
hasClass: s,
addClass: c,
removeClass: l,
toggleClass: i
}), window.addEventListener("load", function() {
var t, a = e.components;
for (t in a) for (var n = 0, l = document.querySelectorAll("." + t), s = l.length, c = a[t]; n < s; n++) new c(l[n], n, t);
}), e;
var t, n = e.components;
for (t in n)
for (var a = 0, s = document.querySelectorAll("." + t), c = s.length, l = n[t]; c > a; a++) new l(s[a], a, t)
}), e
}();

!function() {
! function() {
"use strict";

function e(e) {
var t = this.classes;
whale.forEach(e.querySelectorAll("a"), function(e, a) {
var n = a.parentNode, l = n.querySelectorAll("ul"), s = n.querySelectorAll("a"), c = document.createElement("span"), i = l[0];
l.length && (whale.addClass(n, t.parent), whale.addClass(c, t.arrow), a.appendChild(c),
a.addEventListener("click", function(e) {
e.preventDefault(), whale.hasClass(i, t.active) ? (whale.removeClass.collection(l, t.active),
whale.removeClass.collection(s, t.active)) : whale.addClass.collection([ a, i ], t.active);
}));
});
whale.forEach(e.querySelectorAll("a"), function(e, n) {
var a = n.parentNode,
s = a.querySelectorAll("ul"),
c = a.querySelectorAll("a"),
l = document.createElement("span"),
i = s[0];
s.length && (whale.addClass(a, t.parent), whale.addClass(l, t.arrow), n.appendChild(l), n.addEventListener("click", function(e) {
e.preventDefault(), whale.hasClass(i, t.active) ? (whale.removeClass.collection(s, t.active), whale.removeClass.collection(c, t.active)) : whale.addClass.collection([n, i], t.active)
}))
})
}

function t(e) {
var t = this.classes, a = e.querySelectorAll("." + t.item), n = e.querySelectorAll("." + t.panel);
a.length && whale.forEach(a, function(l, s) {
var c = s.href.split("#")[1], i = e.querySelector("#" + c);
i && (whale.hasClass(i, t.active) && whale.addClass(s, t.active), s.addEventListener("click", function(e) {
e.preventDefault(), whale.forEach([ a, n ], function(e, a) {
whale.removeClass.collection(a, t.active);
}), whale.addClass.collection([ s, i ], t.active);
}));
});
var t = this.classes,
n = e.querySelectorAll("." + t.item),
a = e.querySelectorAll("." + t.panel);
n.length && whale.forEach(n, function(s, c) {
var l = c.href.split("#")[1],
i = e.querySelector("#" + l);
i && (whale.hasClass(i, t.active) && whale.addClass(c, t.active), c.addEventListener("click", function(e) {
e.preventDefault(), whale.forEach([n, a], function(e, n) {
whale.removeClass.collection(n, t.active)
}), whale.addClass.collection([c, i], t.active)
}))
})
}
function a(e) {
var t = this.classes, a = e.getAttribute(this.data.target), n = document.getElementById(a);
e.addEventListener("click", function(a) {
if (a.preventDefault(), whale.hasClass(n, t.active)) whale.removeClass.collection([ e, n ], t.active); else {
whale.addClass.collection([ e, n ], t.active);
var l = function(s) {
var c = s.target;
s === a || c === n || n.contains(c) || (whale.removeClass.collection([ e, n ], t.active),
document.removeEventListener("click", l));

function n(e) {
var t = this.classes,
n = e.getAttribute(this.data.target),
a = document.getElementById(n);
e.addEventListener("click", function(n) {
if (n.preventDefault(), whale.hasClass(a, t.active)) whale.removeClass.collection([e, a], t.active);
else {
whale.addClass.collection([e, a], t.active);
var s = function(c) {
var l = c.target;
c === n || l === a || a.contains(l) || (whale.removeClass.collection([e, a], t.active), document.removeEventListener("click", s))
};
document.addEventListener("click", l);
document.addEventListener("click", s)
}
});
})
}

function a(e) {
var t = this.classes,
n = e.querySelector("." + t.button),
a = e.querySelector("." + t.content),
s = t.active;
whale.hasClass(a, s) && whale.addClass(n, s), n.addEventListener("click", function() {
whale.toggleClass.collection([n, a], s)
})
}

function s(e) {
var t = this.defaults,
n = t.width,
a = t.height,
s = "left=" + (screen.width - n) / 2 + ",top=" + (screen.height - a) / 2 + ",width=" + n + ",height=" + a;
e.addEventListener("click", function(e) {
e.preventDefault(), window.open(this.href, this.target, s)
})
}

function c(e) {
this.container = e, this.titles = e.querySelectorAll("." + this["const"].TITLE), this.collection = e.querySelectorAll("." + this["const"].CONTENT), this.prev = null, this.init()
}
e.prototype = {
classes: {
Expand All @@ -114,49 +153,52 @@ var whale = function() {
panel: "wjs-panel",
active: "is-active"
};
var n = a.prototype = {
classes: {
active: "is-active"
var l = n.prototype = {
classes: {
active: "is-active"
},
data: {
target: "data-target"
}
},
data: {
target: "data-target"
}
}, l = {};
function s(e) {
var t = this.classes, a = e.querySelector("." + t.button), n = e.querySelector("." + t.content), l = t.active;
whale.hasClass(n, l) && whale.addClass(a, l), a.addEventListener("click", function() {
whale.toggleClass.collection([ a, n ], l);
});
}
function c(e) {
var t = this.defaults, a = t.width, n = t.height, l = "left=" + (screen.width - a) / 2 + ",top=" + (screen.height - n) / 2 + ",width=" + a + ",height=" + n;
e.addEventListener("click", function(e) {
e.preventDefault(), window.open(this.href, this.target, l);
});
}
whale.forEach([ "addClass", "removeClass", "toggleClass" ], function(e, t) {
l[t] = function(e) {
var a, l = e.getAttribute(n.data.target), s = document.querySelectorAll("." + l);
i = {};
whale.forEach(["addClass", "removeClass", "toggleClass"], function(e, t) {
i[t] = function(e) {
var n, a = e.getAttribute(l.data.target),
s = document.querySelectorAll("." + a);
s && e.addEventListener("click", function() {
(a = whale[t])(e, n.classes.active), a.collection(s, n.classes.active);
});
};
}), s.prototype = {
n = whale[t], n(e, l.classes.active), n.collection(s, l.classes.active)
})
}
}), a.prototype = {
classes: {
active: "is-active",
content: "wjs-container",
button: "wjs-button"
}
}, c.prototype = {
}, s.prototype = {
defaults: {
width: 600,
height: 400
}
}, whale.addElements(l).addElements({
}, c.prototype.init = function() {
var e = this;
whale.forEach(e.titles, function(t, n) {
var a = (e.collection[t], n.parentNode);
a.classList.contains(e["const"].IS_ACTIVE) && (e.prev = a), n.addEventListener("click", function(t) {
t.preventDefault(), console.log(a), e.prev && e.prev.classList.remove(e["const"].IS_ACTIVE), e.prev === a ? (a.classList.remove(e["const"].IS_ACTIVE), e.prev = null) : (a.classList.add(e["const"].IS_ACTIVE), e.prev = a)
})
})
}, c.prototype["const"] = {
TITLE: "accordion-title",
CONTENT: "accordion-content",
IS_ACTIVE: "is-active"
}, whale.addElements(i).addElements({
"wjs-menu": e,
"wjs-tab": t,
"wjs-spoiler": s,
"wjs-outsite": a,
"wjs-window": c
});
"wjs-spoiler": a,
"wjs-outsite": n,
"wjs-window": s,
"wjs-accordion": c
})
}();
Loading

0 comments on commit d95e0d4

Please sign in to comment.