diff --git a/block.js b/block.js index daa1a61..bc494d7 100644 --- a/block.js +++ b/block.js @@ -563,6 +563,22 @@ Block = function () { 'var $dataCallback = function (block, data, style) {\n\n' + $dataJS + '\n\n};' ); Block($type, $initCallback, $dataCallback); + } else if ($key.substring(0, 1) == '#') { + $reservedAttributes.push($key); + var $name = $key.substring(1); + var callbackJS = '' + if (Is.obj($blockdata[$key]) && Is.str($blockdata[$key]['__js'])) + $callbackJS = $blockdata[$key]['__js']; + eval( + '/* block.js auto-generated data binding\n' + + ' ("on-the-fly" data binding callback)\n' + + ' block type = ' + type + '\n' + + ' block marking = ' + marking + '\n' + + ' data name = ' + $name + '\n' + + '*/\n' + + 'var $callback = function (' + $name + ') {\n' + $callbackJS + '\n};' + ); + this.bind($name, $callback); } else if ($key.substring(0, 1) == '$') { $reservedAttributes.push($key); this.key($key.substring(1), $blockdata[$key]); @@ -630,8 +646,10 @@ Block = function () { element.style[$property] = $style[$property]; } for (var $key in dataBindings) { - if (dataBindings.hasOwnProperty($key) && $data.hasOwnProperty($key)) + if (dataBindings.hasOwnProperty($key) && $data.hasOwnProperty($key)) { + $reservedAttributes.push($key); dataBindings[$key]($data[$key], this); + } } for (var $key in $data) { if ($data.hasOwnProperty($key) && !Block.inArr($key, $reservedAttributes)) diff --git a/block.min.js b/block.min.js index 4d10949..dc221b1 100644 --- a/block.min.js +++ b/block.min.js @@ -6,4 +6,4 @@ License: MIT [https://github.com/anuvgupta/block.js/blob/v3/LICENSE.md] Copyright: (c) 2016 Anuv Gupta */ -var Block;Block=function(){var block,addblock,__addblock,element,events={},customEvents={},type=arguments[0],marking=arguments[1],parent,__parent,children={},__children={},keys={},blockdata={count:0},dataBindings={},mediaQueries={},resizeQuery;if(void 0!=marking&&null!=marking&&"function"==typeof marking)return Block.blocks[type]={},Block.blocks[type].create=arguments[1],void 0!=arguments[2]&&null!=arguments[2]&&"function"==typeof arguments[2]&&(Block.blocks[type].load=arguments[2]),!0;var Is=Block.is;if(Is.unset(type)&&(type="block"),1==marking)marking=type;else if(Is.unset(marking)||0==marking)do marking="_"+Math.floor(1e3*Math.random()+1).toString();while(Is.obj(children[marking]));if(block={block:!0,add:function(){var e=[].slice.call(arguments),t=null;if(Is.set(e[0])&&e[0].block!==!0){e.length>=3&&(t=e[2],e=e.slice(0,2));var n=Block.apply(Block,e)}else{e.length>=2&&(t=e[1],e=e.slice(0,1));var n=e[0]}return children[n.mark()]=n,n.parent(this),Is.obj(addblock)&&addblock.block?addblock.add(n,t):Is.str(t)&&Is.obj(children[t])&&children[t].block?element.insertBefore(n.node(),children[t].node()):element.appendChild(n.node()),this},__add:function(){var e=[].slice.call(arguments),t=null;if(Is.set(e[0])&&e[0].block!==!0){e.length>=3&&(t=e[2],e=e.slice(0,2));var n=Block.apply(Block,e)}else{e.length>=2&&(t=e[1],e=e.slice(0,1));var n=e[0]}return __children[n.mark()]=n,n.__parent(this),Is.obj(__addblock)&&__addblock.block?addblock.__add(n,t):Is.str(t)&&Is.obj(__children[t])&&__children[t].block?element.insertBefore(n.node(),__children[t].node()):element.appendChild(n.node()),this},setAdd:function(e){return Is.obj(e)&&e.block&&(addblock=e),this},__setAdd:function(e){return Is.obj(e)&&e.block&&(__addblock=e),this},remove:function(){return $marking=arguments[0],Is["null"]($marking)&&Is.undef($marking)&&Is["null"](parent)&&Is.undef(parent)?parent.remove(marking):Is.str($marking)&&!Is["null"](children[$marking])&&(Is.obj(addblock)&&addblock.block?addblock.node().removeChild(children[$marking].node()):element.removeChild(children[$marking].node()),delete children[$marking]),this},__remove:function(){return $marking=arguments[0],Is["null"]($marking)&&Is.undef($marking)&&Is["null"](__parent)&&Is.undef(__parent)?__parent.__remove(marking):Is.str($marking)&&!Is["null"](__children[$marking])&&(Is.obj(__addblock)&&__addblock.block?__addblock.node().removeChild(__children[$marking].node()):element.removeChild(__children[$marking].node()),delete __children[$marking]),this},empty:function(){for(var e in children)this.remove(e);return this},__empty:function(){for(var e in children)this.remove(e);return this},type:function(){var e=arguments[0];return Is.str(e)?(Is.set(Block.blocks[e])&&(type=e),this):type},"class":function(){return Is.str(arguments[0])?(element.className+=" "+arguments[0],this):element.className},id:function(){return Is.str(arguments[0])?(element.id=arguments[0],this):element.id},mark:function(){var e=arguments[0];return Is.str(e)?("css"==e?console.warn("[BLOCK] cannot mark as '"+e+"' (reserved)"):marking=e,this):marking},attribute:function(e){var t=arguments[1];return Is.str(t)?(element.setAttribute(e,t),this):element.getAttribute(e)},css:function(){var e=arguments[0];if(Is.obj(e))for(var t in e)e.hasOwnProperty(t)&&Is.str(e[t])&&(element.style[t]=e[t]);else{if(!Is.str(e)){var n={},r=element.style;for(var a in r)!r.hasOwnProperty(a)||""==r[a]||!isNaN(parseFloat(a))&&isFinite(a)||(n[a]=r[a]);return n}var s=arguments[1];if(!Is.str(s))return element.style[e];element.style[e]=s}return this},key:function(e){var t=arguments[1];if(Is.unset(t)){if(Is.str(e)||!Is.obj(e))return Is.unset(keys[e])?null:keys[e];for($subkey in e)e.hasOwnProperty($subkey)&&(keys[$subkey]=e[$subkey])}else keys[e]=t;return this},blockdata:function(e){return Is.unset(blockdata[e])?null:blockdata[e]},on:function(e,t){var n=this;if(Is.str(e))if(Is.func(t)){var r=function(e){e.detail;Is.unset(e.detail)?t(e,n,{}):t(e,n,e.detail)};if(Is.str(arguments[2])){var a=arguments[2],s=e+"_"+a;Is.obj(events[e])||(events[e]={}),events[e][a]=function(e){r(e)},element.addEventListener(s,events[e][a],!1),events[s]=function(t){var r=t.detail;Is.unset(t.detail)?n.on(e,a,{}):n.on(e,a,r)},element.addEventListener(e,events[s],!1)}else element.addEventListener(e,r,!1)}else{s=Is.str(t)?e+"_"+t:e;var i=arguments[arguments.length-1];if((Is.unset(i)||!Is.obj(i))&&(i={}),window.CustomEvent){var l=new CustomEvent(s,{detail:i,bubbles:!0,cancelable:!0});element.dispatchEvent(l)}else document.createEvent?(l=document.createEvent("Event"),l.initEvent(s,!0,!0,i),element.dispatchEvent(l)):document.createEventObject?(l=document.createEventObject(),l.eventType=s,l.detail=i,element.fireEvent("on"+s,l),console.warn("Event bubbling and data not fully supported")):console.warn("Events not fully supported")}return this},off:function(e,t){var n=events[e+"_"+t],r=null;return Is.set(events[e])&&(r=events[e][t]),Is.func(n)&&(events[e+"_"+t]=null,element.removeEventListener(e,n)),Is.func(r)&&(events[e][t]=null,element.removeEventListener(e+"_"+t,r)),this},child:function(e){if(Is.str(e)){if(!e.includes("/"))return Is.set(children[e])?children[e]:null;var t=e.substring(0,e.indexOf("/"));if(Is.set(children[t]))return children[t].child(e.substring(e.indexOf("/")+1))}return null},children:function(){return children},childCount:function(){var e=0;for(var t in children)e++;return e},__child:function(e){return Is.str(e)?e.includes("/")?__children[e.substring(0,e.indexOf("/"))].__child(e.substring(e.indexOf("/")+1)):Is.set(__children[e])?__children[e]:null:null},__children:function(){return __children},__childCount:function(){var e=0;for(var t in __children)e++;return e},sibling:function(e){return null!=parent&&void 0!=parent?parent.child(e):null},siblings:function(){return null!=parent&&void 0!=parent?parent.children():null},siblingCount:function(){return null!=parent&&void 0!=parent?parent.childCount():null},__sibling:function(e){return null!=__parent&&void 0!=__parent?__parent.__child(e):null},__siblings:function(){return null!=__parent&&void 0!=__parent?__parent.__children():null},__siblingCount:function(){return null!=__parent&&void 0!=__parent?__parent.__childCount():null},parent:function(){var e=arguments[0];return Is.obj(e)&&e.block&&Is.unset(parent)?(parent=e,this):Is["int"](e)&&Is.set(e)?0==e?parent:parent.parent(e-1):Is.unset(parent)?null:parent},__parent:function(){var e=arguments[0];return Is.obj(e)&&e.block&&Is.unset(__parent)?(__parent=e,this):Is["int"](e)&&Is.set(__parent)?0==e?__parent:__parent.__parent(e-1):Is.unset(__parent)?null:__parent},html:function(){var e=arguments[0],t=arguments[1];return Is.str(e)?(Is.set(t)&&t===!0?element.innerHTML+=e:element.innerHTML=e,this):element.innerHTML},node:function(){return element},fill:function(e){return Is.obj(e)&&e.block?(e.empty(),e=e.node()):Is.str(e)&&(e=document.querySelector(e)),Is.elem(e)&&(e.innerHTML="",e.appendChild(element)),this},jQuery:function(){if(Block.jQuery){var e=this;return jQuery.extend(jQuery(element),{block:function(){return e}})}return console.warn("jQuery not detected"),null},$:function(){return this.jQuery()},query:function(e,t){if(Is.str(e)){var n;if(Is.func(t))n=t.toString().match(/function[^{]+\{([\s\S]*)\}$/)[1];else{if(!Is.str(t))return this;n=t}var r=e,a=r.substring(r.search(/ /)+1),s=a.substring(a.search(/ /)+1),i=r.substring(0,r.search(/ /)).trim(),l=a.substring(0,a.search(/ /)).trim(),o=s.trim();"window"==i&&("height"==l?l="innerHeight":"width"==l&&(l="innerWidth"));var n="if ("+i+"."+l+" "+o+") { "+n+" }";Is.obj(mediaQueries[i])?Is.arr(mediaQueries[i][l])||(mediaQueries[i][l]=[]):(mediaQueries[i]={},mediaQueries[i][l]=[]),mediaQueries[i][l].unshift(n)}else resizeQuery(new CustomEvent(marking+"_query_"+Math.floor(Date.now()/1e3).toString()));return this},data:function($blockdata){var $data={},$style={},$reservedAttributes=[];if(Is.obj($blockdata)){if($reservedAttributes.push("__keys"),Is.arr($blockdata.__keys))var $iterableKeys=$blockdata.__keys;else var $iterableKeys=Object.keys($blockdata);for(var $j=0;$j<$iterableKeys.length;$j++){var $key=$iterableKeys[$j];if($blockdata.hasOwnProperty($key)){var $midspace=$key.search(/ /);if("css"==$key)$style=$blockdata.css,$reservedAttributes.push("css");else if("__js"==$key)eval("/* block.js auto-generated JS clause\n (temporary event callback)\n block type = "+type+"\n block marking = "+marking+"\n*/\nvar $callback = function (event, block, data) {\n\n"+$blockdata.__js+"\n\n};"),this.on("__temp_event",$callback,"__rand"),this.on("__temp_event","__rand"),this.off("__temp_event","__rand"),$reservedAttributes.push("__js");else if(":"==$key.substring(0,1)){$reservedAttributes.push($key);var $dataToLoad=$blockdata[$key],$eventTypes=$key.substring(1),$eventCallback="";Is.str($dataToLoad.__js)&&($eventCallback+=$dataToLoad.__js,delete $dataToLoad.__js),Is.set($dataToLoad)&&($dataToLoad=JSON.stringify($dataToLoad),$eventCallback+=Is.str(arguments[1])?" block.data("+$dataToLoad+', "'+arguments[1]+'");':" block.data("+$dataToLoad+");"),eval("/* block.js auto-generated event listener\n (event listener callback)\n block type = "+type+"\n block marking = "+marking+"\n events = "+$eventTypes+"\n*/\nvar $callback = function (event, block, data) {\n\n"+$eventCallback+"\n\n};"),$eventTypes=$eventTypes.split(","),$eventTypes.forEach(function(e){this.on(e.trim(),$callback)},this)}else if("@"==$key.substring(0,1)){if($reservedAttributes.push($key),$key.length>6&&"query"==$key.substring(1,6)){$dataToLoad=$blockdata[$key];var $callbackJS="";Is.str($dataToLoad.__js)&&($callbackJS+=$dataToLoad.__js,delete $dataToLoad.__js),Is.set($dataToLoad)&&($dataToLoad=JSON.stringify($dataToLoad),$callbackJS+=Is.str(arguments[1])?" block.data("+$dataToLoad+', "'+arguments[1]+'");':" block.data("+$dataToLoad+");");var $query=$key.substring(7);this.query($query,$callbackJS)}}else if("!"==$key.substring(0,1)){$reservedAttributes.push($key);var $type=$key.substring(1),$initJS="",$callbacks=$blockdata[$key];Is.obj($callbacks.init)&&Is.str($callbacks.init.__js)&&($initJS=$callbacks.init.__js),eval("/* block.js auto-generated custom block initialization\n (initialization callback)\n custom block type = "+$type+"\n*/\nvar $initCallback = function () {\n\n"+$initJS+"\n\n};");var $dataJS="";Is.obj($callbacks.load)&&Is.str($callbacks.load.__js)&&($dataJS=$callbacks.load.__js),eval("/* block.js auto-generated custom block data loading\n (data loading callback)\n custom block type = "+$type+"\n*/\nvar $dataCallback = function (block, data, style) {\n\n"+$dataJS+"\n\n};"),Block($type,$initCallback,$dataCallback)}else if("$"==$key.substring(0,1))$reservedAttributes.push($key),this.key($key.substring(1),$blockdata[$key]);else if($midspace>0){var $childtype=$key.substring(0,$midspace),$childmarking=$key.substring($midspace+1),$childblock=Block($childtype,$childmarking);Is.obj($blockdata[$key])&&(Is.str(arguments[1])?$childblock.data($blockdata[$key],arguments[1]):$childblock.data($blockdata[$key]),$reservedAttributes.push($key)),this.add($childblock,Is.set($iterableKeys[$j+1])?$iterableKeys[$j+1]:null),$reservedAttributes.push($key)}else Is.obj($blockdata[$key])&&Is.obj(children[$key])?(Is.str(arguments[1])?children[$key].data($blockdata[$key],arguments[1]):children[$key].data($blockdata[$key]),$reservedAttributes.push($key)):(Is.obj($blockdata[$key])&&$reservedAttributes.push($key),$data[$key]=$blockdata[$key])}}}else if(Is.str($blockdata)||Is["int"]($blockdata))$data={val:$blockdata};else{if(!Is["null"]($blockdata)&&Is.obj($blockdata))return this;$data={}}if("block"!=type&&Is.set(Block.blocks[type])){var $getData=function(e,t){var n;return"this"==e?n=$data:Is.unset($data[e])?n=null:($reservedAttributes.push(e),n=$data[e]),Is.func(t)&&Is.set(n)&&t(n),n},$getStyle=function(e,t){var n;return n="this"==e?$style:Is.unset($style[e])?null:$style[e],Is.func(t,"function")&&Is.set(n)&&t(n),n};Block.blocks[type].load(this,$getData,$getStyle)}for(var $property in $style)$style.hasOwnProperty($property)&&(element.style[$property]=$style[$property]);for(var $key in dataBindings)dataBindings.hasOwnProperty($key)&&$data.hasOwnProperty($key)&&dataBindings[$key]($data[$key],this);for(var $key in $data)$data.hasOwnProperty($key)&&!Block.inArr($key,$reservedAttributes)&&element.setAttribute($key,$data[$key]);return blockdata.count++,blockdata[Is.str(arguments[1])?arguments[1]:"#"+blockdata.count]={data:$data,css:$style},this},bind:function(e,t){return Is.str(e)&&Is.func(t)&&(dataBindings[e]=t),this},parse:function(e,t){t=t.replace(/\r\n|\r|\n/g,"\n");var n=t.substring(0,t.indexOf("*")),r=Block.parse(t.substring(t.indexOf("*")+2),n);if(arguments[arguments.length-1]===!0)return r;var a={};for(var s in r)r.hasOwnProperty(s)&&s!=marking&&(a[s]=r[s]);return Block("u").data(a),Is.str(arguments[2])?this.data(r[marking],arguments[2]):this.data(r[marking]),Is.func(e)&&e(this),this},load:function(e,t){var n=this,r=function(e,r){n.parse.apply(n,[e,r,t])},a=arguments[2],s=arguments[3];if((null==s||void 0==s)&&(s=!0),Is.str(a)&&"jquery"===a.toLowerCase())Block.jQuery?jQuery.ajax({url:t+".block",type:"GET",async:s,success:function(t){r(e,t)}}):console.warn("jQuery not detected");else if(a===!0){var i;window.XMLHttpRequest?i=new XMLHttpRequest:window.ActiveXObject?i=new ActiveXObject("Microsoft.XMLHTTP"):console.warn("XHR (XMLHttpRequest) not supported"),i.onreadystatechange=function(){4==i.readyState&&200==i.status&&r(e,i.responseText)},i.open("GET",t+".block",s),i.send()}else r(e,customBlockData[t]);return this}},"block"==type){element=Block.node("div"),block.css({width:"100%",height:"100%",display:"table",textAlign:"center"});var content=Block("div").mark("content").css({display:"table-cell",textAlign:"center",verticalAlign:"middle",margin:"0 auto"});block.setAdd(content).__add(content)}else null!=Block.blocks[type]?block=Block.blocks[type].create().type(type).mark(marking):element=Block.node(type);return block.attribute("block",marking),resizeQuery=function($e){var $callback="";for(var $objectName in mediaQueries)if(mediaQueries.hasOwnProperty($objectName)){var $object=mediaQueries[$objectName];for(var $propertyName in $object)if($object.hasOwnProperty($propertyName)){var $property=$object[$propertyName];for(var $i in $property)$callback+=0==$i?" "+$property[$i]:" else "+$property[$i]}}eval("/* block.js auto-generated media query\n (window resize event callback)\n block type = "+type+"\n block marking = "+marking+"\n*/\n$callback = function (event, block, data) {\n\n"+$callback+"\n\n};"),Is.unset($e.detail)?$callback($e,block,{}):$callback($e,block,$e.detail)},window.addEventListener("blockjs_query",resizeQuery),block},Block.is={"null":function(e){return null==e},eqnull:function(e){return null===e},undef:function(e){return void 0==e},set:function(e){return void 0!=e&&null!==e},unset:function(e){return void 0==e||null===e},str:function(e){return null!==e&&void 0!=e&&("string"==typeof e||e instanceof String)},func:function(e){return null!==e&&void 0!=e&&("function"==typeof e||e instanceof Function)},node:function(e){return null!==e&&void 0!=e&&("object"==typeof e||e instanceof Object)&&e instanceof Node},elem:function(e){return null!==e&&void 0!=e&&("object"==typeof e||e instanceof Object)&&e instanceof Node&&e instanceof Element},arr:function(e){return null!==e&&void 0!=e&&("array"==typeof e||e instanceof Array)},obj:function(e){return null!==e&&void 0!=e&&("object"==typeof e||e instanceof Object)},"int":function(e){return null!==e&&void 0!=e&&e===parseInt(e,10)&&!isNaN(e)},type:function(e,t){return typeof e==t}},Block.node=function(e){return document.createElement(e)},Block.inArr=function(e,t){return t.indexOf(e)>-1},Block.set=function(e,t,n){return 1==t.length?(e[t[0]]=n,e):t.length>1?Block.set(e[t[0]],t.slice(1),n):void 0},Block.get=function(e,t){return 1==t.length?e[t[0]]:t.length>1?Block.get(e[t[0]],t.slice(1)):void 0},Block.parse=function(e,t){for(var n={},r=[],a=e.split("\n"),s=0;s=3&&(t=e[2],e=e.slice(0,2));var n=Block.apply(Block,e)}else{e.length>=2&&(t=e[1],e=e.slice(0,1));var n=e[0]}return children[n.mark()]=n,n.parent(this),Is.obj(addblock)&&addblock.block?addblock.add(n,t):Is.str(t)&&Is.obj(children[t])&&children[t].block?element.insertBefore(n.node(),children[t].node()):element.appendChild(n.node()),this},__add:function(){var e=[].slice.call(arguments),t=null;if(Is.set(e[0])&&e[0].block!==!0){e.length>=3&&(t=e[2],e=e.slice(0,2));var n=Block.apply(Block,e)}else{e.length>=2&&(t=e[1],e=e.slice(0,1));var n=e[0]}return __children[n.mark()]=n,n.__parent(this),Is.obj(__addblock)&&__addblock.block?addblock.__add(n,t):Is.str(t)&&Is.obj(__children[t])&&__children[t].block?element.insertBefore(n.node(),__children[t].node()):element.appendChild(n.node()),this},setAdd:function(e){return Is.obj(e)&&e.block&&(addblock=e),this},__setAdd:function(e){return Is.obj(e)&&e.block&&(__addblock=e),this},remove:function(){return $marking=arguments[0],Is["null"]($marking)&&Is.undef($marking)&&Is["null"](parent)&&Is.undef(parent)?parent.remove(marking):Is.str($marking)&&!Is["null"](children[$marking])&&(Is.obj(addblock)&&addblock.block?addblock.node().removeChild(children[$marking].node()):element.removeChild(children[$marking].node()),delete children[$marking]),this},__remove:function(){return $marking=arguments[0],Is["null"]($marking)&&Is.undef($marking)&&Is["null"](__parent)&&Is.undef(__parent)?__parent.__remove(marking):Is.str($marking)&&!Is["null"](__children[$marking])&&(Is.obj(__addblock)&&__addblock.block?__addblock.node().removeChild(__children[$marking].node()):element.removeChild(__children[$marking].node()),delete __children[$marking]),this},empty:function(){for(var e in children)this.remove(e);return this},__empty:function(){for(var e in children)this.remove(e);return this},type:function(){var e=arguments[0];return Is.str(e)?(Is.set(Block.blocks[e])&&(type=e),this):type},"class":function(){return Is.str(arguments[0])?(element.className+=" "+arguments[0],this):element.className},id:function(){return Is.str(arguments[0])?(element.id=arguments[0],this):element.id},mark:function(){var e=arguments[0];return Is.str(e)?("css"==e?console.warn("[BLOCK] cannot mark as '"+e+"' (reserved)"):marking=e,this):marking},attribute:function(e){var t=arguments[1];return Is.str(t)?(element.setAttribute(e,t),this):element.getAttribute(e)},css:function(){var e=arguments[0];if(Is.obj(e))for(var t in e)e.hasOwnProperty(t)&&Is.str(e[t])&&(element.style[t]=e[t]);else{if(!Is.str(e)){var n={},r=element.style;for(var a in r)!r.hasOwnProperty(a)||""==r[a]||!isNaN(parseFloat(a))&&isFinite(a)||(n[a]=r[a]);return n}var s=arguments[1];if(!Is.str(s))return element.style[e];element.style[e]=s}return this},key:function(e){var t=arguments[1];if(Is.unset(t)){if(Is.str(e)||!Is.obj(e))return Is.unset(keys[e])?null:keys[e];for($subkey in e)e.hasOwnProperty($subkey)&&(keys[$subkey]=e[$subkey])}else keys[e]=t;return this},blockdata:function(e){return Is.unset(blockdata[e])?null:blockdata[e]},on:function(e,t){var n=this;if(Is.str(e))if(Is.func(t)){var r=function(e){e.detail;Is.unset(e.detail)?t(e,n,{}):t(e,n,e.detail)};if(Is.str(arguments[2])){var a=arguments[2],s=e+"_"+a;Is.obj(events[e])||(events[e]={}),events[e][a]=function(e){r(e)},element.addEventListener(s,events[e][a],!1),events[s]=function(t){var r=t.detail;Is.unset(t.detail)?n.on(e,a,{}):n.on(e,a,r)},element.addEventListener(e,events[s],!1)}else element.addEventListener(e,r,!1)}else{s=Is.str(t)?e+"_"+t:e;var l=arguments[arguments.length-1];if((Is.unset(l)||!Is.obj(l))&&(l={}),window.CustomEvent){var i=new CustomEvent(s,{detail:l,bubbles:!0,cancelable:!0});element.dispatchEvent(i)}else document.createEvent?(i=document.createEvent("Event"),i.initEvent(s,!0,!0,l),element.dispatchEvent(i)):document.createEventObject?(i=document.createEventObject(),i.eventType=s,i.detail=l,element.fireEvent("on"+s,i),console.warn("Event bubbling and data not fully supported")):console.warn("Events not fully supported")}return this},off:function(e,t){var n=events[e+"_"+t],r=null;return Is.set(events[e])&&(r=events[e][t]),Is.func(n)&&(events[e+"_"+t]=null,element.removeEventListener(e,n)),Is.func(r)&&(events[e][t]=null,element.removeEventListener(e+"_"+t,r)),this},child:function(e){if(Is.str(e)){if(!e.includes("/"))return Is.set(children[e])?children[e]:null;var t=e.substring(0,e.indexOf("/"));if(Is.set(children[t]))return children[t].child(e.substring(e.indexOf("/")+1))}return null},children:function(){return children},childCount:function(){var e=0;for(var t in children)e++;return e},__child:function(e){return Is.str(e)?e.includes("/")?__children[e.substring(0,e.indexOf("/"))].__child(e.substring(e.indexOf("/")+1)):Is.set(__children[e])?__children[e]:null:null},__children:function(){return __children},__childCount:function(){var e=0;for(var t in __children)e++;return e},sibling:function(e){return null!=parent&&void 0!=parent?parent.child(e):null},siblings:function(){return null!=parent&&void 0!=parent?parent.children():null},siblingCount:function(){return null!=parent&&void 0!=parent?parent.childCount():null},__sibling:function(e){return null!=__parent&&void 0!=__parent?__parent.__child(e):null},__siblings:function(){return null!=__parent&&void 0!=__parent?__parent.__children():null},__siblingCount:function(){return null!=__parent&&void 0!=__parent?__parent.__childCount():null},parent:function(){var e=arguments[0];return Is.obj(e)&&e.block&&Is.unset(parent)?(parent=e,this):Is["int"](e)&&Is.set(e)?0==e?parent:parent.parent(e-1):Is.unset(parent)?null:parent},__parent:function(){var e=arguments[0];return Is.obj(e)&&e.block&&Is.unset(__parent)?(__parent=e,this):Is["int"](e)&&Is.set(__parent)?0==e?__parent:__parent.__parent(e-1):Is.unset(__parent)?null:__parent},html:function(){var e=arguments[0],t=arguments[1];return Is.str(e)?(Is.set(t)&&t===!0?element.innerHTML+=e:element.innerHTML=e,this):element.innerHTML},node:function(){return element},fill:function(e){return Is.obj(e)&&e.block?(e.empty(),e=e.node()):Is.str(e)&&(e=document.querySelector(e)),Is.elem(e)&&(e.innerHTML="",e.appendChild(element)),this},jQuery:function(){if(Block.jQuery){var e=this;return jQuery.extend(jQuery(element),{block:function(){return e}})}return console.warn("jQuery not detected"),null},$:function(){return this.jQuery()},query:function(e,t){if(Is.str(e)){var n;if(Is.func(t))n=t.toString().match(/function[^{]+\{([\s\S]*)\}$/)[1];else{if(!Is.str(t))return this;n=t}var r=e,a=r.substring(r.search(/ /)+1),s=a.substring(a.search(/ /)+1),l=r.substring(0,r.search(/ /)).trim(),i=a.substring(0,a.search(/ /)).trim(),o=s.trim();"window"==l&&("height"==i?i="innerHeight":"width"==i&&(i="innerWidth"));var n="if ("+l+"."+i+" "+o+") { "+n+" }";Is.obj(mediaQueries[l])?Is.arr(mediaQueries[l][i])||(mediaQueries[l][i]=[]):(mediaQueries[l]={},mediaQueries[l][i]=[]),mediaQueries[l][i].unshift(n)}else resizeQuery(new CustomEvent(marking+"_query_"+Math.floor(Date.now()/1e3).toString()));return this},data:function($blockdata){var $data={},$style={},$reservedAttributes=[];if(Is.obj($blockdata)){if($reservedAttributes.push("__keys"),Is.arr($blockdata.__keys))var $iterableKeys=$blockdata.__keys;else var $iterableKeys=Object.keys($blockdata);for(var $j=0;$j<$iterableKeys.length;$j++){var $key=$iterableKeys[$j];if($blockdata.hasOwnProperty($key)){var $midspace=$key.search(/ /);if("css"==$key)$style=$blockdata.css,$reservedAttributes.push("css");else if("__js"==$key)eval("/* block.js auto-generated JS clause\n (temporary event callback)\n block type = "+type+"\n block marking = "+marking+"\n*/\nvar $callback = function (event, block, data) {\n\n"+$blockdata.__js+"\n\n};"),this.on("__temp_event",$callback,"__rand"),this.on("__temp_event","__rand"),this.off("__temp_event","__rand"),$reservedAttributes.push("__js");else if(":"==$key.substring(0,1)){$reservedAttributes.push($key);var $dataToLoad=$blockdata[$key],$eventTypes=$key.substring(1),$eventCallback="";Is.str($dataToLoad.__js)&&($eventCallback+=$dataToLoad.__js,delete $dataToLoad.__js),Is.set($dataToLoad)&&($dataToLoad=JSON.stringify($dataToLoad),$eventCallback+=Is.str(arguments[1])?" block.data("+$dataToLoad+', "'+arguments[1]+'");':" block.data("+$dataToLoad+");"),eval("/* block.js auto-generated event listener\n (event listener callback)\n block type = "+type+"\n block marking = "+marking+"\n events = "+$eventTypes+"\n*/\nvar $callback = function (event, block, data) {\n\n"+$eventCallback+"\n\n};"),$eventTypes=$eventTypes.split(","),$eventTypes.forEach(function(e){this.on(e.trim(),$callback)},this)}else if("@"==$key.substring(0,1)){if($reservedAttributes.push($key),$key.length>6&&"query"==$key.substring(1,6)){$dataToLoad=$blockdata[$key];var $callbackJS="";Is.str($dataToLoad.__js)&&($callbackJS+=$dataToLoad.__js,delete $dataToLoad.__js),Is.set($dataToLoad)&&($dataToLoad=JSON.stringify($dataToLoad),$callbackJS+=Is.str(arguments[1])?" block.data("+$dataToLoad+', "'+arguments[1]+'");':" block.data("+$dataToLoad+");");var $query=$key.substring(7);this.query($query,$callbackJS)}}else if("!"==$key.substring(0,1)){$reservedAttributes.push($key);var $type=$key.substring(1),$initJS="",$callbacks=$blockdata[$key];Is.obj($callbacks.init)&&Is.str($callbacks.init.__js)&&($initJS=$callbacks.init.__js),eval("/* block.js auto-generated custom block initialization\n (initialization callback)\n custom block type = "+$type+"\n*/\nvar $initCallback = function () {\n\n"+$initJS+"\n\n};");var $dataJS="";Is.obj($callbacks.load)&&Is.str($callbacks.load.__js)&&($dataJS=$callbacks.load.__js),eval("/* block.js auto-generated custom block data loading\n (data loading callback)\n custom block type = "+$type+"\n*/\nvar $dataCallback = function (block, data, style) {\n\n"+$dataJS+"\n\n};"),Block($type,$initCallback,$dataCallback)}else if("#"==$key.substring(0,1)){$reservedAttributes.push($key);var $name=$key.substring(1),callbackJS="";Is.obj($blockdata[$key])&&Is.str($blockdata[$key].__js)&&($callbackJS=$blockdata[$key].__js),eval('/* block.js auto-generated data binding\n ("on-the-fly" data binding callback)\n block type = '+type+"\n block marking = "+marking+"\n data name = "+$name+"\n*/\nvar $callback = function ("+$name+") {\n"+$callbackJS+"\n};"),this.bind($name,$callback)}else if("$"==$key.substring(0,1))$reservedAttributes.push($key),this.key($key.substring(1),$blockdata[$key]);else if($midspace>0){var $childtype=$key.substring(0,$midspace),$childmarking=$key.substring($midspace+1),$childblock=Block($childtype,$childmarking);Is.obj($blockdata[$key])&&(Is.str(arguments[1])?$childblock.data($blockdata[$key],arguments[1]):$childblock.data($blockdata[$key]),$reservedAttributes.push($key)),this.add($childblock,Is.set($iterableKeys[$j+1])?$iterableKeys[$j+1]:null),$reservedAttributes.push($key)}else Is.obj($blockdata[$key])&&Is.obj(children[$key])?(Is.str(arguments[1])?children[$key].data($blockdata[$key],arguments[1]):children[$key].data($blockdata[$key]),$reservedAttributes.push($key)):(Is.obj($blockdata[$key])&&$reservedAttributes.push($key),$data[$key]=$blockdata[$key])}}}else if(Is.str($blockdata)||Is["int"]($blockdata))$data={val:$blockdata};else{if(!Is["null"]($blockdata)&&Is.obj($blockdata))return this;$data={}}if("block"!=type&&Is.set(Block.blocks[type])){var $getData=function(e,t){var n;return"this"==e?n=$data:Is.unset($data[e])?n=null:($reservedAttributes.push(e),n=$data[e]),Is.func(t)&&Is.set(n)&&t(n),n},$getStyle=function(e,t){var n;return n="this"==e?$style:Is.unset($style[e])?null:$style[e],Is.func(t,"function")&&Is.set(n)&&t(n),n};Block.blocks[type].load(this,$getData,$getStyle)}for(var $property in $style)$style.hasOwnProperty($property)&&(element.style[$property]=$style[$property]);for(var $key in dataBindings)dataBindings.hasOwnProperty($key)&&$data.hasOwnProperty($key)&&($reservedAttributes.push($key),dataBindings[$key]($data[$key],this));for(var $key in $data)$data.hasOwnProperty($key)&&!Block.inArr($key,$reservedAttributes)&&element.setAttribute($key,$data[$key]);return blockdata.count++,blockdata[Is.str(arguments[1])?arguments[1]:"#"+blockdata.count]={data:$data,css:$style},this},bind:function(e,t){return Is.str(e)&&Is.func(t)&&(dataBindings[e]=t),this},parse:function(e,t){t=t.replace(/\r\n|\r|\n/g,"\n");var n=t.substring(0,t.indexOf("*")),r=Block.parse(t.substring(t.indexOf("*")+2),n);if(arguments[arguments.length-1]===!0)return r;var a={};for(var s in r)r.hasOwnProperty(s)&&s!=marking&&(a[s]=r[s]);return Block("u").data(a),Is.str(arguments[2])?this.data(r[marking],arguments[2]):this.data(r[marking]),Is.func(e)&&e(this),this},load:function(e,t){var n=this,r=function(e,r){n.parse.apply(n,[e,r,t])},a=arguments[2],s=arguments[3];if((null==s||void 0==s)&&(s=!0),Is.str(a)&&"jquery"===a.toLowerCase())Block.jQuery?jQuery.ajax({url:t+".block",type:"GET",async:s,success:function(t){r(e,t)}}):console.warn("jQuery not detected");else if(a===!0){var l;window.XMLHttpRequest?l=new XMLHttpRequest:window.ActiveXObject?l=new ActiveXObject("Microsoft.XMLHTTP"):console.warn("XHR (XMLHttpRequest) not supported"),l.onreadystatechange=function(){4==l.readyState&&200==l.status&&r(e,l.responseText)},l.open("GET",t+".block",s),l.send()}else r(e,customBlockData[t]);return this}},"block"==type){element=Block.node("div"),block.css({width:"100%",height:"100%",display:"table",textAlign:"center"});var content=Block("div").mark("content").css({display:"table-cell",textAlign:"center",verticalAlign:"middle",margin:"0 auto"});block.setAdd(content).__add(content)}else null!=Block.blocks[type]?block=Block.blocks[type].create().type(type).mark(marking):element=Block.node(type);return block.attribute("block",marking),resizeQuery=function($e){var $callback="";for(var $objectName in mediaQueries)if(mediaQueries.hasOwnProperty($objectName)){var $object=mediaQueries[$objectName];for(var $propertyName in $object)if($object.hasOwnProperty($propertyName)){var $property=$object[$propertyName];for(var $i in $property)$callback+=0==$i?" "+$property[$i]:" else "+$property[$i]}}eval("/* block.js auto-generated media query\n (window resize event callback)\n block type = "+type+"\n block marking = "+marking+"\n*/\n$callback = function (event, block, data) {\n\n"+$callback+"\n\n};"),Is.unset($e.detail)?$callback($e,block,{}):$callback($e,block,$e.detail)},window.addEventListener("blockjs_query",resizeQuery),block},Block.is={"null":function(e){return null==e},eqnull:function(e){return null===e},undef:function(e){return void 0==e},set:function(e){return void 0!=e&&null!==e},unset:function(e){return void 0==e||null===e},str:function(e){return null!==e&&void 0!=e&&("string"==typeof e||e instanceof String)},func:function(e){return null!==e&&void 0!=e&&("function"==typeof e||e instanceof Function)},node:function(e){return null!==e&&void 0!=e&&("object"==typeof e||e instanceof Object)&&e instanceof Node},elem:function(e){return null!==e&&void 0!=e&&("object"==typeof e||e instanceof Object)&&e instanceof Node&&e instanceof Element},arr:function(e){return null!==e&&void 0!=e&&("array"==typeof e||e instanceof Array)},obj:function(e){return null!==e&&void 0!=e&&("object"==typeof e||e instanceof Object)},"int":function(e){return null!==e&&void 0!=e&&e===parseInt(e,10)&&!isNaN(e)},type:function(e,t){return typeof e==t}},Block.node=function(e){return document.createElement(e)},Block.inArr=function(e,t){return t.indexOf(e)>-1},Block.set=function(e,t,n){return 1==t.length?(e[t[0]]=n,e):t.length>1?Block.set(e[t[0]],t.slice(1),n):void 0},Block.get=function(e,t){return 1==t.length?e[t[0]]:t.length>1?Block.get(e[t[0]],t.slice(1)):void 0},Block.parse=function(e,t){for(var n={},r=[],a=e.split("\n"),s=0;s