Comparing version 1.0.9 to 1.0.10
@@ -31,18 +31,12 @@ var cbs, noop; | ||
popstate: function(o) { | ||
var adder, remover; | ||
remover = noop; | ||
o["this"] = this; | ||
adder = function() { | ||
o.activate = function() { | ||
cbs.push(o); | ||
return remover = function() { | ||
cbs.splice(cbs.indexOf(o), 1); | ||
return remover = noop; | ||
return function() { | ||
return cbs.splice(cbs.indexOf(o), 1); | ||
}; | ||
}; | ||
return { | ||
adder: adder, | ||
remover: remover | ||
}; | ||
return o; | ||
} | ||
} | ||
}; |
module.exports = { | ||
_name: "#if", | ||
_v: 1, | ||
mixins: [require("./structure")], | ||
mixins: [require("./directives")], | ||
_attrLookup: { | ||
"if": { | ||
"#": function(el, path, mods) { | ||
return this.$structure.beforeInsert.push(function(structure) { | ||
var comment, index, parent, value; | ||
comment = document.createComment("#if"); | ||
parent = el.parentNode || this; | ||
if (parent === this) { | ||
value = this.$path.toValue({ | ||
path: path | ||
}).value; | ||
"#": function(o) { | ||
var cb, comment, parent; | ||
comment = document.createComment("#if"); | ||
parent = o.el.parentElement; | ||
cb = (function(_this) { | ||
return function() { | ||
return _this.$computed.orWatch(o.value, function(value, oldVal) { | ||
if (value && comment.parentElement === parent) { | ||
return parent.replaceChild(o.el, comment); | ||
} else if (!value && o.el.parentElement === parent) { | ||
return parent.replaceChild(comment, o.el); | ||
} | ||
}); | ||
}; | ||
})(this); | ||
if (parent) { | ||
return cb(); | ||
} else if (this.$structure) { | ||
this.$structure.beforeInsert.push(function(structure) { | ||
var index, value; | ||
parent = this; | ||
value = this.$path.getValue(o.value); | ||
if (!value) { | ||
index = structure.indexOf(el); | ||
structure[index] = comment; | ||
index = structure.indexOf(o.el); | ||
return structure[index] = comment; | ||
} | ||
} | ||
return this.$watch.path({ | ||
path: path, | ||
cbs: function(value, oldVal) { | ||
if (value && comment.parentNode === parent) { | ||
return parent.replaceChild(el, comment); | ||
} else if (!value && el.parentNode === parent) { | ||
return parent.replaceChild(comment, el); | ||
} | ||
} | ||
}); | ||
}); | ||
return this.$structure.afterInsert.push(cb); | ||
} else { | ||
if(process.env.NODE_ENV!=='production' && true){console.warn('#if: no parent found for element: ' + o.el)}; | ||
return null; | ||
} | ||
} | ||
@@ -33,0 +40,0 @@ } |
module.exports = { | ||
_name: "#model", | ||
_v: 1, | ||
mixins: [require("./structure")], | ||
mixins: [require("./directives")], | ||
_attrLookup: { | ||
model: { | ||
"#": function(el, path, mods) { | ||
var event, o; | ||
"#": function(o) { | ||
var event; | ||
event = (function() { | ||
switch (el.type) { | ||
switch (o.el.type) { | ||
case "checkbox": | ||
@@ -20,6 +20,5 @@ case "radio": | ||
})(); | ||
o = this.$path.toNameAndParent({ | ||
path: path | ||
}); | ||
el.addEventListener(event, (function(_this) { | ||
o.path = o.value; | ||
this.$path.toNameAndParent(o); | ||
o.el.addEventListener(event, (function(_this) { | ||
return function(e) { | ||
@@ -32,6 +31,6 @@ if (o.parent[o.name] !== e.target.value) { | ||
return this.$watch.path({ | ||
path: path, | ||
path: o.value, | ||
cbs: function(value) { | ||
if (el.value !== value) { | ||
return el.value = value; | ||
if (o.el.value !== value) { | ||
return o.el.value = value; | ||
} | ||
@@ -38,0 +37,0 @@ } |
module.exports = { | ||
_name: "#show", | ||
_v: 1, | ||
mixins: [require("./structure"), require("./style")], | ||
mixins: [require("./directives"), require("./style")], | ||
_attrLookup: { | ||
show: { | ||
"#": function(el, path, mods) { | ||
this.$style.set(el, { | ||
"#": function(o) { | ||
this.$style.set(o.el, { | ||
visibility: "hidden" | ||
}); | ||
return this.$watch.path({ | ||
path: path, | ||
path: o.value, | ||
cbs: function(value, oldVal) { | ||
@@ -18,8 +18,8 @@ var style; | ||
}; | ||
if (value && (mods != null ? mods.delay : void 0)) { | ||
if (value && o.delay) { | ||
return this.$nextTick(function() { | ||
return this.$style.set(el, style); | ||
return this.$style.set(o.el, style); | ||
}); | ||
} else { | ||
return this.$style.set(el, style); | ||
return this.$style.set(o.el, style); | ||
} | ||
@@ -26,0 +26,0 @@ } |
@@ -1,2 +0,2 @@ | ||
var easing, isArray, step; | ||
var easing, isArray, procesPreserve, processStyle, step; | ||
@@ -44,5 +44,40 @@ isArray = require("./_helpers").isArray; | ||
processStyle = function(style, aniStyle, fac, preserve) { | ||
var key, tmp, transform, val; | ||
transform = []; | ||
for (key in aniStyle) { | ||
val = aniStyle[key]; | ||
if ((preserve != null) && preserve.indexOf(key) > -1) { | ||
continue; | ||
} | ||
tmp = val[0] + fac * (val[1] - val[0]); | ||
if (val[2]) { | ||
tmp += val[2]; | ||
} | ||
if (style[key] != null) { | ||
style[key] = tmp; | ||
} else { | ||
transform.push(key + "(" + tmp + ")"); | ||
} | ||
} | ||
if (transform.length > 0) { | ||
return style.transform = transform.join(" "); | ||
} | ||
}; | ||
procesPreserve = function(style, preserve) { | ||
var key, results, val; | ||
if (preserve) { | ||
results = []; | ||
for (key in preserve) { | ||
val = preserve[key]; | ||
results.push(style[key] = val); | ||
} | ||
return results; | ||
} | ||
}; | ||
step = function(o) { | ||
return function(timestamp) { | ||
var fac, i, key, len, percent, ref, ref1, ref2, s, tmp, transform, val; | ||
var fac, i, key, len, percent, ref, ref1, s, tmp, val; | ||
if (!o.stopped) { | ||
@@ -81,25 +116,11 @@ s = o.el.style; | ||
} | ||
transform = []; | ||
ref2 = o.style; | ||
for (key in ref2) { | ||
val = ref2[key]; | ||
tmp = val[0] + fac * (val[1] - val[0]); | ||
if (val[2]) { | ||
tmp += val[2]; | ||
} | ||
if (s[key] != null) { | ||
s[key] = tmp; | ||
} else { | ||
transform.push(key + "(" + tmp + ")"); | ||
} | ||
} | ||
if (transform.length > 0) { | ||
s.transform = transform.join(" "); | ||
} | ||
processStyle(s, o.style, fac); | ||
if (fac !== 1) { | ||
return requestAnimationFrame(o.next); | ||
} else { | ||
o.stop({ | ||
reset: true | ||
}); | ||
if (typeof o.stop === "function") { | ||
o.stop({ | ||
reset: true | ||
}); | ||
} | ||
return typeof o.done === "function" ? o.done(o) : void 0; | ||
@@ -119,3 +140,3 @@ } | ||
} | ||
if (o != null) { | ||
if ((o != null ? o.stop : void 0) != null) { | ||
return o.stop(newO); | ||
@@ -127,7 +148,20 @@ } else { | ||
$animate: function(o) { | ||
var cb, key, ref, tmp, val; | ||
var cb, key, ref, ref1, s, tmp, transform, val; | ||
if (o.done != null) { | ||
o.done = o.done.bind(this); | ||
} | ||
if (o.el == null) { | ||
o.el = this; | ||
} | ||
if (o.animate === false) { | ||
transform = []; | ||
s = o.el.style; | ||
if (o.init) { | ||
ref = o.init; | ||
for (key in ref) { | ||
val = ref[key]; | ||
s[key] = val; | ||
} | ||
} | ||
processStyle(s, o.style, 1, o.preserve); | ||
return typeof o.done === "function" ? o.done() : void 0; | ||
@@ -137,5 +171,2 @@ } | ||
cb = step(o); | ||
if (o.el == null) { | ||
o.el = this; | ||
} | ||
if (o.duration == null) { | ||
@@ -152,5 +183,5 @@ o.duration = 300; | ||
if (o._style != null) { | ||
ref = o._style; | ||
for (key in ref) { | ||
val = ref[key]; | ||
ref1 = o._style; | ||
for (key in ref1) { | ||
val = ref1[key]; | ||
tmp = val.slice(0).reverse(); | ||
@@ -163,11 +194,5 @@ if (tmp.length === 3) { | ||
} | ||
if (o.delay) { | ||
setTimeout(o.next, o.delay); | ||
} else { | ||
cb(performance.now()); | ||
} | ||
this.$animations.push(o); | ||
o.stop = (function(_this) { | ||
return function(obj) { | ||
var percent, ref1, s; | ||
var percent; | ||
if (!o.stopped) { | ||
@@ -178,10 +203,3 @@ o.stopped = true; | ||
if (obj.reset) { | ||
if (o.preserve) { | ||
s = o.el.style; | ||
ref1 = o.preserve; | ||
for (key in ref1) { | ||
val = ref1[key]; | ||
s[key] = val; | ||
} | ||
} | ||
procesPreserve(o.el.style, o.preserve); | ||
} else { | ||
@@ -204,2 +222,8 @@ percent = Math.min(1, (performance.now() - o.start) / o.duration); | ||
}; | ||
if (o.delay) { | ||
setTimeout(o.next, o.delay); | ||
} else { | ||
cb(performance.now()); | ||
} | ||
this.$animations.push(o); | ||
} | ||
@@ -206,0 +230,0 @@ return o; |
@@ -12,2 +12,3 @@ var isString; | ||
}), | ||
mixins: [require("./parseElement")], | ||
methods: { | ||
@@ -39,3 +40,3 @@ $class: { | ||
setStr: function(el, str) { | ||
return el.className = str; | ||
return this.$parseElement.byString(el).className = str; | ||
}, | ||
@@ -61,7 +62,3 @@ set: function(el, obj) { | ||
v = ref[k]; | ||
if (k === "this") { | ||
results.push(this.$class.setStr(this, v)); | ||
} else { | ||
results.push(this.$class.setStr(this[k], v)); | ||
} | ||
results.push(this.$class.setStr(k, v)); | ||
} | ||
@@ -68,0 +65,0 @@ return results; |
@@ -15,11 +15,5 @@ module.exports = { | ||
cbFactory: function(name) { | ||
var el; | ||
if (name === "this") { | ||
el = this; | ||
} else { | ||
el = this[name]; | ||
} | ||
return [ | ||
function(val) { | ||
return this.$class.set(el, val); | ||
return this.$class.set(name, val); | ||
} | ||
@@ -26,0 +20,0 @@ ]; |
@@ -1,9 +0,54 @@ | ||
var arrayize, clone, isArray, isFunction, isString, noop, ref; | ||
var arrayize, cAF, clone, isArray, isFunction, isString, listener, noop, rAF, ref, throttled; | ||
ref = require("./_helpers"), isString = ref.isString, isFunction = ref.isFunction, isArray = ref.isArray, arrayize = ref.arrayize, noop = ref.noop, clone = ref.clone; | ||
rAF = requestAnimationFrame; | ||
cAF = cancelAnimationFrame; | ||
listener = function(o, e) { | ||
cAF(o.lastRequest); | ||
return o.lastRequest = rAF(function() { | ||
var cb, j, len, ref1, results; | ||
ref1 = o.cbs; | ||
results = []; | ||
for (j = 0, len = ref1.length; j < len; j++) { | ||
cb = ref1[j]; | ||
results.push(cb(e)); | ||
} | ||
return results; | ||
}); | ||
}; | ||
throttled = function(el, event, cb) { | ||
var o, ref1; | ||
if ((o = (ref1 = el.__ceriEventListener) != null ? ref1[event] : void 0) == null) { | ||
if (el.__ceriEventListener == null) { | ||
el.__ceriEventListener = {}; | ||
} | ||
o = el.__ceriEventListener[event] = {}; | ||
o.lastRequest = null; | ||
o.cbs = [cb]; | ||
o.listener = listener.bind(null, o); | ||
} else { | ||
o.cbs.push(cb); | ||
} | ||
if (o.cbs.length === 1) { | ||
el.addEventListener(event, o.listener); | ||
} | ||
return function() { | ||
var i; | ||
if ((i = o.cbs.indexOf(cb)) > -1) { | ||
o.cbs.splice(i, 1); | ||
if (o.cbs.length === 0) { | ||
return el.removeEventListener(event, o.listener); | ||
} | ||
} | ||
}; | ||
}; | ||
module.exports = { | ||
_name: "events", | ||
_v: 1, | ||
_prio: 900, | ||
_prio: 700, | ||
_mergers: [ | ||
@@ -16,18 +61,15 @@ require("./_merger").concat({ | ||
], | ||
mixins: [require("./computed")], | ||
mixins: [require("./computed"), require("./parseElement"), require("./parseActive")], | ||
_evLookup: {}, | ||
methods: { | ||
"$once": function(o) { | ||
$once: function(o) { | ||
o.once = true; | ||
return this.$on(o); | ||
}, | ||
"$on": function(o) { | ||
var adder, cb, cbs, fn, i, len, obj, ref1, ref2, remover; | ||
if (o.el == null) { | ||
o.el = this; | ||
} | ||
$on: function(o) { | ||
var cb, cbs, fn, j, len, obj, ref1; | ||
cbs = []; | ||
ref1 = arrayize(o.cbs); | ||
for (i = 0, len = ref1.length; i < len; i++) { | ||
fn = ref1[i]; | ||
for (j = 0, len = ref1.length; j < len; j++) { | ||
fn = ref1[j]; | ||
if (isString(fn)) { | ||
@@ -40,5 +82,8 @@ fn = this[fn]; | ||
if (this._evLookup[o.event] != null) { | ||
ref2 = this._evLookup[o.event].call(this, o), adder = ref2.adder, remover = ref2.remover; | ||
o = this._evLookup[o.event].call(this, o); | ||
} else { | ||
if (o.toggle) { | ||
if (!isString(o.toggle)) { | ||
o.toggle = o.value; | ||
} | ||
obj = this.$path.toNameAndParent({ | ||
@@ -51,5 +96,5 @@ path: o.toggle | ||
} else { | ||
cb = function(e) { | ||
var j, len1, ocb, ref3, target; | ||
if (o.self && e.target !== o.el) { | ||
cb = function(el, e) { | ||
var l, len1, ocb, ref2, target; | ||
if (o.self && e.target !== el) { | ||
return; | ||
@@ -72,6 +117,6 @@ } | ||
} | ||
ref3 = o._cbs; | ||
for (j = 0, len1 = ref3.length; j < len1; j++) { | ||
ocb = ref3[j]; | ||
ocb.apply(this, arguments); | ||
ref2 = o._cbs; | ||
for (l = 0, len1 = ref2.length; l < len1; l++) { | ||
ocb = ref2[l]; | ||
ocb.call(this, e); | ||
} | ||
@@ -85,42 +130,23 @@ if (o.prevent) { | ||
if (o.once) { | ||
return remover(); | ||
return o.deactivate(); | ||
} | ||
}; | ||
} | ||
remover = noop; | ||
cb = cb.bind(this); | ||
adder = function() { | ||
var el; | ||
if (isString(o.el)) { | ||
el = o.el === "this" ? this : this[o.el]; | ||
o.activate = function() { | ||
var _cb, el; | ||
el = this.$parseElement.byString(o.el); | ||
_cb = cb.bind(this, el); | ||
if (o.throttled) { | ||
return o.deactivate = throttled(el, o.event, _cb); | ||
} else { | ||
el = o.el; | ||
el.addEventListener(o.event, _cb, o.capture); | ||
return o.deactivate = function() { | ||
return el.removeEventListener(o.event, _cb); | ||
}; | ||
} | ||
el.addEventListener(o.event, cb, o.capture); | ||
remover = function() { | ||
el.removeEventListener(o.event, cb); | ||
return remover = noop; | ||
}; | ||
if (o.destroy) { | ||
this.__eventsToDestroy.push(remover); | ||
} | ||
}; | ||
} | ||
if (o.active) { | ||
return this.$computed.orWatch(o.active, function(val) { | ||
if (val) { | ||
if (o.delay) { | ||
return this.$nextTick(adder); | ||
} else { | ||
return adder.call(this); | ||
} | ||
} else { | ||
return remover(); | ||
} | ||
}); | ||
} else { | ||
return adder.call(this); | ||
} | ||
return this.$parseActive(o); | ||
}, | ||
"$emit": function(o) { | ||
$emit: function(o) { | ||
var evt; | ||
@@ -136,9 +162,8 @@ if (o.el == null) { | ||
connectedCallback: function() { | ||
var el, events, i, k, len, o, ref1, results, v, v2; | ||
var el, events, j, k, len, o, ref1, results, v, v2; | ||
if (this._isFirstConnect) { | ||
this.__eventsToDestroy = []; | ||
ref1 = this.events; | ||
results = []; | ||
for (i = 0, len = ref1.length; i < len; i++) { | ||
events = ref1[i]; | ||
for (j = 0, len = ref1.length; j < len; j++) { | ||
events = ref1[j]; | ||
results.push((function() { | ||
@@ -180,12 +205,2 @@ var results1; | ||
} | ||
}, | ||
destroy: function() { | ||
var cb, i, len, ref1, results; | ||
ref1 = this.__eventsToDestroy; | ||
results = []; | ||
for (i = 0, len = ref1.length; i < len; i++) { | ||
cb = ref1[i]; | ||
results.push(cb()); | ||
} | ||
return results; | ||
} | ||
@@ -192,0 +207,0 @@ }; |
126
lib/open.js
module.exports = { | ||
_name: "open", | ||
_v: 1, | ||
mixins: [require("./computed"), require("./events"), require("./@popstate")], | ||
events: { | ||
popstate: { | ||
active: "openingOrOpen", | ||
cbs: function() { | ||
return this.hide(false); | ||
} | ||
}, | ||
click: { | ||
el: document.documentElement, | ||
outside: true, | ||
cbs: "hide", | ||
active: function() { | ||
return this.openingOrOpen && !this.keepOpen; | ||
}, | ||
delay: true, | ||
destroy: true | ||
}, | ||
keyup: { | ||
el: document.documentElement, | ||
notPrevented: true, | ||
destroy: true, | ||
keyCode: [27], | ||
active: function() { | ||
return this.openingOrOpen && !this.keepOpen; | ||
}, | ||
cbs: "hide" | ||
} | ||
}, | ||
props: { | ||
open: { | ||
type: Boolean | ||
}, | ||
keepOpen: { | ||
type: Boolean | ||
} | ||
@@ -19,14 +51,53 @@ }, | ||
methods: { | ||
attach: function() { | ||
if (!this.parentElement) { | ||
if (this.onBody) { | ||
if (this.parentElement !== document.body) { | ||
return document.body.appendChild(this); | ||
} | ||
} else if (this.parentElement !== this.__parentElement) { | ||
return this.__parentElement.replaceChild(this, this.__placeholder); | ||
} | ||
} | ||
}, | ||
detach: function() { | ||
if (this.parentElement) { | ||
if (this.onBody) { | ||
if (this.parentElement === document.body) { | ||
return this.remove(); | ||
} | ||
} else if (this.parentElement === this.__parentElement) { | ||
return this.__parentElement.replaceChild(this.__placeholder, this); | ||
} | ||
} | ||
}, | ||
setOpen: function() { | ||
this.closing = false; | ||
this.opening = false; | ||
this.isOpen = true; | ||
this.open = true; | ||
this.openingOrOpen = true; | ||
this.$emit({ | ||
name: "toggle", | ||
detail: true | ||
}); | ||
return typeof this.onOpen === "function" ? this.onOpen() : void 0; | ||
}, | ||
setClose: function() { | ||
this.closing = false; | ||
this.opening = false; | ||
this.isOpen = false; | ||
this.open = false; | ||
this.openingOrOpen = false; | ||
this.$emit({ | ||
name: "toggle", | ||
detail: false | ||
}); | ||
return typeof this.onClose === "function" ? this.onClose() : void 0; | ||
}, | ||
show: function(animate) { | ||
var done; | ||
if (this.openingOrOpen) { | ||
return; | ||
} | ||
if (!this.parentElement) { | ||
if (this.onBody) { | ||
document.body.appendChild(this); | ||
} else { | ||
this.__parentElement.replaceChild(this, this.__placeholder); | ||
} | ||
} | ||
this.attach(); | ||
this.toggleAnimate = animate = animate !== false; | ||
@@ -36,22 +107,12 @@ this.opening = true; | ||
this.closing = false; | ||
if (typeof this.beforeShow === "function") { | ||
this.beforeShow(animate); | ||
if (typeof this.onShow === "function") { | ||
this.onShow(animate); | ||
} | ||
done = function() { | ||
this.opening = false; | ||
this.isOpen = true; | ||
this.open = true; | ||
this.$emit({ | ||
name: "toggle", | ||
detail: true | ||
}); | ||
return typeof this.afterOpen === "function" ? this.afterOpen() : void 0; | ||
}; | ||
if (this.$animate && (this.enter != null)) { | ||
return this.animation = this.enter(this.$cancelAnimation(this.animation, { | ||
animate: animate, | ||
done: done | ||
done: this.setOpen | ||
})); | ||
} else { | ||
return done.call(this); | ||
return this.setOpen(this); | ||
} | ||
@@ -67,21 +128,8 @@ }, | ||
this.openingOrOpen = false; | ||
if (typeof this.beforeHide === "function") { | ||
this.beforeHide(animate); | ||
if (typeof this.onHide === "function") { | ||
this.onHide(animate); | ||
} | ||
done = function() { | ||
this.isOpen = false; | ||
this.open = false; | ||
if (this.parentElement) { | ||
if (this.onBody) { | ||
this.remove(); | ||
} else if (this.parentElement === this.__parentElement) { | ||
this.__parentElement.replaceChild(this.__placeholder, this); | ||
} | ||
} | ||
this.closing = false; | ||
this.$emit({ | ||
name: "toggle", | ||
detail: false | ||
}); | ||
return typeof this.afterClose === "function" ? this.afterClose() : void 0; | ||
this.setClose(); | ||
return this.detach(); | ||
}; | ||
@@ -88,0 +136,0 @@ if (this.$animate && (this.leave != null)) { |
@@ -105,10 +105,9 @@ var attach, clone, close, dEl, detach, getAnimateObj, getLastItem, isString, noop, overlay, ref, s, stack; | ||
module.exports = { | ||
mixins: [require("./animate"), require("./getViewportSize"), require("./path")], | ||
mixins: [require("./animate"), require("./getViewportSize"), require("./path"), require("./parseActive")], | ||
methods: { | ||
$overlay: function(o) { | ||
var open; | ||
if (o == null) { | ||
o = clone(this.overlay) || {}; | ||
} | ||
open = function() { | ||
o.activate = function() { | ||
var k, li, ref1, ref2, v, val; | ||
@@ -136,2 +135,5 @@ ref1 = { | ||
o.close = noop; | ||
if (!o.open) { | ||
return; | ||
} | ||
o.open = false; | ||
@@ -159,53 +161,13 @@ if ((ref2 = _this.$path.resolveValue(o.onClose)) != null) { | ||
} | ||
return this.$animate(getAnimateObj(o, li, this.getViewportSize)); | ||
this.$animate(getAnimateObj(o, li, this.getViewportSize)); | ||
return o.close; | ||
}; | ||
if (o.delay) { | ||
this.$nextTick(open); | ||
} else { | ||
open.call(this); | ||
} | ||
return o; | ||
return this.$parseActive(o); | ||
} | ||
}, | ||
connectedCallback: function() { | ||
var w; | ||
if (this.overlay) { | ||
if (this.overlay.active) { | ||
if ((w = this.__overlayWatcher) == null) { | ||
return this.__overlayWatcher = this.$computed.orWatch(this.overlay.active, function(val) { | ||
var ref1; | ||
if (val) { | ||
if (!this.__overlay) { | ||
return this.__overlay = this.$overlay(); | ||
} | ||
} else { | ||
if ((ref1 = this.__overlay) != null) { | ||
if (typeof ref1.close === "function") { | ||
ref1.close(); | ||
} | ||
} | ||
return this.__overlay = null; | ||
} | ||
}); | ||
} else { | ||
if (w.parent[w.name]) { | ||
if (!this.__overlay) { | ||
return this.__overlay = this.$overlay(); | ||
} | ||
} | ||
} | ||
} else { | ||
return this.__overlay = this.$overlay(); | ||
} | ||
if (this._isFirstConnect && this.overlay) { | ||
return this.$overlay(clone(this.overlay)); | ||
} | ||
}, | ||
disconnectedCallback: function() { | ||
var ref1; | ||
if ((ref1 = this.__overlay) != null) { | ||
if (typeof ref1.close === "function") { | ||
ref1.close(); | ||
} | ||
} | ||
return this.__overlay = null; | ||
} | ||
}; |
@@ -43,2 +43,15 @@ var isString, splittedToObjects; | ||
}, | ||
resolveMultiple: function(o, arr) { | ||
var j, len, results, str; | ||
results = []; | ||
for (j = 0, len = arr.length; j < len; j++) { | ||
str = arr[j]; | ||
if (o[str]) { | ||
results.push(o[str] = this.$path.resolveValue(o[str])); | ||
} else { | ||
results.push(void 0); | ||
} | ||
} | ||
return results; | ||
}, | ||
setValue: function(o) { | ||
@@ -45,0 +58,0 @@ if (o.value != null) { |
@@ -1,4 +0,4 @@ | ||
var arrayize, camelize, hyphenate, ref; | ||
var arrayize, camelize, clone, hyphenate, ref; | ||
ref = require("./_helpers"), arrayize = ref.arrayize, hyphenate = ref.hyphenate, camelize = ref.camelize; | ||
ref = require("./_helpers"), arrayize = ref.arrayize, hyphenate = ref.hyphenate, camelize = ref.camelize, clone = ref.clone; | ||
@@ -49,3 +49,3 @@ module.exports = { | ||
created: function() { | ||
var k, name, ref1, results, v; | ||
var k, o, ref1, results, v; | ||
if (this.props == null) { | ||
@@ -59,6 +59,11 @@ this.props = {}; | ||
if (v.type == null) { | ||
this.props[k] = { | ||
type: v | ||
v = { | ||
type: v, | ||
name: k | ||
}; | ||
v = this.props[k]; | ||
this.props[k] = v; | ||
} else { | ||
if (v.name == null) { | ||
v.name = k; | ||
} | ||
} | ||
@@ -68,15 +73,13 @@ if (v.type === Boolean && (v["default"] == null)) { | ||
} | ||
if (v.name) { | ||
name = v.name; | ||
} else { | ||
name = k; | ||
o = clone(v); | ||
o.parent = this; | ||
o.value = this[o.name]; | ||
o.cbs = arrayize(o.cbs).concat([this.$setAttribute.bind(this, this, hyphenate(o.name))]); | ||
if (o.path == null) { | ||
o.path = o.name; | ||
} | ||
results.push(this.$watch.path({ | ||
parent: this, | ||
name: name, | ||
path: name, | ||
initial: false, | ||
value: this[name], | ||
cbs: [this.$setAttribute.bind(this, this, hyphenate(k))] | ||
})); | ||
if (o.initial == null) { | ||
o.initial = false; | ||
} | ||
results.push(this.$watch.path(o)); | ||
} | ||
@@ -83,0 +86,0 @@ return results; |
@@ -1,3 +0,2 @@ | ||
var arrayize, camelize, isElement, isString, ref, | ||
slice = [].slice; | ||
var arrayize, camelize, isElement, isString, ref; | ||
@@ -9,32 +8,10 @@ ref = require("./_helpers"), isElement = ref.isElement, isString = ref.isString, arrayize = ref.arrayize, camelize = ref.camelize; | ||
_v: 1, | ||
_prio: 800, | ||
_prio: 900, | ||
_mergers: [ | ||
require("./_merger").copy({ | ||
source: "_elLookup" | ||
}), require("./_merger").copy({ | ||
source: "_attrLookup" | ||
}) | ||
], | ||
_rebind: "$structure", | ||
mixins: [require("./watch"), require("./setAttribute"), require("./events")], | ||
_attrLookup: { | ||
text: { | ||
":": function(el, val) { | ||
return this.$watch.path({ | ||
path: val, | ||
cbs: function(val) { | ||
return el.textContent = val; | ||
} | ||
}); | ||
}, | ||
"#": function(el, val) { | ||
return el.textContent = val; | ||
} | ||
}, | ||
ref: { | ||
"#": function(el, val) { | ||
return this[val] = el; | ||
} | ||
} | ||
}, | ||
mixins: [require("./directives")], | ||
methods: { | ||
@@ -46,3 +23,3 @@ "$structure": { | ||
el: function(name, options, children) { | ||
var cb, child, el, i, len, lookupObj, mods, ref1, type, types, value; | ||
var child, el, i, len, o, ref1, type, types, value; | ||
if (((ref1 = this._elLookup) != null ? ref1[name] : void 0) != null) { | ||
@@ -56,81 +33,16 @@ el = this._elLookup[name].call(this, name); | ||
types = options[name]; | ||
lookupObj = this._attrLookup[name]; | ||
for (type in types) { | ||
value = types[type]; | ||
if (value.mods != null) { | ||
mods = value.mods; | ||
value = value.val; | ||
if (mods.camel) { | ||
name = camelize(name); | ||
} | ||
o = value.mods; | ||
o.value = value.val; | ||
} else { | ||
mods = {}; | ||
o = { | ||
value: value | ||
}; | ||
} | ||
if (lookupObj != null) { | ||
if (lookupObj[type] != null) { | ||
lookupObj[type].call(this, el, value, mods); | ||
continue; | ||
} | ||
if(process.env.NODE_ENV!=='production' && lookupObj[type] == null){console.warn(type + name + ' found, but not expected')}; | ||
} | ||
switch (type) { | ||
case "$": | ||
this.$watch.path({ | ||
path: value, | ||
cbs: (function(el, name, val) { | ||
return el[name] = val; | ||
}).bind(this, el, name) | ||
}); | ||
break; | ||
case ":": | ||
this.$watch.path({ | ||
path: value, | ||
cbs: this.$setAttribute.bind(this, el, name) | ||
}); | ||
break; | ||
case "@": | ||
if (mods.toggle) { | ||
mods.toggle = value; | ||
} else { | ||
mods.cbs = [value]; | ||
} | ||
if (mods.event == null) { | ||
mods.event = name; | ||
} | ||
if (mods.el == null) { | ||
mods.el = el; | ||
} | ||
this.$on(mods); | ||
break; | ||
case "~": | ||
if (this[name] == null) { | ||
this[name] = (function(_this) { | ||
return function() { | ||
var cb, i, len, ref2, results; | ||
ref2 = _this[name]._cbs; | ||
results = []; | ||
for (i = 0, len = ref2.length; i < len; i++) { | ||
cb = ref2[i]; | ||
results.push(cb.apply(null, arguments)); | ||
} | ||
return results; | ||
}; | ||
})(this); | ||
} | ||
if (mods != null ? mods.event : void 0) { | ||
cb = (function(el, value, e) { | ||
return el.dispatchEvent(value, e); | ||
}).bind(null, el, value); | ||
} else { | ||
cb = (function() { | ||
var args, el, value; | ||
el = arguments[0], value = arguments[1], args = 3 <= arguments.length ? slice.call(arguments, 2) : []; | ||
return el[value].apply(null, args); | ||
}).bind(null, el, value); | ||
} | ||
this[name]._cbs.push(cb); | ||
break; | ||
default: | ||
el.setAttribute(name, value); | ||
} | ||
o.el = el; | ||
o.type = type; | ||
o.name = o.camel ? camelize(name) : name; | ||
this.$directive(o); | ||
} | ||
@@ -137,0 +49,0 @@ } |
@@ -28,3 +28,3 @@ var parseStyleString; | ||
}), | ||
mixins: [require("./style"), require("./combined")], | ||
mixins: [require("./style"), require("./combined"), require("./parseElement")], | ||
connectedCallback: function() { | ||
@@ -39,7 +39,3 @@ if (this._isFirstConnect) { | ||
var el; | ||
if (name === "this") { | ||
el = this; | ||
} else { | ||
el = this[name]; | ||
} | ||
el = this.$parseElement.byString(name); | ||
return [ | ||
@@ -46,0 +42,0 @@ function(val) { |
{ | ||
"name": "ceri", | ||
"description": "Custom Elements enRIched", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"homepage": "https://github.com/cerijs/", | ||
@@ -6,0 +6,0 @@ "author": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
93299
34
2813
10