Comparing version 0.2.68 to 0.2.69
@@ -1,2 +0,2 @@ | ||
/* version: 0.2.68 */ | ||
/* version: 0.2.69 */ | ||
var Absurd = (function(w) { | ||
@@ -33,5 +33,37 @@ var lib = { | ||
var str2DOMElement = function(html) { | ||
var temp = document.createElement('div'); | ||
temp.innerHTML = html; | ||
return temp.childNodes[0]; | ||
/* code taken from jQuery */ | ||
var wrapMap = { | ||
option: [ 1, "<select multiple='multiple'>", "</select>" ], | ||
legend: [ 1, "<fieldset>", "</fieldset>" ], | ||
area: [ 1, "<map>", "</map>" ], | ||
param: [ 1, "<object>", "</object>" ], | ||
thead: [ 1, "<table>", "</table>" ], | ||
tr: [ 2, "<table><tbody>", "</tbody></table>" ], | ||
col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ], | ||
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], | ||
// IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags, | ||
// unless wrapped in a div with non-breaking characters in front of it. | ||
_default: [ 1, "<div>", "</div>" ] | ||
}; | ||
wrapMap.optgroup = wrapMap.option; | ||
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; | ||
wrapMap.th = wrapMap.td; | ||
var element = document.createElement('div'); | ||
var match = /<\s*\w.*?>/g.exec(html); | ||
if(match != null) { | ||
var tag = match[0].replace(/</g, '').replace(/>/g, ''); | ||
var map = wrapMap[tag] || wrapMap._default, element; | ||
html = map[1] + html + map[2]; | ||
element.innerHTML = html; | ||
// Descend through wrappers to the right content | ||
var j = map[0]+1; | ||
while(j--) { | ||
element = element.lastChild; | ||
} | ||
} else { | ||
element.innerHTML = html; | ||
element = element.lastChild; | ||
} | ||
return element; | ||
} | ||
@@ -372,3 +404,3 @@ var addEventListener = function(obj, evt, fnc) { | ||
async.funcs[index] = {args: args, name: func}; | ||
return '<span data-absurd-async="' + index + '"></span>'; | ||
return '<script data-absurd-async="' + index + '"></script>'; | ||
}, | ||
@@ -385,3 +417,3 @@ child: function() { | ||
}}; | ||
return '<span data-absurd-async="' + index + '"></span>'; | ||
return '<script data-absurd-async="' + index + '"></script>'; | ||
} | ||
@@ -388,0 +420,0 @@ } |
@@ -1,1 +0,1 @@ | ||
var Absurd=function(){var a={api:{},helpers:{},plugins:{},processors:{css:{plugins:{}},html:{plugins:{},helpers:{}},component:{plugins:{}}}},b=function(a,b){!function c(){a.length>0&&a.shift().apply(b||{},[c].concat(Array.prototype.slice.call(arguments,0)))}()},d=function(a,b){var c;try{c=(b||document).querySelectorAll(a)}catch(d){c=document.querySelectorAll(a)}return c},e=function(a){var b=document.createElement("div");return b.innerHTML=a,b.childNodes[0]},f=function(a,b,c){return a.addEventListener?(a.addEventListener(b,c,!1),!0):a.attachEvent?a.attachEvent("on"+b,c):void 0},g=function(a){for(var b,c=a.childNodes,d=c.length,e=0,f=/^\s*$/;d>e;e++)b=c[e],3==b.nodeType&&f.test(b.nodeValue)&&(a.removeChild(b),e--,d--);return a},h=function(b){return b.indexOf("css/CSS.js")>0||"/../CSS.js"==b?a.processors.css.CSS:b.indexOf("html/HTML.js")>0?a.processors.html.HTML:b.indexOf("component/Component.js")>0?a.processors.component.Component:"js-beautify"==b?{html:function(a){return a}}:"./helpers/PropAnalyzer"==b?a.processors.html.helpers.PropAnalyzer:"../../helpers/TransformUppercase"==b?a.helpers.TransformUppercase:"./helpers/TemplateEngine"==b?a.processors.html.helpers.TemplateEngine:"../helpers/Extend"==b?a.helpers.Extend:"../helpers/Clone"==b?a.helpers.Clone:"../helpers/Prefixes"==b||"/../../../helpers/Prefixes"==b?a.helpers.Prefixes:function(){}},i="",j=function(a){var b=[];return{listeners:b,on:function(a,c,d){return b[a]||(b[a]=[]),b[a].push({callback:c,scope:d}),this},off:function(a,c){return b[a]?(c||(b[a]=[]),this):this},dispatch:function(c,d,e){if(!d||"object"!=typeof d||d instanceof Array||(d.target=this),b[c])for(var f=0;f<b[c].length;f++){var g=b[c][f].callback;g.apply(e||b[c][f].scope||{},[d])}return this[c]&&"function"==typeof this[c]&&this[c](d),a&&a.dispatch(c,d),this}}},k=function(c,h){var i=!1,j=!1,k=!1,l=a.helpers.Extend,m={},n=!1,o={funcs:{},index:0},p={events:{}},q=function(a){this.css?h.flush().add(this.css).compile(function(b,e){if(i)i.raw!==e&&(i.raw=e,i.element.innerHTML=e);else{var f=document.createElement("style");f.setAttribute("id",c+"-css"),f.setAttribute("type","text/css"),f.innerHTML=e,(d("head")||d("body"))[0].appendChild(f),i={raw:e,element:f}}a()}):a()},r=function(a){if(this.html)if("string"==typeof this.html){if(k===!1){var b=d(this.html);b.length>0&&(k=b[0]),j={"":k.outerHTML.replace(/</g,"<").replace(/>/g,">")}}a()}else"object"==typeof this.html?(j=l({},this.html),k===!1?h.flush().morph("html").add(j).compile(function(b,c){k=e(c),a(!0)},this):a()):a();else a()},s=function(a,b){j&&b!==!0?h.flush().morph("html").add(j).compile(function(b,c){!function d(a,b){if(g(a),g(b),"undefined"!=typeof a&&"undefined"!=typeof b&&!a.isEqualNode(b)){if(a.nodeName!==b.nodeName)return a.parentNode&&a.parentNode.replaceChild(b,a),void 0;if(a.nodeValue!==b.nodeValue&&(a.nodeValue=b.nodeValue),a.attributes){for(var c,e,f=a.attributes,h=b.attributes,i={},j=0;j<f.length,c=f[j];j++){for(var k=0;k<h.length,e=h[k];k++)c.name===e.name&&(a.setAttribute(c.name,e.value),i[c.name]=!0);i[c.name]||a.removeAttribute(c.name)}for(var j=0;j<h.length,e=h[j];j++)i[e.name]||a.setAttribute(e.name,e.value)}var l=[];if(a.childNodes.length>=b.childNodes.length)for(var j=0;j<a.childNodes.length;j++)b.childNodes[j]||b.appendChild(document.createTextNode("")),l.push([a.childNodes[j],b.childNodes[j]]);else for(var j=0;j<b.childNodes.length;j++)a.appendChild(document.createTextNode("")),l.push([a.childNodes[j],b.childNodes[j]]);for(var j=0;j<l.length;j++)d(l[j][0],l[j][1])}}(k,e(c)),a()},this):a()},t=function(a){if(k){var b=[];if(k.hasAttribute&&k.hasAttribute("data-absurd-async"))b.push(k);else for(var c=k.querySelectorAll?k.querySelectorAll("[data-absurd-async]"):[],d=0;d<c.length;d++)b.push(c[d]);if(0===b.length)a();else{var f=this;!function g(){if(0===b.length)a();else{var c=b.shift(),d=c.getAttribute("data-absurd-async"),h=function(a){"string"==typeof a?c.parentNode.replaceChild(e(a),c):c.parentNode.replaceChild(a,c),g()};"function"==typeof f[o.funcs[d].name]?f[o.funcs[d].name].apply(f,[h].concat(o.funcs[d].args)):"function"==typeof o.funcs[d].func&&o.funcs[d].func.apply(f,[h].concat(o.funcs[d].args))}}()}}else a()},u=function(a){!n&&k&&this.get("parent")&&(n=!0,this.get("parent").appendChild(k)),a()},v=function(a){if(k){var b=this,c=function(a){var c=a.getAttribute("data-absurd-event");c=c.split(":"),c.length>=2&&(!p.events[c[0]]||p.events[c[0]].indexOf(a)<0)&&(p.events[c[0]]||(p.events[c[0]]=[]),p.events[c[0]].push(a),f(a,c[0],function(a){"function"==typeof b[c[1]]&&b[c[1]](a)}))};k.hasAttribute&&k.hasAttribute("data-absurd-event")&&c(k);for(var d=k.querySelectorAll?k.querySelectorAll("[data-absurd-event]"):[],e=0;e<d.length;e++)c(d[e])}a()},w={__name:c,populate:function(a){return b([q,r,s,u,v,t,function(){o={funcs:{},index:0};var b={css:i,html:{element:k}};this.dispatch("populated",b),a&&"function"==typeof a.callback&&a.callback(b)}],this),this},el:function(){return k},set:function(a,b){return m[a]=b,this},get:function(a){return m[a]},wire:function(a){h.components.events.on(a,this[a]||function(){},this)},async:function(){var a=Array.prototype.slice.call(arguments,0),b=a.shift(),c="_"+o.index++;return o.funcs[c]={args:a,name:b},'<span data-absurd-async="'+c+'"></span>'},child:function(){var a=Array.prototype.slice.call(arguments,0),b=this.get("children"),c=b&&b[a.shift()],d="_"+o.index++;return o.funcs[d]={args:a,func:function(a){c.populate({callback:function(b){a(b.html.element)}})}},'<span data-absurd-async="'+d+'"></span>'}};return w},l=function(a){return function(b,c){return"undefined"==typeof c?a.components.get(b):a.components.register(b,c)}},m=function(b){var c=a.helpers.Extend,d=a.helpers.Clone,e={},f={},g=[];return e.events=c({},j()),e.register=function(a,h){return f[a]=function(){var f=c({},j(e.events),k(a,b),d(h));return b.di.resolveObject(f),g.push(f),"function"==typeof f.constructor&&f.constructor.apply(f,Array.prototype.slice.call(arguments,0)),f}},e.get=function(a){if(f[a])return f[a];throw new Error("There is no component with name '"+a+"'.")},e.remove=function(a){return f[a]?(delete f[a],!0):!1},e.list=function(){var a=[];for(var b in f)a.push(b);return a},e.flush=function(){return f={},g=[],e},e.broadcast=function(a,b){for(var c=0;c<g.length,instance=g[c];c++)"function"==typeof instance[a]&&instance[a](b);return e},e},n=function(){return function(b){var d=function(a,b){for(var c in b)hasOwnProperty.call(b,c)&&(a[c]=b[c]);return a},e={defaultProcessor:a.processors.css.CSS()},f={},g={},h={},i={};e.getRules=function(a){return"undefined"==typeof a?f:("undefined"==typeof f[a]&&(f[a]=[]),f[a])},e.getPlugins=function(){return h},e.getStorage=function(){return g},e.flush=function(){return f={},g=[],i={},e.defaultProcessor=a.processors.css.CSS(),e},e.import=function(){return e.callHooks("import",arguments)?e:e},e.addHook=function(a,b){i[a]||(i[a]=[]);for(var d=!1,e=0;c=i[a][e];e++)c===b&&(d=!0);d===!1?i[a].push(b):null},e.callHooks=function(a,b){if(i[a])for(var d=0;c=i[a][d];d++)if(c.apply(e,b)===!0)return!0;return!1},e.numOfAddedRules=0,e.components=m(e),e.component=l(e),e.di=a.DI(e),e.compile=function(a,b){if(e.callHooks("compile",arguments))return e;var c={combineSelectors:!0,minify:!1,processor:e.defaultProcessor,keepCamelCase:!1,api:e};b=d(c,b||{}),b.processor(e.getRules(),a||function(){},b),e.flush()};for(var j in a.api)"compile"!==j&&(e[j]=a.api[j](e),e[j]=function(b){return function(){var c=a.api[b](e);return e.callHooks(b,arguments)?e:c.apply(e,arguments)}}(j));for(var k in a.processors.css.plugins)e.plugin(k,a.processors.css.plugins[k]());return"function"==typeof b&&b(e),"undefined"!=typeof Organic&&Organic.init(e),e}};a.DI=function(){var a={dependencies:{},register:function(a,b){return this.dependencies[a]=b,this},resolve:function(){var a,b,c,d=this,e=!1;"string"==typeof arguments[0]?(a=arguments[1],b=arguments[0].replace(/ /g,"").split(","),c=arguments[2]||{}):(a=arguments[0],b=a.toString().match(/^function\s*[^\(]*\(\s*([^\)]*)\)/m)[1].replace(/ /g,"").split(","),c=arguments[1]||{});for(var f=0;f<b.length;f++)"undefined"!=typeof this.dependencies[b[f]]&&(e=!0);return e?function(){for(var e=[],f=Array.prototype.slice.call(arguments,0),g=0;g<b.length;g++){var h=b[g];e.push(d.dependencies[h]&&""!=h?d.dependencies[h]:f.shift())}return a.apply(c,e)}:a},resolveObject:function(a){if("object"==typeof a)for(var b in a)"function"==typeof a[b]?a[b]=this.resolve(a[b],a):a[b]instanceof Array&&2==a[b].length&&"string"==typeof a[b][0]&&"function"==typeof a[b][1]&&(a[b]=this.resolve(a[b][0],a[b][1],a));return this},flush:function(){return this.dependencies={},this}};return a},a.api.add=function(a){var b=(h("../helpers/Extend"),h("../helpers/Prefixes")),c=[],d=function(c,d,f,g,h){var i=b.nonPrefixProp(d),j=a.getPlugins()[i.prop];if("undefined"!=typeof j){var k=j(a,f,i.prefix);return k&&e(c,k,g,h),!0}return!1},e=function(a,f,g,h){if(g=g||"mainstream",/, ?/g.test(a))for(var i=a.replace(/, /g,",").split(","),j=0;j<i.length,p=i[j];j++)e(p,f,g,h);else if("undefined"==typeof f.length||"object"!=typeof f){if(!d(null,a,f,g,h)){var k={},l=a,m={},n={};for(var o in f){var q=typeof f[o];"object"!==q&&"function"!==q?d(a,o,f[o],g,h)===!1&&(l="undefined"!=typeof h?h+" "+a:a,k[o]=f[o],b.addPrefixes(o,k)):"object"===q?m[o]=f[o]:"function"===q&&(n[o]=f[o])}c.push({selector:l,props:k,stylesheet:g});for(var o in m)if(":"===o.charAt(0))e(a+o,m[o],g,h);else if(/&/g.test(o))if(/, ?/g.test(o))for(var i=o.replace(/, /g,",").split(","),j=0;j<i.length,p=i[j];j++)p.indexOf("&")>=0?e(p.replace(/&/g,a),m[o],g,h):e(p,m[o],g,"undefined"!=typeof h?h+" "+a:a);else e(o.replace(/&/g,a),m[o],g,h);else 0===o.indexOf("@media")||0===o.indexOf("@supports")?e(a,m[o],o,h):0===a.indexOf("@media")||0===o.indexOf("@supports")?e(o,m[o],a,h):d(a,o,m[o],g,h)===!1&&e(o,m[o],g,(h?h+" ":"")+a);for(var o in n){var r={};r[o]=n[o](),e(a,r,g,h)}}}else for(var j=0;j<f.length,o=f[j];j++)e(a,o,g,h)},f=function(b,d){c=[],a.numOfAddedRules+=1;var f=a.defaultProcessor.type;for(var g in b)e(g,b[g],d||"mainstream");for(var h=0;h<c.length;h++){var d=c[h].stylesheet,g=c[h].selector,i=c[h].props,j=a.getRules(d),k=j[g]||{};for(var l in i){var m=i[l];"object"!=typeof m&&(k[l]="css"==f?"+"===m.toString().charAt(0)?k&&k[l]?k[l]+", "+m.substr(1,m.length-1):m.substr(1,m.length-1):">"===m.toString().charAt(0)?k&&k[l]?k[l]+" "+m.substr(1,m.length-1):m.substr(1,m.length-1):m:m)}j[g]=k}return a};return f};var q=h("../helpers/Extend");a.api.compile=function(a){return function(){for(var b=null,c=null,d=null,e=0;e<arguments.length;e++)switch(typeof arguments[e]){case"function":c=arguments[e];break;case"string":b=arguments[e];break;case"object":d=arguments[e]}var f={combineSelectors:!0,minify:!1,keepCamelCase:!1,processor:a.defaultProcessor,api:a};d=q(f,d||{}),d.processor(a.getRules(),function(d,e){if(null!=b)try{t.writeFile(b,e,function(a){c(a,e)})}catch(d){c.apply({},arguments)}else c.apply({},arguments);a.flush()},d)}},a.api.compileFile=function(a){return a.compile};var r=function(a,b){a=String(a).replace(/[^0-9a-f]/gi,""),a.length<6&&(a=a[0]+a[0]+a[1]+a[1]+a[2]+a[2]),b=b||0;var c,d,e="#";for(d=0;3>d;d++)c=parseInt(a.substr(2*d,2),16),c=Math.round(Math.min(Math.max(0,c+c*b),255)).toString(16),e+=("00"+c).substr(c.length);return e};a.api.darken=function(){return function(a,b){return r(a,-(b/100))}},a.api.define=function(a){return function(b,c){return a.getStorage().__defined||(a.getStorage().__defined={}),a.getStorage().__defined[b]=c,a}},a.api.hook=function(a){return function(b,c){return a.addHook(b,c),a}};var r=function(a,b){a=String(a).replace(/[^0-9a-f]/gi,""),a.length<6&&(a=a[0]+a[0]+a[1]+a[1]+a[2]+a[2]),b=b||0;var c,d,e="#";for(d=0;3>d;d++)c=parseInt(a.substr(2*d,2),16),c=Math.round(Math.min(Math.max(0,c+c*b),255)).toString(16),e+=("00"+c).substr(c.length);return e};a.api.lighten=function(){return function(a,b){return r(a,b/100)}};var s={html:function(a){a.defaultProcessor=h(i+"/../processors/html/HTML.js")(),a.hook("add",function(b,c){return a.getRules(c||"mainstream").push(b),!0})},component:function(a){a.defaultProcessor=h(i+"/../processors/component/Component.js")(),a.hook("add",function(b){b instanceof Array||(b=[b]);for(var d=0;d<b.length,c=b[d];d++)a.getRules("mainstream").push(c);return!0})}};a.api.morph=function(a){return function(b){return s[b]&&(a.flush(),s[b](a)),a}},a.api.plugin=function(a){var b=function(b,c){return a.getPlugins()[b]=c,a};return b},a.api.raw=function(a){return function(b){var c={},d={},e="____raw_"+a.numOfAddedRules;return d[e]=b,c[e]=d,a.add(c),a}};{var t=h("fs");h("path")}a.api.rawImport=function(a){var b=function(b){var c=t.readFileSync(b,{encoding:"utf8"});a.raw(c)};return function(c){var d,e,f;if("string"==typeof c)b(c);else for(e=0,f=c.length;f>e;e++)d=c[e],b(d);return a}},a.api.register=function(a){return function(b,c){return a[b]=c,a}},a.api.storage=function(a){var b=a.getStorage(),c=function(d,e){if("undefined"!=typeof e)b[d]=e;else{if("object"!=typeof d){if(b[d])return b[d];throw new Error("There is no data in the storage associated with '"+d+"'")}for(var f in d)Object.prototype.hasOwnProperty.call(d,f)&&c(f,d[f])}return a};return c},a.helpers.Clone=function N(a){if(!a)return a;var b,c=[Number,String,Boolean];if(c.forEach(function(c){a instanceof c&&(b=c(a))}),"undefined"==typeof b)if("[object Array]"===Object.prototype.toString.call(a))b=[],a.forEach(function(a,c){b[c]=N(a)});else if("object"==typeof a)if(a.nodeType&&"function"==typeof a.cloneNode)var b=a.cloneNode(!0);else if(a.prototype)b=a;else if(a instanceof Date)b=new Date(a);else{b={};for(var d in a)b[d]=N(a[d])}else b=a;return b},a.helpers.ColorLuminance=function(a,b){a=String(a).replace(/[^0-9a-f]/gi,""),a.length<6&&(a=a[0]+a[0]+a[1]+a[1]+a[2]+a[2]),b=b||0;var c,d,e="#";for(d=0;3>d;d++)c=parseInt(a.substr(2*d,2),16),c=Math.round(Math.min(Math.max(0,c+c*b),255)).toString(16),e+=("00"+c).substr(c.length);return e},a.helpers.Extend=function(){for(var a=function(a,b){for(var c in b)hasOwnProperty.call(b,c)&&(a[c]=b[c]);return a},b=arguments[0],c=1;c<arguments.length;c++)b=a(b,arguments[c]);return b};var u=function(a){var b,c;return(c=a.match(/^\-(w|m|s|o)+\-/)||"-"===a.charAt(0))?null!==c&&c[0]?(b={prefix:c[0].replace(/-/g,"")},b.prop=a.replace(c[0],"")):(b={prefix:""},b.prop=a.substr(1,a.length)):b={prefix:!1,prop:a},b};a.helpers.Prefixes={addPrefixes:function(a,b){var c=a,d=u(a),e=b[a];d.prefix!==!1&&(delete b[c],b[d.prop]=e,(""===d.prefix||d.prefix.indexOf("w")>=0)&&(b["-webkit-"+d.prop]=e),(""===d.prefix||d.prefix.indexOf("m")>=0)&&(b["-moz-"+d.prop]=e),(""===d.prefix||d.prefix.indexOf("s")>=0)&&(b["-ms-"+d.prop]=e),(""===d.prefix||d.prefix.indexOf("o")>=0)&&(b["-o-"+d.prop]=e))},nonPrefixProp:function(a){var b=u(a);return b.prefix!==!1&&(b.prefix=""==b.prefix?"-":"-"+b.prefix+"-"),b}},a.helpers.RequireUncached=function(a){return delete h.cache[h.resolve(a)],h(a)},a.helpers.TransformUppercase=function(a){for(var b="",d=0;c=a.charAt(d);d++)b+=c===c.toUpperCase()&&c.toLowerCase()!==c.toUpperCase()?"-"+c.toLowerCase():c;return b};var w=function(a,b,d){var e="",f="",g=[],j=d.api;cssPreprocessor=h(i+"/../css/CSS.js")(),htmlPreprocessor=h(i+"/../html/HTML.js")();for(var k=function(a){for(var b=0;b<g.length,l=g[b];b++)"function"==typeof l&&(l=l()),j.add(l.css?l.css:{});cssPreprocessor(j.getRules(),function(b,c){e+=c,a(b)},d)},m=function(b){var c=0,e=null,g=function(){if(c>a.length-1)return b(e),void 0;var h=a[c];"function"==typeof h&&(h=h()),j.morph("html").add(h.html?h.html:{}),htmlPreprocessor(j.getRules(),function(a,b){f+=b,c+=1,e=a,g()},d)};g()},n=function(a){for(var b in a)if("_include"===b)if(a[b]instanceof Array)for(var d=0;d<a[b].length,c=a[b][d];d++)"function"==typeof c&&(c=c()),g.push(c),n(c);else"function"==typeof a[b]&&(a[b]=a[b]()),g.push(a[b]),n(a[b]);else"object"==typeof a[b]&&n(a[b])},o=0;o<a.length,c=a[o];o++)"function"==typeof c&&(c=c()),g.push(c),n(c);j.flush(),k(function(a){j.morph("html"),m(function(c){b(a||c?{error:{css:a,html:c}}:null,e,f)})})};a.processors.component.Component=function(){var a=function(a,b,c){w(a.mainstream,b,c)};return a.type="component",a};var x="\n",y={combineSelectors:!0,minify:!1,keepCamelCase:!1},z=h("../../helpers/TransformUppercase"),A=function(a,b){var c="";for(var d in a)if(0===d.indexOf("____raw"))c+=a[d][d]+x;else{var e=d+" {"+x;for(var f in a[d]){var g=a[d][f];""===g&&(g='""'),e+=b&&b.keepCamelCase===!0?" "+f+": "+g+";"+x:" "+z(f)+": "+g+";"+x}e+="}"+x,c+=e}return c},B=function(a){var b={},c={};for(var d in a){var e=a[d];for(var f in e){var g=e[f];b[f]||(b[f]={}),b[f][g]||(b[f][g]=[]),b[f][g].push(d)}}for(var f in b){var h=b[f];for(var g in h){var i=h[g];c[i.join(", ")]||(c[i.join(", ")]={});var d=c[i.join(", ")];d[f]=g}}return c},C=function(a){return a=a.replace(/\/\*(?:(?!\*\/)[\s\S])*\*\/|[\r\n\t]+/g,""),a=a.replace(/ {2,}/g," "),a=a.replace(/ ([{:}]) /g,"$1"),a=a.replace(/([;,]) /g,"$1"),a=a.replace(/ !/g,"!")},D=function(a,b){if(b&&b.api&&b.api.getStorage().__defined){var c=b.api.getStorage().__defined;for(var d in c){var e=new RegExp("<%( )?"+d+"( )?%>","g");a="function"!=typeof c[d]?a.replace(e,c[d]):a.replace(e,c[d]())}}return a};a.processors.css.CSS=function(){var a=function(a,b,c){c=c||y;var d="";for(var e in a){var f=a[e];f=c.combineSelectors?B(f):f,d+="mainstream"===e?A(f,c):e+" {"+x+A(f,c)+"}"+x}return d=D(d,c),c.minify?(d=C(d),b&&b(null,d)):b&&b(null,d),d};return a.type="css",a},a.processors.css.plugins.charset=function(){return function(a,b){"string"==typeof b?a.raw('@charset: "'+b+'";'):"object"==typeof b&&(b=b.charset.replace(/:/g,"").replace(/'/g,"").replace(/"/g,"").replace(/ /g,""),a.raw('@charset: "'+b+'";'))}},a.processors.css.plugins.document=function(){return function(a,b){if("object"==typeof b){var c="";if(c+="@"+b.vendor+"document",c+=" "+b.document,b.rules&&b.rules.length)for(var d=0;rule=b.rules[d];d++)a.handlecssrule(rule,c);else"undefined"!=typeof b.styles&&a.add(b.styles,c)}}},a.processors.css.plugins.keyframes=function(){return function(a,b){var c=h(i+"/../CSS.js")(),d=h(i+"/../../../helpers/Prefixes");if("object"==typeof b)if("undefined"!=typeof b.frames){for(var e in b.frames)for(var f in b.frames[e])d.addPrefixes(f,b.frames[e]);var g="@keyframes "+b.name+" {\n";g+=c({mainstream:b.frames}),g+="}",a.raw(g+"\n"+g.replace("@keyframes","@-webkit-keyframes"))}else if("undefined"!=typeof b.keyframes){for(var g="@keyframes "+b.name+" {\n",j={},k=0;rule=b.keyframes[k];k++)if("keyframe"===rule.type)for(var l=j[rule.values]={},m=0;declaration=rule.declarations[m];m++)"declaration"===declaration.type&&(l[declaration.property]=declaration.value);g+=c({mainstream:j}),g+="}",a.raw(g+"\n"+g.replace("@keyframes","@-webkit-keyframes"))}}},a.processors.css.plugins.media=function(){return function(a,b){var c=h(i+"/../CSS.js")();if("object"==typeof b){for(var d="@media "+b.media+" {\n",e={},f=0;rule=b.rules[f];f++){var g=e[rule.selectors.toString()]={};if("rule"===rule.type)for(var j=0;declaration=rule.declarations[j];j++)"declaration"===declaration.type&&(g[declaration.property]=declaration.value)}d+=c({mainstream:e}),d+="}",a.raw(d)}}},a.processors.css.plugins.namespace=function(){return function(a,b){"string"==typeof b?a.raw('@namespace: "'+b+'";'):"object"==typeof b&&(b=b.namespace.replace(/: /g,"").replace(/'/g,"").replace(/"/g,"").replace(/ /g,"").replace(/:h/g,"h"),a.raw('@namespace: "'+b+'";'))}},a.processors.css.plugins.page=function(){return function(a,b){if("object"==typeof b){var c="";c+=b.selectors.length>0?"@page "+b.selectors.join(", ")+" {\n":"@page {\n";for(var d=0;declaration=b.declarations[d];d++)"declaration"==declaration.type&&(c+=" "+declaration.property+": "+declaration.value+";\n");c+="}",a.raw(c)}}},a.processors.css.plugins.supports=function(){return function(a,b){var c=h(i+"/../CSS.js")();if("object"==typeof b){for(var d="@supports "+b.supports+" {\n",e={},f=0;rule=b.rules[f];f++){var g=e[rule.selectors.toString()]={};if("rule"===rule.type)for(var j=0;declaration=rule.declarations[j];j++)"declaration"===declaration.type&&(g[declaration.property]=declaration.value)}d+=c({mainstream:e}),d+="}",a.raw(d)}}};var E=null,x="\n",y={},F=h("js-beautify").html,G=h("../../helpers/TransformUppercase"),H={},I=function(a){var b="";for(var c in E)if(c==a)for(var d=E[c].length,e=0;d>e;e++)b+=K("",E[c][e]);return b},J=function(a,b){return b&&b.keepCamelCase===!0?a:G(a,b)},K=function(a,b){var c="",d="",e="",f=h("./helpers/PropAnalyzer")(a);if(a=f.tag,""!=f.attrs&&(d+=" "+f.attrs),"string"==typeof b)return L(a,d,b);var g=function(a){""!=e&&(e+=x),e+=a};for(var i in b){var j=b[i];switch(i){case"_attrs":for(var k in j)d+="function"==typeof j[k]?" "+J(k,H)+'="'+j[k]()+'"':" "+J(k,H)+'="'+j[k]+'"';break;case"_":g(j);break;case"_tpl":if("string"==typeof j)g(I(j));else if(j instanceof Array){for(var l="",m=0;tpl=j[m];m++)l+=I(tpl),m<j.length-1&&(l+=x);g(l)}break;case"_include":var l="",n=function(a){"function"==typeof a&&(a=a()),a.css&&a.html&&(a=a.html),l+=K("",a)};if(j instanceof Array)for(var m=0;m<j.length,o=j[m];m++)n(o);else"object"==typeof j&&n(j);g(l);break;default:switch(typeof j){case"string":g(K(i,j));break;case"object":if(j.length&&j.length>0){for(var l="",m=0;v=j[m];m++)l+=K("","function"==typeof v?v():v),m<j.length-1&&(l+=x);g(K(i,l))}else g(K(i,j));break;case"function":g(K(i,j()))}}}return c+=""!=a?L(a,d,e):e},L=function(a,b,c){var d="";return""==a&&""==b&&""!=c?c:(a=""==a?"div":a,d+=""!==c?"<"+J(a,H)+b+">"+x+c+x+"</"+J(a,H)+">":"<"+J(a,H)+b+"/>")},M=function(a){return a=h("./helpers/TemplateEngine")(a.replace(/[\r\t\n]/g,""),H),H.minify?a:F(a,{indent_size:H.indentSize||4})};return a.processors.html.HTML=function(){var a=function(a,b,c){E=a,b=b||function(){},c=H=c||y;var d=M(I("mainstream"));return b(null,d),d};return a.type="html",a},a.processors.html.helpers.PropAnalyzer=function(a){var b={tag:"",attrs:""},d=(a.length,""),e=!1,f=[],g="",h=!1,i="",j=!1;if(/(#|\.|\[|\])/gi.test(a)===!1)return{tag:a,attrs:""};for(var k=0;k<a.length,c=a[k];k++)"["!==c||j?j?"]"!=c?i+=c:(j=!1,k-=1):"."!==c||e?e?"."!=c&&"#"!=c&&"["!=c&&"]"!=c?d+=c:(f.push(d),e=!1,d="",k-=1):"#"!==c||h?h?"."!=c&&"#"!=c&&"["!=c&&"]"!=c?g+=c:(h=!1,k-=1):"."!=c&&"#"!=c&&"["!=c&&"]"!=c&&(b.tag+=c):h=!0:e=!0:j=!0;""!=d&&f.push(d);for(var l="",k=0;cls=f[k];k++)l+=""===l?cls:" "+cls;return b.attrs+=""!=l?'class="'+l+'"':"",""!=g&&(b.attrs+=(""!=b.attrs?" ":"")+'id="'+g+'"'),""===b.tag&&""!=b.attrs&&(b.tag="div"),""!=i&&(b.attrs+=(""!=b.attrs?" ":"")+i),b},a.processors.html.helpers.TemplateEngine=function(a,b){for(var c,d=/<%(.+?)%>/g,e=/(^( )?(if|for|else|switch|case|break|{|}|;))(.*)?/g,f="var r=[];\n",g=0,h=function(a,b){return f+=b?a.match(e)?a+"\n":"r.push("+a+");\n":""!=a?'r.push("'+a.replace(/"/g,'\\"')+'");\n':"",h};match=d.exec(a);)h(a.slice(g,match.index))(match[1],!0),g=match.index+match[0].length;h(a.substr(g,a.length-g)),f=(f+'return r.join("");').replace(/[\r\t\n]/g,"");try{c=new Function(f).apply(b)}catch(i){console.error("'"+i.message+"'"," in \n\nCode:\n",f,"\n")}return c},n()}(window); | ||
var Absurd=function(){var a={api:{},helpers:{},plugins:{},processors:{css:{plugins:{}},html:{plugins:{},helpers:{}},component:{plugins:{}}}},b=function(a,b){!function c(){a.length>0&&a.shift().apply(b||{},[c].concat(Array.prototype.slice.call(arguments,0)))}()},d=function(a,b){var c;try{c=(b||document).querySelectorAll(a)}catch(d){c=document.querySelectorAll(a)}return c},e=function(a){var b={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[1,"<div>","</div>"]};b.optgroup=b.option,b.tbody=b.tfoot=b.colgroup=b.caption=b.thead,b.th=b.td;var c=document.createElement("div"),d=/<\s*\w.*?>/g.exec(a);if(null!=d){var c,e=d[0].replace(/</g,"").replace(/>/g,""),f=b[e]||b._default;a=f[1]+a+f[2],c.innerHTML=a;for(var g=f[0]+1;g--;)c=c.lastChild}else c.innerHTML=a,c=c.lastChild;return c},f=function(a,b,c){return a.addEventListener?(a.addEventListener(b,c,!1),!0):a.attachEvent?a.attachEvent("on"+b,c):void 0},g=function(a){for(var b,c=a.childNodes,d=c.length,e=0,f=/^\s*$/;d>e;e++)b=c[e],3==b.nodeType&&f.test(b.nodeValue)&&(a.removeChild(b),e--,d--);return a},h=function(b){return b.indexOf("css/CSS.js")>0||"/../CSS.js"==b?a.processors.css.CSS:b.indexOf("html/HTML.js")>0?a.processors.html.HTML:b.indexOf("component/Component.js")>0?a.processors.component.Component:"js-beautify"==b?{html:function(a){return a}}:"./helpers/PropAnalyzer"==b?a.processors.html.helpers.PropAnalyzer:"../../helpers/TransformUppercase"==b?a.helpers.TransformUppercase:"./helpers/TemplateEngine"==b?a.processors.html.helpers.TemplateEngine:"../helpers/Extend"==b?a.helpers.Extend:"../helpers/Clone"==b?a.helpers.Clone:"../helpers/Prefixes"==b||"/../../../helpers/Prefixes"==b?a.helpers.Prefixes:function(){}},i="",j=function(a){var b=[];return{listeners:b,on:function(a,c,d){return b[a]||(b[a]=[]),b[a].push({callback:c,scope:d}),this},off:function(a,c){return b[a]?(c||(b[a]=[]),this):this},dispatch:function(c,d,e){if(!d||"object"!=typeof d||d instanceof Array||(d.target=this),b[c])for(var f=0;f<b[c].length;f++){var g=b[c][f].callback;g.apply(e||b[c][f].scope||{},[d])}return this[c]&&"function"==typeof this[c]&&this[c](d),a&&a.dispatch(c,d),this}}},k=function(c,h){var i=!1,j=!1,k=!1,l=a.helpers.Extend,m={},n=!1,o={funcs:{},index:0},p={events:{}},q=function(a){this.css?h.flush().add(this.css).compile(function(b,e){if(i)i.raw!==e&&(i.raw=e,i.element.innerHTML=e);else{var f=document.createElement("style");f.setAttribute("id",c+"-css"),f.setAttribute("type","text/css"),f.innerHTML=e,(d("head")||d("body"))[0].appendChild(f),i={raw:e,element:f}}a()}):a()},r=function(a){if(this.html)if("string"==typeof this.html){if(k===!1){var b=d(this.html);b.length>0&&(k=b[0]),j={"":k.outerHTML.replace(/</g,"<").replace(/>/g,">")}}a()}else"object"==typeof this.html?(j=l({},this.html),k===!1?h.flush().morph("html").add(j).compile(function(b,c){k=e(c),a(!0)},this):a()):a();else a()},s=function(a,b){j&&b!==!0?h.flush().morph("html").add(j).compile(function(b,c){!function d(a,b){if(g(a),g(b),"undefined"!=typeof a&&"undefined"!=typeof b&&!a.isEqualNode(b)){if(a.nodeName!==b.nodeName)return a.parentNode&&a.parentNode.replaceChild(b,a),void 0;if(a.nodeValue!==b.nodeValue&&(a.nodeValue=b.nodeValue),a.attributes){for(var c,e,f=a.attributes,h=b.attributes,i={},j=0;j<f.length,c=f[j];j++){for(var k=0;k<h.length,e=h[k];k++)c.name===e.name&&(a.setAttribute(c.name,e.value),i[c.name]=!0);i[c.name]||a.removeAttribute(c.name)}for(var j=0;j<h.length,e=h[j];j++)i[e.name]||a.setAttribute(e.name,e.value)}var l=[];if(a.childNodes.length>=b.childNodes.length)for(var j=0;j<a.childNodes.length;j++)b.childNodes[j]||b.appendChild(document.createTextNode("")),l.push([a.childNodes[j],b.childNodes[j]]);else for(var j=0;j<b.childNodes.length;j++)a.appendChild(document.createTextNode("")),l.push([a.childNodes[j],b.childNodes[j]]);for(var j=0;j<l.length;j++)d(l[j][0],l[j][1])}}(k,e(c)),a()},this):a()},t=function(a){if(k){var b=[];if(k.hasAttribute&&k.hasAttribute("data-absurd-async"))b.push(k);else for(var c=k.querySelectorAll?k.querySelectorAll("[data-absurd-async]"):[],d=0;d<c.length;d++)b.push(c[d]);if(0===b.length)a();else{var f=this;!function g(){if(0===b.length)a();else{var c=b.shift(),d=c.getAttribute("data-absurd-async"),h=function(a){"string"==typeof a?c.parentNode.replaceChild(e(a),c):c.parentNode.replaceChild(a,c),g()};"function"==typeof f[o.funcs[d].name]?f[o.funcs[d].name].apply(f,[h].concat(o.funcs[d].args)):"function"==typeof o.funcs[d].func&&o.funcs[d].func.apply(f,[h].concat(o.funcs[d].args))}}()}}else a()},u=function(a){!n&&k&&this.get("parent")&&(n=!0,this.get("parent").appendChild(k)),a()},v=function(a){if(k){var b=this,c=function(a){var c=a.getAttribute("data-absurd-event");c=c.split(":"),c.length>=2&&(!p.events[c[0]]||p.events[c[0]].indexOf(a)<0)&&(p.events[c[0]]||(p.events[c[0]]=[]),p.events[c[0]].push(a),f(a,c[0],function(a){"function"==typeof b[c[1]]&&b[c[1]](a)}))};k.hasAttribute&&k.hasAttribute("data-absurd-event")&&c(k);for(var d=k.querySelectorAll?k.querySelectorAll("[data-absurd-event]"):[],e=0;e<d.length;e++)c(d[e])}a()},w={__name:c,populate:function(a){return b([q,r,s,u,v,t,function(){o={funcs:{},index:0};var b={css:i,html:{element:k}};this.dispatch("populated",b),a&&"function"==typeof a.callback&&a.callback(b)}],this),this},el:function(){return k},set:function(a,b){return m[a]=b,this},get:function(a){return m[a]},wire:function(a){h.components.events.on(a,this[a]||function(){},this)},async:function(){var a=Array.prototype.slice.call(arguments,0),b=a.shift(),c="_"+o.index++;return o.funcs[c]={args:a,name:b},'<script data-absurd-async="'+c+'"></script>'},child:function(){var a=Array.prototype.slice.call(arguments,0),b=this.get("children"),c=b&&b[a.shift()],d="_"+o.index++;return o.funcs[d]={args:a,func:function(a){c.populate({callback:function(b){a(b.html.element)}})}},'<script data-absurd-async="'+d+'"></script>'}};return w},l=function(a){return function(b,c){return"undefined"==typeof c?a.components.get(b):a.components.register(b,c)}},m=function(b){var c=a.helpers.Extend,d=a.helpers.Clone,e={},f={},g=[];return e.events=c({},j()),e.register=function(a,h){return f[a]=function(){var f=c({},j(e.events),k(a,b),d(h));return b.di.resolveObject(f),g.push(f),"function"==typeof f.constructor&&f.constructor.apply(f,Array.prototype.slice.call(arguments,0)),f}},e.get=function(a){if(f[a])return f[a];throw new Error("There is no component with name '"+a+"'.")},e.remove=function(a){return f[a]?(delete f[a],!0):!1},e.list=function(){var a=[];for(var b in f)a.push(b);return a},e.flush=function(){return f={},g=[],e},e.broadcast=function(a,b){for(var c=0;c<g.length,instance=g[c];c++)"function"==typeof instance[a]&&instance[a](b);return e},e},n=function(){return function(b){var d=function(a,b){for(var c in b)hasOwnProperty.call(b,c)&&(a[c]=b[c]);return a},e={defaultProcessor:a.processors.css.CSS()},f={},g={},h={},i={};e.getRules=function(a){return"undefined"==typeof a?f:("undefined"==typeof f[a]&&(f[a]=[]),f[a])},e.getPlugins=function(){return h},e.getStorage=function(){return g},e.flush=function(){return f={},g=[],i={},e.defaultProcessor=a.processors.css.CSS(),e},e.import=function(){return e.callHooks("import",arguments)?e:e},e.addHook=function(a,b){i[a]||(i[a]=[]);for(var d=!1,e=0;c=i[a][e];e++)c===b&&(d=!0);d===!1?i[a].push(b):null},e.callHooks=function(a,b){if(i[a])for(var d=0;c=i[a][d];d++)if(c.apply(e,b)===!0)return!0;return!1},e.numOfAddedRules=0,e.components=m(e),e.component=l(e),e.di=a.DI(e),e.compile=function(a,b){if(e.callHooks("compile",arguments))return e;var c={combineSelectors:!0,minify:!1,processor:e.defaultProcessor,keepCamelCase:!1,api:e};b=d(c,b||{}),b.processor(e.getRules(),a||function(){},b),e.flush()};for(var j in a.api)"compile"!==j&&(e[j]=a.api[j](e),e[j]=function(b){return function(){var c=a.api[b](e);return e.callHooks(b,arguments)?e:c.apply(e,arguments)}}(j));for(var k in a.processors.css.plugins)e.plugin(k,a.processors.css.plugins[k]());return"function"==typeof b&&b(e),"undefined"!=typeof Organic&&Organic.init(e),e}};a.DI=function(){var a={dependencies:{},register:function(a,b){return this.dependencies[a]=b,this},resolve:function(){var a,b,c,d=this,e=!1;"string"==typeof arguments[0]?(a=arguments[1],b=arguments[0].replace(/ /g,"").split(","),c=arguments[2]||{}):(a=arguments[0],b=a.toString().match(/^function\s*[^\(]*\(\s*([^\)]*)\)/m)[1].replace(/ /g,"").split(","),c=arguments[1]||{});for(var f=0;f<b.length;f++)"undefined"!=typeof this.dependencies[b[f]]&&(e=!0);return e?function(){for(var e=[],f=Array.prototype.slice.call(arguments,0),g=0;g<b.length;g++){var h=b[g];e.push(d.dependencies[h]&&""!=h?d.dependencies[h]:f.shift())}return a.apply(c,e)}:a},resolveObject:function(a){if("object"==typeof a)for(var b in a)"function"==typeof a[b]?a[b]=this.resolve(a[b],a):a[b]instanceof Array&&2==a[b].length&&"string"==typeof a[b][0]&&"function"==typeof a[b][1]&&(a[b]=this.resolve(a[b][0],a[b][1],a));return this},flush:function(){return this.dependencies={},this}};return a},a.api.add=function(a){var b=(h("../helpers/Extend"),h("../helpers/Prefixes")),c=[],d=function(c,d,f,g,h){var i=b.nonPrefixProp(d),j=a.getPlugins()[i.prop];if("undefined"!=typeof j){var k=j(a,f,i.prefix);return k&&e(c,k,g,h),!0}return!1},e=function(a,f,g,h){if(g=g||"mainstream",/, ?/g.test(a))for(var i=a.replace(/, /g,",").split(","),j=0;j<i.length,p=i[j];j++)e(p,f,g,h);else if("undefined"==typeof f.length||"object"!=typeof f){if(!d(null,a,f,g,h)){var k={},l=a,m={},n={};for(var o in f){var q=typeof f[o];"object"!==q&&"function"!==q?d(a,o,f[o],g,h)===!1&&(l="undefined"!=typeof h?h+" "+a:a,k[o]=f[o],b.addPrefixes(o,k)):"object"===q?m[o]=f[o]:"function"===q&&(n[o]=f[o])}c.push({selector:l,props:k,stylesheet:g});for(var o in m)if(":"===o.charAt(0))e(a+o,m[o],g,h);else if(/&/g.test(o))if(/, ?/g.test(o))for(var i=o.replace(/, /g,",").split(","),j=0;j<i.length,p=i[j];j++)p.indexOf("&")>=0?e(p.replace(/&/g,a),m[o],g,h):e(p,m[o],g,"undefined"!=typeof h?h+" "+a:a);else e(o.replace(/&/g,a),m[o],g,h);else 0===o.indexOf("@media")||0===o.indexOf("@supports")?e(a,m[o],o,h):0===a.indexOf("@media")||0===o.indexOf("@supports")?e(o,m[o],a,h):d(a,o,m[o],g,h)===!1&&e(o,m[o],g,(h?h+" ":"")+a);for(var o in n){var r={};r[o]=n[o](),e(a,r,g,h)}}}else for(var j=0;j<f.length,o=f[j];j++)e(a,o,g,h)},f=function(b,d){c=[],a.numOfAddedRules+=1;var f=a.defaultProcessor.type;for(var g in b)e(g,b[g],d||"mainstream");for(var h=0;h<c.length;h++){var d=c[h].stylesheet,g=c[h].selector,i=c[h].props,j=a.getRules(d),k=j[g]||{};for(var l in i){var m=i[l];"object"!=typeof m&&(k[l]="css"==f?"+"===m.toString().charAt(0)?k&&k[l]?k[l]+", "+m.substr(1,m.length-1):m.substr(1,m.length-1):">"===m.toString().charAt(0)?k&&k[l]?k[l]+" "+m.substr(1,m.length-1):m.substr(1,m.length-1):m:m)}j[g]=k}return a};return f};var q=h("../helpers/Extend");a.api.compile=function(a){return function(){for(var b=null,c=null,d=null,e=0;e<arguments.length;e++)switch(typeof arguments[e]){case"function":c=arguments[e];break;case"string":b=arguments[e];break;case"object":d=arguments[e]}var f={combineSelectors:!0,minify:!1,keepCamelCase:!1,processor:a.defaultProcessor,api:a};d=q(f,d||{}),d.processor(a.getRules(),function(d,e){if(null!=b)try{t.writeFile(b,e,function(a){c(a,e)})}catch(d){c.apply({},arguments)}else c.apply({},arguments);a.flush()},d)}},a.api.compileFile=function(a){return a.compile};var r=function(a,b){a=String(a).replace(/[^0-9a-f]/gi,""),a.length<6&&(a=a[0]+a[0]+a[1]+a[1]+a[2]+a[2]),b=b||0;var c,d,e="#";for(d=0;3>d;d++)c=parseInt(a.substr(2*d,2),16),c=Math.round(Math.min(Math.max(0,c+c*b),255)).toString(16),e+=("00"+c).substr(c.length);return e};a.api.darken=function(){return function(a,b){return r(a,-(b/100))}},a.api.define=function(a){return function(b,c){return a.getStorage().__defined||(a.getStorage().__defined={}),a.getStorage().__defined[b]=c,a}},a.api.hook=function(a){return function(b,c){return a.addHook(b,c),a}};var r=function(a,b){a=String(a).replace(/[^0-9a-f]/gi,""),a.length<6&&(a=a[0]+a[0]+a[1]+a[1]+a[2]+a[2]),b=b||0;var c,d,e="#";for(d=0;3>d;d++)c=parseInt(a.substr(2*d,2),16),c=Math.round(Math.min(Math.max(0,c+c*b),255)).toString(16),e+=("00"+c).substr(c.length);return e};a.api.lighten=function(){return function(a,b){return r(a,b/100)}};var s={html:function(a){a.defaultProcessor=h(i+"/../processors/html/HTML.js")(),a.hook("add",function(b,c){return a.getRules(c||"mainstream").push(b),!0})},component:function(a){a.defaultProcessor=h(i+"/../processors/component/Component.js")(),a.hook("add",function(b){b instanceof Array||(b=[b]);for(var d=0;d<b.length,c=b[d];d++)a.getRules("mainstream").push(c);return!0})}};a.api.morph=function(a){return function(b){return s[b]&&(a.flush(),s[b](a)),a}},a.api.plugin=function(a){var b=function(b,c){return a.getPlugins()[b]=c,a};return b},a.api.raw=function(a){return function(b){var c={},d={},e="____raw_"+a.numOfAddedRules;return d[e]=b,c[e]=d,a.add(c),a}};{var t=h("fs");h("path")}a.api.rawImport=function(a){var b=function(b){var c=t.readFileSync(b,{encoding:"utf8"});a.raw(c)};return function(c){var d,e,f;if("string"==typeof c)b(c);else for(e=0,f=c.length;f>e;e++)d=c[e],b(d);return a}},a.api.register=function(a){return function(b,c){return a[b]=c,a}},a.api.storage=function(a){var b=a.getStorage(),c=function(d,e){if("undefined"!=typeof e)b[d]=e;else{if("object"!=typeof d){if(b[d])return b[d];throw new Error("There is no data in the storage associated with '"+d+"'")}for(var f in d)Object.prototype.hasOwnProperty.call(d,f)&&c(f,d[f])}return a};return c},a.helpers.Clone=function N(a){if(!a)return a;var b,c=[Number,String,Boolean];if(c.forEach(function(c){a instanceof c&&(b=c(a))}),"undefined"==typeof b)if("[object Array]"===Object.prototype.toString.call(a))b=[],a.forEach(function(a,c){b[c]=N(a)});else if("object"==typeof a)if(a.nodeType&&"function"==typeof a.cloneNode)var b=a.cloneNode(!0);else if(a.prototype)b=a;else if(a instanceof Date)b=new Date(a);else{b={};for(var d in a)b[d]=N(a[d])}else b=a;return b},a.helpers.ColorLuminance=function(a,b){a=String(a).replace(/[^0-9a-f]/gi,""),a.length<6&&(a=a[0]+a[0]+a[1]+a[1]+a[2]+a[2]),b=b||0;var c,d,e="#";for(d=0;3>d;d++)c=parseInt(a.substr(2*d,2),16),c=Math.round(Math.min(Math.max(0,c+c*b),255)).toString(16),e+=("00"+c).substr(c.length);return e},a.helpers.Extend=function(){for(var a=function(a,b){for(var c in b)hasOwnProperty.call(b,c)&&(a[c]=b[c]);return a},b=arguments[0],c=1;c<arguments.length;c++)b=a(b,arguments[c]);return b};var u=function(a){var b,c;return(c=a.match(/^\-(w|m|s|o)+\-/)||"-"===a.charAt(0))?null!==c&&c[0]?(b={prefix:c[0].replace(/-/g,"")},b.prop=a.replace(c[0],"")):(b={prefix:""},b.prop=a.substr(1,a.length)):b={prefix:!1,prop:a},b};a.helpers.Prefixes={addPrefixes:function(a,b){var c=a,d=u(a),e=b[a];d.prefix!==!1&&(delete b[c],b[d.prop]=e,(""===d.prefix||d.prefix.indexOf("w")>=0)&&(b["-webkit-"+d.prop]=e),(""===d.prefix||d.prefix.indexOf("m")>=0)&&(b["-moz-"+d.prop]=e),(""===d.prefix||d.prefix.indexOf("s")>=0)&&(b["-ms-"+d.prop]=e),(""===d.prefix||d.prefix.indexOf("o")>=0)&&(b["-o-"+d.prop]=e))},nonPrefixProp:function(a){var b=u(a);return b.prefix!==!1&&(b.prefix=""==b.prefix?"-":"-"+b.prefix+"-"),b}},a.helpers.RequireUncached=function(a){return delete h.cache[h.resolve(a)],h(a)},a.helpers.TransformUppercase=function(a){for(var b="",d=0;c=a.charAt(d);d++)b+=c===c.toUpperCase()&&c.toLowerCase()!==c.toUpperCase()?"-"+c.toLowerCase():c;return b};var w=function(a,b,d){var e="",f="",g=[],j=d.api;cssPreprocessor=h(i+"/../css/CSS.js")(),htmlPreprocessor=h(i+"/../html/HTML.js")();for(var k=function(a){for(var b=0;b<g.length,l=g[b];b++)"function"==typeof l&&(l=l()),j.add(l.css?l.css:{});cssPreprocessor(j.getRules(),function(b,c){e+=c,a(b)},d)},m=function(b){var c=0,e=null,g=function(){if(c>a.length-1)return b(e),void 0;var h=a[c];"function"==typeof h&&(h=h()),j.morph("html").add(h.html?h.html:{}),htmlPreprocessor(j.getRules(),function(a,b){f+=b,c+=1,e=a,g()},d)};g()},n=function(a){for(var b in a)if("_include"===b)if(a[b]instanceof Array)for(var d=0;d<a[b].length,c=a[b][d];d++)"function"==typeof c&&(c=c()),g.push(c),n(c);else"function"==typeof a[b]&&(a[b]=a[b]()),g.push(a[b]),n(a[b]);else"object"==typeof a[b]&&n(a[b])},o=0;o<a.length,c=a[o];o++)"function"==typeof c&&(c=c()),g.push(c),n(c);j.flush(),k(function(a){j.morph("html"),m(function(c){b(a||c?{error:{css:a,html:c}}:null,e,f)})})};a.processors.component.Component=function(){var a=function(a,b,c){w(a.mainstream,b,c)};return a.type="component",a};var x="\n",y={combineSelectors:!0,minify:!1,keepCamelCase:!1},z=h("../../helpers/TransformUppercase"),A=function(a,b){var c="";for(var d in a)if(0===d.indexOf("____raw"))c+=a[d][d]+x;else{var e=d+" {"+x;for(var f in a[d]){var g=a[d][f];""===g&&(g='""'),e+=b&&b.keepCamelCase===!0?" "+f+": "+g+";"+x:" "+z(f)+": "+g+";"+x}e+="}"+x,c+=e}return c},B=function(a){var b={},c={};for(var d in a){var e=a[d];for(var f in e){var g=e[f];b[f]||(b[f]={}),b[f][g]||(b[f][g]=[]),b[f][g].push(d)}}for(var f in b){var h=b[f];for(var g in h){var i=h[g];c[i.join(", ")]||(c[i.join(", ")]={});var d=c[i.join(", ")];d[f]=g}}return c},C=function(a){return a=a.replace(/\/\*(?:(?!\*\/)[\s\S])*\*\/|[\r\n\t]+/g,""),a=a.replace(/ {2,}/g," "),a=a.replace(/ ([{:}]) /g,"$1"),a=a.replace(/([;,]) /g,"$1"),a=a.replace(/ !/g,"!")},D=function(a,b){if(b&&b.api&&b.api.getStorage().__defined){var c=b.api.getStorage().__defined;for(var d in c){var e=new RegExp("<%( )?"+d+"( )?%>","g");a="function"!=typeof c[d]?a.replace(e,c[d]):a.replace(e,c[d]())}}return a};a.processors.css.CSS=function(){var a=function(a,b,c){c=c||y;var d="";for(var e in a){var f=a[e];f=c.combineSelectors?B(f):f,d+="mainstream"===e?A(f,c):e+" {"+x+A(f,c)+"}"+x}return d=D(d,c),c.minify?(d=C(d),b&&b(null,d)):b&&b(null,d),d};return a.type="css",a},a.processors.css.plugins.charset=function(){return function(a,b){"string"==typeof b?a.raw('@charset: "'+b+'";'):"object"==typeof b&&(b=b.charset.replace(/:/g,"").replace(/'/g,"").replace(/"/g,"").replace(/ /g,""),a.raw('@charset: "'+b+'";'))}},a.processors.css.plugins.document=function(){return function(a,b){if("object"==typeof b){var c="";if(c+="@"+b.vendor+"document",c+=" "+b.document,b.rules&&b.rules.length)for(var d=0;rule=b.rules[d];d++)a.handlecssrule(rule,c);else"undefined"!=typeof b.styles&&a.add(b.styles,c)}}},a.processors.css.plugins.keyframes=function(){return function(a,b){var c=h(i+"/../CSS.js")(),d=h(i+"/../../../helpers/Prefixes");if("object"==typeof b)if("undefined"!=typeof b.frames){for(var e in b.frames)for(var f in b.frames[e])d.addPrefixes(f,b.frames[e]);var g="@keyframes "+b.name+" {\n";g+=c({mainstream:b.frames}),g+="}",a.raw(g+"\n"+g.replace("@keyframes","@-webkit-keyframes"))}else if("undefined"!=typeof b.keyframes){for(var g="@keyframes "+b.name+" {\n",j={},k=0;rule=b.keyframes[k];k++)if("keyframe"===rule.type)for(var l=j[rule.values]={},m=0;declaration=rule.declarations[m];m++)"declaration"===declaration.type&&(l[declaration.property]=declaration.value);g+=c({mainstream:j}),g+="}",a.raw(g+"\n"+g.replace("@keyframes","@-webkit-keyframes"))}}},a.processors.css.plugins.media=function(){return function(a,b){var c=h(i+"/../CSS.js")();if("object"==typeof b){for(var d="@media "+b.media+" {\n",e={},f=0;rule=b.rules[f];f++){var g=e[rule.selectors.toString()]={};if("rule"===rule.type)for(var j=0;declaration=rule.declarations[j];j++)"declaration"===declaration.type&&(g[declaration.property]=declaration.value)}d+=c({mainstream:e}),d+="}",a.raw(d)}}},a.processors.css.plugins.namespace=function(){return function(a,b){"string"==typeof b?a.raw('@namespace: "'+b+'";'):"object"==typeof b&&(b=b.namespace.replace(/: /g,"").replace(/'/g,"").replace(/"/g,"").replace(/ /g,"").replace(/:h/g,"h"),a.raw('@namespace: "'+b+'";'))}},a.processors.css.plugins.page=function(){return function(a,b){if("object"==typeof b){var c="";c+=b.selectors.length>0?"@page "+b.selectors.join(", ")+" {\n":"@page {\n";for(var d=0;declaration=b.declarations[d];d++)"declaration"==declaration.type&&(c+=" "+declaration.property+": "+declaration.value+";\n");c+="}",a.raw(c)}}},a.processors.css.plugins.supports=function(){return function(a,b){var c=h(i+"/../CSS.js")();if("object"==typeof b){for(var d="@supports "+b.supports+" {\n",e={},f=0;rule=b.rules[f];f++){var g=e[rule.selectors.toString()]={};if("rule"===rule.type)for(var j=0;declaration=rule.declarations[j];j++)"declaration"===declaration.type&&(g[declaration.property]=declaration.value)}d+=c({mainstream:e}),d+="}",a.raw(d)}}};var E=null,x="\n",y={},F=h("js-beautify").html,G=h("../../helpers/TransformUppercase"),H={},I=function(a){var b="";for(var c in E)if(c==a)for(var d=E[c].length,e=0;d>e;e++)b+=K("",E[c][e]);return b},J=function(a,b){return b&&b.keepCamelCase===!0?a:G(a,b)},K=function(a,b){var c="",d="",e="",f=h("./helpers/PropAnalyzer")(a);if(a=f.tag,""!=f.attrs&&(d+=" "+f.attrs),"string"==typeof b)return L(a,d,b);var g=function(a){""!=e&&(e+=x),e+=a};for(var i in b){var j=b[i];switch(i){case"_attrs":for(var k in j)d+="function"==typeof j[k]?" "+J(k,H)+'="'+j[k]()+'"':" "+J(k,H)+'="'+j[k]+'"';break;case"_":g(j);break;case"_tpl":if("string"==typeof j)g(I(j));else if(j instanceof Array){for(var l="",m=0;tpl=j[m];m++)l+=I(tpl),m<j.length-1&&(l+=x);g(l)}break;case"_include":var l="",n=function(a){"function"==typeof a&&(a=a()),a.css&&a.html&&(a=a.html),l+=K("",a)};if(j instanceof Array)for(var m=0;m<j.length,o=j[m];m++)n(o);else"object"==typeof j&&n(j);g(l);break;default:switch(typeof j){case"string":g(K(i,j));break;case"object":if(j.length&&j.length>0){for(var l="",m=0;v=j[m];m++)l+=K("","function"==typeof v?v():v),m<j.length-1&&(l+=x);g(K(i,l))}else g(K(i,j));break;case"function":g(K(i,j()))}}}return c+=""!=a?L(a,d,e):e},L=function(a,b,c){var d="";return""==a&&""==b&&""!=c?c:(a=""==a?"div":a,d+=""!==c?"<"+J(a,H)+b+">"+x+c+x+"</"+J(a,H)+">":"<"+J(a,H)+b+"/>")},M=function(a){return a=h("./helpers/TemplateEngine")(a.replace(/[\r\t\n]/g,""),H),H.minify?a:F(a,{indent_size:H.indentSize||4})};return a.processors.html.HTML=function(){var a=function(a,b,c){E=a,b=b||function(){},c=H=c||y;var d=M(I("mainstream"));return b(null,d),d};return a.type="html",a},a.processors.html.helpers.PropAnalyzer=function(a){var b={tag:"",attrs:""},d=(a.length,""),e=!1,f=[],g="",h=!1,i="",j=!1;if(/(#|\.|\[|\])/gi.test(a)===!1)return{tag:a,attrs:""};for(var k=0;k<a.length,c=a[k];k++)"["!==c||j?j?"]"!=c?i+=c:(j=!1,k-=1):"."!==c||e?e?"."!=c&&"#"!=c&&"["!=c&&"]"!=c?d+=c:(f.push(d),e=!1,d="",k-=1):"#"!==c||h?h?"."!=c&&"#"!=c&&"["!=c&&"]"!=c?g+=c:(h=!1,k-=1):"."!=c&&"#"!=c&&"["!=c&&"]"!=c&&(b.tag+=c):h=!0:e=!0:j=!0;""!=d&&f.push(d);for(var l="",k=0;cls=f[k];k++)l+=""===l?cls:" "+cls;return b.attrs+=""!=l?'class="'+l+'"':"",""!=g&&(b.attrs+=(""!=b.attrs?" ":"")+'id="'+g+'"'),""===b.tag&&""!=b.attrs&&(b.tag="div"),""!=i&&(b.attrs+=(""!=b.attrs?" ":"")+i),b},a.processors.html.helpers.TemplateEngine=function(a,b){for(var c,d=/<%(.+?)%>/g,e=/(^( )?(if|for|else|switch|case|break|{|}|;))(.*)?/g,f="var r=[];\n",g=0,h=function(a,b){return f+=b?a.match(e)?a+"\n":"r.push("+a+");\n":""!=a?'r.push("'+a.replace(/"/g,'\\"')+'");\n':"",h};match=d.exec(a);)h(a.slice(g,match.index))(match[1],!0),g=match.index+match[0].length;h(a.substr(g,a.length-g)),f=(f+'return r.join("");').replace(/[\r\t\n]/g,"");try{c=new Function(f).apply(b)}catch(i){console.error("'"+i.message+"'"," in \n\nCode:\n",f,"\n")}return c},n()}(window); |
@@ -1,2 +0,2 @@ | ||
/* version: 0.2.68 */ | ||
/* version: 0.2.69 */ | ||
var Organic = (function(w){ | ||
@@ -3,0 +3,0 @@ var o = { |
@@ -31,5 +31,37 @@ var lib = { | ||
var str2DOMElement = function(html) { | ||
var temp = document.createElement('div'); | ||
temp.innerHTML = html; | ||
return temp.childNodes[0]; | ||
/* code taken from jQuery */ | ||
var wrapMap = { | ||
option: [ 1, "<select multiple='multiple'>", "</select>" ], | ||
legend: [ 1, "<fieldset>", "</fieldset>" ], | ||
area: [ 1, "<map>", "</map>" ], | ||
param: [ 1, "<object>", "</object>" ], | ||
thead: [ 1, "<table>", "</table>" ], | ||
tr: [ 2, "<table><tbody>", "</tbody></table>" ], | ||
col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ], | ||
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], | ||
// IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags, | ||
// unless wrapped in a div with non-breaking characters in front of it. | ||
_default: [ 1, "<div>", "</div>" ] | ||
}; | ||
wrapMap.optgroup = wrapMap.option; | ||
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; | ||
wrapMap.th = wrapMap.td; | ||
var element = document.createElement('div'); | ||
var match = /<\s*\w.*?>/g.exec(html); | ||
if(match != null) { | ||
var tag = match[0].replace(/</g, '').replace(/>/g, ''); | ||
var map = wrapMap[tag] || wrapMap._default, element; | ||
html = map[1] + html + map[2]; | ||
element.innerHTML = html; | ||
// Descend through wrappers to the right content | ||
var j = map[0]+1; | ||
while(j--) { | ||
element = element.lastChild; | ||
} | ||
} else { | ||
element.innerHTML = html; | ||
element = element.lastChild; | ||
} | ||
return element; | ||
} | ||
@@ -36,0 +68,0 @@ var addEventListener = function(obj, evt, fnc) { |
@@ -237,3 +237,3 @@ var Component = function(componentName, absurd) { | ||
async.funcs[index] = {args: args, name: func}; | ||
return '<span data-absurd-async="' + index + '"></span>'; | ||
return '<script data-absurd-async="' + index + '"></script>'; | ||
}, | ||
@@ -250,3 +250,3 @@ child: function() { | ||
}}; | ||
return '<span data-absurd-async="' + index + '"></span>'; | ||
return '<script data-absurd-async="' + index + '"></script>'; | ||
} | ||
@@ -253,0 +253,0 @@ } |
@@ -65,4 +65,4 @@ describe("Testing components (nesting)", function() { | ||
tr: [ | ||
'<td class="team"><% this.name %></td>', | ||
'<td class="score">V</td>' | ||
'<td class="c1"><% this.name %></td>', | ||
'<td class="c2">test</td>' | ||
] | ||
@@ -76,3 +76,3 @@ }, | ||
html: { | ||
'table.kuusi-pelia': [ | ||
'table': [ | ||
'<% this.child("home") %>', | ||
@@ -87,3 +87,3 @@ '<% this.child("away") %>' | ||
}).populate({ callback: function(res) { | ||
// console.log(res.html.element.outerHTML); | ||
expect(res.html.element.outerHTML).toBe('<table><tr><td class="c1">AChild</td><td class="c2">test</td></tr><tr><td class="c1">BChild</td><td class="c2">test</td></tr></table>'); | ||
done(); | ||
@@ -95,24 +95,20 @@ }}); | ||
/* | ||
var Last6GamesTable = absurd.component("Last6GamesTable", { | ||
html: { | ||
tr: [ | ||
'<td class="team"><% this.name %></td>', | ||
'<td class="score"><span>H</span></td>', | ||
'<td class="score"><span>V</span></td>', | ||
'<td class="score"><span>V</span></td>', | ||
'<td class="score"><span>H</span></td>', | ||
'<td class="score"><span>V</span></td>', | ||
'<td class="score"><span>V</span></td>' | ||
] | ||
}, | ||
constructor: function(data) { | ||
this.name = data.name; | ||
}, | ||
populated: function(res) { | ||
console.log(res.html.element.outerHTML); | ||
} | ||
it("should compile tr tag", function(done) { | ||
absurd.component("Person", { | ||
name: "John", | ||
age: 42, | ||
html: { | ||
tr: [ | ||
'<td class="A"><% this.name %></td>', | ||
'<td class="B"><% this.age %></td>', | ||
] | ||
}, | ||
constructor: function() { | ||
this.populate({ callback: function(res) { | ||
expect(res.html.element.outerHTML).toBe('<tr><td class="A">John</td><td class="B">42</td></tr>'); | ||
done(); | ||
}}); | ||
} | ||
})(); | ||
}); | ||
*/ | ||
}); |
{ | ||
"name": "absurd", | ||
"version": "0.2.68", | ||
"version": "0.2.69", | ||
"homepage": "http://krasimir.github.io/absurd", | ||
@@ -5,0 +5,0 @@ "description": "CSS/HTML preprocessor. Check out krasimirtsonev.com/blog/article/AbsurdJS-fundamentals", |
649516
20187