-
Notifications
You must be signed in to change notification settings - Fork 21
/
vlex.min.js
2 lines (2 loc) · 1.69 KB
/
vlex.min.js
1
2
/*! VLEX v0.2 | (c) 2014 Stefan Keim (indus) | https://github.com/indus/VLEX/blob/master/license.md */
var VLEX = function (k) { var d, m, a = {}, c = function b(c, e) { k.removeEventListener("resize", b.onresize); k.removeEventListener("mousemove", b.onmousemove); if (null !== c) return d = "string" == typeof c || c instanceof String ? document.getElementById(c) : c || document.body || document, e = e || {}, a = e.$ || a, !1 !== e.onresize && k.addEventListener("resize", b.onresize), e.onmousemove && (k.addEventListener("mousemove", b.onmousemove), a.mX = a.mY = -99999), b.onresize(), b.update }; c.$ = a; c.onresize = function (b) { a.x = d.clientWidth || d.parentNode.clientWidth; a.y = d.clientHeight || d.parentNode.clientHeight; a.cX = a.x / 2; a.cY = a.y / 2; c.update() }; c.onmousemove = function (b) { a.mX = b.pageX - d.parentNode.offsetLeft; a.mY = b.pageY - d.parentNode.offsetTop; c.update() }; var r = /({.*?})/, s = /{(.*?)}/, t = /\$([a-z0-9]*)/g, u = /\r?\n|\r/g, v = RegExp("(" + Object.getOwnPropertyNames(Math).join("|") + ")", "g"); c.update = function ($, a) { $ = $ || c.$; if (d) { m = m && !a ? m : d.querySelectorAll("[vlex]"); for (var e = 0, k = m.length; e < k; e++) { var g = $.$ = m[e]; if (!g.vlex || a) { var f = g.getAttribute("vlex").split(";"), p, l; g.vlex = {}; for (var h = 0, w = f.length; h < w; h++) if (f[h] = f[h].split(":"), 1 < f[h].length) { p = f[h].shift().trim(); l = f[h].join(":").replace(u, "").replace(v, "Math.$1").replace(t, "$.$1").trim().split(r); for (var n = 0, x = l.length, q; n < x; n++) l[n] = (q = s.exec(l[n])) ? "(" + q[1] + ")" : '"' + l[n] + '"'; g.vlex[p] = l.join("+") } } for (f in g.vlex) g.setAttribute(f, eval(g.vlex[f])) } } }; return c }(window);