Comparing version 0.1.3 to 0.1.4
@@ -1,3 +0,3 @@ | ||
/* jsep v0.3.1 (http://jsep.from.so/) */ | ||
!function(a){"use strict";var b="Compound",c="Identifier",d="MemberExpression",e="Literal",f="ThisExpression",g="CallExpression",h="UnaryExpression",i="BinaryExpression",j="LogicalExpression",k="ConditionalExpression",l="ArrayExpression",m=46,n=44,o=39,p=34,q=40,r=41,s=91,t=93,u=63,v=59,w=58,x=function(a,b){var c=new Error(a+" at character "+b);throw c.index=b,c.description=a,c},y=!0,z={"-":y,"!":y,"~":y,"+":y},A={"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},B=function(a){var b,c=0;for(var d in a)(b=d.length)>c&&a.hasOwnProperty(d)&&(c=b);return c},C=B(z),D=B(A),E={"true":!0,"false":!1,"null":null},F="this",G=function(a){return A[a]||0},H=function(a,b,c){var d="||"===a||"&&"===a?j:i;return{type:d,operator:a,left:b,right:c}},I=function(a){return a>=48&&a<=57},J=function(a){return 36===a||95===a||a>=65&&a<=90||a>=97&&a<=122||a>=128&&!A[String.fromCharCode(a)]},K=function(a){return 36===a||95===a||a>=65&&a<=90||a>=97&&a<=122||a>=48&&a<=57||a>=128&&!A[String.fromCharCode(a)]},L=function(a){for(var i,j,y=0,B=a.charAt,L=a.charCodeAt,M=function(b){return B.call(a,b)},N=function(b){return L.call(a,b)},O=a.length,P=function(){for(var a=N(y);32===a||9===a||10===a||13===a;)a=N(++y)},Q=function(){var a,b,c=S();return P(),N(y)!==u?c:(y++,a=Q(),a||x("Expected expression",y),P(),N(y)===w?(y++,b=Q(),b||x("Expected expression",y),{type:k,test:c,consequent:a,alternate:b}):void x("Expected :",y))},R=function(){P();for(var b=a.substr(y,D),c=b.length;c>0;){if(A.hasOwnProperty(b))return y+=c,b;b=b.substr(0,--c)}return!1},S=function(){var a,b,c,d,e,f,g,h;if(f=T(),b=R(),!b)return f;for(e={value:b,prec:G(b)},g=T(),g||x("Expected expression after "+b,y),d=[f,e,g];(b=R())&&(c=G(b),0!==c);){for(e={value:b,prec:c};d.length>2&&c<=d[d.length-2].prec;)g=d.pop(),b=d.pop().value,f=d.pop(),a=H(b,f,g),d.push(a);a=T(),a||x("Expected expression after "+b,y),d.push(e,a)}for(h=d.length-1,a=d[h];h>1;)a=H(d[h-1].value,d[h-2],a),h-=2;return a},T=function(){var b,c,d;if(P(),b=N(y),I(b)||b===m)return U();if(b===o||b===p)return V();if(J(b)||b===q)return Y();if(b===s)return $();for(c=a.substr(y,C),d=c.length;d>0;){if(z.hasOwnProperty(c))return y+=d,{type:h,operator:c,argument:T(),prefix:!0};c=c.substr(0,--d)}return!1},U=function(){for(var a,b,c="";I(N(y));)c+=M(y++);if(N(y)===m)for(c+=M(y++);I(N(y));)c+=M(y++);if(a=M(y),"e"===a||"E"===a){for(c+=M(y++),a=M(y),"+"!==a&&"-"!==a||(c+=M(y++));I(N(y));)c+=M(y++);I(N(y-1))||x("Expected exponent ("+c+M(y)+")",y)}return b=N(y),J(b)?x("Variable names cannot start with a number ("+c+M(y)+")",y):b===m&&x("Unexpected period",y),{type:e,value:parseFloat(c),raw:c}},V=function(){for(var a,b="",c=M(y++),d=!1;y<O;){if(a=M(y++),a===c){d=!0;break}if("\\"===a)switch(a=M(y++)){case"n":b+="\n";break;case"r":b+="\r";break;case"t":b+="\t";break;case"b":b+="\b";break;case"f":b+="\f";break;case"v":b+="\x0B";break;default:b+="\\"+a}else b+=a}return d||x('Unclosed quote after "'+b+'"',y),{type:e,value:b,raw:c+b+c}},W=function(){var b,d=N(y),g=y;for(J(d)?y++:x("Unexpected "+M(y),y);y<O&&(d=N(y),K(d));)y++;return b=a.slice(g,y),E.hasOwnProperty(b)?{type:e,value:E[b],raw:b}:b===F?{type:f}:{type:c,name:b}},X=function(a){for(var c,d,e=[],f=!1;y<O;){if(P(),c=N(y),c===a){f=!0,y++;break}c===n?y++:(d=Q(),d&&d.type!==b||x("Expected comma",y),e.push(d))}return f||x("Expected "+String.fromCharCode(a),y),e},Y=function(){var a,b;for(a=N(y),b=a===q?Z():W(),P(),a=N(y);a===m||a===s||a===q;)y++,a===m?(P(),b={type:d,computed:!1,object:b,property:W()}):a===s?(b={type:d,computed:!0,object:b,property:Q()},P(),a=N(y),a!==t&&x("Unclosed [",y),y++):a===q&&(b={type:g,arguments:X(r),callee:b}),P(),a=N(y);return b},Z=function(){y++;var a=Q();return P(),N(y)===r?(y++,a):void x("Unclosed (",y)},$=function(){return y++,{type:l,elements:X(t)}},_=[];y<O;)i=N(y),i===v||i===n?y++:(j=Q())?_.push(j):y<O&&x('Unexpected "'+M(y)+'"',y);return 1===_.length?_[0]:{type:b,body:_}};if(L.version="0.3.1",L.toString=function(){return"JavaScript Expression Parser (JSEP) v"+L.version},L.addUnaryOp=function(a){return C=Math.max(a.length,C),z[a]=y,this},L.addBinaryOp=function(a,b){return D=Math.max(a.length,D),A[a]=b,this},L.addLiteral=function(a,b){return E[a]=b,this},L.removeUnaryOp=function(a){return delete z[a],a.length===C&&(C=B(z)),this},L.removeBinaryOp=function(a){return delete A[a],a.length===D&&(D=B(A)),this},L.removeLiteral=function(a){return delete E[a],this},"undefined"==typeof exports){var M=a.jsep;a.jsep=L,L.noConflict=function(){return a.jsep===L&&(a.jsep=M),L}}else"undefined"!=typeof module&&module.exports?exports=module.exports=L:exports.parse=L}(this); | ||
/* jsep v0.3.2 (http://jsep.from.so/) */ | ||
!function(e){"use strict";var r=function(e,r){var t=new Error(e+" at character "+r);throw t.index=r,t.description=e,t},t={"-":!0,"!":!0,"~":!0,"+":!0},n={"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},o=function(e){var r,t=0;for(var n in e)(r=n.length)>t&&e.hasOwnProperty(n)&&(t=r);return t},i=o(t),a=o(n),u={true:!0,false:!1,null:null},s=function(e){return n[e]||0},p=function(e,r,t){return{type:"||"===e||"&&"===e?"LogicalExpression":"BinaryExpression",operator:e,left:r,right:t}},f=function(e){return e>=48&&e<=57},c=function(e){return 36===e||95===e||e>=65&&e<=90||e>=97&&e<=122||e>=128&&!n[String.fromCharCode(e)]},l=function(e){return 36===e||95===e||e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e>=128&&!n[String.fromCharCode(e)]},d=function(e){for(var o,d,h=0,v=e.charAt,x=e.charCodeAt,y=function(r){return v.call(e,r)},m=function(r){return x.call(e,r)},b=e.length,E=function(){for(var e=m(h);32===e||9===e||10===e||13===e;)e=m(++h)},g=function(){var e,t,n=w();return E(),63!==m(h)?n:(h++,(e=g())||r("Expected expression",h),E(),58===m(h)?(h++,(t=g())||r("Expected expression",h),{type:"ConditionalExpression",test:n,consequent:e,alternate:t}):void r("Expected :",h))},C=function(){E();for(var r=e.substr(h,a),t=r.length;t>0;){if(n.hasOwnProperty(r))return h+=t,r;r=r.substr(0,--t)}return!1},w=function(){var e,t,n,o,i,a,u,f;if(a=O(),!(t=C()))return a;for(i={value:t,prec:s(t)},(u=O())||r("Expected expression after "+t,h),o=[a,i,u];(t=C())&&0!==(n=s(t));){for(i={value:t,prec:n};o.length>2&&n<=o[o.length-2].prec;)u=o.pop(),t=o.pop().value,a=o.pop(),e=p(t,a,u),o.push(e);(e=O())||r("Expected expression after "+t,h),o.push(i,e)}for(e=o[f=o.length-1];f>1;)e=p(o[f-1].value,o[f-2],e),f-=2;return e},O=function(){var r,n,o;if(E(),r=m(h),f(r)||46===r)return U();if(39===r||34===r)return k();if(91===r)return S();for(o=(n=e.substr(h,i)).length;o>0;){if(t.hasOwnProperty(n))return h+=o,{type:"UnaryExpression",operator:n,argument:O(),prefix:!0};n=n.substr(0,--o)}return!(!c(r)&&40!==r)&&A()},U=function(){for(var e,t,n="";f(m(h));)n+=y(h++);if(46===m(h))for(n+=y(h++);f(m(h));)n+=y(h++);if("e"===(e=y(h))||"E"===e){for(n+=y(h++),"+"!==(e=y(h))&&"-"!==e||(n+=y(h++));f(m(h));)n+=y(h++);f(m(h-1))||r("Expected exponent ("+n+y(h)+")",h)}return t=m(h),c(t)?r("Variable names cannot start with a number ("+n+y(h)+")",h):46===t&&r("Unexpected period",h),{type:"Literal",value:parseFloat(n),raw:n}},k=function(){for(var e,t="",n=y(h++),o=!1;h<b;){if((e=y(h++))===n){o=!0;break}if("\\"===e)switch(e=y(h++)){case"n":t+="\n";break;case"r":t+="\r";break;case"t":t+="\t";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=e}else t+=e}return o||r('Unclosed quote after "'+t+'"',h),{type:"Literal",value:t,raw:n+t+n}},L=function(){var t,n=m(h),o=h;for(c(n)?h++:r("Unexpected "+y(h),h);h<b&&(n=m(h),l(n));)h++;return t=e.slice(o,h),u.hasOwnProperty(t)?{type:"Literal",value:u[t],raw:t}:"this"===t?{type:"ThisExpression"}:{type:"Identifier",name:t}},j=function(e){for(var t,n,o=[],i=!1;h<b;){if(E(),(t=m(h))===e){i=!0,h++;break}44===t?h++:((n=g())&&"Compound"!==n.type||r("Expected comma",h),o.push(n))}return i||r("Expected "+String.fromCharCode(e),h),o},A=function(){var e,t;for(t=40===(e=m(h))?P():L(),E(),e=m(h);46===e||91===e||40===e;)h++,46===e?(E(),t={type:"MemberExpression",computed:!1,object:t,property:L()}):91===e?(t={type:"MemberExpression",computed:!0,object:t,property:g()},E(),93!==(e=m(h))&&r("Unclosed [",h),h++):40===e&&(t={type:"CallExpression",arguments:j(41),callee:t}),E(),e=m(h);return t},P=function(){h++;var e=g();if(E(),41===m(h))return h++,e;r("Unclosed (",h)},S=function(){return h++,{type:"ArrayExpression",elements:j(93)}},B=[];h<b;)59===(o=m(h))||44===o?h++:(d=g())?B.push(d):h<b&&r('Unexpected "'+y(h)+'"',h);return 1===B.length?B[0]:{type:"Compound",body:B}};if(d.version="0.3.2",d.toString=function(){return"JavaScript Expression Parser (JSEP) v"+d.version},d.addUnaryOp=function(e){return i=Math.max(e.length,i),t[e]=!0,this},d.addBinaryOp=function(e,r){return a=Math.max(e.length,a),n[e]=r,this},d.addLiteral=function(e,r){return u[e]=r,this},d.removeUnaryOp=function(e){return delete t[e],e.length===i&&(i=o(t)),this},d.removeAllUnaryOps=function(){return t={},i=0,this},d.removeBinaryOp=function(e){return delete n[e],e.length===a&&(a=o(n)),this},d.removeAllBinaryOps=function(){return n={},a=0,this},d.removeLiteral=function(e){return delete u[e],this},d.removeAllLiterals=function(){return u={},this},"undefined"==typeof exports){var h=e.jsep;e.jsep=d,d.noConflict=function(){return e.jsep===d&&(e.jsep=h),d}}else"undefined"!=typeof module&&module.exports?exports=module.exports=d:exports.parse=d}(this); | ||
//# sourceMappingURL=jsep.min.js.map |
@@ -1,4 +0,4 @@ | ||
!function(){function e(e,t){return e instanceof Node||e instanceof Window?[e]:[].slice.call("string"==typeof e?(t||document).querySelectorAll(e):e||[])}if(self.Element&&(Element.prototype.matches||(Element.prototype.matches=Element.prototype.webkitMatchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||null),Element.prototype.matches)){var t=self.Stretchy={selectors:{base:'textarea, select:not([size]), input:not([type]), input[type="'+"text url email tel".split(" ").join('"], input[type="')+'"]',filter:"*"},script:document.currentScript||e("script").pop(),resize:function(e){if(t.resizes(e)){var i,n=getComputedStyle(e),o=0;!e.value&&e.placeholder&&(i=!0,e.value=e.placeholder);var l=e.nodeName.toLowerCase();if("textarea"==l)e.style.height="0","border-box"==n.boxSizing?o=e.offsetHeight:"content-box"==n.boxSizing&&(o=-e.clientHeight+parseFloat(n.minHeight)),e.style.height=e.scrollHeight+o+"px";else if("input"==l)if(e.style.width="1000px", | ||
e.offsetWidth){e.style.width="0","border-box"==n.boxSizing?o=e.offsetWidth:"padding-box"==n.boxSizing?o=e.clientWidth:"content-box"==n.boxSizing&&(o=parseFloat(n.minWidth));var r=Math.max(o,e.scrollWidth-e.clientWidth);e.style.width=r+"px";for(var s=0;s<10&&(e.scrollLeft=1e10,0!=e.scrollLeft);s++)r+=e.scrollLeft,e.style.width=r+"px"}else e.style.width=e.value.length+1+"ch";else if("select"==l){var c=e.selectedIndex>0?e.selectedIndex:0,a=document.createElement("_");a.textContent=e.options[c].textContent,e.parentNode.insertBefore(a,e.nextSibling);var d;for(var h in n){var p=n[h];/^(width|webkitLogicalWidth|length)$/.test(h)||"string"!=typeof p||(a.style[h]=p,/appearance$/i.test(h)&&(d=h))}a.style.width="",a.offsetWidth>0&&(e.style.width=a.offsetWidth+"px",n[d]&&"none"===n[d]||(e.style.width="calc("+e.style.width+" + 2em)")),a.parentNode.removeChild(a),a=null}i&&(e.value="")}},resizeAll:function(i){e(i||t.selectors.base).forEach(function(e){t.resize(e)})},active:!0,resizes:function(e){return e&&e.parentNode&&e.matches&&e.matches(t.selectors.base)&&e.matches(t.selectors.filter); | ||
},init:function(){t.selectors.filter=t.script.getAttribute("data-filter")||(e("[data-stretchy-filter]").pop()||document.body).getAttribute("data-stretchy-filter")||Stretchy.selectors.filter||"*",t.resizeAll()},$$:e};"loading"!==document.readyState?t.init():document.addEventListener("DOMContentLoaded",t.init);var i=function(e){t.active&&t.resize(e.target)};document.documentElement.addEventListener("input",i),document.documentElement.addEventListener("change",i),self.MutationObserver&&new MutationObserver(function(e){t.active&&e.forEach(function(e){"childList"==e.type&&Stretchy.resizeAll(e.addedNodes)})}).observe(document.documentElement,{childList:!0,subtree:!0})}}(); | ||
!function(){function e(e,t){return e instanceof Node||e instanceof Window?[e]:[].slice.call("string"==typeof e?(t||document).querySelectorAll(e):e||[])}if(self.Element&&(Element.prototype.matches||(Element.prototype.matches=Element.prototype.webkitMatchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||null),Element.prototype.matches)){var t=self.Stretchy={selectors:{base:'textarea, select:not([size]), input:not([type]), input[type="'+"text number url email tel".split(" ").join('"], input[type="')+'"]',filter:"*"},script:document.currentScript||e("script").pop(),resize:function(e){if(t.resizes(e)){var i,n=getComputedStyle(e),o=0;!e.value&&e.placeholder&&(i=!0,e.value=e.placeholder);var l=e.nodeName.toLowerCase();if("textarea"==l)e.style.height="0","border-box"==n.boxSizing?o=e.offsetHeight:"content-box"==n.boxSizing&&(o=-e.clientHeight+parseFloat(n.minHeight)), | ||
e.style.height=e.scrollHeight+o+"px";else if("input"==l)if(e.style.width="1000px",e.offsetWidth){e.style.width="0","border-box"==n.boxSizing?o=e.offsetWidth:"padding-box"==n.boxSizing?o=e.clientWidth:"content-box"==n.boxSizing&&(o=parseFloat(n.minWidth));var r=Math.max(o,e.scrollWidth-e.clientWidth);e.style.width=r+"px";for(var s=0;s<10&&(e.scrollLeft=1e10,0!=e.scrollLeft);s++)r+=e.scrollLeft,e.style.width=r+"px"}else e.style.width=e.value.length+1+"ch";else if("select"==l){var c=e.selectedIndex>0?e.selectedIndex:0,a=document.createElement("_");a.textContent=e.options[c].textContent,e.parentNode.insertBefore(a,e.nextSibling);var d;for(var h in n){var p=n[h];/^(width|webkitLogicalWidth|length)$/.test(h)||"string"!=typeof p||(a.style[h]=p,/appearance$/i.test(h)&&(d=h))}a.style.width="",a.offsetWidth>0&&(e.style.width=a.offsetWidth+"px",n[d]&&"none"===n[d]||(e.style.width="calc("+e.style.width+" + 2em)")),a.parentNode.removeChild(a),a=null}i&&(e.value="")}},resizeAll:function(i){ | ||
e(i||t.selectors.base).forEach(function(e){t.resize(e)})},active:!0,resizes:function(e){return e&&e.parentNode&&e.matches&&e.matches(t.selectors.base)&&e.matches(t.selectors.filter)},init:function(){t.selectors.filter=t.script.getAttribute("data-filter")||(e("[data-stretchy-filter]").pop()||document.body).getAttribute("data-stretchy-filter")||Stretchy.selectors.filter||"*",t.resizeAll()},$$:e};"loading"!==document.readyState?t.init():document.addEventListener("DOMContentLoaded",t.init);var i=function(e){t.active&&t.resize(e.target)};document.documentElement.addEventListener("input",i),document.documentElement.addEventListener("change",i),self.MutationObserver&&new MutationObserver(function(e){t.active&&e.forEach(function(e){"childList"==e.type&&Stretchy.resizeAll(e.addedNodes)})}).observe(document.documentElement,{childList:!0,subtree:!0})}}(); | ||
//# sourceMappingURL=stretchy.min.js.map |
{ | ||
"name": "mavo", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Create web applications with HTML and CSS", | ||
@@ -5,0 +5,0 @@ "main": "dist/mavo.js", |
@@ -76,2 +76,6 @@ (function($, $$) { | ||
if (!env.options.live) { | ||
env.data = Mavo.subset(this.data, this.inPath, env.data); | ||
} | ||
Mavo.hooks.run("node-getdata-end", env); | ||
@@ -325,24 +329,2 @@ | ||
/** | ||
* Delete all items in the collection. Not undoable. | ||
*/ | ||
clear: function() { | ||
if (this.modes == "read") { | ||
return; | ||
} | ||
if (this.mutable) { | ||
for (var i = 1, item; item = this.children[i]; i++) { | ||
item.element.remove(); | ||
item.destroy(); | ||
} | ||
this.children = this.children.slice(0, 1); | ||
this.dataChanged("clear"); | ||
} | ||
this.propagate("clear"); | ||
}, | ||
dataChanged: function(action, o = {}) { | ||
@@ -349,0 +331,0 @@ o.element = o.element || this.marker; |
@@ -81,4 +81,15 @@ (function($) { | ||
destroy: function() { | ||
_.special.delete(this); | ||
}, | ||
changedBy: function(evt) { | ||
return !this.parsed.every(expr => !(expr instanceof Mavo.Expression) || !expr.changedBy(evt)); | ||
if (!this.identifiers) { | ||
this.identifiers = Mavo.flatten(this.parsed.map(x => x.identifiers || [])); | ||
// Any identifiers that need additional updating? | ||
_.special.add(this); | ||
} | ||
return Mavo.Expression.changedBy(this.identifiers, evt); | ||
}, | ||
@@ -133,3 +144,11 @@ | ||
env.value = env.value.length === 1? env.value[0] : env.value.map(Mavo.Primitive.format).join(""); | ||
if (env.value.length === 1) { | ||
env.value = env.value[0]; | ||
} | ||
else { | ||
env.value = env.value.map(v => Mavo.Primitive.format(v, { | ||
attribute: this.attribute, | ||
element: this.element | ||
})).join(""); | ||
} | ||
@@ -190,2 +209,86 @@ this.output(env.value); | ||
return all; | ||
}, | ||
special: { | ||
add: function(domexpression, name) { | ||
if (name) { | ||
var o = this.vars[name]; | ||
if (o && domexpression.identifiers.indexOf(name) > -1) { | ||
o.all = o.all || new Set(); | ||
o.all.add(domexpression); | ||
if (o.all.size === 1) { | ||
o.observe(); | ||
} | ||
else if (!o.all.size) { | ||
o.unobserve(); | ||
} | ||
} | ||
} | ||
else { | ||
// All names | ||
for (var name in this.vars) { | ||
this.add(domexpression, name); | ||
} | ||
} | ||
}, | ||
delete: function(domexpression, name) { | ||
if (name) { | ||
var o = this.vars[name]; | ||
o.all = o.all || new Set(); | ||
o.all.delete(domexpression); | ||
if (!o.all.size) { | ||
o.unobserve(); | ||
} | ||
} | ||
else { | ||
// All names | ||
for (var name in this.vars) { | ||
this.delete(domexpression, name); | ||
} | ||
} | ||
}, | ||
update: function() { | ||
if (this.update) { | ||
this.update(...arguments); | ||
} | ||
for (var domexpression of this.all) { | ||
domexpression.update(); | ||
} | ||
}, | ||
event: function(name, {type, update, target = document} = {}) { | ||
this.vars[name] = { | ||
observe: function() { | ||
this.callback = this.callback || _.special.update.bind(this); | ||
target.addEventListener(type, this.callback); | ||
}, | ||
unobserve: function() { | ||
target.removeEventListener(type, this.callback); | ||
} | ||
}; | ||
if (update) { | ||
this.vars[name].update = function(evt) { | ||
Mavo.Functions[name] = update(evt); | ||
}; | ||
} | ||
}, | ||
vars: { | ||
"$now": { | ||
observe: function() { | ||
this.timer = setInterval(_.special.update.bind(this), 100); | ||
}, | ||
unobserve: function() { | ||
clearInterval(this.timer); | ||
} | ||
} | ||
} | ||
} | ||
@@ -195,2 +298,14 @@ } | ||
_.special.event("$mouse", { | ||
type: "mousemove", | ||
update: function(evt) { | ||
return {x: evt.clientX, y: evt.clientY}; | ||
} | ||
}); | ||
_.special.event("$hash", { | ||
type: "hashchange", | ||
target: window | ||
}); | ||
})(Bliss); |
@@ -11,4 +11,2 @@ (function($) { | ||
eval: function(data) { | ||
this.oldValue = this.value; | ||
Mavo.hooks.run("expression-eval-beforeeval", this); | ||
@@ -19,6 +17,5 @@ | ||
this.function = Mavo.Script.compile(this.expression); | ||
this.identifiers = this.expression.match(/[$a-z][$\w]*/ig) || []; | ||
} | ||
this.value = this.function(data); | ||
return this.function(data); | ||
} | ||
@@ -31,6 +28,4 @@ catch (exception) { | ||
this.value = exception; | ||
return exception; | ||
} | ||
return this.value; | ||
}, | ||
@@ -43,40 +38,44 @@ | ||
changedBy: function(evt) { | ||
if (!evt) { | ||
return true; | ||
} | ||
return _.changedBy(this.identifiers, evt); | ||
}, | ||
if (!this.identifiers) { | ||
return false; | ||
live: { | ||
expression: function(value) { | ||
this.function = null; | ||
this.identifiers = value.match(/[$a-z][$\w]*/ig) || []; | ||
} | ||
}, | ||
if (this.identifiers.indexOf(evt.property) > -1) { | ||
return true; | ||
} | ||
static: { | ||
changedBy: function(identifiers, evt) { | ||
if (!evt) { | ||
return true; | ||
} | ||
if (Mavo.Functions.intersects(evt.properties, this.identifiers)) { | ||
return true; | ||
} | ||
if (!identifiers) { | ||
return false; | ||
} | ||
if (evt.action != "propertychange") { | ||
if (Mavo.Functions.intersects(["$index", "$previous", "$next"], this.identifiers)) { | ||
if (identifiers.indexOf(evt.property) > -1) { | ||
return true; | ||
} | ||
var collection = evt.node.collection || evt.node; | ||
if (Mavo.Functions.intersects(collection.properties, this.identifiers)) { | ||
if (Mavo.Functions.intersects(evt.properties, identifiers)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}, | ||
if (evt.action != "propertychange") { | ||
if (Mavo.Functions.intersects(["$index", "$previous", "$next"], identifiers)) { | ||
return true; | ||
} | ||
live: { | ||
expression: function(value) { | ||
this.function = null; | ||
} | ||
}, | ||
var collection = evt.node.collection || evt.node; | ||
static: { | ||
if (Mavo.Functions.intersects(collection.properties, identifiers)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}, | ||
} | ||
@@ -83,0 +82,0 @@ }); |
@@ -56,2 +56,17 @@ /** | ||
url: (id, url = location) => { | ||
if (id === undefined) { | ||
return location.href; | ||
} | ||
if (id) { | ||
id = str(id).replace(/[^\w-:]/g); | ||
var ret = url.search.match(RegExp(`[?&]${id}(?:=(.+?))?(?=$|&)`)) | ||
|| url.pathname.match(RegExp(`(?:^|\\/)${id}\\/([^\\/]*)`)); | ||
} | ||
return ret === null || !id? null : ret[1] || ""; | ||
}, | ||
// TODO return first/last non-null? | ||
@@ -147,3 +162,3 @@ first: arr => arr && arr[0] || "", | ||
iff: function(condition, iftrue, iffalse="") { | ||
iff: function(condition, iftrue=condition, iffalse="") { | ||
if (Array.isArray(condition)) { | ||
@@ -260,2 +275,3 @@ return condition.map((c, i) => { | ||
second: getDateComponent("second"), | ||
ms: getDateComponent("ms"), | ||
@@ -284,2 +300,9 @@ date: date => { | ||
// Other special variables (some updated via events) | ||
$mouse: {x: 0, y: 0}, | ||
get $hash() { | ||
return location.hash.slice(1); | ||
}, | ||
// "Private" helpers | ||
@@ -353,2 +376,3 @@ util: { | ||
// $url: Read-only syntactic sugar for URL stuff | ||
// Deprecated. Use url() instead. | ||
$.lazy(_, "$url", function() { | ||
@@ -374,20 +398,2 @@ var ret = {}; | ||
var aliases = { | ||
average: "avg", | ||
iff: "iff IF", | ||
subtract: "minus", | ||
multiply: "mult product", | ||
divide: "div", | ||
lt: "lessThan smaller", | ||
gt: "moreThan greater greaterThan bigger", | ||
eq: "equal equality", | ||
th: "ordinal" | ||
}; | ||
for (let name in aliases) { | ||
aliases[name].split(/\s+/g).forEach(alias => _[alias] = _[name]); | ||
} | ||
// Make function names case insensitive | ||
@@ -402,11 +408,19 @@ _._Trap = self.Proxy? new Proxy(_, { | ||
if (canonicalProperty) { | ||
ret = functions[canonicalProperty] || Math[canonicalProperty]; | ||
ret = functions[canonicalProperty]; | ||
if (ret === undefined) { | ||
ret = Math[canonicalProperty]; | ||
} | ||
} | ||
if (ret) { | ||
// For when function names are used as unquoted strings, see #160 | ||
ret.toString = () => property; | ||
if (ret !== undefined) { | ||
if (typeof ret === "function") { | ||
// For when function names are used as unquoted strings, see #160 | ||
ret.toString = () => property; | ||
} | ||
return ret; | ||
} | ||
// Still not found? Maybe it's a global | ||
if (property in self) { | ||
@@ -466,3 +480,4 @@ return self[property]; | ||
minute: d => d.getMinutes(), | ||
second: d => d.getSeconds() | ||
second: d => d.getSeconds(), | ||
ms: d => d.getMilliseconds() | ||
}; | ||
@@ -489,3 +504,3 @@ | ||
if (component != "weekday") { | ||
ret.twodigit = (ret < 10? "0" : "") + (ret < 1? "0" : "") + ret % 100; | ||
ret.twodigit = (ret % 100 < 10? "0" : "") + ret % 100; | ||
} | ||
@@ -492,0 +507,0 @@ |
Mavo.Locale.register("en", { | ||
"edit": "Edit", | ||
"save": "Save", | ||
"clear": "Clear", | ||
"logout": "Logout", | ||
@@ -21,3 +20,2 @@ "login": "Login", | ||
"delete-item": "Delete this {name}", | ||
"delete-confirmation": "This will delete all your data. Are you sure?", | ||
"gh-updated-file": "Updated {name}", | ||
@@ -24,0 +22,0 @@ "gh-edit-suggestion-saved-in-profile": "Your edits are saved to <a href=\"{previewURL}\" target=\"_blank\">your own profile</a>, because you are not allowed to edit this page.", |
@@ -7,3 +7,3 @@ /** | ||
(function ($, $$) { | ||
console.log("local"); | ||
var _ = self.Mavo = $.Class({ | ||
@@ -355,8 +355,2 @@ constructor: function (element) { | ||
clear: function() { | ||
if (confirm(this._("delete-confirmation"))) { | ||
this.store(null).then(() => this.root.clear()); | ||
} | ||
}, | ||
edit: function() { | ||
@@ -516,3 +510,5 @@ this.root.edit(); | ||
this.inProgress = false; | ||
$.fire(this.element, "mavo:load"); | ||
requestAnimationFrame(() => { | ||
$.fire(this.element, "mavo:load"); | ||
}); | ||
}); | ||
@@ -628,9 +624,2 @@ }, | ||
if (value != this._primaryBackend) { | ||
if (value) { | ||
this.element.style.setProperty("--mv-backend", `"${value.id}"`); | ||
} | ||
else { | ||
this.element.style.removeProperty("--mv-backend"); | ||
} | ||
return value; | ||
@@ -687,3 +676,3 @@ } | ||
attributes: [ | ||
"mv-app", "mv-storage", "mv-source", "mv-init", "mv-path", "mv-format", | ||
"mv-app", "mv-storage", "mv-source", "mv-init", "mv-path", "mv-multiple-path", "mv-format", | ||
"mv-attribute", "mv-default", "mv-mode", "mv-edit", "mv-permisssions", | ||
@@ -690,0 +679,0 @@ "mv-rel" |
@@ -8,3 +8,5 @@ (function($, val, $u) { | ||
for (let symbol of Mavo.toArray(o.symbol)) { | ||
Mavo.Script.symbols[symbol] = name; | ||
Mavo.Script.unarySymbols[symbol] = name; | ||
jsep.addUnaryOp(symbol); | ||
} | ||
@@ -27,6 +29,6 @@ } | ||
Mavo.Script.symbols[symbol] = name; | ||
} | ||
if (o.precedence) { | ||
jsep.addBinaryOp(o.symbol, o.precedence); | ||
if (o.precedence) { | ||
jsep.addBinaryOp(symbol, o.precedence); | ||
} | ||
} | ||
@@ -97,4 +99,5 @@ } | ||
symbols: {}, | ||
unarySymbols: {}, | ||
getOperatorName: op => Mavo.Script.symbols[op] || op, | ||
getOperatorName: (op, unary) => Mavo.Script[unary? "unarySymbols" : "symbols"][op] || op, | ||
@@ -128,5 +131,10 @@ /** | ||
}, | ||
"plus": { | ||
scalar: a => +a, | ||
symbol: "+" | ||
}, | ||
"subtract": { | ||
scalar: (a, b) => { | ||
if (isNaN(a) || isNaN(b)) { | ||
// Handle dates | ||
var dateA = $u.date(a), dateB = $u.date(b); | ||
@@ -143,2 +151,6 @@ | ||
}, | ||
"minus": { | ||
scalar: a => -a, | ||
symbol: "-" | ||
}, | ||
"mod": { | ||
@@ -149,3 +161,5 @@ scalar: (a, b) => { | ||
return ret; | ||
} | ||
}, | ||
symbol: "mod", | ||
precedence: 6 | ||
}, | ||
@@ -192,3 +206,4 @@ "lte": { | ||
symbol: ["=", "=="], | ||
identity: true | ||
identity: true, | ||
precedence: 6 | ||
}, | ||
@@ -205,3 +220,4 @@ "neq": { | ||
identity: true, | ||
symbol: "&&" | ||
symbol: ["&&", "and"], | ||
precedence: 2 | ||
}, | ||
@@ -213,3 +229,4 @@ "or": { | ||
identity: false, | ||
symbol: "||" | ||
symbol: ["||", "or"], | ||
precedence: 2 | ||
}, | ||
@@ -286,3 +303,3 @@ "concatenate": { | ||
"UnaryExpression": node => { | ||
var name = Mavo.Script.getOperatorName(node.operator); | ||
var name = Mavo.Script.getOperatorName(node.operator, true); | ||
@@ -336,10 +353,2 @@ if (name) { | ||
if (self.jsep) { | ||
jsep.addBinaryOp("and", 2); | ||
jsep.addBinaryOp("or", 2); | ||
jsep.addBinaryOp("=", 6); | ||
jsep.addBinaryOp("mod", 10); | ||
jsep.removeBinaryOp("==="); | ||
} | ||
_.serializers.LogicalExpression = _.serializers.BinaryExpression; | ||
@@ -359,2 +368,17 @@ _.transformations.LogicalExpression = _.transformations.BinaryExpression; | ||
var aliases = { | ||
average: "avg", | ||
iff: "iff IF", | ||
multiply: "mult product", | ||
divide: "div", | ||
lt: "smaller", | ||
gt: "larger bigger", | ||
eq: "equal equality", | ||
th: "ordinal" | ||
}; | ||
for (let name in aliases) { | ||
aliases[name].split(/\s+/g).forEach(alias => Mavo.Functions[alias] = Mavo.Functions[name]); | ||
} | ||
})(Bliss, Mavo.value, Mavo.Functions.util); |
@@ -104,2 +104,8 @@ (function($, $$) { | ||
} | ||
if (this.expressions) { | ||
for (var expression of this.expressions) { | ||
expression.destroy(); | ||
} | ||
} | ||
}, | ||
@@ -194,8 +200,2 @@ | ||
clear: function() { | ||
if (this.modes != "read") { | ||
this.propagate("clear"); | ||
} | ||
}, | ||
propagate: function(callback) { | ||
@@ -310,2 +310,28 @@ for (let i in this.children) { | ||
// Resolve a property name from this node | ||
resolve: function(property) { | ||
// First look in descendants | ||
var ret = this.find(property); | ||
if (ret === undefined) { | ||
// Still not found, look in ancestors | ||
ret = this.walkUp(group => { | ||
if (group.property == property) { | ||
return group; | ||
} | ||
if (property in group.children) { | ||
return group.children[property]; | ||
}; | ||
}); | ||
} | ||
if (ret === undefined) { | ||
// Still not found, look anywhere | ||
ret = this.mavo.root.find(property); | ||
} | ||
return ret; | ||
}, | ||
relativizeData: self.Proxy? function(data, options = {live: true}) { | ||
@@ -350,23 +376,4 @@ var cache = {}; | ||
// First look in descendants | ||
var ret = this.find(property); | ||
var ret = this.resolve(property); | ||
if (ret === undefined) { | ||
// Still not found, look in ancestors | ||
ret = this.walkUp(group => { | ||
if (group.property == property) { | ||
return group; | ||
} | ||
if (property in group.children) { | ||
return group.children[property]; | ||
}; | ||
}); | ||
} | ||
if (ret === undefined) { | ||
// Still not found, look anywhere | ||
ret = this.mavo.root.find(property); | ||
} | ||
if (ret !== undefined) { | ||
@@ -471,7 +478,5 @@ if (Array.isArray(ret)) { | ||
inPath: function() { | ||
if (this.nodeType != "Collection") { | ||
return (this.element.getAttribute("mv-path") || "").split("/").filter(p => p.length); | ||
} | ||
var attribute = this.nodeType == "Collection"? "mv-multiple-path" : "mv-path"; | ||
return []; | ||
return (this.element.getAttribute(attribute) || "").split("/").filter(p => p.length); | ||
}, | ||
@@ -478,0 +483,0 @@ |
@@ -223,3 +223,3 @@ (function($, $$) { | ||
} | ||
else if (!this.inPath.length) { | ||
else if (this.inPath.length) { | ||
env.data = Mavo.subset(this.data, this.inPath, env.data); | ||
@@ -424,8 +424,2 @@ } | ||
clear: function() { | ||
if (this.modes != "read") { | ||
this.value = this.templateValue; | ||
} | ||
}, | ||
dataRender: function(data) { | ||
@@ -502,2 +496,4 @@ if (data && typeof data === "object") { | ||
var oldDatatype = this.datatype; | ||
// If there's no datatype, adopt that of the value | ||
@@ -510,3 +506,3 @@ if (!this.datatype && (typeof value == "number" || typeof value == "boolean")) { | ||
if (value == this._value && !o.force) { | ||
if (!o.force && value == this._value && oldDatatype == this.datatype) { | ||
// Do nothing if value didn't actually change, unless forced to | ||
@@ -780,4 +776,8 @@ return value; | ||
if ($.type(value) === "number" || o.datatype == "number") { | ||
return _.formatNumber(value); | ||
if (($.type(value) === "number" || o.datatype == "number")) { | ||
var skipNumberFormatting = o.attribute || o.element && o.element.matches("style, pre"); | ||
if (!skipNumberFormatting) { | ||
return _.formatNumber(value); | ||
} | ||
} | ||
@@ -784,0 +784,0 @@ |
@@ -10,5 +10,18 @@ (function ($, $$) { | ||
this.element = $(".mv-bar", this.mavo.element); | ||
this.template = this.mavo.element.getAttribute("mv-bar"); | ||
if (this.element) { | ||
this.custom = true; | ||
this.template = this.element.getAttribute("mv-bar") || this.template || ""; | ||
var selector = Object.keys(_.controls).map(id => `.mv-${id}`).join(", "); | ||
this.customControls = $$(selector, this.element); | ||
for (let id in _.controls) { | ||
this[id] = $(`.mv-${id}`, this.element); | ||
if (this[id]) { | ||
this.template += ` yes-${id}`; | ||
} | ||
} | ||
} | ||
@@ -41,4 +54,2 @@ else { | ||
this[id] = $(`.mv-${id}`, this.element); | ||
if (this[id]) { | ||
@@ -164,27 +175,46 @@ // Custom control, remove to not mess up order | ||
getControls: function(attribute) { | ||
var initial = Object.keys(_.controls).filter(id => !_.controls[id].optional); | ||
if (attribute) { | ||
var ids = attribute == "none"? [] : attribute.split(/\s+/); | ||
var ids = attribute == "none"? [] : attribute.trim().split(/\s+/); | ||
// Is there ANY non-negative key? | ||
var excludeOnly = !/(\s+|^)(?!no\-)[a-z]+(\s+|$)/.test(attribute); | ||
// Is there ANY non-relative key? | ||
var relative = true; | ||
var values = {}; | ||
var keys = excludeOnly? Object.keys(_.controls) : []; | ||
// Make map of ids and relativeness, dropping duplicates | ||
for (var value of ids) { | ||
let id = Mavo.match(value, /([a-z]+)\s*$/i, 1); | ||
for (var key of ids) { | ||
var negative = /^\s*no\-/i.test(key); | ||
var id = Mavo.match(key, /([a-z]+)\s*$/i, 1); | ||
if (id in _.controls) { | ||
values[id] = Mavo.match(value, /^(no|yes)\-/i, 1); | ||
} | ||
} | ||
if (negative) { | ||
// Any absolute value left? | ||
for (var id in values) { | ||
if (!values[id]) { | ||
relative = false; | ||
break; | ||
} | ||
} | ||
var keys = relative? initial : []; | ||
for (var id in values) { | ||
var rel = values[id]; | ||
if (rel == "no" || !rel) { | ||
Mavo.delete(keys, id); | ||
} | ||
else if (id in _.controls) { | ||
if (keys.indexOf(id) === -1 && rel != "no") { | ||
keys.push(id); | ||
} | ||
} | ||
return keys; | ||
} | ||
else { | ||
return Object.keys(_.controls); | ||
} | ||
return keys; | ||
return initial; | ||
}, | ||
@@ -257,9 +287,2 @@ | ||
clear: { | ||
action: function() { | ||
this.clear(); | ||
}, | ||
permission: "delete" | ||
}, | ||
login: { | ||
@@ -266,0 +289,0 @@ action: function() { |
@@ -415,4 +415,13 @@ (function ($, $$) { | ||
if (path.length) { | ||
var last = path[path.length - 1]; | ||
var parent = $.value(obj, ...path.slice(0, -1)); | ||
parent[path[path.length - 1]] = value; | ||
if (Array.isArray(parent) && Array.isArray(value)) { | ||
// Merge arrays instead of adding array inside array | ||
parent.splice(last, 1, ...value); | ||
} | ||
else { | ||
parent[path[path.length - 1]] = value; | ||
} | ||
return obj; | ||
@@ -437,2 +446,6 @@ } | ||
} | ||
// Not found | ||
path[i] = obj.length; | ||
return {id: property}; | ||
} | ||
@@ -439,0 +452,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
1974389
51
44881