imba-source 0.14.3.1 → 0.14.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,4152 @@
1
- !function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){!function(){return"undefined"==typeof Imba?(n(1),n(2),n(3),n(4),n(5),n(6),n(7),n(8),n(9),n(10),n(11)):console.warn("Imba v"+Imba.VERSION+" is already loaded")}()},function(t,e,n){(function(t){!function(){"undefined"!=typeof window&&(t=window);var e="object"==typeof window&&this==window;Imba={VERSION:"0.14.3",CLIENT:e,SERVER:!e,DEBUG:!1};var n=/-./g;return Imba.isClient=function(){return!0},Imba.isServer=function(){return!1},Imba.subclass=function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t.prototype=Object.create(e.prototype),t.__super__=t.prototype.__super__=e.prototype,t.prototype.initialize=t.prototype.constructor=t,t},Imba.iterable=function(t){return t?t.toArray?t.toArray():t:[]},Imba.await=function(t){return t instanceof Array?Promise.all(t):t&&t.then?t:Promise.resolve(t)},Imba.toCamelCase=function(t){return t.replace(n,function(t){return t.charAt(1).toUpperCase()})},Imba.toCamelCase=function(t){return t.replace(n,function(t){return t.charAt(1).toUpperCase()})},Imba.indexOf=function(t,e){return e&&e.indexOf?e.indexOf(t):[].indexOf.call(t,e)},Imba.prop=function(t,e,n){return t.defineProperty?t.defineProperty(e,n):void 0},Imba.attr=function(t,e,n){if(t.defineAttribute)return t.defineAttribute(e,n);var r=Imba.toCamelCase(e),i=Imba.toCamelCase("set-"+e);t.prototype[r]=function(){return this.getAttribute(e)},t.prototype[i]=function(t){return this.setAttribute(e,t),this}}}()}).call(e,function(){return this}())},function(t,e){!function(){function t(t,e,n){for(var r,i,o;(r=n)&&(n=n.next);)(i=n.listener)&&(o=n.path&&i[n.path]?e?i[n.path].apply(i,e):i[n.path]():e?i.apply(n,e):i.call(n)),n.times&&--n.times<=0&&(r.next=n.next,n.listener=null)}return Imba.listen=function(t,e,n,r){var i,o,s,a;return o=t.__listeners__||(t.__listeners__={}),s=o[i=e]||(o[i]={}),a=s.tail||(s.tail=s.next={}),a.listener=n,a.path=r,s.tail=a.next={},a},Imba.once=function(t,e,n){var r=Imba.listen(t,e,n);return r.times=1,r},Imba.unlisten=function(t,e,n,r){var i,o,s=t.__listeners__;if(s&&(i=s[e]))for(;(o=i)&&(i=i.next);)if(i==n||i.listener==n){o.next=i.next,i.listener=null;break}},Imba.emit=function(e,n,r){var i;(i=e.__listeners__)&&(i[n]&&t(n,r,i[n]),i.all&&t(n,[n,r],i.all))},Imba.observeProperty=function(t,e,n,r,i){return i&&"object"==typeof i&&Imba.unlisten(i,"all",t,n),r&&"object"==typeof r&&Imba.listen(r,"all",t,n),this}}()},function(t,e){(function(t){!function(){function e(t,e){return e&&e.indexOf?e.indexOf(t):[].indexOf.call(t,e)}var n;return n||(n=t.requestAnimationFrame),n||(n=t.webkitRequestAnimationFrame),n||(n=t.mozRequestAnimationFrame),n||(n=function(t){return setTimeout(t,1e3/60)}),Imba.tick=function(t){this._scheduled&&n(Imba.ticker()),Imba.Scheduler.willRun(),this.emit(this,"tick",[t]),Imba.Scheduler.didRun()},Imba.ticker=function(){var t=this;return t._ticker||(t._ticker=function(e){return t.tick(e)})},Imba.schedule=function(t,e){return void 0===e&&(e="tick"),this.listen(this,"tick",t,e),this._scheduled||(this._scheduled=!0,n(Imba.ticker())),this},Imba.unschedule=function(t,e){this.unlisten(this,"tick",t,e);var n=this.__listeners__||(this.__listeners__={});return n.tick&&n.tick.next&&n.tick.next.listener||(this._scheduled=!1),this},Imba.setTimeout=function(t,e){return setTimeout(function(){return e(),Imba.Scheduler.markDirty()},t)},Imba.setInterval=function(t,e){return setInterval(function(){return e(),Imba.Scheduler.markDirty()},t)},Imba.clearInterval=function(t){return clearInterval(t)},Imba.clearTimeout=function(t){return clearTimeout(t)},Imba.Scheduler=function(t){var e=this;e._target=t,e._marked=!1,e._active=!1,e._marker=function(){return e.mark()},e._ticker=function(t){return e.tick(t)},e._events=!0,e._fps=1,e._dt=0,e._timestamp=0,e._ticks=0,e._flushes=0},Imba.Scheduler.markDirty=function(){return this._dirty=!0,this},Imba.Scheduler.isDirty=function(){return!!this._dirty},Imba.Scheduler.willRun=function(){return this._active=!0},Imba.Scheduler.didRun=function(){return this._active=!1,this._dirty=!1},Imba.Scheduler.isActive=function(){return!!this._active},Imba.Scheduler.prototype.active=function(){return this._active},Imba.Scheduler.prototype.dt=function(){return this._dt},Imba.Scheduler.prototype.configure=function(t){t&&t.constructor===Object||(t={});var e=void 0!==t.fps?t.fps:1,n=void 0!==t.events?t.events:!0;return null!=n&&(this._events=n),null!=e&&(this._fps=e),this},Imba.Scheduler.prototype.mark=function(){return this._marked=!0,this},Imba.Scheduler.prototype.flush=function(){return this._marked=!1,this._flushes++,this._target.tick(),this},Imba.Scheduler.prototype.tick=function(t){this._ticks++,this._dt=t;var e=this._fps;if(60==e)this._marked=!0;else if(30==e)this._ticks%2&&(this._marked=!0);else if(e){var n=60/e/60*1e3,r=Math.floor(Date.now()/n);this._beat!=r&&(this._beat=r,this._marked=!0)}return(this._marked||this._events&&Imba.Scheduler.isDirty())&&this.flush(),this},Imba.Scheduler.prototype.activate=function(){return this._active||(this._active=!0,this._commit=this._target.commit,this._target.commit=function(){return this},Imba.schedule(this),this._events&&Imba.listen(Imba,"event",this,"onevent"),this._target&&this._target.flag&&this._target.flag("scheduled_"),this.tick(0)),this},Imba.Scheduler.prototype.deactivate=function(){return this._active&&(this._active=!1,this._target.commit=this._commit,Imba.unschedule(this),Imba.unlisten(Imba,"event",this),this._target&&this._target.unflag&&this._target.unflag("scheduled_")),this},Imba.Scheduler.prototype.track=function(){return this._marker},Imba.Scheduler.prototype.onevent=function(t){var n;return this._marked?this:(this._events instanceof Function?this._events(t)&&this.mark():this._events instanceof Array?e((n=t)&&n.type&&n.type(),this._events)>=0&&this.mark():this._events&&t._responder&&this.mark(),this)},Imba.Scheduler}()}).call(e,function(){return this}())},function(t,e){!function(){function t(t,e){return e&&e.indexOf?e.indexOf(t):[].indexOf.call(t,e)}function e(t,e){for(var n=0,r=Object.keys(e),i=r.length;i>n;n++)null==t[$1=r[n]]?t[$1]=e[r[n]]:t[$1];return t.prototype=Object.create(e.prototype),t.__super__=t.prototype.__super__=e.prototype,t.prototype.initialize=t.prototype.constructor=t,e.inherit&&e.inherit(t),t}function n(){return function(t){return this.setDom(t),this}}function r(t){return function(){return t.build()}}Imba["static"]=function(t,e){return t["static"]=e,t},Imba.Tag=function(t){this.setDom(t)},Imba.Tag.createNode=function(){throw"Not implemented"},Imba.Tag.build=function(){return new this(this.createNode())},Imba.Tag.prototype.object=function(t){return this._object},Imba.Tag.prototype.setObject=function(t){return this._object=t,this},Imba.Tag.prototype.dom=function(){return this._dom},Imba.Tag.prototype.setDom=function(t){return t._tag=this,this._dom=t,this},Imba.Tag.prototype.setRef=function(t,e){return this.flag(this._ref=t),this},Imba.Tag.prototype.setHandler=function(t,e,n){var r="on"+t;if(e instanceof Function)this[r]=e;else if(e instanceof Array){var i=e.shift();this[r]=function(t){return n[i].apply(n,e.concat(t))}}else this[r]=function(t){return n[e](t)};return this},Imba.Tag.prototype.setId=function(t){return this.dom().id=t,this},Imba.Tag.prototype.id=function(){return this.dom().id},Imba.Tag.prototype.setAttribute=function(t,e){var n=this.dom().getAttribute(t);return n==e?e:null!=e&&e!==!1?this.dom().setAttribute(t,e):this.dom().removeAttribute(t)},Imba.Tag.prototype.removeAttribute=function(t){return this.dom().removeAttribute(t)},Imba.Tag.prototype.getAttribute=function(t){return this.dom().getAttribute(t)},Imba.Tag.prototype.setContent=function(t,e){return this.setChildren(t,e),this},Imba.Tag.prototype.setChildren=function(t,e){throw"Not implemented"},Imba.Tag.prototype.text=function(t){return this._dom.textContent},Imba.Tag.prototype.setText=function(t){return this._empty=!1,this._dom.textContent=null==t?t="":t,this},Imba.Tag.prototype.dataset=function(t,e){throw"Not implemented"},Imba.Tag.prototype.render=function(){return this},Imba.Tag.prototype.build=function(){return this.render(),this},Imba.Tag.prototype.commit=function(){return this.render(),this},Imba.Tag.prototype.tick=function(){return this.render(),this},Imba.Tag.prototype.end=function(){return this._built?this.commit():(this._built=!0,this.build()),this},Imba.Tag.prototype.synced=function(){return this},Imba.Tag.prototype.awaken=function(){return this},Imba.Tag.prototype.flags=function(){return this._dom.classList},Imba.Tag.prototype.flag=function(t,e){return 2!=arguments.length||e?this._dom.classList.add(t):this._dom.classList.remove(t),this},Imba.Tag.prototype.unflag=function(t){return this._dom.classList.remove(t),this},Imba.Tag.prototype.toggleFlag=function(t){return this._dom.classList.toggle(t),this},Imba.Tag.prototype.hasFlag=function(t){return this._dom.classList.contains(t)},Imba.Tag.prototype.scheduler=function(){return null==this._scheduler?this._scheduler=new Imba.Scheduler(this):this._scheduler},Imba.Tag.prototype.schedule=function(t){return void 0===t&&(t={}),this.scheduler().configure(t).activate(),this},Imba.Tag.prototype.unschedule=function(){return this._scheduler&&this.scheduler().deactivate(),this},Imba.Tag.prototype.parent=function(){return tag$wrap(this.dom().parentNode)},Imba.Tag.prototype.log=function(){for(var t=arguments,e=t.length,n=new Array(e>0?e:0);e>0;)n[e-1]=t[--e];return n.unshift(console),Function.prototype.call.apply(console.log,n),this},Imba.Tag.prototype.css=function(t,e){if(t instanceof Object)for(var n=0,r=Object.keys(t),i=r.length;i>n;n++)this.css(r[n],t[r[n]]);else if(null==e)this.dom().style.removeProperty(t);else{if(void 0==e)return this.dom().style[t];("number"==typeof e||e instanceof Number)&&t.match(/width|height|left|right|top|bottom/)&&(e+="px"),this.dom().style[t]=e}return this},Imba.Tag.prototype.setTransform=function(t){return this.css("transform",t),this},Imba.Tag.prototype.transform=function(){return this.css("transform")},Imba.Tag.prototype.initialize=Imba.Tag,HTML_TAGS="a abbr address area article aside audio b base bdi bdo big blockquote body br button canvas caption cite code col colgroup data datalist dd del details dfn div dl dt em embed fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 head header hr html i iframe img input ins kbd keygen label legend li link main map mark menu menuitem meta meter nav noscript object ol optgroup option output p param pre progress q rp rt ruby s samp script section select small source span strong style sub summary sup table tbody td textarea tfoot th thead time title tr track u ul var video wbr".split(" "),HTML_TAGS_UNSAFE="article aside header section".split(" "),SVG_TAGS="circle defs ellipse g line linearGradient mask path pattern polygon polyline radialGradient rect stop svg text tspan".split(" "),Imba.Tags=function(){},Imba.Tags.prototype.__clone=function(t){var e=Object.create(this);return e._parent=this,e},Imba.Tags.prototype.defineNamespace=function(t){var e=Object.create(this);return e._parent=this,e._ns=t,this[t.toUpperCase()]=e,e},Imba.Tags.prototype.baseType=function(e){return t(e,HTML_TAGS)>=0?"htmlelement":"div"},Imba.Tags.prototype.defineTag=function(t,i,o){void 0==o&&"function"==typeof i&&(o=i,i=""),void 0==i&&(i=""),i||(i=this.baseType(t));var s=this[i],a=n(),u=t.replace(/\-/g,"_");return a._name=t,e(a,s),"#"==t[0]?(this[t]=a,Imba.SINGLETONS[t.slice(1)]=a):(this[t]=a,this["$"+u]=r(a)),o&&(2==o.length&&(a.hasOwnProperty("TAGS")||(a.TAGS=(s.TAGS||this).__clone())),o.call(a,a,a.TAGS||this)),a},Imba.Tags.prototype.defineSingleton=function(t,e,n){return this.defineTag(t,e,n)},Imba.Tags.prototype.extendTag=function(t,e,n){void 0==n&&"function"==typeof e&&(n=e,e=""),void 0==e&&(e="");var r="string"==typeof t||t instanceof String?this[t]:t;return n&&n&&n.call(r,r,r.prototype),r},Imba.TAGS=new Imba.Tags,Imba.TAGS.element=Imba.Tag;var i=Imba.TAGS.defineNamespace("svg");i.baseType=function(t){return"svgelement"},Imba.SINGLETONS={},Imba.defineTag=function(t,e,n){return void 0==n&&"function"==typeof e&&(n=e,e=""),void 0==e&&(e=""),Imba.TAGS.defineTag(t,e,n)},Imba.defineSingletonTag=function(t,e,n){return void 0==n&&"function"==typeof e&&(n=e,e="div"),void 0==e&&(e="div"),Imba.TAGS.defineTag(this.name(),e,n)},Imba.extendTag=function(t,e){return Imba.TAGS.extendTag(t,e)},Imba.tag=function(t){var e=Imba.TAGS[t];if(!e)throw new Error("tag "+t+" is not defined");return new e(e.createNode())},Imba.tagWithId=function(t,e){var n=Imba.TAGS[t];if(!n)throw new Error("tag "+t+" is not defined");var r=n.createNode();return r.id=e,new n(r)},Imba.getTagSingleton=function(t){var e,n,r;return(e=Imba.SINGLETONS[t])?e&&e.Instance?e.Instance:(n=Imba.document().getElementById(t))?(r=e.Instance=new e(n),r.awaken(n),r):(n=e.createNode(),n.id=t,r=e.Instance=new e(n),r.end().awaken(n),r):(n=Imba.document().getElementById(t))?Imba.getTagForDom(n):void 0};var o="undefined"!=typeof SVGElement;return Imba.getTagForDom=function(t){var e;if(!t)return null;if(t._dom)return t;if(t._tag)return t._tag;if(!t.nodeName)return null;var n=null,r=t.id,i=t.nodeName.toLowerCase(),s=Imba.TAGS,a=i,u=t.className;if(r&&Imba.SINGLETONS[r])return Imba.getTagSingleton(r);o&&t instanceof SVGElement&&(n="svg",u=t.className.baseVal,s=s.SVG);var h;return u&&((e=u.match(/\b_([a-z\-]+)\b(?!\s*_[a-z\-]+)/))&&(i=e[1]),(e=u.match(/\b([A-Z\-]+)_\b/))&&(n=e[1])),h=s[i]||s[a],h?new h(t).awaken(t):null},tag$=Imba.TAGS,t$=Imba.tag,tc$=Imba.tagWithFlags,ti$=Imba.tagWithId,tic$=Imba.tagWithIdAndFlags,id$=Imba.getTagSingleton,tag$wrap=Imba.getTagForDom}()},function(t,e){!function(){function t(t){return t?t.toArray?t.toArray():t:[]}return Imba.document=function(){return window.document},Imba.root=function(){return tag$wrap(Imba.document().body)},tag$.defineTag("htmlelement","element",function(e){e.inherit=function(t){if(t.prototype._empty=!0,t._protoDom=null,!this._nodeType)return t._nodeType=t._name,t._classes=[];t._nodeType=this._nodeType;var e="_"+t._name.replace(/_/g,"-");return"#"!=t._name[0]?t._classes=this._classes.concat(e):void 0},e.buildNode=function(){var t=Imba.document().createElement(this._nodeType),e=this._classes.join(" ");return e&&(t.className=e),t},e.createNode=function(){var t=this._protoDom||(this._protoDom=this.buildNode());return t.cloneNode(!1)},e.dom=function(){return this._protoDom||(this._protoDom=this.buildNode())},e.prototype.id=function(t){return this.getAttribute("id")},e.prototype.setId=function(t){return this.setAttribute("id",t),this},e.prototype.tabindex=function(t){return this.getAttribute("tabindex")},e.prototype.setTabindex=function(t){return this.setAttribute("tabindex",t),this},e.prototype.title=function(t){return this.getAttribute("title")},e.prototype.setTitle=function(t){return this.setAttribute("title",t),this},e.prototype.role=function(t){return this.getAttribute("role")},e.prototype.setRole=function(t){return this.setAttribute("role",t),this},e.prototype.width=function(){return this._dom.offsetWidth},e.prototype.height=function(){return this._dom.offsetHeight},e.prototype.setChildren=function(t,e){return this._empty?this.append(t):this.empty().append(t),this._children=null,this},e.prototype.setHtml=function(t){return this._dom.innerHTML=t,this},e.prototype.html=function(){return this._dom.innerHTML},e.prototype.empty=function(){for(;this._dom.firstChild;)this._dom.removeChild(this._dom.firstChild);return this._children=null,this._empty=!0,this},e.prototype.remove=function(t){var e=this.dom(),n=t&&t.dom();return n&&n.parentNode==e&&e.removeChild(n),this},e.prototype.emit=function(t,e){e&&e.constructor===Object||(e={});var n=void 0!==e.data?e.data:null,r=void 0!==e.bubble?e.bubble:!0;return Imba.Events.trigger(t,this,{data:n,bubble:r}),this},e.prototype.dataset=function(e,n){if(e instanceof Object){for(var r=0,i=Object.keys(e),o=i.length;o>r;r++)this.dataset(i[r],e[i[r]]);return this}if(2==arguments.length)return this.setAttribute("data-"+e,n),this;if(e)return this.getAttribute("data-"+e);var s=this.dom().dataset;if(!s){s={};for(var a,r=0,u=t(this.dom().attributes),h=u.length;h>r;r++)a=u[r],"data-"==a.name.substr(0,5)&&(s[Imba.toCamelCase(a.name.slice(5))]=a.value)}return s},e.prototype.find=function(t){return new Imba.Selector(t,this)},e.prototype.first=function(t){return t?this.find(t).first():tag$wrap(this.dom().firstElementChild)},e.prototype.last=function(t){return t?this.find(t).last():tag$wrap(this.dom().lastElementChild)},e.prototype.child=function(t){return tag$wrap(this.dom().children[t||0])},e.prototype.children=function(t){var e=new Imba.Selector(null,this,this._dom.children);return t?e.filter(t):e},e.prototype.orphanize=function(){var t;return(t=this.dom().parentNode)&&t.removeChild(this._dom),this},e.prototype.matches=function(t){var e;return t instanceof Function?t(this):(t.query&&(t=t.query()),(e=this._dom.matches||this._dom.matchesSelector||this._dom.webkitMatchesSelector||this._dom.msMatchesSelector||this._dom.mozMatchesSelector)?e.call(this._dom,t):void 0)},e.prototype.closest=function(t){if(!t)return this.parent();var e=this;for(t.query&&(t=t.query());e;){if(e.matches(t))return e;e=e.parent()}return null},e.prototype.up=function(t){return t?this.parent()&&this.parent().closest(t):this.parent()},e.prototype.path=function(t){var e=this,n=[];for(t&&t.query&&(t=t.query());e;)(!t||e.matches(t))&&n.push(e),e=e.parent();return n},e.prototype.parents=function(t){var e=this.parent();return e?e.path(t):[]},e.prototype.siblings=function(t){var e,n=this;if(!(e=this.parent()))return[];var r=this.dom().parentNode.children,i=new Imba.Selector(null,this,r);return i.filter(function(e){return e!=n&&(!t||e.matches(t))})},e.prototype.next=function(t){if(t){for(var e=this;e=e.next();)if(e.matches(t))return e;return null}return tag$wrap(this.dom().nextElementSibling)},e.prototype.prev=function(t){if(t){for(var e=this;e=e.prev();)if(e.matches(t))return e;return null}return tag$wrap(this.dom().previousElementSibling)},e.prototype.contains=function(t){return this.dom().contains(t&&t._dom||t)},e.prototype.index=function(){for(var t=0,e=this.dom();e.previousSibling;)e=e.previousSibling,t++;return t},e.prototype.insert=function(t,e){e&&e.constructor===Object||(e={});var n=void 0!==e.before?e.before:null,r=void 0!==e.after?e.after:null;return r&&(n=r.next()),t instanceof Array&&(t=tag$.$fragment().setContent(t,0).end()),n?this.dom().insertBefore(t.dom(),n.dom()):this.append(t),this},e.prototype.focus=function(){return this.dom().focus(),this},e.prototype.blur=function(){return this.dom().blur(),this},e.prototype.template=function(){return null},e.prototype.prepend=function(t){var e=this._dom.childNodes[0];return e?this.insertBefore(t,e):this.appendChild(t),this},e.prototype.append=function(e){if(!e)return this;if(e instanceof Array)for(var n,r=0,i=t(e),o=i.length;o>r;r++)n=i[r],n&&this.append(n);else if("string"==typeof e||e instanceof String||"number"==typeof e||e instanceof Number){var s=Imba.document().createTextNode(e);this._dom.appendChild(s),this._empty&&(this._empty=!1)}else this._dom.appendChild(e._dom||e),this._empty&&(this._empty=!1);return this},e.prototype.insertBefore=function(t,e){return("string"==typeof t||t instanceof String)&&(t=Imba.document().createTextNode(t)),t&&e&&this.dom().insertBefore(t._dom||t,e._dom||e),this},e.prototype.appendChild=function(t){return("string"==typeof t||t instanceof String)&&(t=Imba.document().createTextNode(t)),t&&this.dom().appendChild(t._dom||t),this},e.prototype.removeChild=function(t){return t&&this.dom().removeChild(t._dom||t),this},e.prototype.toString=function(){return this._dom.toString()},e.prototype.classes=function(){return console.log("Imba.Tag#classes is deprecated"),this._dom.classList}}),tag$.defineTag("svgelement","htmlelement")}()},function(t,e){!function(){return tag$.defineTag("fragment","htmlelement",function(t){t.createNode=function(){return Imba.document().createDocumentFragment()}}),tag$.defineTag("a",function(t){t.prototype.href=function(t){return this.getAttribute("href")},t.prototype.setHref=function(t){return this.setAttribute("href",t),this}}),tag$.defineTag("abbr"),tag$.defineTag("address"),tag$.defineTag("area"),tag$.defineTag("article"),tag$.defineTag("aside"),tag$.defineTag("audio"),tag$.defineTag("b"),tag$.defineTag("base"),tag$.defineTag("bdi"),tag$.defineTag("bdo"),tag$.defineTag("big"),tag$.defineTag("blockquote"),tag$.defineTag("body"),tag$.defineTag("br"),tag$.defineTag("button",function(t){t.prototype.autofocus=function(t){return this.getAttribute("autofocus")},t.prototype.setAutofocus=function(t){return this.setAttribute("autofocus",t),this},t.prototype.type=function(t){return this.getAttribute("type")},t.prototype.setType=function(t){return this.setAttribute("type",t),this},t.prototype.disabled=function(t){return this.getAttribute("disabled")},t.prototype.setDisabled=function(t){return this.setAttribute("disabled",t),this}}),tag$.defineTag("canvas",function(t){t.prototype.setWidth=function(t){return this.width()!=t&&(this.dom().width=t),this},t.prototype.setHeight=function(t){return this.height()!=t&&(this.dom().height=t),this},t.prototype.width=function(){return this.dom().width},t.prototype.height=function(){return this.dom().height},t.prototype.context=function(t){return void 0===t&&(t="2d"),this.dom().getContext(t)}}),tag$.defineTag("caption"),tag$.defineTag("cite"),tag$.defineTag("code"),tag$.defineTag("col"),tag$.defineTag("colgroup"),tag$.defineTag("data"),tag$.defineTag("datalist"),tag$.defineTag("dd"),tag$.defineTag("del"),tag$.defineTag("details"),tag$.defineTag("dfn"),tag$.defineTag("div"),tag$.defineTag("dl"),tag$.defineTag("dt"),tag$.defineTag("em"),tag$.defineTag("embed"),tag$.defineTag("fieldset"),tag$.defineTag("figcaption"),tag$.defineTag("figure"),tag$.defineTag("footer"),tag$.defineTag("form",function(t){t.prototype.method=function(t){return this.getAttribute("method")},t.prototype.setMethod=function(t){return this.setAttribute("method",t),this},t.prototype.action=function(t){return this.getAttribute("action")},t.prototype.setAction=function(t){return this.setAttribute("action",t),this}}),tag$.defineTag("h1"),tag$.defineTag("h2"),tag$.defineTag("h3"),tag$.defineTag("h4"),tag$.defineTag("h5"),tag$.defineTag("h6"),tag$.defineTag("head"),tag$.defineTag("header"),tag$.defineTag("hr"),tag$.defineTag("html"),tag$.defineTag("i"),tag$.defineTag("iframe",function(t){t.prototype.src=function(t){return this.getAttribute("src")},t.prototype.setSrc=function(t){return this.setAttribute("src",t),this}}),tag$.defineTag("img",function(t){t.prototype.src=function(t){return this.getAttribute("src")},t.prototype.setSrc=function(t){return this.setAttribute("src",t),this}}),tag$.defineTag("input",function(t){t.prototype.name=function(t){return this.getAttribute("name")},t.prototype.setName=function(t){return this.setAttribute("name",t),this},t.prototype.type=function(t){return this.getAttribute("type")},t.prototype.setType=function(t){return this.setAttribute("type",t),this},t.prototype.required=function(t){return this.getAttribute("required")},t.prototype.setRequired=function(t){return this.setAttribute("required",t),this},t.prototype.disabled=function(t){return this.getAttribute("disabled")},t.prototype.setDisabled=function(t){return this.setAttribute("disabled",t),this},t.prototype.autofocus=function(t){return this.getAttribute("autofocus")},t.prototype.setAutofocus=function(t){return this.setAttribute("autofocus",t),this},t.prototype.value=function(){return this.dom().value},t.prototype.setValue=function(t){return t!=this.dom().value&&(this.dom().value=t),this},t.prototype.setPlaceholder=function(t){return t!=this.dom().placeholder&&(this.dom().placeholder=t),this},t.prototype.placeholder=function(){return this.dom().placeholder},t.prototype.checked=function(){return this.dom().checked},t.prototype.setChecked=function(t){return t!=this.dom().checked&&(this.dom().checked=t),this}}),tag$.defineTag("ins"),tag$.defineTag("kbd"),tag$.defineTag("keygen"),tag$.defineTag("label"),tag$.defineTag("legend"),tag$.defineTag("li"),tag$.defineTag("link",function(t){t.prototype.rel=function(t){return this.getAttribute("rel")},t.prototype.setRel=function(t){return this.setAttribute("rel",t),this},t.prototype.type=function(t){return this.getAttribute("type")},t.prototype.setType=function(t){return this.setAttribute("type",t),this},t.prototype.href=function(t){return this.getAttribute("href")},t.prototype.setHref=function(t){return this.setAttribute("href",t),this},t.prototype.media=function(t){return this.getAttribute("media")},t.prototype.setMedia=function(t){return this.setAttribute("media",t),this}}),tag$.defineTag("main"),tag$.defineTag("map"),tag$.defineTag("mark"),tag$.defineTag("menu"),tag$.defineTag("menuitem"),tag$.defineTag("meta",function(t){t.prototype.name=function(t){return this.getAttribute("name")},t.prototype.setName=function(t){return this.setAttribute("name",t),this},t.prototype.content=function(t){return this.getAttribute("content")},t.prototype.setContent=function(t){return this.setAttribute("content",t),this},t.prototype.charset=function(t){return this.getAttribute("charset")},t.prototype.setCharset=function(t){return this.setAttribute("charset",t),this}}),tag$.defineTag("meter"),tag$.defineTag("nav"),tag$.defineTag("noscript"),tag$.defineTag("object"),tag$.defineTag("ol"),tag$.defineTag("optgroup"),tag$.defineTag("option",function(t){t.prototype.value=function(t){return this.getAttribute("value")},t.prototype.setValue=function(t){return this.setAttribute("value",t),this}}),tag$.defineTag("output"),tag$.defineTag("p"),tag$.defineTag("param"),tag$.defineTag("pre"),tag$.defineTag("progress"),tag$.defineTag("q"),tag$.defineTag("rp"),tag$.defineTag("rt"),tag$.defineTag("ruby"),tag$.defineTag("s"),tag$.defineTag("samp"),tag$.defineTag("script",function(t){t.prototype.src=function(t){return this.getAttribute("src")},t.prototype.setSrc=function(t){return this.setAttribute("src",t),this},t.prototype.type=function(t){return this.getAttribute("type")},t.prototype.setType=function(t){return this.setAttribute("type",t),this},t.prototype.async=function(t){return this.getAttribute("async")},t.prototype.setAsync=function(t){return this.setAttribute("async",t),this},t.prototype.defer=function(t){return this.getAttribute("defer")},t.prototype.setDefer=function(t){return this.setAttribute("defer",t),this}}),tag$.defineTag("section"),tag$.defineTag("select",function(t){t.prototype.name=function(t){return this.getAttribute("name")},t.prototype.setName=function(t){return this.setAttribute("name",t),this},t.prototype.multiple=function(t){return this.getAttribute("multiple")},t.prototype.setMultiple=function(t){return this.setAttribute("multiple",t),this},t.prototype.required=function(t){return this.getAttribute("required")},t.prototype.setRequired=function(t){return this.setAttribute("required",t),this},t.prototype.disabled=function(t){return this.getAttribute("disabled")},t.prototype.setDisabled=function(t){return this.setAttribute("disabled",t),this},t.prototype.value=function(){return this.dom().value},t.prototype.setValue=function(t){return t!=this.dom().value&&(this.dom().value=t),this}}),tag$.defineTag("small"),tag$.defineTag("source"),tag$.defineTag("span"),tag$.defineTag("strong"),tag$.defineTag("style"),tag$.defineTag("sub"),tag$.defineTag("summary"),tag$.defineTag("sup"),tag$.defineTag("table"),tag$.defineTag("tbody"),tag$.defineTag("td"),tag$.defineTag("textarea",function(t){t.prototype.name=function(t){return this.getAttribute("name")},t.prototype.setName=function(t){return this.setAttribute("name",t),this},t.prototype.disabled=function(t){return this.getAttribute("disabled")},t.prototype.setDisabled=function(t){return this.setAttribute("disabled",t),this},t.prototype.required=function(t){return this.getAttribute("required")},t.prototype.setRequired=function(t){return this.setAttribute("required",t),this},t.prototype.rows=function(t){return this.getAttribute("rows")},t.prototype.setRows=function(t){return this.setAttribute("rows",t),this},t.prototype.cols=function(t){return this.getAttribute("cols")},t.prototype.setCols=function(t){return this.setAttribute("cols",t),this},t.prototype.autofocus=function(t){return this.getAttribute("autofocus")},t.prototype.setAutofocus=function(t){return this.setAttribute("autofocus",t),this},t.prototype.value=function(){return this.dom().value},t.prototype.setValue=function(t){return t!=this.dom().value&&(this.dom().value=t),this},t.prototype.setPlaceholder=function(t){return t!=this.dom().placeholder&&(this.dom().placeholder=t),this},t.prototype.placeholder=function(){return this.dom().placeholder}}),tag$.defineTag("tfoot"),tag$.defineTag("th"),tag$.defineTag("thead"),tag$.defineTag("time"),tag$.defineTag("title"),tag$.defineTag("tr"),tag$.defineTag("track"),tag$.defineTag("u"),tag$.defineTag("ul"),tag$.defineTag("video"),tag$.defineTag("wbr")}()},function(t,e){!function(){function t(t,e){return e&&e.indexOf?e.indexOf(t):[].indexOf.call(t,e)}return tag$.SVG.defineTag("svgelement",function(e){e.namespaceURI=function(){return"http://www.w3.org/2000/svg"};var n="circle defs ellipse g line linearGradient mask path pattern polygon polyline radialGradient rect stop svg text tspan".split(" ");e.buildNode=function(){var t=Imba.document().createElementNS(this.namespaceURI(),this._nodeType),e=this._classes.join(" ");return e&&(t.className.baseVal=e),t},e.inherit=function(e){if(e._protoDom=null,t(e._name,n)>=0)return e._nodeType=e._name,e._classes=[];e._nodeType=this._nodeType;var r="_"+e._name.replace(/_/g,"-");return e._classes=this._classes.concat(r)},Imba.attr(e,"x"),Imba.attr(e,"y"),Imba.attr(e,"width"),Imba.attr(e,"height"),Imba.attr(e,"stroke"),Imba.attr(e,"stroke-width")}),tag$.SVG.defineTag("svg",function(t){Imba.attr(t,"viewbox")}),tag$.SVG.defineTag("g"),tag$.SVG.defineTag("defs"),tag$.SVG.defineTag("symbol",function(t){Imba.attr(t,"preserveAspectRatio"),Imba.attr(t,"viewBox")}),tag$.SVG.defineTag("marker",function(t){Imba.attr(t,"markerUnits"),Imba.attr(t,"refX"),Imba.attr(t,"refY"),Imba.attr(t,"markerWidth"),Imba.attr(t,"markerHeight"),Imba.attr(t,"orient")}),tag$.SVG.defineTag("rect",function(t){Imba.attr(t,"rx"),Imba.attr(t,"ry")}),tag$.SVG.defineTag("circle",function(t){Imba.attr(t,"cx"),Imba.attr(t,"cy"),Imba.attr(t,"r")}),tag$.SVG.defineTag("ellipse",function(t){Imba.attr(t,"cx"),Imba.attr(t,"cy"),Imba.attr(t,"rx"),Imba.attr(t,"ry")}),tag$.SVG.defineTag("path",function(t){Imba.attr(t,"d"),Imba.attr(t,"pathLength")}),tag$.SVG.defineTag("line",function(t){Imba.attr(t,"x1"),Imba.attr(t,"x2"),Imba.attr(t,"y1"),Imba.attr(t,"y2")}),tag$.SVG.defineTag("polyline",function(t){Imba.attr(t,"points")}),tag$.SVG.defineTag("polygon",function(t){Imba.attr(t,"points")}),tag$.SVG.defineTag("text",function(t){Imba.attr(t,"dx"),Imba.attr(t,"dy"),Imba.attr(t,"text-anchor"),Imba.attr(t,"rotate"),Imba.attr(t,"textLength"),Imba.attr(t,"lengthAdjust")}),tag$.SVG.defineTag("tspan",function(t){Imba.attr(t,"dx"),Imba.attr(t,"dy"),Imba.attr(t,"rotate"),Imba.attr(t,"textLength"),Imba.attr(t,"lengthAdjust")})}()},function(t,e,n){!function(){function t(t){return t?t.toArray?t.toArray():t:[]}var e=window.getComputedStyle(document.documentElement,"");Imba.CSSKeyMap={};for(var n,r=0,i=t(e),o=i.length;o>r;r++){n=i[r];var s=n.replace(/^-(webkit|ms|moz|o|blink)-/,""),a=s.replace(/-(\w)/g,function(t,e){return e.toUpperCase()});n!=s&&e.hasOwnProperty(s)||(Imba.CSSKeyMap[s]=Imba.CSSKeyMap[a]=n)}return tag$.extendTag("element",function(t){t.prototype.css=function(t,e){if(t instanceof Object){for(var n=0,r=Object.keys(t),i=r.length;i>n;n++)this.css(r[n],t[r[n]]);return this}if(t=Imba.CSSKeyMap[t]||t,null==e)this.dom().style.removeProperty(t);else{if(void 0==e)return this.dom().style[t];("number"==typeof e||e instanceof Number)&&t.match(/width|height|left|right|top|bottom/)&&(e+="px"),
2
- this.dom().style[t]=e}return this}}),document.documentElement.classList?void 0:(tag$.extendTag("element",function(t){t.prototype.hasFlag=function(t){return new RegExp("(^|\\s)"+t+"(\\s|$)").test(this._dom.className)},t.prototype.addFlag=function(t){return this.hasFlag(t)?this:(this._dom.className+=(this._dom.className?" ":"")+t,this)},t.prototype.unflag=function(t){if(!this.hasFlag(t))return this;var e=new RegExp("(^|\\s)*"+t+"(\\s|$)*","g");return this._dom.className=this._dom.className.replace(e,""),this},t.prototype.toggleFlag=function(t){return this.hasFlag(t)?this.unflag(t):this.flag(t)},t.prototype.flag=function(t,e){return 2==arguments.length&&!!e==!1?this.unflag(t):this.addFlag(t)}}),!0)}()},function(t,e){!function(){function t(t){return t?t.toArray?t.toArray():t:[]}var e=document,n=window,r=window&&void 0!==window.ontouchstart;Imba.Pointer=function(){return this.setButton(-1),this.setEvent({x:0,y:0,type:"uninitialized"}),this},Imba.Pointer.prototype.phase=function(t){return this._phase},Imba.Pointer.prototype.setPhase=function(t){return this._phase=t,this},Imba.Pointer.prototype.prevEvent=function(t){return this._prevEvent},Imba.Pointer.prototype.setPrevEvent=function(t){return this._prevEvent=t,this},Imba.Pointer.prototype.button=function(t){return this._button},Imba.Pointer.prototype.setButton=function(t){return this._button=t,this},Imba.Pointer.prototype.event=function(t){return this._event},Imba.Pointer.prototype.setEvent=function(t){return this._event=t,this},Imba.Pointer.prototype.dirty=function(t){return this._dirty},Imba.Pointer.prototype.setDirty=function(t){return this._dirty=t,this},Imba.Pointer.prototype.events=function(t){return this._events},Imba.Pointer.prototype.setEvents=function(t){return this._events=t,this},Imba.Pointer.prototype.touch=function(t){return this._touch},Imba.Pointer.prototype.setTouch=function(t){return this._touch=t,this},Imba.Pointer.prototype.update=function(t){return this.setEvent(t),this.setDirty(!0),this},Imba.Pointer.prototype.process=function(){var t=this.event();if(this.dirty())if(this.setPrevEvent(t),this.setDirty(!1),"mousedown"==t.type){if(this.setButton(t.button),2==this.button()||this.touch()&&0!=this.button())return;this.touch()&&this.touch().cancel(),this.setTouch(new Imba.Touch(t,this)),this.touch().mousedown(t,t)}else"mousemove"==t.type?this.touch()&&this.touch().mousemove(t,t):"mouseup"==t.type&&(this.setButton(-1),this.touch()&&this.touch().button()==t.button&&(this.touch().mouseup(t,t),this.setTouch(null)));else this.touch()&&this.touch().idle();return this},Imba.Pointer.prototype.cleanup=function(){return Imba.POINTERS},Imba.Pointer.prototype.x=function(){return this.event().x},Imba.Pointer.prototype.y=function(){return this.event().y},Imba.Pointer.update=function(){for(var e=0,r=t(Imba.POINTERS),i=r.length;i>e;e++)r[e].process();return n.requestAnimationFrame(Imba.Pointer.update),this};var i=0,o=50;Imba.Touch=function(t,e){return this.setEvent(t),this.setData({}),this.setActive(!0),this._button=t&&t.button||0,this._suppress=!1,this._captured=!1,this.setBubble(!1),e=e,this.setUpdates(0),this};var s=[],a=0,u={};return Imba.Touch.count=function(){return a},Imba.Touch.lookup=function(t){return t&&(t.__touch__||u[t.identifier])},Imba.Touch.release=function(t,e){var n,r;n=u[t.identifier],delete u[t.identifier],n,r=t.__touch__,delete t.__touch__,r},Imba.Touch.ontouchstart=function(e){for(var n,r=0,i=t(e.changedTouches),o=i.length;o>r;r++)if(n=i[r],!this.lookup(n)){var h=u[n.identifier]=new this(e);n.__touch__=h,s.push(h),a++,h.touchstart(e,n)}return this},Imba.Touch.ontouchmove=function(e){for(var n,r,i=0,o=t(e.changedTouches),s=o.length;s>i;i++)r=o[i],(n=this.lookup(r))&&n.touchmove(e,r);return this},Imba.Touch.ontouchend=function(e){for(var n,r,i=0,o=t(e.changedTouches),s=o.length;s>i;i++)r=o[i],(n=this.lookup(r))&&(n.touchend(e,r),this.release(r,n),a--);return this},Imba.Touch.ontouchcancel=function(e){for(var n,r,i=0,o=t(e.changedTouches),s=o.length;s>i;i++)r=o[i],(n=this.lookup(r))&&(n.touchcancel(e,r),this.release(r,n),a--);return this},Imba.Touch.onmousedown=function(t){return this},Imba.Touch.onmousemove=function(t){return this},Imba.Touch.onmouseup=function(t){return this},Imba.Touch.prototype.phase=function(t){return this._phase},Imba.Touch.prototype.setPhase=function(t){return this._phase=t,this},Imba.Touch.prototype.active=function(t){return this._active},Imba.Touch.prototype.setActive=function(t){return this._active=t,this},Imba.Touch.prototype.event=function(t){return this._event},Imba.Touch.prototype.setEvent=function(t){return this._event=t,this},Imba.Touch.prototype.pointer=function(t){return this._pointer},Imba.Touch.prototype.setPointer=function(t){return this._pointer=t,this},Imba.Touch.prototype.target=function(t){return this._target},Imba.Touch.prototype.setTarget=function(t){return this._target=t,this},Imba.Touch.prototype.handler=function(t){return this._handler},Imba.Touch.prototype.setHandler=function(t){return this._handler=t,this},Imba.Touch.prototype.updates=function(t){return this._updates},Imba.Touch.prototype.setUpdates=function(t){return this._updates=t,this},Imba.Touch.prototype.suppress=function(t){return this._suppress},Imba.Touch.prototype.setSuppress=function(t){return this._suppress=t,this},Imba.Touch.prototype.data=function(t){return this._data},Imba.Touch.prototype.setData=function(t){return this._data=t,this},Imba.Touch.prototype.__bubble={chainable:!0,name:"bubble"},Imba.Touch.prototype.bubble=function(t){return void 0!==t?(this.setBubble(t),this):this._bubble},Imba.Touch.prototype.setBubble=function(t){return this._bubble=t,this},Imba.Touch.prototype.gestures=function(t){return this._gestures},Imba.Touch.prototype.setGestures=function(t){return this._gestures=t,this},Imba.Touch.prototype.capture=function(){return this._captured=!0,this._event&&this._event.preventDefault(),this},Imba.Touch.prototype.isCaptured=function(){return!!this._captured},Imba.Touch.prototype.extend=function(t){return this._gestures||(this._gestures=[]),this._gestures.push(t),this},Imba.Touch.prototype.redirect=function(t){return this._redirect=t,this},Imba.Touch.prototype.suppress=function(){return this._active=!1,this},Imba.Touch.prototype.setSuppress=function(t){return console.warn("Imba.Touch#suppress= is deprecated"),this._supress=t,this},Imba.Touch.prototype.touchstart=function(t,e){return this._event=t,this._touch=e,this._button=0,this._x=e.clientX,this._y=e.clientY,this.began(),t&&this.isCaptured()&&t.preventDefault(),this},Imba.Touch.prototype.touchmove=function(t,e){return this._event=t,this._x=e.clientX,this._y=e.clientY,this.update(),t&&this.isCaptured()&&t.preventDefault(),this},Imba.Touch.prototype.touchend=function(t,e){if(this._event=t,this._x=e.clientX,this._y=e.clientY,this.ended(),i=t.timeStamp,this._maxdr<20){var n=new Imba.Event(t);n.setType("tap"),n.process(),n._responder&&t.preventDefault()}return t&&this.isCaptured()&&t.preventDefault(),this},Imba.Touch.prototype.touchcancel=function(t,e){return this.cancel()},Imba.Touch.prototype.mousedown=function(t,n){var r=this;return r._event=t,r._button=t.button,r._x=n.clientX,r._y=n.clientY,r.began(),r._mousemove=function(t){return r.mousemove(t,t)},e.addEventListener("mousemove",r._mousemove,!0),r},Imba.Touch.prototype.mousemove=function(t,e){return this._x=e.clientX,this._y=e.clientY,this._event=t,this.isCaptured()&&t.preventDefault(),this.update(),this.move(),this},Imba.Touch.prototype.mouseup=function(t,n){return this._x=n.clientX,this._y=n.clientY,this.ended(),e.removeEventListener("mousemove",this._mousemove,!0),this._mousemove=null,this},Imba.Touch.prototype.idle=function(){return this.update()},Imba.Touch.prototype.began=function(){this._maxdr=this._dr=0,this._x0=this._x,this._y0=this._y;var t=this.event().target,e=null;for(this._sourceTarget=t&&tag$wrap(t);t&&(e=tag$wrap(t),!e||!e.ontouchstart||(this._bubble=!1,this.setTarget(e),this.target().ontouchstart(this),this._bubble));)t=t.parentNode;return this._updates++,this},Imba.Touch.prototype.update=function(){var e;if(!this._active)return this;var n=Math.sqrt(this.dx()*this.dx()+this.dy()*this.dy());if(n>this._dr&&(this._maxdr=n),this._dr=n,this._redirect&&(this._target&&this._target.ontouchcancel&&this._target.ontouchcancel(this),this.setTarget(this._redirect),this._redirect=null,this.target().ontouchstart&&this.target().ontouchstart(this)),this._updates++,this._gestures)for(var r=0,i=t(this._gestures),o=i.length;o>r;r++)i[r].ontouchupdate(this);return(e=this.target())&&e.ontouchupdate&&e.ontouchupdate(this),this},Imba.Touch.prototype.move=function(){var e;if(!this._active)return this;if(this._gestures)for(var n,r=0,i=t(this._gestures),o=i.length;o>r;r++)n=i[r],n.ontouchmove&&n.ontouchmove(this,this._event);return(e=this.target())&&e.ontouchmove&&e.ontouchmove(this,this._event),this},Imba.Touch.prototype.ended=function(){var e;if(!this._active)return this;if(this._updates++,this._gestures)for(var n=0,r=t(this._gestures),i=r.length;i>n;n++)r[n].ontouchend(this);return(e=this.target())&&e.ontouchend&&e.ontouchend(this),this},Imba.Touch.prototype.cancel=function(){return this._cancelled||(this._cancelled=!0,this.cancelled(),this._mousemove&&e.removeEventListener("mousemove",this._mousemove,!0)),this},Imba.Touch.prototype.cancelled=function(){var e;if(!this._active)return this;if(this._cancelled=!0,this._updates++,this._gestures)for(var n,r=0,i=t(this._gestures),o=i.length;o>r;r++)n=i[r],n.ontouchcancel&&n.ontouchcancel(this);return(e=this.target())&&e.ontouchcancel&&e.ontouchcancel(this),this},Imba.Touch.prototype.dr=function(){return this._dr},Imba.Touch.prototype.dx=function(){return this._x-this._x0},Imba.Touch.prototype.dy=function(){return this._y-this._y0},Imba.Touch.prototype.x0=function(){return this._x0},Imba.Touch.prototype.y0=function(){return this._y0},Imba.Touch.prototype.x=function(){return this._x},Imba.Touch.prototype.y=function(){return this._y},Imba.Touch.prototype.tx=function(){return this._targetBox||(this._targetBox=this._target.dom().getBoundingClientRect()),this._x-this._targetBox.left},Imba.Touch.prototype.ty=function(){return this._targetBox||(this._targetBox=this._target.dom().getBoundingClientRect()),this._y-this._targetBox.top},Imba.Touch.prototype.button=function(){return this._button},Imba.Touch.prototype.sourceTarget=function(){return this._sourceTarget},Imba.TouchGesture=function(){},Imba.TouchGesture.prototype.__active={"default":!1,name:"active"},Imba.TouchGesture.prototype.active=function(t){return this._active},Imba.TouchGesture.prototype.setActive=function(t){return this._active=t,this},Imba.TouchGesture.prototype._active=!1,Imba.TouchGesture.prototype.ontouchstart=function(t){return this},Imba.TouchGesture.prototype.ontouchupdate=function(t){return this},Imba.TouchGesture.prototype.ontouchend=function(t){return this},Imba.POINTER=new Imba.Pointer,Imba.POINTERS=[Imba.POINTER],Imba.KEYMAP={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",19:"break",20:"caps",27:"esc",32:"space",35:"end",36:"home",37:"larr",38:"uarr",39:"rarr",40:"darr",45:"insert",46:"delete",107:"plus",106:"mult",91:"meta"},Imba.CHARMAP={"%":"modulo","*":"multiply","+":"add","-":"sub","/":"divide",".":"dot"},Imba.Event=function(t){this.setEvent(t),this.setBubble(!0)},Imba.Event.prototype.event=function(t){return this._event},Imba.Event.prototype.setEvent=function(t){return this._event=t,this},Imba.Event.prototype.prefix=function(t){return this._prefix},Imba.Event.prototype.setPrefix=function(t){return this._prefix=t,this},Imba.Event.prototype.data=function(t){return this._data},Imba.Event.prototype.setData=function(t){return this._data=t,this},Imba.Event.prototype.source=function(t){return this._source},Imba.Event.prototype.setSource=function(t){return this._source=t,this},Imba.Event.prototype.__bubble={type:Boolean,chainable:!0,name:"bubble"},Imba.Event.prototype.bubble=function(t){return void 0!==t?(this.setBubble(t),this):this._bubble},Imba.Event.prototype.setBubble=function(t){return this._bubble=t,this},Imba.Event.wrap=function(t){return new this(t)},Imba.Event.prototype.setType=function(t){return this._type=t,this},Imba.Event.prototype.type=function(){return this._type||this.event().type},Imba.Event.prototype.name=function(){return this._name||(this._name=this.type().toLowerCase().replace(/\:/g,""))},Imba.Event.prototype.bubble=function(t){return void 0!=t?(this.setBubble(t),this):this._bubble},Imba.Event.prototype.halt=function(){return this.setBubble(!1),this},Imba.Event.prototype.cancel=function(){return this.event().preventDefault&&this.event().preventDefault(),this._cancel=!0,this},Imba.Event.prototype.silence=function(){return this._silenced=!0,this},Imba.Event.prototype.isSilenced=function(){return!!this._silenced},Imba.Event.prototype.isPrevented=function(){return this.event()&&this.event().defaultPrevented||this._cancel},Imba.Event.prototype.target=function(){return tag$wrap(this.event()._target||this.event().target)},Imba.Event.prototype.responder=function(){return this._responder},Imba.Event.prototype.redirect=function(t){return this._redirect=t,this},Imba.Event.prototype.keychar=function(){if(this.event()instanceof KeyboardEvent){var t=this.event().keyIdentifier,e=Imba.KEYMAP[this.event().keyCode];return e||"U+"!=t.substr(0,2)||(e=String.fromCharCode(parseInt(t.substr(2),16))),e}return this.event()instanceof(window.TextEvent||window.InputEvent)?this.event().data:null},Imba.Event.prototype.keycombo=function(){var t;if(t=this.keychar()){t=Imba.CHARMAP[t]||t;var e=[],n=this.event();return n.ctrlKey&&e.push("ctrl"),n.shiftKey&&e.push("shift"),n.altKey&&e.push("alt"),n.metaKey&&e.push("cmd"),e.push(t),e.join("_").toLowerCase()}},Imba.Event.prototype.process=function(){for(var t,e,n="on"+(this._prefix||"")+this.name(),r=null,i=this.event()._target||this.event().target,o=i._responder||i;o;){if(this._redirect=null,t=tag$wrap(o)){if("string"==typeof t[e=n]||t[e]instanceof String){n=t[n];continue}if(t[n]instanceof Array){r=t[n].concat(t),n=r.shift();continue}t[n]instanceof Function&&(this._responder||(this._responder=t),r?t[n].apply(t,r):t[n](this,this.data()))}if(!this.bubble()||!(o=this._redirect||(t?t.parent():o.parentNode)))break}return this.processed(),this},Imba.Event.prototype.processed=function(){return this._silenced||Imba.emit(Imba,"event",[this]),this},Imba.Event.prototype.x=function(){return this.event().x},Imba.Event.prototype.y=function(){return this.event().y},Imba.Event.prototype.which=function(){return this.event().which},Imba.EventManager=function(e,n){var r=this;n&&n.constructor===Object||(n={});var i=void 0!==n.events?n.events:[];r.setRoot(e),r.setCount(0),r.setListeners([]),r.setDelegators({}),r.setDelegator(function(t){return r.delegate(t),!0});for(var o=0,s=t(i),a=s.length;a>o;o++)r.register(s[o]);return r},Imba.EventManager.prototype.root=function(t){return this._root},Imba.EventManager.prototype.setRoot=function(t){return this._root=t,this},Imba.EventManager.prototype.count=function(t){return this._count},Imba.EventManager.prototype.setCount=function(t){return this._count=t,this},Imba.EventManager.prototype.__enabled={"default":!1,watch:"enabledDidSet",name:"enabled"},Imba.EventManager.prototype.enabled=function(t){return this._enabled},Imba.EventManager.prototype.setEnabled=function(t){var e=this.enabled();return t!=e&&(this._enabled=t),t!=e&&this.enabledDidSet&&this.enabledDidSet(t,e,this.__enabled),this},Imba.EventManager.prototype._enabled=!1,Imba.EventManager.prototype.listeners=function(t){return this._listeners},Imba.EventManager.prototype.setListeners=function(t){return this._listeners=t,this},Imba.EventManager.prototype.delegators=function(t){return this._delegators},Imba.EventManager.prototype.setDelegators=function(t){return this._delegators=t,this},Imba.EventManager.prototype.delegator=function(t){return this._delegator},Imba.EventManager.prototype.setDelegator=function(t){return this._delegator=t,this},Imba.EventManager.prototype.enabledDidSet=function(t){return t?this.onenable():this.ondisable(),this},Imba.EventManager.prototype.register=function(e,n){if(void 0===n&&(n=!0),e instanceof Array){for(var r=0,i=t(e),o=i.length;o>r;r++)this.register(i[r],n);return this}if(this.delegators()[e])return this;var s=this.delegators()[e]=n instanceof Function?n:this.delegator();return this.enabled()?this.root().addEventListener(e,s,!0):void 0},Imba.EventManager.prototype.listen=function(t,e,n){return void 0===n&&(n=!0),this.listeners().push([t,e,n]),this.enabled()&&this.root().addEventListener(t,e,n),this},Imba.EventManager.prototype.delegate=function(t){this.setCount(this.count()+1);var e=Imba.Event.wrap(t);return e.process(),this},Imba.EventManager.prototype.create=function(t,e,n){n&&n.constructor===Object||(n={});var r=void 0!==n.data?n.data:null,i=void 0!==n.source?n.source:null,o=Imba.Event.wrap({type:t,target:e});return r&&(o.setData(r),r),i&&(o.setSource(i),i),o},Imba.EventManager.prototype.trigger=function(){return this.create.apply(this,arguments).process()},Imba.EventManager.prototype.onenable=function(){for(var e=this.delegators(),n=0,r=Object.keys(e),i=r.length;i>n;n++)this.root().addEventListener(r[n],e[r[n]],!0);for(var o,n=0,s=t(this.listeners()),a=s.length;a>n;n++)o=s[n],this.root().addEventListener(o[0],o[1],o[2]);return this},Imba.EventManager.prototype.ondisable=function(){for(var e=this.delegators(),n=0,r=Object.keys(e),i=r.length;i>n;n++)this.root().removeEventListener(r[n],e[r[n]],!0);for(var o,n=0,s=t(this.listeners()),a=s.length;a>n;n++)o=s[n],this.root().removeEventListener(o[0],o[1],o[2]);return this},ED=Imba.Events=new Imba.EventManager(document,{events:["keydown","keyup","keypress","textInput","input","change","submit","focusin","focusout","blur","contextmenu","dblclick","mousewheel","wheel","scroll"]}),r&&(Imba.Events.listen("touchstart",function(t){var e,n;return(e=Imba.Events).setCount(n=e.count()+1),Imba.Touch.ontouchstart(t)}),Imba.Events.listen("touchmove",function(t){var e,n;return(e=Imba.Events).setCount(n=e.count()+1),Imba.Touch.ontouchmove(t)}),Imba.Events.listen("touchend",function(t){var e,n;return(e=Imba.Events).setCount(n=e.count()+1),Imba.Touch.ontouchend(t)}),Imba.Events.listen("touchcancel",function(t){var e,n;return(e=Imba.Events).setCount(n=e.count()+1),Imba.Touch.ontouchcancel(t)})),Imba.Events.register("click",function(t){if(t.timeStamp-i>o){var e=new Imba.Event(t);if(e.setType("tap"),e.process(),e._responder)return t.preventDefault()}return Imba.Events.delegate(t)}),Imba.Events.listen("mousedown",function(t){return t.timeStamp-i>o&&Imba.POINTER?Imba.POINTER.update(t).process():void 0}),Imba.Events.listen("mouseup",function(t){return t.timeStamp-i>o&&Imba.POINTER?Imba.POINTER.update(t).process():void 0}),Imba.Events.register(["mousedown","mouseup"]),Imba.Events.setEnabled(!0),!0}()},function(t,e){!function(){function t(t){return t?t.toArray?t.toArray():t:[]}function e(n,r,i){if(r instanceof u)n.removeChild(r);else if(r instanceof Array)for(var o=0,s=t(r),a=s.length;a>o;o++)e(n,s[o],i);else{var h=i?i.nextSibling:n._dom.firstChild;if(!(h instanceof Text&&h.textContent==r))throw"cannot remove string";n.removeChild(h)}return i}function n(e,r){if(r instanceof u)e.appendChild(r);else if(r instanceof Array)for(var i=0,o=t(r),s=o.length;s>i;i++)n(e,o[i]);else null!=r&&r!==!1&&e.appendChild(Imba.document().createTextNode(r))}function r(e,n,i){if(n instanceof u)e.insertBefore(n,i);else if(n instanceof Array)for(var o=0,s=t(n),a=s.length;a>o;o++)r(e,s[o],i);else null!=n&&n!==!1&&e.insertBefore(Imba.document().createTextNode(n),i);return i}function i(t,e,i){var o=i?i.nextSibling:t._dom.firstChild;return o?(r(t,e,o),o.previousSibling):(n(t,e),t._dom.lastChild)}function o(e,n,r,o){for(var s,a=n.length,u=n[a-1],h=[],c=[],p=[],f=0,d=0,m=0,l=t(r),b=l.length;b>m;m++){s=l[m];var g=n.indexOf(s);if(h.push(g),-1!=g){for(var y=h.length-2;y>=0;)if(-1==h[y])y--;else{if(g>h[y])break;y=c[y]}c.push(y);var v=-1==y?0:p[y]+1;v>f&&(f=v,d=m),p.push(v)}else e.removeChild(s),c.push(-1),p.push(-1)}for(var _=[],I=h.length-1;I>=0;)I==d&&-1!=h[I]&&(_[h[I]]=!0,d=c[d]),I-=1;for(var T=0,l=t(n),b=l.length;b>T;T++)if(!_[T]){var S=n[T-1];i(e,l[T],S&&S._dom||o)}return u&&u._dom||o}function s(t,e,n,r){var i=e.length,s=i,a=e[i-1];if(i==n.length&&e[0]===n[0])for(;s--&&e[s]===n[s];);return-1==s?a&&a._dom||r:o(t,e,n,r)}function a(n,r,o,h){var c=null==r||r===!1,p=null==o||o===!1;if(r===o)return c?h:r&&r._dom?r._dom:h?h.nextSibling:n._dom.firstChild;if(r instanceof Array){if(o instanceof Array){if(!r["static"]&&!o["static"])return s(n,r,o,h);if(r["static"]==o["static"]){for(var f=0,d=t(r),m=d.length;m>f;f++)h=a(n,d[f],o[f],h);return h}e(n,o,h)}else o instanceof u?n.removeChild(o):p||n.removeChild(h?h.nextSibling:n._dom.firstChild);return i(n,r,h)}if(r instanceof u)return p||e(n,o,h),i(n,r,h),r;if(c)return p||e(n,o,h),h;var l;if(o instanceof Array)e(n,o,h);else if(o instanceof u)n.removeChild(o);else if(!p&&(l=h?h.nextSibling:n._dom.firstChild,l instanceof Text&&l.textContent!=r))return l.textContent=r,l;return i(n,r,h)}var u=Imba.TAGS.element;return tag$.extendTag("htmlelement",function(e){e.prototype.setChildren=function(e,r){var i=this._children;if(e===i)return this;if(i){if(2==r)return this;if(1==r)for(var o=null,h=0,c=t(e),p=c.length;p>h;h++)o=a(this,c[h],i[h],o);else if(3==r)if(e instanceof u)this.empty(),this.appendChild(e);else{if(!(e instanceof Array))return this.setText(e),this;i instanceof Array?s(this,e,i,null):(this.empty(),n(this,e))}else e instanceof Array&&i instanceof Array?s(this,e,i,null):(this.empty(),n(this,e))}else this.empty(),n(this,e);return this._children=e,this},e.prototype.setStaticChildren=function(e){for(var n=this._children,r=null,i=0,o=t(e),s=o.length;s>i;i++)r=a(this,o[i],n[i],r);return this._children=e,this},e.prototype.content=function(){return this._content||this.children().toArray()},e.prototype.setText=function(t){return t!=this._children&&(this._children=t,this.dom().textContent=null==t||t===!1?"":t),this}})}()},function(t,e){!function(){function t(t){return t?t.toArray?t.toArray():t:[]}return Imba.Selector=function(e,n,r){if(this._query=e instanceof Imba.Selector?e.query():e,this._context=n,r){for(var i=0,o=t(r),s=o.length,a=[];s>i;i++)a.push(tag$wrap(o[i]));this._nodes=a}return this._lazy=!r,this},Imba.Selector.one=function(t,e){var n=(e||Imba.document()).querySelector(t);return n&&tag$wrap(n)||null},Imba.Selector.all=function(t,e){return new Imba.Selector(t,e)},Imba.Selector.prototype.query=function(t){return this._query},Imba.Selector.prototype.setQuery=function(t){return this._query=t,this},Imba.Selector.prototype.reload=function(){return this._nodes=null,this},Imba.Selector.prototype.scope=function(){var t;return this._scope?this._scope:(t=this._context)?this._scope=t.toScope?t.toScope():t:Imba.document()},Imba.Selector.prototype.first=function(){return this._lazy?tag$wrap(this._first||(this._first=this.scope().querySelector(this.query()))):this.nodes()[0]},Imba.Selector.prototype.last=function(){return this.nodes()[this._nodes.length-1]},Imba.Selector.prototype.nodes=function(){if(this._nodes)return this._nodes;for(var e=this.scope().querySelectorAll(this.query()),n=0,r=t(e),i=r.length,o=[];i>n;n++)o.push(tag$wrap(r[n]));return this._nodes=o,this._lazy=!1,this._nodes},Imba.Selector.prototype.count=function(){return this.nodes().length},Imba.Selector.prototype.len=function(){return this.nodes().length},Imba.Selector.prototype.some=function(){return this.count()>=1},Imba.Selector.prototype.at=function(t){return this.nodes()[t]},Imba.Selector.prototype.forEach=function(t){return this.nodes().forEach(t),this},Imba.Selector.prototype.map=function(t){return this.nodes().map(t)},Imba.Selector.prototype.toArray=function(){return this.nodes()},Imba.Selector.prototype.closest=function(t){return this._nodes=this.map(function(e){return e.closest(t)}),this},Imba.Selector.prototype.siblings=function(t){return this._nodes=this.map(function(e){return e.siblings(t)}),this},Imba.Selector.prototype.find=function(t){return this._nodes=this.__query__(t.query(),this.nodes()),this},Imba.Selector.prototype.reject=function(t){return this.filter(t,!1)},Imba.Selector.prototype.filter=function(t,e){void 0===e&&(e=!0);var n=t instanceof Function&&t||function(e){return e.matches(t)},r=this.nodes().filter(function(t){return n(t)==e});return new Imba.Selector("",this._scope,r)},Imba.Selector.prototype.__query__=function(t,e){for(var n=[],r=0,i=e.length;i>r;)n.push.apply(n,e[r++].querySelectorAll(t));return n},Imba.Selector.prototype.__matches__=function(){return!0},Imba.Selector.prototype.flag=function(t){return this.forEach(function(e){return e.flag(t)})},Imba.Selector.prototype.unflag=function(t){return this.forEach(function(e){return e.unflag(t)})},q$=function(t,e){return new Imba.Selector(t,e)},q$$=function(t,e){var n=(e||Imba.document()).querySelector(t);return n&&tag$wrap(n)||null},tag$.extendTag("element",function(t){t.prototype.querySelectorAll=function(t){return this._dom.querySelectorAll(t)},t.prototype.querySelector=function(t){return this._dom.querySelector(t)},t.prototype.find=function(t){return new Imba.Selector(t,this)}})}()}]);
1
+ /******/ (function(modules) { // webpackBootstrap
2
+ /******/ // The module cache
3
+ /******/ var installedModules = {};
4
+
5
+ /******/ // The require function
6
+ /******/ function __webpack_require__(moduleId) {
7
+
8
+ /******/ // Check if module is in cache
9
+ /******/ if(installedModules[moduleId])
10
+ /******/ return installedModules[moduleId].exports;
11
+
12
+ /******/ // Create a new module (and put it into the cache)
13
+ /******/ var module = installedModules[moduleId] = {
14
+ /******/ exports: {},
15
+ /******/ id: moduleId,
16
+ /******/ loaded: false
17
+ /******/ };
18
+
19
+ /******/ // Execute the module function
20
+ /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21
+
22
+ /******/ // Flag the module as loaded
23
+ /******/ module.loaded = true;
24
+
25
+ /******/ // Return the exports of the module
26
+ /******/ return module.exports;
27
+ /******/ }
28
+
29
+
30
+ /******/ // expose the modules object (__webpack_modules__)
31
+ /******/ __webpack_require__.m = modules;
32
+
33
+ /******/ // expose the module cache
34
+ /******/ __webpack_require__.c = installedModules;
35
+
36
+ /******/ // __webpack_public_path__
37
+ /******/ __webpack_require__.p = "";
38
+
39
+ /******/ // Load entry module and return exports
40
+ /******/ return __webpack_require__(0);
41
+ /******/ })
42
+ /************************************************************************/
43
+ /******/ ([
44
+ /* 0 */
45
+ /***/ function(module, exports, __webpack_require__) {
46
+
47
+ (function(){
48
+
49
+ if (typeof Imba === 'undefined') {
50
+ __webpack_require__(1);
51
+ __webpack_require__(2);
52
+ __webpack_require__(3);
53
+ __webpack_require__(4);
54
+ __webpack_require__(5);
55
+ __webpack_require__(6);
56
+ __webpack_require__(7);
57
+
58
+ if (false) {
59
+ require('./dom.server');
60
+ };
61
+
62
+ if (true) {
63
+ __webpack_require__(8);
64
+ __webpack_require__(9);
65
+ __webpack_require__(10);
66
+ };
67
+
68
+ return __webpack_require__(11);
69
+ } else {
70
+ return console.warn(("Imba v" + (Imba.VERSION) + " is already loaded"));
71
+ };
72
+
73
+ })();
74
+
75
+ /***/ },
76
+ /* 1 */
77
+ /***/ function(module, exports, __webpack_require__) {
78
+
79
+ (function(){
80
+ var isClient = (typeof window == 'object' && this == window);
81
+
82
+ if (isClient) {
83
+ // should not go there
84
+ window.global || (window.global = window);
85
+ };
86
+
87
+ /*
88
+ Imba is the namespace for all runtime related utilities
89
+ @namespace
90
+ */
91
+
92
+ Imba = {
93
+ VERSION: '0.14.4',
94
+ CLIENT: isClient,
95
+ SERVER: !isClient,
96
+ DEBUG: false
97
+ };
98
+
99
+ var reg = /-./g;
100
+
101
+ /*
102
+ True if running in client environment.
103
+ @return {bool}
104
+ */
105
+
106
+ Imba.isClient = function (){
107
+ return (true) == true;
108
+ };
109
+
110
+ /*
111
+ True if running in server environment.
112
+ @return {bool}
113
+ */
114
+
115
+ Imba.isServer = function (){
116
+ return (false) == true;
117
+ };
118
+
119
+ Imba.subclass = function (obj,sup){
120
+ ;
121
+ for (var k in sup){
122
+ if (sup.hasOwnProperty(k)) { obj[k] = sup[k] };
123
+ };
124
+
125
+ obj.prototype = Object.create(sup.prototype);
126
+ obj.__super__ = obj.prototype.__super__ = sup.prototype;
127
+ obj.prototype.initialize = obj.prototype.constructor = obj;
128
+ return obj;
129
+ };
130
+
131
+ /*
132
+ Lightweight method for making an object iterable in imbas for/in loops.
133
+ If the compiler cannot say for certain that a target in a for loop is an
134
+ array, it will cache the iterable version before looping.
135
+
136
+ ```imba
137
+ # this is the whole method
138
+ def Imba.iterable o
139
+ return o ? (o:toArray ? o.toArray : o) : []
140
+
141
+ class CustomIterable
142
+ def toArray
143
+ [1,2,3]
144
+
145
+ # will return [2,4,6]
146
+ for x in CustomIterable.new
147
+ x * 2
148
+
149
+ ```
150
+ */
151
+
152
+ Imba.iterable = function (o){
153
+ return o ? ((o.toArray ? (o.toArray()) : (o))) : ([]);
154
+ };
155
+
156
+ /*
157
+ Coerces a value into a promise. If value is array it will
158
+ call `Promise.all(value)`, or if it is not a promise it will
159
+ wrap the value in `Promise.resolve(value)`. Used for experimental
160
+ await syntax.
161
+ @return {Promise}
162
+ */
163
+
164
+ Imba.await = function (value){
165
+ if (value instanceof Array) {
166
+ return Promise.all(value);
167
+ } else if (value && value.then) {
168
+ return value;
169
+ } else {
170
+ return Promise.resolve(value);
171
+ };
172
+ };
173
+
174
+ Imba.toCamelCase = function (str){
175
+ return str.replace(reg,function(m) { return m.charAt(1).toUpperCase(); });
176
+ };
177
+
178
+ Imba.toCamelCase = function (str){
179
+ return str.replace(reg,function(m) { return m.charAt(1).toUpperCase(); });
180
+ };
181
+
182
+ Imba.indexOf = function (a,b){
183
+ return (b && b.indexOf) ? (b.indexOf(a)) : ([].indexOf.call(a,b));
184
+ };
185
+
186
+ Imba.prop = function (scope,name,opts){
187
+ if (scope.defineProperty) {
188
+ return scope.defineProperty(name,opts);
189
+ };
190
+ return;
191
+ };
192
+
193
+ return Imba.attr = function (scope,name,opts){
194
+ if (scope.defineAttribute) {
195
+ return scope.defineAttribute(name,opts);
196
+ };
197
+
198
+ var getName = Imba.toCamelCase(name);
199
+ var setName = Imba.toCamelCase('set-' + name);
200
+
201
+ scope.prototype[getName] = function() {
202
+ return this.getAttribute(name);
203
+ };
204
+
205
+ scope.prototype[setName] = function(value) {
206
+ this.setAttribute(name,value);
207
+ return this;
208
+ };
209
+
210
+ return;
211
+ };
212
+
213
+ })();
214
+
215
+ /***/ },
216
+ /* 2 */
217
+ /***/ function(module, exports) {
218
+
219
+ (function(){
220
+
221
+
222
+ function emit__(event,args,node){
223
+ // var node = cbs[event]
224
+ var prev,cb,ret;
225
+
226
+ while ((prev = node) && (node = node.next)){
227
+ if (cb = node.listener) {
228
+ if (node.path && cb[node.path]) {
229
+ ret = args ? (cb[node.path].apply(cb,args)) : (cb[node.path]());
230
+ } else {
231
+ // check if it is a method?
232
+ ret = args ? (cb.apply(node,args)) : (cb.call(node));
233
+ };
234
+ };
235
+
236
+ if (node.times && --node.times <= 0) {
237
+ prev.next = node.next;
238
+ node.listener = null;
239
+ };
240
+ };
241
+ return;
242
+ };
243
+
244
+ // method for registering a listener on object
245
+ Imba.listen = function (obj,event,listener,path){
246
+ var $1;
247
+ var cbs,list,tail;
248
+ cbs = obj.__listeners__ || (obj.__listeners__ = {});
249
+ list = cbs[($1 = event)] || (cbs[$1] = {});
250
+ tail = list.tail || (list.tail = (list.next = {}));
251
+ tail.listener = listener;
252
+ tail.path = path;
253
+ list.tail = tail.next = {};
254
+ return tail;
255
+ };
256
+
257
+ Imba.once = function (obj,event,listener){
258
+ var tail = Imba.listen(obj,event,listener);
259
+ tail.times = 1;
260
+ return tail;
261
+ };
262
+
263
+ Imba.unlisten = function (obj,event,cb,meth){
264
+ var node,prev;
265
+ var meta = obj.__listeners__;
266
+ if (!meta) { return };
267
+
268
+ if (node = meta[event]) {
269
+ while ((prev = node) && (node = node.next)){
270
+ if (node == cb || node.listener == cb) {
271
+ prev.next = node.next;
272
+ // check for correct path as well?
273
+ node.listener = null;
274
+ break;
275
+ };
276
+ };
277
+ };
278
+ return;
279
+ };
280
+
281
+ Imba.emit = function (obj,event,params){
282
+ var cb;
283
+ if (cb = obj.__listeners__) {
284
+ if (cb[event]) { emit__(event,params,cb[event]) };
285
+ if (cb.all) { emit__(event,[event,params],cb.all) }; // and event != 'all'
286
+ };
287
+ return;
288
+ };
289
+
290
+ return Imba.observeProperty = function (observer,key,trigger,target,prev){
291
+ if (prev && typeof prev == 'object') {
292
+ Imba.unlisten(prev,'all',observer,trigger);
293
+ };
294
+ if (target && typeof target == 'object') {
295
+ Imba.listen(target,'all',observer,trigger);
296
+ };
297
+ return this;
298
+ };
299
+
300
+ })();
301
+
302
+ /***/ },
303
+ /* 3 */
304
+ /***/ function(module, exports) {
305
+
306
+ /* WEBPACK VAR INJECTION */(function(global) {(function(){
307
+ function idx$(a,b){
308
+ return (b && b.indexOf) ? b.indexOf(a) : [].indexOf.call(a,b);
309
+ };
310
+
311
+
312
+ var raf; // very simple raf polyfill
313
+ raf || (raf = global.requestAnimationFrame);
314
+ raf || (raf = global.webkitRequestAnimationFrame);
315
+ raf || (raf = global.mozRequestAnimationFrame);
316
+ raf || (raf = function(blk) { return setTimeout(blk,1000 / 60); });
317
+
318
+ Imba.tick = function (d){
319
+ if (this._scheduled) { raf(Imba.ticker()) };
320
+ Imba.Scheduler.willRun();
321
+ this.emit(this,'tick',[d]);
322
+ Imba.Scheduler.didRun();
323
+ return;
324
+ };
325
+
326
+ Imba.ticker = function (){
327
+ var self = this;
328
+ return self._ticker || (self._ticker = function(e) { return self.tick(e); });
329
+ };
330
+
331
+ /*
332
+
333
+ Global alternative to requestAnimationFrame. Schedule a target
334
+ to tick every frame. You can specify which method to call on the
335
+ target (defaults to tick).
336
+
337
+ */
338
+
339
+ Imba.schedule = function (target,method){
340
+ if(method === undefined) method = 'tick';
341
+ this.listen(this,'tick',target,method);
342
+ // start scheduling now if this was the first one
343
+ if (!this._scheduled) {
344
+ this._scheduled = true;
345
+ raf(Imba.ticker());
346
+ };
347
+ return this;
348
+ };
349
+
350
+ /*
351
+
352
+ Unschedule a previously scheduled target
353
+
354
+ */
355
+
356
+ Imba.unschedule = function (target,method){
357
+ this.unlisten(this,'tick',target,method);
358
+ var cbs = this.__listeners__ || (this.__listeners__ = {});
359
+ if (!cbs.tick || !cbs.tick.next || !cbs.tick.next.listener) {
360
+ this._scheduled = false;
361
+ };
362
+ return this;
363
+ };
364
+
365
+ /*
366
+
367
+ Light wrapper around native setTimeout that expects the block / function
368
+ as last argument (instead of first). It also triggers an event to Imba
369
+ after the timeout to let schedulers update (to rerender etc) afterwards.
370
+
371
+ */
372
+
373
+ Imba.setTimeout = function (delay,block){
374
+ return setTimeout(function() {
375
+ block();
376
+ return Imba.Scheduler.markDirty();
377
+ // Imba.emit(Imba,'timeout',[block])
378
+ },delay);
379
+ };
380
+
381
+ /*
382
+
383
+ Light wrapper around native setInterval that expects the block / function
384
+ as last argument (instead of first). It also triggers an event to Imba
385
+ after every interval to let schedulers update (to rerender etc) afterwards.
386
+
387
+ */
388
+
389
+ Imba.setInterval = function (interval,block){
390
+ return setInterval(function() {
391
+ block();
392
+ return Imba.Scheduler.markDirty();
393
+ // Imba.emit(Imba,'interval',[block])
394
+ },interval);
395
+ };
396
+
397
+ /*
398
+ Clear interval with specified id
399
+ */
400
+
401
+ Imba.clearInterval = function (interval){
402
+ return clearInterval(interval);
403
+ };
404
+
405
+ /*
406
+ Clear timeout with specified id
407
+ */
408
+
409
+ Imba.clearTimeout = function (timeout){
410
+ return clearTimeout(timeout);
411
+ };
412
+
413
+ // should add an Imba.run / setImmediate that
414
+ // pushes listener onto the tick-queue with times - once
415
+
416
+
417
+ /*
418
+
419
+ Instances of Imba.Scheduler manages when to call `tick()` on their target,
420
+ at a specified framerate or when certain events occur. Root-nodes in your
421
+ applications will usually have a scheduler to make sure they rerender when
422
+ something changes. It is also possible to make inner components use their
423
+ own schedulers to control when they render.
424
+
425
+ @iname scheduler
426
+
427
+ */
428
+
429
+ Imba.Scheduler = function Scheduler(target){
430
+ var self = this;
431
+ self._target = target;
432
+ self._marked = false;
433
+ self._active = false;
434
+ self._marker = function() { return self.mark(); };
435
+ self._ticker = function(e) { return self.tick(e); };
436
+
437
+ self._events = true;
438
+ self._fps = 1;
439
+
440
+ self._dt = 0;
441
+ self._timestamp = 0;
442
+ self._ticks = 0;
443
+ self._flushes = 0;
444
+ };
445
+
446
+ Imba.Scheduler.markDirty = function (){
447
+ this._dirty = true;
448
+ return this;
449
+ };
450
+
451
+ Imba.Scheduler.isDirty = function (){
452
+ return !!this._dirty;
453
+ };
454
+
455
+ Imba.Scheduler.willRun = function (){
456
+ return this._active = true;
457
+ };
458
+
459
+ Imba.Scheduler.didRun = function (){
460
+ this._active = false;
461
+ return this._dirty = false;
462
+ };
463
+
464
+ Imba.Scheduler.isActive = function (){
465
+ return !!this._active;
466
+ };
467
+
468
+ /*
469
+ Create a new Imba.Scheduler for specified target
470
+ @return {Imba.Scheduler}
471
+ */
472
+
473
+ /*
474
+ Check whether the current scheduler is active or not
475
+ @return {bool}
476
+ */
477
+
478
+ Imba.Scheduler.prototype.active = function (){
479
+ return this._active;
480
+ };
481
+
482
+ /*
483
+ Delta time between the two last ticks
484
+ @return {Number}
485
+ */
486
+
487
+ Imba.Scheduler.prototype.dt = function (){
488
+ return this._dt;
489
+ };
490
+
491
+ /*
492
+ Configure the scheduler
493
+ @return {self}
494
+ */
495
+
496
+ Imba.Scheduler.prototype.configure = function (pars){
497
+ if(!pars||pars.constructor !== Object) pars = {};
498
+ var fps = pars.fps !== undefined ? pars.fps : 1;
499
+ var events = pars.events !== undefined ? pars.events : true;
500
+ if (events != null) { this._events = events };
501
+ if (fps != null) { this._fps = fps };
502
+ return this;
503
+ };
504
+
505
+ /*
506
+ Mark the scheduler as dirty. This will make sure that
507
+ the scheduler calls `target.tick` on the next frame
508
+ @return {self}
509
+ */
510
+
511
+ Imba.Scheduler.prototype.mark = function (){
512
+ this._marked = true;
513
+ return this;
514
+ };
515
+
516
+ /*
517
+ Instantly trigger target.tick and mark scheduler as clean (not dirty/marked).
518
+ This is called implicitly from tick, but can also be called manually if you
519
+ really want to force a tick without waiting for the next frame.
520
+ @return {self}
521
+ */
522
+
523
+ Imba.Scheduler.prototype.flush = function (){
524
+ this._marked = false;
525
+ this._flushes++;
526
+ this._target.tick();
527
+ return this;
528
+ };
529
+
530
+ /*
531
+ @fixme this expects raf to run at 60 fps
532
+
533
+ Called automatically on every frame while the scheduler is active.
534
+ It will only call `target.tick` if the scheduler is marked dirty,
535
+ or when according to @fps setting.
536
+
537
+ If you have set up a scheduler with an fps of 1, tick will still be
538
+ called every frame, but `target.tick` will only be called once every
539
+ second, and it will *make sure* each `target.tick` happens in separate
540
+ seconds according to Date. So if you have a node that renders a clock
541
+ based on Date.now (or something similar), you can schedule it with 1fps,
542
+ never needing to worry about two ticks happening within the same second.
543
+ The same goes for 4fps, 10fps etc.
544
+
545
+ @protected
546
+ @return {self}
547
+ */
548
+
549
+ Imba.Scheduler.prototype.tick = function (delta){
550
+ this._ticks++;
551
+ this._dt = delta;
552
+
553
+ var fps = this._fps;
554
+
555
+ if (fps == 60) {
556
+ this._marked = true;
557
+ } else if (fps == 30) {
558
+ if (this._ticks % 2) { this._marked = true };
559
+ } else if (fps) {
560
+ // if it is less round - we trigger based
561
+ // on date, for consistent rendering.
562
+ // ie, if you want to render every second
563
+ // it is important that no two renders
564
+ // happen during the same second (according to Date)
565
+ var period = ((60 / fps) / 60) * 1000;
566
+ var beat = Math.floor(Date.now() / period);
567
+
568
+ if (this._beat != beat) {
569
+ this._beat = beat;
570
+ this._marked = true;
571
+ };
572
+ };
573
+
574
+ if (this._marked || (this._events && Imba.Scheduler.isDirty())) this.flush();
575
+ // reschedule if @active
576
+ return this;
577
+ };
578
+
579
+ /*
580
+ Start the scheduler if it is not already active.
581
+ **While active**, the scheduler will override `target.commit`
582
+ to do nothing. By default Imba.tag#commit calls render, so
583
+ that rendering is cascaded through to children when rendering
584
+ a node. When a scheduler is active (for a node), Imba disables
585
+ this automatic rendering.
586
+ */
587
+
588
+ Imba.Scheduler.prototype.activate = function (){
589
+ if (!this._active) {
590
+ this._active = true;
591
+ // override target#commit while this is active
592
+ this._commit = this._target.commit;
593
+ this._target.commit = function() { return this; };
594
+ Imba.schedule(this);
595
+ if (this._events) { Imba.listen(Imba,'event',this,'onevent') };
596
+ this._target && this._target.flag && this._target.flag('scheduled_');
597
+ this.tick(0); // start ticking
598
+ };
599
+ return this;
600
+ };
601
+
602
+ /*
603
+ Stop the scheduler if it is active.
604
+ */
605
+
606
+ Imba.Scheduler.prototype.deactivate = function (){
607
+ if (this._active) {
608
+ this._active = false;
609
+ this._target.commit = this._commit;
610
+ Imba.unschedule(this);
611
+ Imba.unlisten(Imba,'event',this);
612
+ this._target && this._target.unflag && this._target.unflag('scheduled_');
613
+ };
614
+ return this;
615
+ };
616
+
617
+ Imba.Scheduler.prototype.track = function (){
618
+ return this._marker;
619
+ };
620
+
621
+ Imba.Scheduler.prototype.onevent = function (event){
622
+ var $1;
623
+ if (this._marked) { return this };
624
+
625
+ if (this._events instanceof Function) {
626
+ if (this._events(event)) this.mark();
627
+ } else if (this._events instanceof Array) {
628
+ if (idx$(($1 = event) && $1.type && $1.type(),this._events) >= 0) this.mark();
629
+ } else if (this._events) {
630
+ if (event._responder) this.mark();
631
+ };
632
+ return this;
633
+ };
634
+ return Imba.Scheduler;
635
+
636
+ })();
637
+ /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
638
+
639
+ /***/ },
640
+ /* 4 */
641
+ /***/ function(module, exports) {
642
+
643
+ (function(){
644
+ function idx$(a,b){
645
+ return (b && b.indexOf) ? b.indexOf(a) : [].indexOf.call(a,b);
646
+ };
647
+
648
+ Imba.static = function (items,nr){
649
+ items.static = nr;
650
+ return items;
651
+ };
652
+
653
+ /*
654
+ This is the baseclass that all tags in imba inherit from.
655
+ @iname node
656
+ */
657
+
658
+ Imba.Tag = function Tag(dom){
659
+ this.setDom(dom);
660
+ };
661
+
662
+ Imba.Tag.createNode = function (){
663
+ throw "Not implemented";
664
+ };
665
+
666
+ Imba.Tag.build = function (){
667
+ return new this(this.createNode());
668
+ };
669
+
670
+ Imba.Tag.prototype.object = function(v){ return this._object; }
671
+ Imba.Tag.prototype.setObject = function(v){ this._object = v; return this; };
672
+
673
+ Imba.Tag.prototype.dom = function (){
674
+ return this._dom;
675
+ };
676
+
677
+ Imba.Tag.prototype.setDom = function (dom){
678
+ dom._tag = this;
679
+ this._dom = dom;
680
+ return this;
681
+ };
682
+
683
+ /*
684
+ Setting references for tags like
685
+ `<div@header>` will compile to `tag('div').setRef('header',this).end()`
686
+ By default it adds the reference as a className to the tag.
687
+ @return {self}
688
+ */
689
+
690
+ Imba.Tag.prototype.setRef = function (ref,ctx){
691
+ this.flag(this._ref = ref);
692
+ return this;
693
+ };
694
+
695
+ /*
696
+ Method that is called by the compiled tag-chains, for
697
+ binding events on tags to methods etc.
698
+ `<a :tap=fn>` compiles to `tag('a').setHandler('tap',fn,this).end()`
699
+ where this refers to the context in which the tag is created.
700
+ @return {self}
701
+ */
702
+
703
+ Imba.Tag.prototype.setHandler = function (event,handler,ctx){
704
+ var key = 'on' + event;
705
+
706
+ if (handler instanceof Function) {
707
+ this[key] = handler;
708
+ } else if (handler instanceof Array) {
709
+ var fn = handler.shift();
710
+ this[key] = function(e) { return ctx[fn].apply(ctx,handler.concat(e)); };
711
+ } else {
712
+ this[key] = function(e) { return ctx[handler](e); };
713
+ };
714
+ return this;
715
+ };
716
+
717
+ Imba.Tag.prototype.setId = function (id){
718
+ this.dom().id = id;
719
+ this;
720
+ return this;
721
+ };
722
+
723
+ Imba.Tag.prototype.id = function (){
724
+ return this.dom().id;
725
+ };
726
+
727
+ /*
728
+ Adds a new attribute or changes the value of an existing attribute
729
+ on the specified tag. If the value is null or false, the attribute
730
+ will be removed.
731
+ @return {self}
732
+ */
733
+
734
+ Imba.Tag.prototype.setAttribute = function (name,value){
735
+ // should this not return self?
736
+ var old = this.dom().getAttribute(name);
737
+
738
+ if (old == value) {
739
+ return value;
740
+ } else if (value != null && value !== false) {
741
+ return this.dom().setAttribute(name,value);
742
+ } else {
743
+ return this.dom().removeAttribute(name);
744
+ };
745
+ };
746
+
747
+ /*
748
+ removes an attribute from the specified tag
749
+ */
750
+
751
+ Imba.Tag.prototype.removeAttribute = function (name){
752
+ return this.dom().removeAttribute(name);
753
+ };
754
+
755
+ /*
756
+ returns the value of an attribute on the tag.
757
+ If the given attribute does not exist, the value returned
758
+ will either be null or "" (the empty string)
759
+ */
760
+
761
+ Imba.Tag.prototype.getAttribute = function (name){
762
+ return this.dom().getAttribute(name);
763
+ };
764
+
765
+ /*
766
+ Override this to provide special wrapping etc.
767
+ @return {self}
768
+ */
769
+
770
+ Imba.Tag.prototype.setContent = function (content,type){
771
+ this.setChildren(content,type);
772
+ return this;
773
+ };
774
+
775
+ /*
776
+ Set the children of node. type param is optional,
777
+ and should only be used by Imba when compiling tag trees.
778
+ @return {self}
779
+ */
780
+
781
+ Imba.Tag.prototype.setChildren = function (nodes,type){
782
+ throw "Not implemented";
783
+ };
784
+
785
+ /*
786
+ Get text of node. Uses textContent behind the scenes (not innerText)
787
+ [https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent]()
788
+ @return {string} inner text of node
789
+ */
790
+
791
+ Imba.Tag.prototype.text = function (v){
792
+ return this._dom.textContent;
793
+ };
794
+
795
+ /*
796
+ Set text of node. Uses textContent behind the scenes (not innerText)
797
+ [https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent]()
798
+ */
799
+
800
+ Imba.Tag.prototype.setText = function (txt){
801
+ this._empty = false;
802
+ this._dom.textContent = txt == null ? (txt = "") : (txt);
803
+ this;
804
+ return this;
805
+ };
806
+
807
+
808
+ /*
809
+ Method for getting and setting data-attributes. When called with zero
810
+ arguments it will return the actual dataset for the tag.
811
+
812
+ var node = <div data-name='hello'>
813
+ # get the whole dataset
814
+ node.dataset # {name: 'hello'}
815
+ # get a single value
816
+ node.dataset('name') # 'hello'
817
+ # set a single value
818
+ node.dataset('name','newname') # self
819
+
820
+
821
+ */
822
+
823
+ Imba.Tag.prototype.dataset = function (key,val){
824
+ throw "Not implemented";
825
+ };
826
+
827
+ /*
828
+ Empty placeholder. Override to implement custom render behaviour.
829
+ Works much like the familiar render-method in React.
830
+ @return {self}
831
+ */
832
+
833
+ Imba.Tag.prototype.render = function (){
834
+ return this;
835
+ };
836
+
837
+ /*
838
+ Called implicitly through Imba.Tag#end, upon creating a tag. All
839
+ properties will have been set before build is called, including
840
+ setContent.
841
+ @return {self}
842
+ */
843
+
844
+ Imba.Tag.prototype.build = function (){
845
+ this.render();
846
+ return this;
847
+ };
848
+
849
+ /*
850
+ Called implicitly through Imba.Tag#end, for tags that are part of
851
+ a tag tree (that are rendered several times).
852
+ @return {self}
853
+ */
854
+
855
+ Imba.Tag.prototype.commit = function (){
856
+ this.render();
857
+ return this;
858
+ };
859
+
860
+ /*
861
+
862
+ Called by the tag-scheduler (if this tag is scheduled)
863
+ By default it will call this.render. Do not override unless
864
+ you really understand it.
865
+
866
+ */
867
+
868
+ Imba.Tag.prototype.tick = function (){
869
+ this.render();
870
+ return this;
871
+ };
872
+
873
+ /*
874
+
875
+ A very important method that you will practically never manually.
876
+ The tag syntax of Imba compiles to a chain of setters, which always
877
+ ends with .end. `<a.large>` compiles to `tag('a').flag('large').end()`
878
+
879
+ You are highly adviced to not override its behaviour. The first time
880
+ end is called it will mark the tag as built and call Imba.Tag#build,
881
+ and call Imba.Tag#commit on subsequent calls.
882
+ @return {self}
883
+ */
884
+
885
+ Imba.Tag.prototype.end = function (){
886
+ if (this._built) {
887
+ this.commit();
888
+ } else {
889
+ this._built = true;
890
+ this.build();
891
+ };
892
+ return this;
893
+ };
894
+
895
+ /*
896
+ This is called instead of Imba.Tag#end for `<self>` tag chains.
897
+ Defaults to noop
898
+ @return {self}
899
+ */
900
+
901
+ Imba.Tag.prototype.synced = function (){
902
+ return this;
903
+ };
904
+
905
+ // called when the node is awakened in the dom - either automatically
906
+ // upon attachment to the dom-tree, or the first time imba needs the
907
+ // tag for a domnode that has been rendered on the server
908
+ Imba.Tag.prototype.awaken = function (){
909
+ return this;
910
+ };
911
+
912
+ /*
913
+ List of flags for this node.
914
+ */
915
+
916
+ Imba.Tag.prototype.flags = function (){
917
+ return this._dom.classList;
918
+ };
919
+
920
+ /*
921
+ Add speficied flag to current node.
922
+ If a second argument is supplied, it will be coerced into a Boolean,
923
+ and used to indicate whether we should remove the flag instead.
924
+ @return {self}
925
+ */
926
+
927
+ Imba.Tag.prototype.flag = function (name,toggler){
928
+ // it is most natural to treat a second undefined argument as a no-switch
929
+ // so we need to check the arguments-length
930
+ if (arguments.length == 2) {
931
+ if (this._dom.classList.contains(name) != !!toggler) {
932
+ this._dom.classList.toggle(name);
933
+ };
934
+ } else {
935
+ this._dom.classList.add(name);
936
+ };
937
+ return this;
938
+ };
939
+
940
+ /*
941
+ Remove specified flag from node
942
+ @return {self}
943
+ */
944
+
945
+ Imba.Tag.prototype.unflag = function (name){
946
+ this._dom.classList.remove(name);
947
+ return this;
948
+ };
949
+
950
+ /*
951
+ Toggle specified flag on node
952
+ @return {self}
953
+ */
954
+
955
+ Imba.Tag.prototype.toggleFlag = function (name){
956
+ this._dom.classList.toggle(name);
957
+ return this;
958
+ };
959
+
960
+ /*
961
+ Check whether current node has specified flag
962
+ @return {bool}
963
+ */
964
+
965
+ Imba.Tag.prototype.hasFlag = function (name){
966
+ return this._dom.classList.contains(name);
967
+ };
968
+
969
+ /*
970
+ Get the scheduler for this node. A new scheduler will be created
971
+ if it does not already exist.
972
+
973
+ @return {Imba.Scheduler}
974
+ */
975
+
976
+ Imba.Tag.prototype.scheduler = function (){
977
+ return this._scheduler == null ? (this._scheduler = new Imba.Scheduler(this)) : (this._scheduler);
978
+ };
979
+
980
+ /*
981
+
982
+ Shorthand to start scheduling a node. The method will basically
983
+ proxy the arguments through to scheduler.configure, and then
984
+ activate the scheduler.
985
+
986
+ @return {self}
987
+ */
988
+
989
+ Imba.Tag.prototype.schedule = function (options){
990
+ if(options === undefined) options = {};
991
+ this.scheduler().configure(options).activate();
992
+ return this;
993
+ };
994
+
995
+ /*
996
+ Shorthand for deactivating scheduler (if tag has one).
997
+ @deprecated
998
+ */
999
+
1000
+ Imba.Tag.prototype.unschedule = function (){
1001
+ if (this._scheduler) { this.scheduler().deactivate() };
1002
+ return this;
1003
+ };
1004
+
1005
+
1006
+ /*
1007
+ Get the parent of current node
1008
+ @return {Imba.Tag}
1009
+ */
1010
+
1011
+ Imba.Tag.prototype.parent = function (){
1012
+ return tag$wrap(this.dom().parentNode);
1013
+ };
1014
+
1015
+ /*
1016
+ Shorthand for console.log on elements
1017
+ @return {self}
1018
+ */
1019
+
1020
+ Imba.Tag.prototype.log = function (){
1021
+ var $0 = arguments, i = $0.length;
1022
+ var args = new Array(i>0 ? i : 0);
1023
+ while(i>0) args[i-1] = $0[--i];
1024
+ args.unshift(console);
1025
+ Function.prototype.call.apply(console.log,args);
1026
+ return this;
1027
+ };
1028
+
1029
+ Imba.Tag.prototype.css = function (key,val){
1030
+ if (key instanceof Object) {
1031
+ for (var i = 0, keys = Object.keys(key), l = keys.length; i < l; i++){
1032
+ this.css(keys[i],key[keys[i]]);
1033
+ };
1034
+ } else if (val == null) {
1035
+ this.dom().style.removeProperty(key);
1036
+ } else if (val == undefined) {
1037
+ return this.dom().style[key];
1038
+ } else {
1039
+ if ((typeof val=='number'||val instanceof Number) && key.match(/width|height|left|right|top|bottom/)) {
1040
+ val = val + "px";
1041
+ };
1042
+ this.dom().style[key] = val;
1043
+ };
1044
+ return this;
1045
+ };
1046
+
1047
+ Imba.Tag.prototype.trigger = function (event,data){
1048
+ if(data === undefined) data = {};
1049
+ return Imba.Events.trigger(event,this,{data: data});
1050
+ };
1051
+
1052
+ Imba.Tag.prototype.setTransform = function (value){
1053
+ this.css('transform',value);
1054
+ this;
1055
+ return this;
1056
+ };
1057
+
1058
+ Imba.Tag.prototype.transform = function (){
1059
+ return this.css('transform');
1060
+ };
1061
+
1062
+ Imba.Tag.prototype.setStyle = function (style){
1063
+ this.setAttribute('style',style);
1064
+ this;
1065
+ return this;
1066
+ };
1067
+
1068
+ Imba.Tag.prototype.style = function (){
1069
+ return this.getAttribute('style');
1070
+ };
1071
+
1072
+ Imba.Tag.prototype.toString = function (){
1073
+ return this.dom().outerHTML;
1074
+ };
1075
+
1076
+
1077
+ Imba.Tag.prototype.initialize = Imba.Tag;
1078
+
1079
+ HTML_TAGS = "a abbr address area article aside audio b base bdi bdo big blockquote body br button canvas caption cite code col colgroup data datalist dd del details dfn div dl dt em embed fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 head header hr html i iframe img input ins kbd keygen label legend li link main map mark menu menuitem meta meter nav noscript object ol optgroup option output p param pre progress q rp rt ruby s samp script section select small source span strong style sub summary sup table tbody td textarea tfoot th thead time title tr track u ul var video wbr".split(" ");
1080
+ HTML_TAGS_UNSAFE = "article aside header section".split(" ");
1081
+ SVG_TAGS = "circle defs ellipse g line linearGradient mask path pattern polygon polyline radialGradient rect stop svg text tspan".split(" ");
1082
+
1083
+
1084
+ function extender(obj,sup){
1085
+ for (var i = 0, keys = Object.keys(sup), l = keys.length; i < l; i++){
1086
+ obj[($1 = keys[i])] == null ? (obj[$1] = sup[keys[i]]) : (obj[$1]);
1087
+ };
1088
+
1089
+ obj.prototype = Object.create(sup.prototype);
1090
+ obj.__super__ = obj.prototype.__super__ = sup.prototype;
1091
+ obj.prototype.initialize = obj.prototype.constructor = obj;
1092
+ if (sup.inherit) { sup.inherit(obj) };
1093
+ return obj;
1094
+ };
1095
+
1096
+ function Tag(){
1097
+ return function(dom) {
1098
+ this.setDom(dom);
1099
+ return this;
1100
+ };
1101
+ };
1102
+
1103
+ function TagSpawner(type){
1104
+ return function() { return type.build(); };
1105
+ };
1106
+
1107
+ Imba.Tags = function Tags(){
1108
+ this;
1109
+ };
1110
+
1111
+ Imba.Tags.prototype.__clone = function (ns){
1112
+ var clone = Object.create(this);
1113
+ clone._parent = this;
1114
+ return clone;
1115
+ };
1116
+
1117
+ Imba.Tags.prototype.ns = function (name){
1118
+ return this[name.toUpperCase()] || this.defineNamespace(name);
1119
+ };
1120
+
1121
+ Imba.Tags.prototype.defineNamespace = function (name){
1122
+ var clone = Object.create(this);
1123
+ clone._parent = this;
1124
+ clone._ns = name;
1125
+ this[name.toUpperCase()] = clone;
1126
+ return clone;
1127
+ };
1128
+
1129
+ Imba.Tags.prototype.baseType = function (name){
1130
+ return idx$(name,HTML_TAGS) >= 0 ? ('htmlelement') : ('div');
1131
+ };
1132
+
1133
+ Imba.Tags.prototype.defineTag = function (name,supr,body){
1134
+ if(body==undefined && typeof supr == 'function') body = supr,supr = '';
1135
+ if(supr==undefined) supr = '';
1136
+ supr || (supr = this.baseType(name));
1137
+ var supertype = this[supr];
1138
+ var tagtype = Tag();
1139
+ var norm = name.replace(/\-/g,'_');
1140
+
1141
+
1142
+ tagtype._name = name;
1143
+ extender(tagtype,supertype);
1144
+
1145
+ if (name[0] == '#') {
1146
+ this[name] = tagtype;
1147
+ Imba.SINGLETONS[name.slice(1)] = tagtype;
1148
+ } else {
1149
+ this[name] = tagtype;
1150
+ this['$' + norm] = TagSpawner(tagtype);
1151
+ };
1152
+
1153
+ if (body) {
1154
+ if (body.length == 2) {
1155
+ // create clone
1156
+ if (!tagtype.hasOwnProperty('TAGS')) {
1157
+ tagtype.TAGS = (supertype.TAGS || this).__clone();
1158
+ };
1159
+ };
1160
+
1161
+ body.call(tagtype,tagtype,tagtype.TAGS || this);
1162
+ };
1163
+
1164
+ return tagtype;
1165
+ };
1166
+
1167
+ Imba.Tags.prototype.defineSingleton = function (name,supr,body){
1168
+ return this.defineTag(name,supr,body);
1169
+ };
1170
+
1171
+ Imba.Tags.prototype.extendTag = function (name,supr,body){
1172
+ if(body==undefined && typeof supr == 'function') body = supr,supr = '';
1173
+ if(supr==undefined) supr = '';
1174
+ var klass = ((typeof name=='string'||name instanceof String) ? (this[name]) : (name));
1175
+ // allow for private tags here as well?
1176
+ if (body) { body && body.call(klass,klass,klass.prototype) };
1177
+ return klass;
1178
+ };
1179
+
1180
+
1181
+ Imba.TAGS = new Imba.Tags();
1182
+ Imba.TAGS.element = Imba.Tag;
1183
+
1184
+ var svg = Imba.TAGS.defineNamespace('svg');
1185
+
1186
+ svg.baseType = function (name){
1187
+ return 'svgelement';
1188
+ };
1189
+
1190
+
1191
+ Imba.SINGLETONS = {};
1192
+
1193
+
1194
+ Imba.defineTag = function (name,supr,body){
1195
+ if(body==undefined && typeof supr == 'function') body = supr,supr = '';
1196
+ if(supr==undefined) supr = '';
1197
+ return Imba.TAGS.defineTag(name,supr,body);
1198
+ };
1199
+
1200
+ Imba.defineSingletonTag = function (id,supr,body){
1201
+ if(body==undefined && typeof supr == 'function') body = supr,supr = 'div';
1202
+ if(supr==undefined) supr = 'div';
1203
+ return Imba.TAGS.defineTag(this.name(),supr,body);
1204
+ };
1205
+
1206
+ Imba.extendTag = function (name,body){
1207
+ return Imba.TAGS.extendTag(name,body);
1208
+ };
1209
+
1210
+ Imba.tag = function (name){
1211
+ var typ = Imba.TAGS[name];
1212
+ if (!typ) { throw new Error(("tag " + name + " is not defined")) };
1213
+ return new typ(typ.createNode());
1214
+ };
1215
+
1216
+ Imba.tagWithId = function (name,id){
1217
+ var typ = Imba.TAGS[name];
1218
+ if (!typ) { throw new Error(("tag " + name + " is not defined")) };
1219
+ var dom = typ.createNode();
1220
+ dom.id = id;
1221
+ return new typ(dom);
1222
+ };
1223
+
1224
+ // TODO: Can we move these out and into dom.imba in a clean way?
1225
+ // These methods depends on Imba.document.getElementById
1226
+
1227
+ Imba.getTagSingleton = function (id){
1228
+ var klass;
1229
+ var dom,node;
1230
+
1231
+ if (klass = Imba.SINGLETONS[id]) {
1232
+ if (klass && klass.Instance) { return klass.Instance };
1233
+
1234
+ // no instance - check for element
1235
+ if (dom = Imba.document().getElementById(id)) {
1236
+ // we have a live instance - when finding it through a selector we should awake it, no?
1237
+ // console.log('creating the singleton from existing node in dom?',id,type)
1238
+ node = klass.Instance = new klass(dom);
1239
+ node.awaken(dom); // should only awaken
1240
+ return node;
1241
+ };
1242
+
1243
+ dom = klass.createNode();
1244
+ dom.id = id;
1245
+ node = klass.Instance = new klass(dom);
1246
+ node.end().awaken(dom);
1247
+ return node;
1248
+ } else if (dom = Imba.document().getElementById(id)) {
1249
+ return Imba.getTagForDom(dom);
1250
+ };
1251
+ };
1252
+
1253
+ var svgSupport = typeof SVGElement !== 'undefined';
1254
+
1255
+ Imba.getTagForDom = function (dom){
1256
+ var m;
1257
+ if (!dom) { return null };
1258
+ if (dom._dom) { return dom }; // could use inheritance instead
1259
+ if (dom._tag) { return dom._tag };
1260
+ if (!dom.nodeName) { return null };
1261
+
1262
+ var ns = null;
1263
+ var id = dom.id;
1264
+ var type = dom.nodeName.toLowerCase();
1265
+ var tags = Imba.TAGS;
1266
+ var native$ = type;
1267
+ var cls = dom.className;
1268
+
1269
+ if (id && Imba.SINGLETONS[id]) {
1270
+ // FIXME control that it is the same singleton?
1271
+ // might collide -- not good?
1272
+ return Imba.getTagSingleton(id);
1273
+ };
1274
+ // look for id - singleton
1275
+
1276
+ // need better test here
1277
+ if (svgSupport && (dom instanceof SVGElement)) {
1278
+ ns = "svg";
1279
+ cls = dom.className.baseVal;
1280
+ tags = tags.SVG;
1281
+ };
1282
+
1283
+ var spawner;
1284
+
1285
+ if (cls) {
1286
+ // there can be several matches here - should choose the last
1287
+ // should fall back to less specific later? - otherwise things may fail
1288
+ // TODO rework this
1289
+ var flags = cls.split(' ');
1290
+ var nr = flags.length;
1291
+
1292
+ while (--nr >= 0){
1293
+ var flag = flags[nr];
1294
+ if (flag[0] == '_') {
1295
+ if (spawner = tags[flag.slice(1)]) {
1296
+ break;
1297
+ };
1298
+ };
1299
+ };
1300
+
1301
+ // if var m = cls.match(/\b_([a-z\-]+)\b(?!\s*_[a-z\-]+)/)
1302
+ // type = m[1] # .replace(/-/g,'_')
1303
+
1304
+ if (m = cls.match(/\b([A-Z\-]+)_\b/)) {
1305
+ ns = m[1];
1306
+ };
1307
+ };
1308
+
1309
+ spawner || (spawner = tags[native$]);
1310
+ return spawner ? (new spawner(dom).awaken(dom)) : (null);
1311
+ };
1312
+
1313
+ tag$ = Imba.TAGS;
1314
+ t$ = Imba.tag;
1315
+ tc$ = Imba.tagWithFlags;
1316
+ ti$ = Imba.tagWithId;
1317
+ tic$ = Imba.tagWithIdAndFlags;
1318
+ id$ = Imba.getTagSingleton;
1319
+ return tag$wrap = Imba.getTagForDom;
1320
+
1321
+
1322
+ })();
1323
+
1324
+ /***/ },
1325
+ /* 5 */
1326
+ /***/ function(module, exports) {
1327
+
1328
+ (function(){
1329
+ function iter$(a){ return a ? (a.toArray ? a.toArray() : a) : []; };
1330
+
1331
+ Imba.document = function (){
1332
+ return window.document;
1333
+ };
1334
+
1335
+ /*
1336
+ Returns the body element wrapped in an Imba.Tag
1337
+ */
1338
+
1339
+ Imba.root = function (){
1340
+ return tag$wrap(Imba.document().body);
1341
+ };
1342
+
1343
+ tag$.defineTag('htmlelement', 'element', function(tag){
1344
+
1345
+ /*
1346
+ Called when a tag type is being subclassed.
1347
+ */
1348
+
1349
+ tag.inherit = function (child){
1350
+ child.prototype._empty = true;
1351
+ child._protoDom = null;
1352
+
1353
+ if (this._nodeType) {
1354
+ child._nodeType = this._nodeType;
1355
+
1356
+ var className = "_" + child._name.replace(/_/g,'-');
1357
+ if (child._name[0] != '#') { return child._classes = this._classes.concat(className) };
1358
+ } else {
1359
+ child._nodeType = child._name;
1360
+ return child._classes = [];
1361
+ };
1362
+ };
1363
+
1364
+ tag.buildNode = function (){
1365
+ var dom = Imba.document().createElement(this._nodeType);
1366
+ var cls = this._classes.join(" ");
1367
+ if (cls) { dom.className = cls };
1368
+ return dom;
1369
+ };
1370
+
1371
+ tag.createNode = function (){
1372
+ var proto = (this._protoDom || (this._protoDom = this.buildNode()));
1373
+ return proto.cloneNode(false);
1374
+ };
1375
+
1376
+ tag.dom = function (){
1377
+ return this._protoDom || (this._protoDom = this.buildNode());
1378
+ };
1379
+
1380
+ tag.prototype.tabindex = function(v){ return this.getAttribute('tabindex'); }
1381
+ tag.prototype.setTabindex = function(v){ this.setAttribute('tabindex',v); return this; };
1382
+ tag.prototype.title = function(v){ return this.getAttribute('title'); }
1383
+ tag.prototype.setTitle = function(v){ this.setAttribute('title',v); return this; };
1384
+ tag.prototype.role = function(v){ return this.getAttribute('role'); }
1385
+ tag.prototype.setRole = function(v){ this.setAttribute('role',v); return this; };
1386
+ tag.prototype.name = function(v){ return this.getAttribute('name'); }
1387
+ tag.prototype.setName = function(v){ this.setAttribute('name',v); return this; };
1388
+
1389
+ tag.prototype.id = function (){
1390
+ return this.dom().id;
1391
+ };
1392
+
1393
+ tag.prototype.setId = function (id){
1394
+ this.dom().id = id;
1395
+ this;
1396
+ return this;
1397
+ };
1398
+
1399
+ tag.prototype.width = function (){
1400
+ return this._dom.offsetWidth;
1401
+ };
1402
+
1403
+ tag.prototype.height = function (){
1404
+ return this._dom.offsetHeight;
1405
+ };
1406
+
1407
+ tag.prototype.setChildren = function (nodes,type){
1408
+ this._empty ? (this.append(nodes)) : (this.empty().append(nodes));
1409
+ this._children = null;
1410
+ return this;
1411
+ };
1412
+
1413
+ /*
1414
+ Set inner html of node
1415
+ */
1416
+
1417
+ tag.prototype.setHtml = function (html){
1418
+ this._dom.innerHTML = html;
1419
+ this;
1420
+ return this;
1421
+ };
1422
+
1423
+ /*
1424
+ Get inner html of node
1425
+ */
1426
+
1427
+ tag.prototype.html = function (){
1428
+ return this._dom.innerHTML;
1429
+ };
1430
+
1431
+ /*
1432
+ Remove all content inside node
1433
+ */
1434
+
1435
+ tag.prototype.empty = function (){
1436
+ while (this._dom.firstChild){
1437
+ this._dom.removeChild(this._dom.firstChild);
1438
+ };
1439
+ this._children = null;
1440
+ this._empty = true;
1441
+ return this;
1442
+ };
1443
+
1444
+ /*
1445
+ Remove specified child from current node.
1446
+ */
1447
+
1448
+ tag.prototype.remove = function (child){
1449
+ var par = this.dom();
1450
+ var el = child && child.dom();
1451
+ if (el && el.parentNode == par) { par.removeChild(el) };
1452
+ return this;
1453
+ };
1454
+
1455
+ tag.prototype.emit = function (name,pars){
1456
+ if(!pars||pars.constructor !== Object) pars = {};
1457
+ var data = pars.data !== undefined ? pars.data : null;
1458
+ var bubble = pars.bubble !== undefined ? pars.bubble : true;
1459
+ Imba.Events.trigger(name,this,{data: data,bubble: bubble});
1460
+ return this;
1461
+ };
1462
+
1463
+ tag.prototype.dataset = function (key,val){
1464
+ if (key instanceof Object) {
1465
+ for (var i = 0, keys = Object.keys(key), l = keys.length; i < l; i++){
1466
+ this.dataset(keys[i],key[keys[i]]);
1467
+ };
1468
+ return this;
1469
+ };
1470
+
1471
+ if (arguments.length == 2) {
1472
+ this.setAttribute(("data-" + key),val);
1473
+ return this;
1474
+ };
1475
+
1476
+ if (key) {
1477
+ return this.getAttribute(("data-" + key));
1478
+ };
1479
+
1480
+ var dataset = this.dom().dataset;
1481
+
1482
+ if (!dataset) {
1483
+ dataset = {};
1484
+ for (var i = 0, ary = iter$(this.dom().attributes), len = ary.length, atr; i < len; i++) {
1485
+ atr = ary[i];
1486
+ if (atr.name.substr(0,5) == 'data-') {
1487
+ dataset[Imba.toCamelCase(atr.name.slice(5))] = atr.value;
1488
+ };
1489
+ };
1490
+ };
1491
+
1492
+ return dataset;
1493
+ };
1494
+
1495
+ /*
1496
+ Get descendants of current node, optionally matching selector
1497
+ @return {Imba.Selector}
1498
+ */
1499
+
1500
+ tag.prototype.find = function (sel){
1501
+ return new Imba.Selector(sel,this);
1502
+ };
1503
+
1504
+ /*
1505
+ Get the first matching child of node
1506
+
1507
+ @return {Imba.Tag}
1508
+ */
1509
+
1510
+ tag.prototype.first = function (sel){
1511
+ return sel ? (this.find(sel).first()) : (tag$wrap(this.dom().firstElementChild));
1512
+ };
1513
+
1514
+ /*
1515
+ Get the last matching child of node
1516
+
1517
+ node.last # returns the last child of node
1518
+ node.last %span # returns the last span inside node
1519
+ node.last do |el| el.text == 'Hi' # return last node with text Hi
1520
+
1521
+ @return {Imba.Tag}
1522
+ */
1523
+
1524
+ tag.prototype.last = function (sel){
1525
+ return sel ? (this.find(sel).last()) : (tag$wrap(this.dom().lastElementChild));
1526
+ };
1527
+
1528
+ /*
1529
+ Get the child at index
1530
+ */
1531
+
1532
+ tag.prototype.child = function (i){
1533
+ return tag$wrap(this.dom().children[i || 0]);
1534
+ };
1535
+
1536
+ tag.prototype.children = function (sel){
1537
+ var nodes = new Imba.Selector(null,this,this._dom.children);
1538
+ return sel ? (nodes.filter(sel)) : (nodes);
1539
+ };
1540
+
1541
+ tag.prototype.orphanize = function (){
1542
+ var par;
1543
+ if (par = this.dom().parentNode) { par.removeChild(this._dom) };
1544
+ return this;
1545
+ };
1546
+
1547
+ tag.prototype.matches = function (sel){
1548
+ var fn;
1549
+ if (sel instanceof Function) {
1550
+ return sel(this);
1551
+ };
1552
+
1553
+ if (sel.query) { sel = sel.query() };
1554
+ if (fn = (this._dom.matches || this._dom.matchesSelector || this._dom.webkitMatchesSelector || this._dom.msMatchesSelector || this._dom.mozMatchesSelector)) {
1555
+ return fn.call(this._dom,sel);
1556
+ };
1557
+ };
1558
+
1559
+ /*
1560
+ Get the first element matching supplied selector / filter
1561
+ traversing upwards, but including the node itself.
1562
+ @return {Imba.Tag}
1563
+ */
1564
+
1565
+ tag.prototype.closest = function (sel){
1566
+ if (!sel) { return this.parent() }; // should return self?!
1567
+ var node = this;
1568
+ if (sel.query) { sel = sel.query() };
1569
+
1570
+ while (node){
1571
+ if (node.matches(sel)) { return node };
1572
+ node = node.parent();
1573
+ };
1574
+ return null;
1575
+ };
1576
+
1577
+ /*
1578
+ Get the closest ancestor of node that matches
1579
+ specified selector / matcher.
1580
+
1581
+ @return {Imba.Tag}
1582
+ */
1583
+
1584
+ tag.prototype.up = function (sel){
1585
+ if (!sel) { return this.parent() };
1586
+ return this.parent() && this.parent().closest(sel);
1587
+ };
1588
+
1589
+ tag.prototype.path = function (sel){
1590
+ var node = this;
1591
+ var nodes = [];
1592
+ if (sel && sel.query) { sel = sel.query() };
1593
+
1594
+ while (node){
1595
+ if (!sel || node.matches(sel)) { nodes.push(node) };
1596
+ node = node.parent();
1597
+ };
1598
+ return nodes;
1599
+ };
1600
+
1601
+ tag.prototype.parents = function (sel){
1602
+ var par = this.parent();
1603
+ return par ? (par.path(sel)) : ([]);
1604
+ };
1605
+
1606
+
1607
+
1608
+ tag.prototype.siblings = function (sel){
1609
+ var par, self = this;
1610
+ if (!(par = this.parent())) { return [] }; // FIXME
1611
+ var ary = this.dom().parentNode.children;
1612
+ var nodes = new Imba.Selector(null,this,ary);
1613
+ return nodes.filter(function(n) { return n != self && (!sel || n.matches(sel)); });
1614
+ };
1615
+
1616
+ /*
1617
+ Get the immediately following sibling of node.
1618
+ */
1619
+
1620
+ tag.prototype.next = function (sel){
1621
+ if (sel) {
1622
+ var el = this;
1623
+ while (el = el.next()){
1624
+ if (el.matches(sel)) { return el };
1625
+ };
1626
+ return null;
1627
+ };
1628
+ return tag$wrap(this.dom().nextElementSibling);
1629
+ };
1630
+
1631
+ /*
1632
+ Get the immediately preceeding sibling of node.
1633
+ */
1634
+
1635
+ tag.prototype.prev = function (sel){
1636
+ if (sel) {
1637
+ var el = this;
1638
+ while (el = el.prev()){
1639
+ if (el.matches(sel)) { return el };
1640
+ };
1641
+ return null;
1642
+ };
1643
+ return tag$wrap(this.dom().previousElementSibling);
1644
+ };
1645
+
1646
+ tag.prototype.contains = function (node){
1647
+ return this.dom().contains(node && node._dom || node);
1648
+ };
1649
+
1650
+ tag.prototype.index = function (){
1651
+ var i = 0;
1652
+ var el = this.dom();
1653
+ while (el.previousSibling){
1654
+ el = el.previousSibling;
1655
+ i++;
1656
+ };
1657
+ return i;
1658
+ };
1659
+
1660
+
1661
+ /*
1662
+
1663
+ @deprecated
1664
+ */
1665
+
1666
+ tag.prototype.insert = function (node,pars){
1667
+ if(!pars||pars.constructor !== Object) pars = {};
1668
+ var before = pars.before !== undefined ? pars.before : null;
1669
+ var after = pars.after !== undefined ? pars.after : null;
1670
+ if (after) { before = after.next() };
1671
+ if (node instanceof Array) {
1672
+ node = (tag$.$fragment().setContent(node,0).end());
1673
+ };
1674
+ if (before) {
1675
+ this.dom().insertBefore(node.dom(),before.dom());
1676
+ } else {
1677
+ this.append(node);
1678
+ };
1679
+ return this;
1680
+ };
1681
+
1682
+ /*
1683
+ Focus on current node
1684
+ @return {self}
1685
+ */
1686
+
1687
+ tag.prototype.focus = function (){
1688
+ this.dom().focus();
1689
+ return this;
1690
+ };
1691
+
1692
+ /*
1693
+ Remove focus from current node
1694
+ @return {self}
1695
+ */
1696
+
1697
+ tag.prototype.blur = function (){
1698
+ this.dom().blur();
1699
+ return this;
1700
+ };
1701
+
1702
+ tag.prototype.template = function (){
1703
+ return null;
1704
+ };
1705
+
1706
+ /*
1707
+ @todo Should support multiple arguments like append
1708
+
1709
+ The .prepend method inserts the specified content as the first
1710
+ child of the target node. If the content is already a child of
1711
+ node it will be moved to the start.
1712
+
1713
+ node.prepend <div.top> # prepend node
1714
+ node.prepend "some text" # prepend text
1715
+ node.prepend [<ul>,<ul>] # prepend array
1716
+
1717
+ */
1718
+
1719
+ tag.prototype.prepend = function (item){
1720
+ var first = this._dom.childNodes[0];
1721
+ first ? (this.insertBefore(item,first)) : (this.appendChild(item));
1722
+ return this;
1723
+ };
1724
+
1725
+ /*
1726
+ The .append method inserts the specified content as the last child
1727
+ of the target node. If the content is already a child of node it
1728
+ will be moved to the end.
1729
+
1730
+ # example
1731
+ var root = <div.root>
1732
+ var item = <div.item> "This is an item"
1733
+ root.append item # appends item to the end of root
1734
+
1735
+ root.prepend "some text" # append text
1736
+ root.prepend [<ul>,<ul>] # append array
1737
+ */
1738
+
1739
+ tag.prototype.append = function (item){
1740
+ // possible to append blank
1741
+ // possible to simplify on server?
1742
+ if (!item) { return this };
1743
+
1744
+ if (item instanceof Array) {
1745
+ for (var i = 0, ary = iter$(item), len = ary.length, member; i < len; i++) {
1746
+ member = ary[i];
1747
+ member && this.append(member);
1748
+ };
1749
+ } else if ((typeof item=='string'||item instanceof String) || (typeof item=='number'||item instanceof Number)) {
1750
+ var node = Imba.document().createTextNode(item);
1751
+ this._dom.appendChild(node);
1752
+ if (this._empty) { this._empty = false };
1753
+ } else {
1754
+ this._dom.appendChild(item._dom || item);
1755
+ if (this._empty) { this._empty = false };
1756
+ };
1757
+
1758
+ return this;
1759
+ };
1760
+
1761
+ /*
1762
+ Insert a node into the current node (self), before another.
1763
+ The relative node must be a child of current node.
1764
+ */
1765
+
1766
+ tag.prototype.insertBefore = function (node,rel){
1767
+ if ((typeof node=='string'||node instanceof String)) { node = Imba.document().createTextNode(node) };
1768
+ if (node && rel) { this.dom().insertBefore((node._dom || node),(rel._dom || rel)) };
1769
+ return this;
1770
+ };
1771
+
1772
+ /*
1773
+ Append a single item (node or string) to the current node.
1774
+ If supplied item is a string it will automatically. This is used
1775
+ by Imba internally, but will practically never be used explicitly.
1776
+ */
1777
+
1778
+ tag.prototype.appendChild = function (node){
1779
+ if ((typeof node=='string'||node instanceof String)) { node = Imba.document().createTextNode(node) };
1780
+ if (node) { this.dom().appendChild(node._dom || node) };
1781
+ return this;
1782
+ };
1783
+
1784
+ /*
1785
+ Remove a single child from the current node.
1786
+ Used by Imba internally.
1787
+ */
1788
+
1789
+ tag.prototype.removeChild = function (node){
1790
+ if (node) { this.dom().removeChild(node._dom || node) };
1791
+ return this;
1792
+ };
1793
+
1794
+ /*
1795
+ @deprecated
1796
+ */
1797
+
1798
+ tag.prototype.classes = function (){
1799
+ console.log('Imba.Tag#classes is deprecated');
1800
+ return this._dom.classList;
1801
+ };
1802
+ });
1803
+
1804
+ return tag$.defineTag('svgelement', 'htmlelement');
1805
+
1806
+ })();
1807
+
1808
+ /***/ },
1809
+ /* 6 */
1810
+ /***/ function(module, exports) {
1811
+
1812
+ (function(){
1813
+
1814
+ // predefine all supported html tags
1815
+ tag$.defineTag('fragment', 'htmlelement', function(tag){
1816
+
1817
+ tag.createNode = function (){
1818
+ return Imba.document().createDocumentFragment();
1819
+ };
1820
+ });
1821
+
1822
+ tag$.defineTag('a', function(tag){
1823
+ tag.prototype.href = function(v){ return this.getAttribute('href'); }
1824
+ tag.prototype.setHref = function(v){ this.setAttribute('href',v); return this; };
1825
+ });
1826
+
1827
+ tag$.defineTag('abbr');
1828
+ tag$.defineTag('address');
1829
+ tag$.defineTag('area');
1830
+ tag$.defineTag('article');
1831
+ tag$.defineTag('aside');
1832
+ tag$.defineTag('audio');
1833
+ tag$.defineTag('b');
1834
+ tag$.defineTag('base');
1835
+ tag$.defineTag('bdi');
1836
+ tag$.defineTag('bdo');
1837
+ tag$.defineTag('big');
1838
+ tag$.defineTag('blockquote');
1839
+ tag$.defineTag('body');
1840
+ tag$.defineTag('br');
1841
+
1842
+ tag$.defineTag('button', function(tag){
1843
+ tag.prototype.autofocus = function(v){ return this.getAttribute('autofocus'); }
1844
+ tag.prototype.setAutofocus = function(v){ this.setAttribute('autofocus',v); return this; };
1845
+ tag.prototype.type = function(v){ return this.getAttribute('type'); }
1846
+ tag.prototype.setType = function(v){ this.setAttribute('type',v); return this; };
1847
+
1848
+ tag.prototype.__disabled = {dom: true,name: 'disabled'};
1849
+ tag.prototype.disabled = function(v){ return this.dom().disabled; }
1850
+ tag.prototype.setDisabled = function(v){ if (v != this.dom().disabled) { this.dom().disabled = v }; return this; };
1851
+ });
1852
+
1853
+ tag$.defineTag('canvas', function(tag){
1854
+ tag.prototype.__width = {dom: true,name: 'width'};
1855
+ tag.prototype.width = function(v){ return this.dom().width; }
1856
+ tag.prototype.setWidth = function(v){ if (v != this.dom().width) { this.dom().width = v }; return this; };
1857
+ tag.prototype.__height = {dom: true,name: 'height'};
1858
+ tag.prototype.height = function(v){ return this.dom().height; }
1859
+ tag.prototype.setHeight = function(v){ if (v != this.dom().height) { this.dom().height = v }; return this; };
1860
+
1861
+ tag.prototype.context = function (type){
1862
+ if(type === undefined) type = '2d';
1863
+ return this.dom().getContext(type);
1864
+ };
1865
+ });
1866
+
1867
+ tag$.defineTag('caption');
1868
+ tag$.defineTag('cite');
1869
+ tag$.defineTag('code');
1870
+ tag$.defineTag('col');
1871
+ tag$.defineTag('colgroup');
1872
+ tag$.defineTag('data');
1873
+ tag$.defineTag('datalist');
1874
+ tag$.defineTag('dd');
1875
+ tag$.defineTag('del');
1876
+ tag$.defineTag('details');
1877
+ tag$.defineTag('dfn');
1878
+ tag$.defineTag('div');
1879
+ tag$.defineTag('dl');
1880
+ tag$.defineTag('dt');
1881
+ tag$.defineTag('em');
1882
+ tag$.defineTag('embed');
1883
+
1884
+ tag$.defineTag('fieldset', function(tag){
1885
+ tag.prototype.__disabled = {dom: true,name: 'disabled'};
1886
+ tag.prototype.disabled = function(v){ return this.dom().disabled; }
1887
+ tag.prototype.setDisabled = function(v){ if (v != this.dom().disabled) { this.dom().disabled = v }; return this; };
1888
+ });
1889
+
1890
+ tag$.defineTag('figcaption');
1891
+ tag$.defineTag('figure');
1892
+ tag$.defineTag('footer');
1893
+
1894
+ tag$.defineTag('form', function(tag){
1895
+ tag.prototype.method = function(v){ return this.getAttribute('method'); }
1896
+ tag.prototype.setMethod = function(v){ this.setAttribute('method',v); return this; };
1897
+ tag.prototype.action = function(v){ return this.getAttribute('action'); }
1898
+ tag.prototype.setAction = function(v){ this.setAttribute('action',v); return this; };
1899
+ tag.prototype.enctype = function(v){ return this.getAttribute('enctype'); }
1900
+ tag.prototype.setEnctype = function(v){ this.setAttribute('enctype',v); return this; };
1901
+ tag.prototype.autocomplete = function(v){ return this.getAttribute('autocomplete'); }
1902
+ tag.prototype.setAutocomplete = function(v){ this.setAttribute('autocomplete',v); return this; };
1903
+ tag.prototype.target = function(v){ return this.getAttribute('target'); }
1904
+ tag.prototype.setTarget = function(v){ this.setAttribute('target',v); return this; };
1905
+
1906
+ tag.prototype.__novalidate = {dom: true,name: 'novalidate'};
1907
+ tag.prototype.novalidate = function(v){ return this.dom().novalidate; }
1908
+ tag.prototype.setNovalidate = function(v){ if (v != this.dom().novalidate) { this.dom().novalidate = v }; return this; };
1909
+ });
1910
+
1911
+ tag$.defineTag('h1');
1912
+ tag$.defineTag('h2');
1913
+ tag$.defineTag('h3');
1914
+ tag$.defineTag('h4');
1915
+ tag$.defineTag('h5');
1916
+ tag$.defineTag('h6');
1917
+ tag$.defineTag('head');
1918
+ tag$.defineTag('header');
1919
+ tag$.defineTag('hr');
1920
+ tag$.defineTag('html');
1921
+ tag$.defineTag('i');
1922
+
1923
+ tag$.defineTag('iframe', function(tag){
1924
+ tag.prototype.src = function(v){ return this.getAttribute('src'); }
1925
+ tag.prototype.setSrc = function(v){ this.setAttribute('src',v); return this; };
1926
+ });
1927
+
1928
+ tag$.defineTag('img', function(tag){
1929
+ tag.prototype.src = function(v){ return this.getAttribute('src'); }
1930
+ tag.prototype.setSrc = function(v){ this.setAttribute('src',v); return this; };
1931
+ tag.prototype.srcset = function(v){ return this.getAttribute('srcset'); }
1932
+ tag.prototype.setSrcset = function(v){ this.setAttribute('srcset',v); return this; };
1933
+ });
1934
+
1935
+ tag$.defineTag('input', function(tag){
1936
+ tag.prototype.type = function(v){ return this.getAttribute('type'); }
1937
+ tag.prototype.setType = function(v){ this.setAttribute('type',v); return this; };
1938
+ tag.prototype.required = function(v){ return this.getAttribute('required'); }
1939
+ tag.prototype.setRequired = function(v){ this.setAttribute('required',v); return this; };
1940
+ tag.prototype.disabled = function(v){ return this.getAttribute('disabled'); }
1941
+ tag.prototype.setDisabled = function(v){ this.setAttribute('disabled',v); return this; };
1942
+ tag.prototype.autofocus = function(v){ return this.getAttribute('autofocus'); }
1943
+ tag.prototype.setAutofocus = function(v){ this.setAttribute('autofocus',v); return this; };
1944
+
1945
+ tag.prototype.__value = {dom: true,name: 'value'};
1946
+ tag.prototype.value = function(v){ return this.dom().value; }
1947
+ tag.prototype.setValue = function(v){ if (v != this.dom().value) { this.dom().value = v }; return this; };
1948
+ tag.prototype.__placeholder = {dom: true,name: 'placeholder'};
1949
+ tag.prototype.placeholder = function(v){ return this.dom().placeholder; }
1950
+ tag.prototype.setPlaceholder = function(v){ if (v != this.dom().placeholder) { this.dom().placeholder = v }; return this; };
1951
+ tag.prototype.__required = {dom: true,name: 'required'};
1952
+ tag.prototype.required = function(v){ return this.dom().required; }
1953
+ tag.prototype.setRequired = function(v){ if (v != this.dom().required) { this.dom().required = v }; return this; };
1954
+ tag.prototype.__disabled = {dom: true,name: 'disabled'};
1955
+ tag.prototype.disabled = function(v){ return this.dom().disabled; }
1956
+ tag.prototype.setDisabled = function(v){ if (v != this.dom().disabled) { this.dom().disabled = v }; return this; };
1957
+ tag.prototype.__multiple = {dom: true,name: 'multiple'};
1958
+ tag.prototype.multiple = function(v){ return this.dom().multiple; }
1959
+ tag.prototype.setMultiple = function(v){ if (v != this.dom().multiple) { this.dom().multiple = v }; return this; };
1960
+ tag.prototype.__checked = {dom: true,name: 'checked'};
1961
+ tag.prototype.checked = function(v){ return this.dom().checked; }
1962
+ tag.prototype.setChecked = function(v){ if (v != this.dom().checked) { this.dom().checked = v }; return this; };
1963
+ tag.prototype.__readOnly = {dom: true,name: 'readOnly'};
1964
+ tag.prototype.readOnly = function(v){ return this.dom().readOnly; }
1965
+ tag.prototype.setReadOnly = function(v){ if (v != this.dom().readOnly) { this.dom().readOnly = v }; return this; };
1966
+ });
1967
+
1968
+ tag$.defineTag('ins');
1969
+ tag$.defineTag('kbd');
1970
+ tag$.defineTag('keygen');
1971
+ tag$.defineTag('label');
1972
+ tag$.defineTag('legend');
1973
+ tag$.defineTag('li');
1974
+
1975
+ tag$.defineTag('link', function(tag){
1976
+ tag.prototype.rel = function(v){ return this.getAttribute('rel'); }
1977
+ tag.prototype.setRel = function(v){ this.setAttribute('rel',v); return this; };
1978
+ tag.prototype.type = function(v){ return this.getAttribute('type'); }
1979
+ tag.prototype.setType = function(v){ this.setAttribute('type',v); return this; };
1980
+ tag.prototype.href = function(v){ return this.getAttribute('href'); }
1981
+ tag.prototype.setHref = function(v){ this.setAttribute('href',v); return this; };
1982
+ tag.prototype.media = function(v){ return this.getAttribute('media'); }
1983
+ tag.prototype.setMedia = function(v){ this.setAttribute('media',v); return this; };
1984
+ });
1985
+
1986
+ tag$.defineTag('main');
1987
+ tag$.defineTag('map');
1988
+ tag$.defineTag('mark');
1989
+ tag$.defineTag('menu');
1990
+ tag$.defineTag('menuitem');
1991
+
1992
+ tag$.defineTag('meta', function(tag){
1993
+ tag.prototype.content = function(v){ return this.getAttribute('content'); }
1994
+ tag.prototype.setContent = function(v){ this.setAttribute('content',v); return this; };
1995
+ tag.prototype.charset = function(v){ return this.getAttribute('charset'); }
1996
+ tag.prototype.setCharset = function(v){ this.setAttribute('charset',v); return this; };
1997
+ });
1998
+
1999
+ tag$.defineTag('meter');
2000
+ tag$.defineTag('nav');
2001
+ tag$.defineTag('noscript');
2002
+
2003
+ tag$.defineTag('ol');
2004
+ tag$.defineTag('optgroup', function(tag){
2005
+ tag.prototype.__disabled = {dom: true,name: 'disabled'};
2006
+ tag.prototype.disabled = function(v){ return this.dom().disabled; }
2007
+ tag.prototype.setDisabled = function(v){ if (v != this.dom().disabled) { this.dom().disabled = v }; return this; };
2008
+ });
2009
+
2010
+ tag$.defineTag('option', function(tag){
2011
+ tag.prototype.__disabled = {dom: true,name: 'disabled'};
2012
+ tag.prototype.disabled = function(v){ return this.dom().disabled; }
2013
+ tag.prototype.setDisabled = function(v){ if (v != this.dom().disabled) { this.dom().disabled = v }; return this; };
2014
+ tag.prototype.__selected = {dom: true,name: 'selected'};
2015
+ tag.prototype.selected = function(v){ return this.dom().selected; }
2016
+ tag.prototype.setSelected = function(v){ if (v != this.dom().selected) { this.dom().selected = v }; return this; };
2017
+ tag.prototype.__value = {dom: true,name: 'value'};
2018
+ tag.prototype.value = function(v){ return this.dom().value; }
2019
+ tag.prototype.setValue = function(v){ if (v != this.dom().value) { this.dom().value = v }; return this; };
2020
+ });
2021
+
2022
+ tag$.defineTag('output');
2023
+ tag$.defineTag('p');
2024
+
2025
+ tag$.defineTag('object', function(tag){
2026
+ Imba.attr(tag,'type');
2027
+ Imba.attr(tag,'data');
2028
+ Imba.attr(tag,'width');
2029
+ Imba.attr(tag,'height');
2030
+ });
2031
+
2032
+ tag$.defineTag('param', function(tag){
2033
+ tag.prototype.name = function(v){ return this.getAttribute('name'); }
2034
+ tag.prototype.setName = function(v){ this.setAttribute('name',v); return this; };
2035
+ tag.prototype.value = function(v){ return this.getAttribute('value'); }
2036
+ tag.prototype.setValue = function(v){ this.setAttribute('value',v); return this; };
2037
+ });
2038
+
2039
+ tag$.defineTag('pre');
2040
+ tag$.defineTag('progress');
2041
+ tag$.defineTag('q');
2042
+ tag$.defineTag('rp');
2043
+ tag$.defineTag('rt');
2044
+ tag$.defineTag('ruby');
2045
+ tag$.defineTag('s');
2046
+ tag$.defineTag('samp');
2047
+
2048
+ tag$.defineTag('script', function(tag){
2049
+ tag.prototype.src = function(v){ return this.getAttribute('src'); }
2050
+ tag.prototype.setSrc = function(v){ this.setAttribute('src',v); return this; };
2051
+ tag.prototype.type = function(v){ return this.getAttribute('type'); }
2052
+ tag.prototype.setType = function(v){ this.setAttribute('type',v); return this; };
2053
+ tag.prototype.async = function(v){ return this.getAttribute('async'); }
2054
+ tag.prototype.setAsync = function(v){ this.setAttribute('async',v); return this; };
2055
+ tag.prototype.defer = function(v){ return this.getAttribute('defer'); }
2056
+ tag.prototype.setDefer = function(v){ this.setAttribute('defer',v); return this; };
2057
+ });
2058
+
2059
+ tag$.defineTag('section');
2060
+
2061
+ tag$.defineTag('select', function(tag){
2062
+ tag.prototype.multiple = function(v){ return this.getAttribute('multiple'); }
2063
+ tag.prototype.setMultiple = function(v){ this.setAttribute('multiple',v); return this; };
2064
+
2065
+ tag.prototype.__disabled = {dom: true,name: 'disabled'};
2066
+ tag.prototype.disabled = function(v){ return this.dom().disabled; }
2067
+ tag.prototype.setDisabled = function(v){ if (v != this.dom().disabled) { this.dom().disabled = v }; return this; };
2068
+ tag.prototype.__required = {dom: true,name: 'required'};
2069
+ tag.prototype.required = function(v){ return this.dom().required; }
2070
+ tag.prototype.setRequired = function(v){ if (v != this.dom().required) { this.dom().required = v }; return this; };
2071
+ tag.prototype.__readOnly = {dom: true,name: 'readOnly'};
2072
+ tag.prototype.readOnly = function(v){ return this.dom().readOnly; }
2073
+ tag.prototype.setReadOnly = function(v){ if (v != this.dom().readOnly) { this.dom().readOnly = v }; return this; };
2074
+ tag.prototype.__value = {dom: true,name: 'value'};
2075
+ tag.prototype.value = function(v){ return this.dom().value; }
2076
+ tag.prototype.setValue = function(v){ if (v != this.dom().value) { this.dom().value = v }; return this; };
2077
+ });
2078
+
2079
+
2080
+ tag$.defineTag('small');
2081
+ tag$.defineTag('source');
2082
+ tag$.defineTag('span');
2083
+ tag$.defineTag('strong');
2084
+ tag$.defineTag('style');
2085
+ tag$.defineTag('sub');
2086
+ tag$.defineTag('summary');
2087
+ tag$.defineTag('sup');
2088
+ tag$.defineTag('table');
2089
+ tag$.defineTag('tbody');
2090
+ tag$.defineTag('td');
2091
+
2092
+ tag$.defineTag('textarea', function(tag){
2093
+ tag.prototype.rows = function(v){ return this.getAttribute('rows'); }
2094
+ tag.prototype.setRows = function(v){ this.setAttribute('rows',v); return this; };
2095
+ tag.prototype.cols = function(v){ return this.getAttribute('cols'); }
2096
+ tag.prototype.setCols = function(v){ this.setAttribute('cols',v); return this; };
2097
+ tag.prototype.autofocus = function(v){ return this.getAttribute('autofocus'); }
2098
+ tag.prototype.setAutofocus = function(v){ this.setAttribute('autofocus',v); return this; };
2099
+
2100
+ tag.prototype.__value = {dom: true,name: 'value'};
2101
+ tag.prototype.value = function(v){ return this.dom().value; }
2102
+ tag.prototype.setValue = function(v){ if (v != this.dom().value) { this.dom().value = v }; return this; };
2103
+ tag.prototype.__disabled = {dom: true,name: 'disabled'};
2104
+ tag.prototype.disabled = function(v){ return this.dom().disabled; }
2105
+ tag.prototype.setDisabled = function(v){ if (v != this.dom().disabled) { this.dom().disabled = v }; return this; };
2106
+ tag.prototype.__required = {dom: true,name: 'required'};
2107
+ tag.prototype.required = function(v){ return this.dom().required; }
2108
+ tag.prototype.setRequired = function(v){ if (v != this.dom().required) { this.dom().required = v }; return this; };
2109
+ tag.prototype.__readOnly = {dom: true,name: 'readOnly'};
2110
+ tag.prototype.readOnly = function(v){ return this.dom().readOnly; }
2111
+ tag.prototype.setReadOnly = function(v){ if (v != this.dom().readOnly) { this.dom().readOnly = v }; return this; };
2112
+ tag.prototype.__placeholder = {dom: true,name: 'placeholder'};
2113
+ tag.prototype.placeholder = function(v){ return this.dom().placeholder; }
2114
+ tag.prototype.setPlaceholder = function(v){ if (v != this.dom().placeholder) { this.dom().placeholder = v }; return this; };
2115
+ });
2116
+
2117
+ tag$.defineTag('tfoot');
2118
+ tag$.defineTag('th');
2119
+ tag$.defineTag('thead');
2120
+ tag$.defineTag('time');
2121
+ tag$.defineTag('title');
2122
+ tag$.defineTag('tr');
2123
+ tag$.defineTag('track');
2124
+ tag$.defineTag('u');
2125
+ tag$.defineTag('ul');
2126
+ tag$.defineTag('video');
2127
+ tag$.defineTag('wbr');
2128
+
2129
+ // var idls =
2130
+ // name: ['button','form','fieldset','iframe','input','keygen','object','output','select','textarea','map','meta','param']
2131
+ // src: ['audio','embed','iframe','img','input','script','source','track','video']
2132
+ // disabled: ['button','fieldset','input','keygen','optgroup','option','select','textarea'] # 'command',
2133
+ // required: ['input','select','textarea']
2134
+
2135
+ // for own name,tags of idls
2136
+ // idls[name] = tags.map do |name|
2137
+ // console.log name
2138
+ // Imba.TAGS[name][:prototype]
2139
+ //
2140
+ // for typ in idls:src
2141
+ // def typ.src do dom:src
2142
+ // def typ.setSrc val
2143
+ // dom:src = val if val != dom:src
2144
+ // self
2145
+ //
2146
+ // for typ in idls:disabled
2147
+ // def typ.disabled do dom:disabled
2148
+ // def typ.setDisabled val
2149
+ // dom:disabled = val if dom:disabled != !!val
2150
+ // self
2151
+ //
2152
+ // for typ in idls:required
2153
+ // def typ.required do dom:required
2154
+ // def typ.setRequired val
2155
+ // dom:required = val if dom:required != !!val
2156
+ // self
2157
+
2158
+
2159
+ return true;
2160
+
2161
+ })();
2162
+
2163
+ /***/ },
2164
+ /* 7 */
2165
+ /***/ function(module, exports) {
2166
+
2167
+ (function(){
2168
+ function idx$(a,b){
2169
+ return (b && b.indexOf) ? b.indexOf(a) : [].indexOf.call(a,b);
2170
+ };
2171
+
2172
+
2173
+ tag$.ns('svg').defineTag('svgelement', function(tag){
2174
+
2175
+ tag.namespaceURI = function (){
2176
+ return "http://www.w3.org/2000/svg";
2177
+ };
2178
+
2179
+ var types = "circle defs ellipse g line linearGradient mask path pattern polygon polyline radialGradient rect stop svg text tspan".split(" ");
2180
+
2181
+ tag.buildNode = function (){
2182
+ var dom = Imba.document().createElementNS(this.namespaceURI(),this._nodeType);
2183
+ var cls = this._classes.join(" ");
2184
+ if (cls) { dom.className.baseVal = cls };
2185
+ return dom;
2186
+ };
2187
+
2188
+ tag.inherit = function (child){
2189
+ child._protoDom = null;
2190
+
2191
+ if (idx$(child._name,types) >= 0) {
2192
+ child._nodeType = child._name;
2193
+ return child._classes = [];
2194
+ } else {
2195
+ child._nodeType = this._nodeType;
2196
+ var className = "_" + child._name.replace(/_/g,'-');
2197
+ return child._classes = this._classes.concat(className);
2198
+ };
2199
+ };
2200
+
2201
+
2202
+ Imba.attr(tag,'x');
2203
+ Imba.attr(tag,'y');
2204
+
2205
+ Imba.attr(tag,'width');
2206
+ Imba.attr(tag,'height');
2207
+
2208
+ Imba.attr(tag,'stroke');
2209
+ Imba.attr(tag,'stroke-width');
2210
+ });
2211
+
2212
+ tag$.ns('svg').defineTag('svg', function(tag){
2213
+ Imba.attr(tag,'viewbox');
2214
+ });
2215
+
2216
+ tag$.ns('svg').defineTag('g');
2217
+
2218
+ tag$.ns('svg').defineTag('defs');
2219
+
2220
+ tag$.ns('svg').defineTag('symbol', function(tag){
2221
+ Imba.attr(tag,'preserveAspectRatio');
2222
+ Imba.attr(tag,'viewBox');
2223
+ });
2224
+
2225
+ tag$.ns('svg').defineTag('marker', function(tag){
2226
+ Imba.attr(tag,'markerUnits');
2227
+ Imba.attr(tag,'refX');
2228
+ Imba.attr(tag,'refY');
2229
+ Imba.attr(tag,'markerWidth');
2230
+ Imba.attr(tag,'markerHeight');
2231
+ Imba.attr(tag,'orient');
2232
+ });
2233
+
2234
+
2235
+ // Basic shapes
2236
+
2237
+ tag$.ns('svg').defineTag('rect', function(tag){
2238
+ Imba.attr(tag,'rx');
2239
+ Imba.attr(tag,'ry');
2240
+ });
2241
+
2242
+ tag$.ns('svg').defineTag('circle', function(tag){
2243
+ Imba.attr(tag,'cx');
2244
+ Imba.attr(tag,'cy');
2245
+ Imba.attr(tag,'r');
2246
+ });
2247
+
2248
+ tag$.ns('svg').defineTag('ellipse', function(tag){
2249
+ Imba.attr(tag,'cx');
2250
+ Imba.attr(tag,'cy');
2251
+ Imba.attr(tag,'rx');
2252
+ Imba.attr(tag,'ry');
2253
+ });
2254
+
2255
+ tag$.ns('svg').defineTag('path', function(tag){
2256
+ Imba.attr(tag,'d');
2257
+ Imba.attr(tag,'pathLength');
2258
+ });
2259
+
2260
+ tag$.ns('svg').defineTag('line', function(tag){
2261
+ Imba.attr(tag,'x1');
2262
+ Imba.attr(tag,'x2');
2263
+ Imba.attr(tag,'y1');
2264
+ Imba.attr(tag,'y2');
2265
+ });
2266
+
2267
+ tag$.ns('svg').defineTag('polyline', function(tag){
2268
+ Imba.attr(tag,'points');
2269
+ });
2270
+
2271
+ tag$.ns('svg').defineTag('polygon', function(tag){
2272
+ Imba.attr(tag,'points');
2273
+ });
2274
+
2275
+ tag$.ns('svg').defineTag('text', function(tag){
2276
+ Imba.attr(tag,'dx');
2277
+ Imba.attr(tag,'dy');
2278
+ Imba.attr(tag,'text-anchor');
2279
+ Imba.attr(tag,'rotate');
2280
+ Imba.attr(tag,'textLength');
2281
+ Imba.attr(tag,'lengthAdjust');
2282
+ });
2283
+
2284
+ return tag$.ns('svg').defineTag('tspan', function(tag){
2285
+ Imba.attr(tag,'dx');
2286
+ Imba.attr(tag,'dy');
2287
+ Imba.attr(tag,'rotate');
2288
+ Imba.attr(tag,'textLength');
2289
+ Imba.attr(tag,'lengthAdjust');
2290
+ });
2291
+
2292
+ })();
2293
+
2294
+ /***/ },
2295
+ /* 8 */
2296
+ /***/ function(module, exports, __webpack_require__) {
2297
+
2298
+ (function(){
2299
+ function iter$(a){ return a ? (a.toArray ? a.toArray() : a) : []; };
2300
+ // Extending Imba.Tag#css to work without prefixes by inspecting
2301
+ // the properties of a CSSStyleDeclaration and creating a map
2302
+
2303
+ // var prefixes = ['-webkit-','-ms-','-moz-','-o-','-blink-']
2304
+ // var props = ['transform','transition','animation']
2305
+
2306
+ if (true) {
2307
+ var styles = window.getComputedStyle(document.documentElement,'');
2308
+
2309
+ Imba.CSSKeyMap = {};
2310
+
2311
+ for (var i = 0, ary = iter$(styles), len = ary.length, prefixed; i < len; i++) {
2312
+ prefixed = ary[i];
2313
+ var unprefixed = prefixed.replace(/^-(webkit|ms|moz|o|blink)-/,'');
2314
+ var camelCase = unprefixed.replace(/-(\w)/g,function(m,a) { return a.toUpperCase(); });
2315
+
2316
+ // if there exists an unprefixed version -- always use this
2317
+ if (prefixed != unprefixed) {
2318
+ if (styles.hasOwnProperty(unprefixed)) { continue; };
2319
+ };
2320
+
2321
+ // register the prefixes
2322
+ Imba.CSSKeyMap[unprefixed] = Imba.CSSKeyMap[camelCase] = prefixed;
2323
+ };
2324
+
2325
+ tag$.extendTag('element', function(tag){
2326
+
2327
+ // override the original css method
2328
+ tag.prototype.css = function (key,val){
2329
+ if (key instanceof Object) {
2330
+ for (var i = 0, keys = Object.keys(key), l = keys.length; i < l; i++){
2331
+ this.css(keys[i],key[keys[i]]);
2332
+ };
2333
+ return this;
2334
+ };
2335
+
2336
+ key = Imba.CSSKeyMap[key] || key;
2337
+
2338
+ if (val == null) {
2339
+ this.dom().style.removeProperty(key);
2340
+ } else if (val == undefined) {
2341
+ return this.dom().style[key];
2342
+ } else {
2343
+ if ((typeof val=='number'||val instanceof Number) && key.match(/width|height|left|right|top|bottom/)) {
2344
+ val = val + "px";
2345
+ };
2346
+ this.dom().style[key] = val;
2347
+ };
2348
+ return this;
2349
+ };
2350
+ });
2351
+
2352
+ if (!document.documentElement.classList) {
2353
+ tag$.extendTag('element', function(tag){
2354
+
2355
+ tag.prototype.hasFlag = function (ref){
2356
+ return new RegExp('(^|\\s)' + ref + '(\\s|$)').test(this._dom.className);
2357
+ };
2358
+
2359
+ tag.prototype.addFlag = function (ref){
2360
+ if (this.hasFlag(ref)) { return this };
2361
+ this._dom.className += (this._dom.className ? (' ') : ('')) + ref;
2362
+ return this;
2363
+ };
2364
+
2365
+ tag.prototype.unflag = function (ref){
2366
+ if (!this.hasFlag(ref)) { return this };
2367
+ var regex = new RegExp('(^|\\s)*' + ref + '(\\s|$)*','g');
2368
+ this._dom.className = this._dom.className.replace(regex,'');
2369
+ return this;
2370
+ };
2371
+
2372
+ tag.prototype.toggleFlag = function (ref){
2373
+ return this.hasFlag(ref) ? (this.unflag(ref)) : (this.flag(ref));
2374
+ };
2375
+
2376
+ tag.prototype.flag = function (ref,bool){
2377
+ if (arguments.length == 2 && !!bool === false) {
2378
+ return this.unflag(ref);
2379
+ };
2380
+ return this.addFlag(ref);
2381
+ };
2382
+ });
2383
+ return true;
2384
+ };
2385
+ };
2386
+
2387
+ })();
2388
+
2389
+ /***/ },
2390
+ /* 9 */
2391
+ /***/ function(module, exports) {
2392
+
2393
+ (function(){
2394
+ function iter$(a){ return a ? (a.toArray ? a.toArray() : a) : []; };
2395
+ var doc = document;
2396
+ var win = window;
2397
+
2398
+ var hasTouchEvents = window && window.ontouchstart !== undefined;
2399
+
2400
+ Imba.Pointer = function Pointer(){
2401
+ this.setButton(-1);
2402
+ this.setEvent({x: 0,y: 0,type: 'uninitialized'});
2403
+ return this;
2404
+ };
2405
+
2406
+ Imba.Pointer.prototype.phase = function(v){ return this._phase; }
2407
+ Imba.Pointer.prototype.setPhase = function(v){ this._phase = v; return this; };
2408
+ Imba.Pointer.prototype.prevEvent = function(v){ return this._prevEvent; }
2409
+ Imba.Pointer.prototype.setPrevEvent = function(v){ this._prevEvent = v; return this; };
2410
+ Imba.Pointer.prototype.button = function(v){ return this._button; }
2411
+ Imba.Pointer.prototype.setButton = function(v){ this._button = v; return this; };
2412
+ Imba.Pointer.prototype.event = function(v){ return this._event; }
2413
+ Imba.Pointer.prototype.setEvent = function(v){ this._event = v; return this; };
2414
+ Imba.Pointer.prototype.dirty = function(v){ return this._dirty; }
2415
+ Imba.Pointer.prototype.setDirty = function(v){ this._dirty = v; return this; };
2416
+ Imba.Pointer.prototype.events = function(v){ return this._events; }
2417
+ Imba.Pointer.prototype.setEvents = function(v){ this._events = v; return this; };
2418
+ Imba.Pointer.prototype.touch = function(v){ return this._touch; }
2419
+ Imba.Pointer.prototype.setTouch = function(v){ this._touch = v; return this; };
2420
+
2421
+ Imba.Pointer.prototype.update = function (e){
2422
+ this.setEvent(e);
2423
+ this.setDirty(true);
2424
+ return this;
2425
+ };
2426
+
2427
+ // this is just for regular mouse now
2428
+ Imba.Pointer.prototype.process = function (){
2429
+ var e1 = this.event();
2430
+
2431
+ if (this.dirty()) {
2432
+ this.setPrevEvent(e1);
2433
+ this.setDirty(false);
2434
+
2435
+ // button should only change on mousedown etc
2436
+ if (e1.type == 'mousedown') {
2437
+ this.setButton(e1.button);
2438
+
2439
+ // do not create touch for right click
2440
+ if (this.button() == 2 || (this.touch() && this.button() != 0)) {
2441
+ return;
2442
+ };
2443
+
2444
+ // cancel the previous touch
2445
+ if (this.touch()) { this.touch().cancel() };
2446
+ this.setTouch(new Imba.Touch(e1,this));
2447
+ this.touch().mousedown(e1,e1);
2448
+ } else if (e1.type == 'mousemove') {
2449
+ if (this.touch()) { this.touch().mousemove(e1,e1) };
2450
+ } else if (e1.type == 'mouseup') {
2451
+ this.setButton(-1);
2452
+
2453
+ if (this.touch() && this.touch().button() == e1.button) {
2454
+ this.touch().mouseup(e1,e1);
2455
+ this.setTouch(null);
2456
+ };
2457
+ // trigger pointerup
2458
+ };
2459
+ } else {
2460
+ if (this.touch()) { this.touch().idle() };
2461
+ };
2462
+ return this;
2463
+ };
2464
+
2465
+ Imba.Pointer.prototype.cleanup = function (){
2466
+ return Imba.POINTERS;
2467
+ };
2468
+
2469
+ Imba.Pointer.prototype.x = function (){
2470
+ return this.event().x;
2471
+ };
2472
+ Imba.Pointer.prototype.y = function (){
2473
+ return this.event().y;
2474
+ };
2475
+
2476
+ // deprecated -- should remove
2477
+ Imba.Pointer.update = function (){
2478
+ // console.log('update touch')
2479
+ for (var i = 0, ary = iter$(Imba.POINTERS), len = ary.length; i < len; i++) {
2480
+ ary[i].process();
2481
+ };
2482
+ // need to be able to prevent the default behaviour of touch, no?
2483
+ win.requestAnimationFrame(Imba.Pointer.update);
2484
+ return this;
2485
+ };
2486
+
2487
+ var lastNativeTouchTimeStamp = 0;
2488
+ var lastNativeTouchTimeout = 50;
2489
+
2490
+ // Imba.Touch
2491
+ // Began A finger touched the screen.
2492
+ // Moved A finger moved on the screen.
2493
+ // Stationary A finger is touching the screen but hasn't moved.
2494
+ // Ended A finger was lifted from the screen. This is the final phase of a touch.
2495
+ // Canceled The system cancelled tracking for the touch.
2496
+
2497
+ /*
2498
+ Consolidates mouse and touch events. Touch objects persist across a touch,
2499
+ from touchstart until end/cancel. When a touch starts, it will traverse
2500
+ down from the innermost target, until it finds a node that responds to
2501
+ ontouchstart. Unless the touch is explicitly redirected, the touch will
2502
+ call ontouchmove and ontouchend / ontouchcancel on the responder when appropriate.
2503
+
2504
+ tag draggable
2505
+ # called when a touch starts
2506
+ def ontouchstart touch
2507
+ flag 'dragging'
2508
+ self
2509
+
2510
+ # called when touch moves - same touch object
2511
+ def ontouchmove touch
2512
+ # move the node with touch
2513
+ css top: touch.dy, left: touch.dx
2514
+
2515
+ # called when touch ends
2516
+ def ontouchend touch
2517
+ unflag 'dragging'
2518
+
2519
+ @iname touch
2520
+ */
2521
+
2522
+ Imba.Touch = function Touch(event,pointer){
2523
+ // @native = false
2524
+ this.setEvent(event);
2525
+ this.setData({});
2526
+ this.setActive(true);
2527
+ this._button = event && event.button || 0;
2528
+ this._suppress = false; // deprecated
2529
+ this._captured = false;
2530
+ this.setBubble(false);
2531
+ pointer = pointer;
2532
+ this.setUpdates(0);
2533
+ return this;
2534
+ };
2535
+
2536
+ var touches = [];
2537
+ var count = 0;
2538
+ var identifiers = {};
2539
+
2540
+ Imba.Touch.count = function (){
2541
+ return count;
2542
+ };
2543
+
2544
+ Imba.Touch.lookup = function (item){
2545
+ return item && (item.__touch__ || identifiers[item.identifier]);
2546
+ };
2547
+
2548
+ Imba.Touch.release = function (item,touch){
2549
+ var v_, $1;
2550
+ (((v_ = identifiers[item.identifier]),delete identifiers[item.identifier], v_));
2551
+ ((($1 = item.__touch__),delete item.__touch__, $1));
2552
+ return;
2553
+ };
2554
+
2555
+ Imba.Touch.ontouchstart = function (e){
2556
+ for (var i = 0, ary = iter$(e.changedTouches), len = ary.length, t; i < len; i++) {
2557
+ t = ary[i];
2558
+ if (this.lookup(t)) { continue; };
2559
+ var touch = identifiers[t.identifier] = new this(e); // (e)
2560
+ t.__touch__ = touch;
2561
+ touches.push(touch);
2562
+ count++;
2563
+ touch.touchstart(e,t);
2564
+ };
2565
+ return this;
2566
+ };
2567
+
2568
+ Imba.Touch.ontouchmove = function (e){
2569
+ var touch;
2570
+ for (var i = 0, ary = iter$(e.changedTouches), len = ary.length, t; i < len; i++) {
2571
+ t = ary[i];
2572
+ if (touch = this.lookup(t)) {
2573
+ touch.touchmove(e,t);
2574
+ };
2575
+ };
2576
+
2577
+ return this;
2578
+ };
2579
+
2580
+ Imba.Touch.ontouchend = function (e){
2581
+ var touch;
2582
+ for (var i = 0, ary = iter$(e.changedTouches), len = ary.length, t; i < len; i++) {
2583
+ t = ary[i];
2584
+ if (touch = this.lookup(t)) {
2585
+ touch.touchend(e,t);
2586
+ this.release(t,touch);
2587
+ count--;
2588
+ };
2589
+ };
2590
+
2591
+ // e.preventDefault
2592
+ // not always supported!
2593
+ // touches = touches.filter(||)
2594
+ return this;
2595
+ };
2596
+
2597
+ Imba.Touch.ontouchcancel = function (e){
2598
+ var touch;
2599
+ for (var i = 0, ary = iter$(e.changedTouches), len = ary.length, t; i < len; i++) {
2600
+ t = ary[i];
2601
+ if (touch = this.lookup(t)) {
2602
+ touch.touchcancel(e,t);
2603
+ this.release(t,touch);
2604
+ count--;
2605
+ };
2606
+ };
2607
+ return this;
2608
+ };
2609
+
2610
+ Imba.Touch.onmousedown = function (e){
2611
+ return this;
2612
+ };
2613
+
2614
+ Imba.Touch.onmousemove = function (e){
2615
+ return this;
2616
+ };
2617
+
2618
+ Imba.Touch.onmouseup = function (e){
2619
+ return this;
2620
+ };
2621
+
2622
+
2623
+ Imba.Touch.prototype.phase = function(v){ return this._phase; }
2624
+ Imba.Touch.prototype.setPhase = function(v){ this._phase = v; return this; };
2625
+ Imba.Touch.prototype.active = function(v){ return this._active; }
2626
+ Imba.Touch.prototype.setActive = function(v){ this._active = v; return this; };
2627
+ Imba.Touch.prototype.event = function(v){ return this._event; }
2628
+ Imba.Touch.prototype.setEvent = function(v){ this._event = v; return this; };
2629
+ Imba.Touch.prototype.pointer = function(v){ return this._pointer; }
2630
+ Imba.Touch.prototype.setPointer = function(v){ this._pointer = v; return this; };
2631
+ Imba.Touch.prototype.target = function(v){ return this._target; }
2632
+ Imba.Touch.prototype.setTarget = function(v){ this._target = v; return this; };
2633
+ Imba.Touch.prototype.handler = function(v){ return this._handler; }
2634
+ Imba.Touch.prototype.setHandler = function(v){ this._handler = v; return this; };
2635
+ Imba.Touch.prototype.updates = function(v){ return this._updates; }
2636
+ Imba.Touch.prototype.setUpdates = function(v){ this._updates = v; return this; };
2637
+ Imba.Touch.prototype.suppress = function(v){ return this._suppress; }
2638
+ Imba.Touch.prototype.setSuppress = function(v){ this._suppress = v; return this; };
2639
+ Imba.Touch.prototype.data = function(v){ return this._data; }
2640
+ Imba.Touch.prototype.setData = function(v){ this._data = v; return this; };
2641
+ Imba.Touch.prototype.__bubble = {chainable: true,name: 'bubble'};
2642
+ Imba.Touch.prototype.bubble = function(v){ return v !== undefined ? (this.setBubble(v),this) : this._bubble; }
2643
+ Imba.Touch.prototype.setBubble = function(v){ this._bubble = v; return this; };
2644
+
2645
+ Imba.Touch.prototype.gestures = function(v){ return this._gestures; }
2646
+ Imba.Touch.prototype.setGestures = function(v){ this._gestures = v; return this; };
2647
+
2648
+ /*
2649
+
2650
+
2651
+ @internal
2652
+ @constructor
2653
+ */
2654
+
2655
+ Imba.Touch.prototype.capture = function (){
2656
+ this._captured = true;
2657
+ this._event && this._event.preventDefault();
2658
+ return this;
2659
+ };
2660
+
2661
+ Imba.Touch.prototype.isCaptured = function (){
2662
+ return !!this._captured;
2663
+ };
2664
+
2665
+ /*
2666
+ Extend the touch with a plugin / gesture.
2667
+ All events (touchstart,move etc) for the touch
2668
+ will be triggered on the plugins in the order they
2669
+ are added.
2670
+ */
2671
+
2672
+ Imba.Touch.prototype.extend = function (plugin){
2673
+ // console.log "added gesture!!!"
2674
+ this._gestures || (this._gestures = []);
2675
+ this._gestures.push(plugin);
2676
+ return this;
2677
+ };
2678
+
2679
+ /*
2680
+ Redirect touch to specified target. ontouchstart will always be
2681
+ called on the new target.
2682
+ @return {Number}
2683
+ */
2684
+
2685
+ Imba.Touch.prototype.redirect = function (target){
2686
+ this._redirect = target;
2687
+ return this;
2688
+ };
2689
+
2690
+ /*
2691
+ Suppress the default behaviour. Will call preventDefault for
2692
+ all native events that are part of the touch.
2693
+ */
2694
+
2695
+ Imba.Touch.prototype.suppress = function (){
2696
+ // collision with the suppress property
2697
+ this._active = false;
2698
+ return this;
2699
+ };
2700
+
2701
+ Imba.Touch.prototype.setSuppress = function (value){
2702
+ console.warn('Imba.Touch#suppress= is deprecated');
2703
+ this._supress = value;
2704
+ this;
2705
+ return this;
2706
+ };
2707
+
2708
+ Imba.Touch.prototype.touchstart = function (e,t){
2709
+ this._event = e;
2710
+ this._touch = t;
2711
+ this._button = 0;
2712
+ this._x = t.clientX;
2713
+ this._y = t.clientY;
2714
+ this.began();
2715
+ if (e && this.isCaptured()) { e.preventDefault() };
2716
+ return this;
2717
+ };
2718
+
2719
+ Imba.Touch.prototype.touchmove = function (e,t){
2720
+ this._event = e;
2721
+ this._x = t.clientX;
2722
+ this._y = t.clientY;
2723
+ this.update();
2724
+ if (e && this.isCaptured()) { e.preventDefault() };
2725
+ return this;
2726
+ };
2727
+
2728
+ Imba.Touch.prototype.touchend = function (e,t){
2729
+ this._event = e;
2730
+ this._x = t.clientX;
2731
+ this._y = t.clientY;
2732
+ this.ended();
2733
+
2734
+ lastNativeTouchTimeStamp = e.timeStamp;
2735
+
2736
+ if (this._maxdr < 20) {
2737
+ var tap = new Imba.Event(e);
2738
+ tap.setType('tap');
2739
+ tap.process();
2740
+ if (tap._responder) { e.preventDefault() };
2741
+ };
2742
+
2743
+ if (e && this.isCaptured()) {
2744
+ e.preventDefault();
2745
+ };
2746
+
2747
+ return this;
2748
+ };
2749
+
2750
+ Imba.Touch.prototype.touchcancel = function (e,t){
2751
+ return this.cancel();
2752
+ };
2753
+
2754
+ Imba.Touch.prototype.mousedown = function (e,t){
2755
+ var self = this;
2756
+ self._event = e;
2757
+ self._button = e.button;
2758
+ self._x = t.clientX;
2759
+ self._y = t.clientY;
2760
+ self.began();
2761
+
2762
+ self._mousemove = function(e) { return self.mousemove(e,e); };
2763
+ doc.addEventListener('mousemove',self._mousemove,true);
2764
+ return self;
2765
+ };
2766
+
2767
+ Imba.Touch.prototype.mousemove = function (e,t){
2768
+ this._x = t.clientX;
2769
+ this._y = t.clientY;
2770
+ this._event = e;
2771
+ if (this.isCaptured()) { e.preventDefault() };
2772
+ this.update();
2773
+ this.move();
2774
+ return this;
2775
+ };
2776
+
2777
+ Imba.Touch.prototype.mouseup = function (e,t){
2778
+ this._x = t.clientX;
2779
+ this._y = t.clientY;
2780
+ this.ended();
2781
+ doc.removeEventListener('mousemove',this._mousemove,true);
2782
+ this._mousemove = null;
2783
+ return this;
2784
+ };
2785
+
2786
+ Imba.Touch.prototype.idle = function (){
2787
+ return this.update();
2788
+ };
2789
+
2790
+ Imba.Touch.prototype.began = function (){
2791
+ this._maxdr = this._dr = 0;
2792
+ this._x0 = this._x;
2793
+ this._y0 = this._y;
2794
+
2795
+ var dom = this.event().target;
2796
+ var node = null;
2797
+
2798
+ this._sourceTarget = dom && tag$wrap(dom);
2799
+
2800
+ while (dom){
2801
+ node = tag$wrap(dom);
2802
+ if (node && node.ontouchstart) {
2803
+ this._bubble = false;
2804
+ this.setTarget(node);
2805
+ this.target().ontouchstart(this);
2806
+ if (!this._bubble) { break; };
2807
+ };
2808
+ dom = dom.parentNode;
2809
+ };
2810
+
2811
+ this._updates++;
2812
+ return this;
2813
+ };
2814
+
2815
+ Imba.Touch.prototype.update = function (){
2816
+ var target_;
2817
+ if (!this._active) { return this };
2818
+
2819
+ var dr = Math.sqrt(this.dx() * this.dx() + this.dy() * this.dy());
2820
+ if (dr > this._dr) { this._maxdr = dr };
2821
+ this._dr = dr;
2822
+
2823
+ // catching a touch-redirect?!?
2824
+ if (this._redirect) {
2825
+ if (this._target && this._target.ontouchcancel) {
2826
+ this._target.ontouchcancel(this);
2827
+ };
2828
+ this.setTarget(this._redirect);
2829
+ this._redirect = null;
2830
+ if (this.target().ontouchstart) { this.target().ontouchstart(this) };
2831
+ };
2832
+
2833
+
2834
+ this._updates++;
2835
+ if (this._gestures) {
2836
+ for (var i = 0, ary = iter$(this._gestures), len = ary.length; i < len; i++) {
2837
+ ary[i].ontouchupdate(this);
2838
+ };
2839
+ };
2840
+
2841
+ (target_ = this.target()) && target_.ontouchupdate && target_.ontouchupdate(this);
2842
+ return this;
2843
+ };
2844
+
2845
+ Imba.Touch.prototype.move = function (){
2846
+ var target_;
2847
+ if (!this._active) { return this };
2848
+
2849
+ if (this._gestures) {
2850
+ for (var i = 0, ary = iter$(this._gestures), len = ary.length, g; i < len; i++) {
2851
+ g = ary[i];
2852
+ if (g.ontouchmove) { g.ontouchmove(this,this._event) };
2853
+ };
2854
+ };
2855
+
2856
+ (target_ = this.target()) && target_.ontouchmove && target_.ontouchmove(this,this._event);
2857
+ return this;
2858
+ };
2859
+
2860
+ Imba.Touch.prototype.ended = function (){
2861
+ var target_;
2862
+ if (!this._active) { return this };
2863
+
2864
+ this._updates++;
2865
+
2866
+ if (this._gestures) {
2867
+ for (var i = 0, ary = iter$(this._gestures), len = ary.length; i < len; i++) {
2868
+ ary[i].ontouchend(this);
2869
+ };
2870
+ };
2871
+
2872
+ (target_ = this.target()) && target_.ontouchend && target_.ontouchend(this);
2873
+
2874
+ return this;
2875
+ };
2876
+
2877
+ Imba.Touch.prototype.cancel = function (){
2878
+ if (!this._cancelled) {
2879
+ this._cancelled = true;
2880
+ this.cancelled();
2881
+ if (this._mousemove) { doc.removeEventListener('mousemove',this._mousemove,true) };
2882
+ };
2883
+ return this;
2884
+ };
2885
+
2886
+ Imba.Touch.prototype.cancelled = function (){
2887
+ var target_;
2888
+ if (!this._active) { return this };
2889
+
2890
+ this._cancelled = true;
2891
+ this._updates++;
2892
+
2893
+ if (this._gestures) {
2894
+ for (var i = 0, ary = iter$(this._gestures), len = ary.length, g; i < len; i++) {
2895
+ g = ary[i];
2896
+ if (g.ontouchcancel) { g.ontouchcancel(this) };
2897
+ };
2898
+ };
2899
+
2900
+ (target_ = this.target()) && target_.ontouchcancel && target_.ontouchcancel(this);
2901
+ return this;
2902
+ };
2903
+
2904
+ /*
2905
+ The absolute distance the touch has moved from starting position
2906
+ @return {Number}
2907
+ */
2908
+
2909
+ Imba.Touch.prototype.dr = function (){
2910
+ return this._dr;
2911
+ };
2912
+
2913
+ /*
2914
+ The distance the touch has moved horizontally
2915
+ @return {Number}
2916
+ */
2917
+
2918
+ Imba.Touch.prototype.dx = function (){
2919
+ return this._x - this._x0;
2920
+ };
2921
+
2922
+ /*
2923
+ The distance the touch has moved vertically
2924
+ @return {Number}
2925
+ */
2926
+
2927
+ Imba.Touch.prototype.dy = function (){
2928
+ return this._y - this._y0;
2929
+ };
2930
+
2931
+ /*
2932
+ Initial horizontal position of touch
2933
+ @return {Number}
2934
+ */
2935
+
2936
+ Imba.Touch.prototype.x0 = function (){
2937
+ return this._x0;
2938
+ };
2939
+
2940
+ /*
2941
+ Initial vertical position of touch
2942
+ @return {Number}
2943
+ */
2944
+
2945
+ Imba.Touch.prototype.y0 = function (){
2946
+ return this._y0;
2947
+ };
2948
+
2949
+ /*
2950
+ Horizontal position of touch
2951
+ @return {Number}
2952
+ */
2953
+
2954
+ Imba.Touch.prototype.x = function (){
2955
+ return this._x;
2956
+ };
2957
+
2958
+ /*
2959
+ Vertical position of touch
2960
+ @return {Number}
2961
+ */
2962
+
2963
+ Imba.Touch.prototype.y = function (){
2964
+ return this._y;
2965
+ };
2966
+
2967
+ /*
2968
+ Horizontal position of touch relative to target
2969
+ @return {Number}
2970
+ */
2971
+
2972
+ Imba.Touch.prototype.tx = function (){
2973
+ this._targetBox || (this._targetBox = this._target.dom().getBoundingClientRect());
2974
+ return this._x - this._targetBox.left;
2975
+ };
2976
+
2977
+ /*
2978
+ Vertical position of touch relative to target
2979
+ @return {Number}
2980
+ */
2981
+
2982
+ Imba.Touch.prototype.ty = function (){
2983
+ this._targetBox || (this._targetBox = this._target.dom().getBoundingClientRect());
2984
+ return this._y - this._targetBox.top;
2985
+ };
2986
+
2987
+ /*
2988
+ Button pressed in this touch. Native touches defaults to left-click (0)
2989
+ @return {Number}
2990
+ */
2991
+
2992
+ Imba.Touch.prototype.button = function (){
2993
+ return this._button;
2994
+ }; // @pointer ? @pointer.button : 0
2995
+
2996
+ Imba.Touch.prototype.sourceTarget = function (){
2997
+ return this._sourceTarget;
2998
+ };
2999
+
3000
+
3001
+ Imba.TouchGesture = function TouchGesture(){ };
3002
+
3003
+ Imba.TouchGesture.prototype.__active = {'default': false,name: 'active'};
3004
+ Imba.TouchGesture.prototype.active = function(v){ return this._active; }
3005
+ Imba.TouchGesture.prototype.setActive = function(v){ this._active = v; return this; }
3006
+ Imba.TouchGesture.prototype._active = false;
3007
+
3008
+ Imba.TouchGesture.prototype.ontouchstart = function (e){
3009
+ return this;
3010
+ };
3011
+
3012
+ Imba.TouchGesture.prototype.ontouchupdate = function (e){
3013
+ return this;
3014
+ };
3015
+
3016
+ Imba.TouchGesture.prototype.ontouchend = function (e){
3017
+ return this;
3018
+ };
3019
+
3020
+
3021
+ // A Touch-event is created on mousedown (always)
3022
+ // and while it exists, mousemove and mouseup will
3023
+ // be delegated to this active event.
3024
+ Imba.POINTER = new Imba.Pointer();
3025
+ Imba.POINTERS = [Imba.POINTER];
3026
+
3027
+
3028
+ // regular event stuff
3029
+ Imba.KEYMAP = {
3030
+ "8": 'backspace',
3031
+ "9": 'tab',
3032
+ "13": 'enter',
3033
+ "16": 'shift',
3034
+ "17": 'ctrl',
3035
+ "18": 'alt',
3036
+ "19": 'break',
3037
+ "20": 'caps',
3038
+ "27": 'esc',
3039
+ "32": 'space',
3040
+ "35": 'end',
3041
+ "36": 'home',
3042
+ "37": 'larr',
3043
+ "38": 'uarr',
3044
+ "39": 'rarr',
3045
+ "40": 'darr',
3046
+ "45": 'insert',
3047
+ "46": 'delete',
3048
+ "107": 'plus',
3049
+ "106": 'mult',
3050
+ "91": 'meta'
3051
+ };
3052
+
3053
+ Imba.CHARMAP = {
3054
+ "%": 'modulo',
3055
+ "*": 'multiply',
3056
+ "+": 'add',
3057
+ "-": 'sub',
3058
+ "/": 'divide',
3059
+ ".": 'dot'
3060
+ };
3061
+
3062
+ /*
3063
+ Imba handles all events in the dom through a single manager,
3064
+ listening at the root of your document. If Imba finds a tag
3065
+ that listens to a certain event, the event will be wrapped
3066
+ in an `Imba.Event`, which normalizes some of the quirks and
3067
+ browser differences.
3068
+
3069
+ @iname event
3070
+ */
3071
+
3072
+ Imba.Event = function Event(e){
3073
+ this.setEvent(e);
3074
+ this.setBubble(true);
3075
+ };
3076
+
3077
+ /* reference to the native event */
3078
+
3079
+ Imba.Event.prototype.event = function(v){ return this._event; }
3080
+ Imba.Event.prototype.setEvent = function(v){ this._event = v; return this; };
3081
+
3082
+ /* reference to the native event */
3083
+
3084
+ Imba.Event.prototype.prefix = function(v){ return this._prefix; }
3085
+ Imba.Event.prototype.setPrefix = function(v){ this._prefix = v; return this; };
3086
+
3087
+ Imba.Event.prototype.data = function(v){ return this._data; }
3088
+ Imba.Event.prototype.setData = function(v){ this._data = v; return this; };
3089
+
3090
+ /*
3091
+ should remove this alltogether?
3092
+ @deprecated
3093
+ */
3094
+
3095
+ Imba.Event.prototype.source = function(v){ return this._source; }
3096
+ Imba.Event.prototype.setSource = function(v){ this._source = v; return this; };
3097
+
3098
+ /* A {Boolean} indicating whether the event bubbles up or not */
3099
+
3100
+ Imba.Event.prototype.__bubble = {type: Boolean,chainable: true,name: 'bubble'};
3101
+ Imba.Event.prototype.bubble = function(v){ return v !== undefined ? (this.setBubble(v),this) : this._bubble; }
3102
+ Imba.Event.prototype.setBubble = function(v){ this._bubble = v; return this; };
3103
+
3104
+ Imba.Event.wrap = function (e){
3105
+ return new this(e);
3106
+ };
3107
+
3108
+ Imba.Event.prototype.setType = function (type){
3109
+ this._type = type;
3110
+ this;
3111
+ return this;
3112
+ };
3113
+
3114
+ /*
3115
+ @return {String} The name of the event (case-insensitive)
3116
+ */
3117
+
3118
+ Imba.Event.prototype.type = function (){
3119
+ return this._type || this.event().type;
3120
+ };
3121
+
3122
+ Imba.Event.prototype.name = function (){
3123
+ return this._name || (this._name = this.type().toLowerCase().replace(/\:/g,''));
3124
+ };
3125
+
3126
+ // mimc getset
3127
+ Imba.Event.prototype.bubble = function (v){
3128
+ if (v != undefined) {
3129
+ this.setBubble(v);
3130
+ return this;
3131
+ };
3132
+ return this._bubble;
3133
+ };
3134
+
3135
+ /*
3136
+ Prevents further propagation of the current event.
3137
+ @return {self}
3138
+ */
3139
+
3140
+ Imba.Event.prototype.halt = function (){
3141
+ this.setBubble(false);
3142
+ return this;
3143
+ };
3144
+
3145
+ /*
3146
+ Cancel the event (if cancelable). In the case of native events it
3147
+ will call `preventDefault` on the wrapped event object.
3148
+ @return {self}
3149
+ */
3150
+
3151
+ Imba.Event.prototype.cancel = function (){
3152
+ if (this.event().preventDefault) { this.event().preventDefault() };
3153
+ this._cancel = true;
3154
+ return this;
3155
+ };
3156
+
3157
+ Imba.Event.prototype.silence = function (){
3158
+ this._silenced = true;
3159
+ return this;
3160
+ };
3161
+
3162
+ Imba.Event.prototype.isSilenced = function (){
3163
+ return !!this._silenced;
3164
+ };
3165
+
3166
+ /*
3167
+ Indicates whether or not event.cancel has been called.
3168
+
3169
+ @return {Boolean}
3170
+ */
3171
+
3172
+ Imba.Event.prototype.isPrevented = function (){
3173
+ return this.event() && this.event().defaultPrevented || this._cancel;
3174
+ };
3175
+
3176
+ /*
3177
+ A reference to the initial target of the event.
3178
+ */
3179
+
3180
+ Imba.Event.prototype.target = function (){
3181
+ return tag$wrap(this.event()._target || this.event().target);
3182
+ };
3183
+
3184
+ /*
3185
+ A reference to the object responding to the event.
3186
+ */
3187
+
3188
+ Imba.Event.prototype.responder = function (){
3189
+ return this._responder;
3190
+ };
3191
+
3192
+ /*
3193
+ Redirect the event to new target
3194
+ */
3195
+
3196
+ Imba.Event.prototype.redirect = function (node){
3197
+ this._redirect = node;
3198
+ return this;
3199
+ };
3200
+
3201
+ /*
3202
+ Get the normalized character for KeyboardEvent/TextEvent
3203
+ @return {String}
3204
+ */
3205
+
3206
+ Imba.Event.prototype.keychar = function (){
3207
+ if (this.event() instanceof KeyboardEvent) {
3208
+ var ki = this.event().keyIdentifier;
3209
+ var sym = Imba.KEYMAP[this.event().keyCode];
3210
+
3211
+ if (!sym && ki.substr(0,2) == "U+") {
3212
+ sym = String.fromCharCode(parseInt(ki.substr(2),16));
3213
+ };
3214
+ return sym;
3215
+ } else if (this.event() instanceof (window.TextEvent || window.InputEvent)) {
3216
+ return this.event().data;
3217
+ };
3218
+
3219
+ return null;
3220
+ };
3221
+
3222
+ /*
3223
+ @deprecated
3224
+ */
3225
+
3226
+ Imba.Event.prototype.keycombo = function (){
3227
+ var sym;
3228
+ if (!(sym = this.keychar())) { return };
3229
+ sym = Imba.CHARMAP[sym] || sym;
3230
+ var combo = [],e = this.event();
3231
+ if (e.ctrlKey) { combo.push('ctrl') };
3232
+ if (e.shiftKey) { combo.push('shift') };
3233
+ if (e.altKey) { combo.push('alt') };
3234
+ if (e.metaKey) { combo.push('cmd') };
3235
+ combo.push(sym);
3236
+ return combo.join("_").toLowerCase();
3237
+ };
3238
+
3239
+
3240
+ Imba.Event.prototype.process = function (){
3241
+ var node;
3242
+ var meth = ("on" + (this._prefix || '') + this.name());
3243
+ var args = null;
3244
+ var domtarget = this.event()._target || this.event().target;
3245
+ // var node = <{domtarget:_responder or domtarget}>
3246
+ // need to clean up and document this behaviour
3247
+
3248
+ var domnode = domtarget._responder || domtarget;
3249
+ // @todo need to stop infinite redirect-rules here
3250
+
3251
+ var $1;while (domnode){
3252
+ this._redirect = null;
3253
+ if (node = tag$wrap(domnode)) { // not only tag
3254
+
3255
+ if ((typeof node[($1 = meth)]=='string'||node[$1] instanceof String)) {
3256
+ // should remember the receiver of the event
3257
+ meth = node[meth];
3258
+ continue; // should not continue?
3259
+ };
3260
+
3261
+ if (node[meth] instanceof Array) {
3262
+ args = node[meth].concat(node);
3263
+ meth = args.shift();
3264
+ continue; // should not continue?
3265
+ };
3266
+
3267
+ if (node[meth] instanceof Function) {
3268
+ this._responder || (this._responder = node);
3269
+ // should autostop bubble here?
3270
+ args ? (node[meth].apply(node,args)) : (node[meth](this,this.data()));
3271
+ };
3272
+ };
3273
+
3274
+ // add node.nextEventResponder as a separate method here?
3275
+ if (!(this.bubble() && (domnode = (this._redirect || (node ? (node.parent()) : (domnode.parentNode)))))) {
3276
+ break;
3277
+ };
3278
+ };
3279
+
3280
+ this.processed();
3281
+ return this;
3282
+ };
3283
+
3284
+
3285
+ Imba.Event.prototype.processed = function (){
3286
+ if (!this._silenced) { Imba.emit(Imba,'event',[this]) };
3287
+ return this;
3288
+ };
3289
+
3290
+ /*
3291
+ Return the x/left coordinate of the mouse / pointer for this event
3292
+ @return {Number} x coordinate of mouse / pointer for event
3293
+ */
3294
+
3295
+ Imba.Event.prototype.x = function (){
3296
+ return this.event().x;
3297
+ };
3298
+
3299
+ /*
3300
+ Return the y/top coordinate of the mouse / pointer for this event
3301
+ @return {Number} y coordinate of mouse / pointer for event
3302
+ */
3303
+
3304
+ Imba.Event.prototype.y = function (){
3305
+ return this.event().y;
3306
+ };
3307
+
3308
+ /*
3309
+ Returns a Number representing a system and implementation
3310
+ dependent numeric code identifying the unmodified value of the
3311
+ pressed key; this is usually the same as keyCode.
3312
+
3313
+ For mouse-events, the returned value indicates which button was
3314
+ pressed on the mouse to trigger the event.
3315
+
3316
+ @return {Number}
3317
+ */
3318
+
3319
+ Imba.Event.prototype.which = function (){
3320
+ return this.event().which;
3321
+ };
3322
+
3323
+
3324
+ /*
3325
+
3326
+ Manager for listening to and delegating events in Imba. A single instance
3327
+ is always created by Imba (as `Imba.Events`), which handles and delegates all
3328
+ events at the very root of the document. Imba does not capture all events
3329
+ by default, so if you want to make sure exotic or custom DOMEvents are delegated
3330
+ in Imba you will need to register them in `Imba.Events.register(myCustomEventName)`
3331
+
3332
+ @iname manager
3333
+
3334
+ */
3335
+
3336
+ Imba.EventManager = function EventManager(node,pars){
3337
+ var self = this;
3338
+ if(!pars||pars.constructor !== Object) pars = {};
3339
+ var events = pars.events !== undefined ? pars.events : [];
3340
+ self.setRoot(node);
3341
+ self.setCount(0);
3342
+ self.setListeners([]);
3343
+ self.setDelegators({});
3344
+ self.setDelegator(function(e) {
3345
+ // console.log "delegating event?! {e}"
3346
+ self.delegate(e);
3347
+ return true;
3348
+ });
3349
+
3350
+ for (var i = 0, ary = iter$(events), len = ary.length; i < len; i++) {
3351
+ self.register(ary[i]);
3352
+ };
3353
+
3354
+ return self;
3355
+ };
3356
+
3357
+ Imba.EventManager.prototype.root = function(v){ return this._root; }
3358
+ Imba.EventManager.prototype.setRoot = function(v){ this._root = v; return this; };
3359
+ Imba.EventManager.prototype.count = function(v){ return this._count; }
3360
+ Imba.EventManager.prototype.setCount = function(v){ this._count = v; return this; };
3361
+ Imba.EventManager.prototype.__enabled = {'default': false,watch: 'enabledDidSet',name: 'enabled'};
3362
+ Imba.EventManager.prototype.enabled = function(v){ return this._enabled; }
3363
+ Imba.EventManager.prototype.setEnabled = function(v){
3364
+ var a = this.enabled();
3365
+ if(v != a) { this._enabled = v; }
3366
+ if(v != a) { this.enabledDidSet && this.enabledDidSet(v,a,this.__enabled) }
3367
+ return this;
3368
+ }
3369
+ Imba.EventManager.prototype._enabled = false;
3370
+ Imba.EventManager.prototype.listeners = function(v){ return this._listeners; }
3371
+ Imba.EventManager.prototype.setListeners = function(v){ this._listeners = v; return this; };
3372
+ Imba.EventManager.prototype.delegators = function(v){ return this._delegators; }
3373
+ Imba.EventManager.prototype.setDelegators = function(v){ this._delegators = v; return this; };
3374
+ Imba.EventManager.prototype.delegator = function(v){ return this._delegator; }
3375
+ Imba.EventManager.prototype.setDelegator = function(v){ this._delegator = v; return this; };
3376
+
3377
+ Imba.EventManager.prototype.enabledDidSet = function (bool){
3378
+ bool ? (this.onenable()) : (this.ondisable());
3379
+ return this;
3380
+ };
3381
+
3382
+ /*
3383
+
3384
+ Tell the current EventManager to intercept and handle event of a certain name.
3385
+ By default, Imba.Events will register interceptors for: *keydown*, *keyup*,
3386
+ *keypress*, *textInput*, *input*, *change*, *submit*, *focusin*, *focusout*,
3387
+ *blur*, *contextmenu*, *dblclick*, *mousewheel*, *wheel*
3388
+
3389
+ */
3390
+
3391
+ Imba.EventManager.prototype.register = function (name,handler){
3392
+ if(handler === undefined) handler = true;
3393
+ if (name instanceof Array) {
3394
+ for (var i = 0, ary = iter$(name), len = ary.length; i < len; i++) {
3395
+ this.register(ary[i],handler);
3396
+ };
3397
+ return this;
3398
+ };
3399
+
3400
+ if (this.delegators()[name]) { return this };
3401
+ // console.log("register for event {name}")
3402
+ var fn = this.delegators()[name] = handler instanceof Function ? (handler) : (this.delegator());
3403
+ if (this.enabled()) { return this.root().addEventListener(name,fn,true) };
3404
+ };
3405
+
3406
+ Imba.EventManager.prototype.listen = function (name,handler,capture){
3407
+ if(capture === undefined) capture = true;
3408
+ this.listeners().push([name,handler,capture]);
3409
+ if (this.enabled()) { this.root().addEventListener(name,handler,capture) };
3410
+ return this;
3411
+ };
3412
+
3413
+ Imba.EventManager.prototype.delegate = function (e){
3414
+ this.setCount(this.count() + 1);
3415
+ var event = Imba.Event.wrap(e);
3416
+ event.process();
3417
+ return this;
3418
+ };
3419
+
3420
+ /*
3421
+
3422
+ Create a new Imba.Event
3423
+
3424
+ */
3425
+
3426
+ Imba.EventManager.prototype.create = function (type,target,pars){
3427
+ if(!pars||pars.constructor !== Object) pars = {};
3428
+ var data = pars.data !== undefined ? pars.data : null;
3429
+ var source = pars.source !== undefined ? pars.source : null;
3430
+ var event = Imba.Event.wrap({type: type,target: target});
3431
+ if (data) { (event.setData(data),data) };
3432
+ if (source) { (event.setSource(source),source) };
3433
+ return event;
3434
+ };
3435
+
3436
+ /*
3437
+
3438
+ Trigger / process an Imba.Event.
3439
+
3440
+ */
3441
+
3442
+ Imba.EventManager.prototype.trigger = function (){
3443
+ return this.create.apply(this,arguments).process();
3444
+ };
3445
+
3446
+ Imba.EventManager.prototype.onenable = function (){
3447
+ for (var o = this.delegators(), i = 0, keys = Object.keys(o), l = keys.length; i < l; i++){
3448
+ this.root().addEventListener(keys[i],o[keys[i]],true);
3449
+ };
3450
+
3451
+ for (var i = 0, ary = iter$(this.listeners()), len = ary.length, item; i < len; i++) {
3452
+ item = ary[i];
3453
+ this.root().addEventListener(item[0],item[1],item[2]);
3454
+ };
3455
+ return this;
3456
+ };
3457
+
3458
+ Imba.EventManager.prototype.ondisable = function (){
3459
+ for (var o = this.delegators(), i = 0, keys = Object.keys(o), l = keys.length; i < l; i++){
3460
+ this.root().removeEventListener(keys[i],o[keys[i]],true);
3461
+ };
3462
+
3463
+ for (var i = 0, ary = iter$(this.listeners()), len = ary.length, item; i < len; i++) {
3464
+ item = ary[i];
3465
+ this.root().removeEventListener(item[0],item[1],item[2]);
3466
+ };
3467
+ return this;
3468
+ };
3469
+
3470
+
3471
+ ED = Imba.Events = new Imba.EventManager(document,{events: [
3472
+ 'keydown','keyup','keypress','textInput','input','change','submit',
3473
+ 'focusin','focusout','blur','contextmenu','dblclick',
3474
+ 'mousewheel','wheel','scroll'
3475
+ ]});
3476
+
3477
+ // should set these up inside the Imba.Events object itself
3478
+ // so that we can have different EventManager for different roots
3479
+
3480
+ if (hasTouchEvents) {
3481
+ Imba.Events.listen('touchstart',function(e) {
3482
+ var Events_, v_;
3483
+ (((Events_ = Imba.Events).setCount(v_ = Events_.count() + 1),v_)) - 1;
3484
+ return Imba.Touch.ontouchstart(e);
3485
+ });
3486
+
3487
+ Imba.Events.listen('touchmove',function(e) {
3488
+ var Events_, v_;
3489
+ (((Events_ = Imba.Events).setCount(v_ = Events_.count() + 1),v_)) - 1;
3490
+ return Imba.Touch.ontouchmove(e);
3491
+ });
3492
+
3493
+ Imba.Events.listen('touchend',function(e) {
3494
+ var Events_, v_;
3495
+ (((Events_ = Imba.Events).setCount(v_ = Events_.count() + 1),v_)) - 1;
3496
+ return Imba.Touch.ontouchend(e);
3497
+ });
3498
+
3499
+ Imba.Events.listen('touchcancel',function(e) {
3500
+ var Events_, v_;
3501
+ (((Events_ = Imba.Events).setCount(v_ = Events_.count() + 1),v_)) - 1;
3502
+ return Imba.Touch.ontouchcancel(e);
3503
+ });
3504
+ };
3505
+
3506
+ Imba.Events.register('click',function(e) {
3507
+ // Only for main mousebutton, no?
3508
+ if ((e.timeStamp - lastNativeTouchTimeStamp) > lastNativeTouchTimeout) {
3509
+ var tap = new Imba.Event(e);
3510
+ tap.setType('tap');
3511
+ tap.process();
3512
+ if (tap._responder) {
3513
+ return e.preventDefault();
3514
+ };
3515
+ };
3516
+ // delegate the real click event
3517
+ return Imba.Events.delegate(e);
3518
+ });
3519
+
3520
+ Imba.Events.listen('mousedown',function(e) {
3521
+ if ((e.timeStamp - lastNativeTouchTimeStamp) > lastNativeTouchTimeout) {
3522
+ if (Imba.POINTER) { return Imba.POINTER.update(e).process() };
3523
+ };
3524
+ });
3525
+
3526
+ // Imba.Events.listen(:mousemove) do |e|
3527
+ // # console.log 'mousemove',e:timeStamp
3528
+ // if (e:timeStamp - lastNativeTouchTimeStamp) > lastNativeTouchTimeout
3529
+ // Imba.POINTER.update(e).process if Imba.POINTER # .process if touch # should not happen? We process through
3530
+
3531
+ Imba.Events.listen('mouseup',function(e) {
3532
+ // console.log 'mouseup',e:timeStamp
3533
+ if ((e.timeStamp - lastNativeTouchTimeStamp) > lastNativeTouchTimeout) {
3534
+ if (Imba.POINTER) { return Imba.POINTER.update(e).process() };
3535
+ };
3536
+ });
3537
+
3538
+
3539
+ Imba.Events.register(['mousedown','mouseup']);
3540
+ return (Imba.Events.setEnabled(true),true);
3541
+
3542
+ })();
3543
+
3544
+ /***/ },
3545
+ /* 10 */
3546
+ /***/ function(module, exports) {
3547
+
3548
+ (function(){
3549
+ function iter$(a){ return a ? (a.toArray ? a.toArray() : a) : []; };
3550
+ var ImbaTag = Imba.TAGS.element;
3551
+
3552
+ function removeNested(root,node,caret){
3553
+ // if node/nodes isa String
3554
+ // we need to use the caret to remove elements
3555
+ // for now we will simply not support this
3556
+ if (node instanceof ImbaTag) {
3557
+ root.removeChild(node);
3558
+ } else if (node instanceof Array) {
3559
+ for (var i = 0, ary = iter$(node), len = ary.length; i < len; i++) {
3560
+ removeNested(root,ary[i],caret);
3561
+ };
3562
+ } else if (node != null) {
3563
+ // what if this is not null?!?!?
3564
+ // take a chance and remove a text-elementng
3565
+ var next = caret ? (caret.nextSibling) : (root._dom.firstChild);
3566
+ if ((next instanceof Text) && next.textContent == node) {
3567
+ root.removeChild(next);
3568
+ } else {
3569
+ throw 'cannot remove string';
3570
+ };
3571
+ };
3572
+
3573
+ return caret;
3574
+ };
3575
+
3576
+ function appendNested(root,node){
3577
+ if (node instanceof ImbaTag) {
3578
+ root.appendChild(node);
3579
+ } else if (node instanceof Array) {
3580
+ for (var i = 0, ary = iter$(node), len = ary.length; i < len; i++) {
3581
+ appendNested(root,ary[i]);
3582
+ };
3583
+ } else if (node != null && node !== false) {
3584
+ root.appendChild(Imba.document().createTextNode(node));
3585
+ };
3586
+
3587
+ return;
3588
+ };
3589
+
3590
+
3591
+ // insert nodes before a certain node
3592
+ // does not need to return any tail, as before
3593
+ // will still be correct there
3594
+ // before must be an actual domnode
3595
+ function insertNestedBefore(root,node,before){
3596
+ if (node instanceof ImbaTag) {
3597
+ root.insertBefore(node,before);
3598
+ } else if (node instanceof Array) {
3599
+ for (var i = 0, ary = iter$(node), len = ary.length; i < len; i++) {
3600
+ insertNestedBefore(root,ary[i],before);
3601
+ };
3602
+ } else if (node != null && node !== false) {
3603
+ root.insertBefore(Imba.document().createTextNode(node),before);
3604
+ };
3605
+
3606
+ return before;
3607
+ };
3608
+
3609
+ // after must be an actual domnode
3610
+ function insertNestedAfter(root,node,after){
3611
+ var before = after ? (after.nextSibling) : (root._dom.firstChild);
3612
+
3613
+ if (before) {
3614
+ insertNestedBefore(root,node,before);
3615
+ return before.previousSibling;
3616
+ } else {
3617
+ appendNested(root,node);
3618
+ return root._dom.lastChild;
3619
+ };
3620
+ };
3621
+
3622
+ function reconcileCollectionChanges(root,new$,old,caret){
3623
+
3624
+ var newLen = new$.length;
3625
+ var lastNew = new$[newLen - 1];
3626
+
3627
+ // This re-order algorithm is based on the following principle:
3628
+ //
3629
+ // We build a "chain" which shows which items are already sorted.
3630
+ // If we're going from [1, 2, 3] -> [2, 1, 3], the tree looks like:
3631
+ //
3632
+ // 3 -> 0 (idx)
3633
+ // 2 -> -1 (idx)
3634
+ // 1 -> -1 (idx)
3635
+ //
3636
+ // This tells us that we have two chains of ordered items:
3637
+ //
3638
+ // (1, 3) and (2)
3639
+ //
3640
+ // The optimal re-ordering then becomes two keep the longest chain intact,
3641
+ // and move all the other items.
3642
+
3643
+ var newPosition = [];
3644
+
3645
+ // The tree/graph itself
3646
+ var prevChain = [];
3647
+ // The length of the chain
3648
+ var lengthChain = [];
3649
+
3650
+ // Keep track of the longest chain
3651
+ var maxChainLength = 0;
3652
+ var maxChainEnd = 0;
3653
+
3654
+ for (var idx = 0, ary = iter$(old), len = ary.length, node; idx < len; idx++) {
3655
+ node = ary[idx];
3656
+ var newPos = new$.indexOf(node);
3657
+ newPosition.push(newPos);
3658
+
3659
+ if (newPos == -1) {
3660
+ root.removeChild(node);
3661
+ prevChain.push(-1);
3662
+ lengthChain.push(-1);
3663
+ continue;
3664
+ };
3665
+
3666
+ var prevIdx = newPosition.length - 2;
3667
+
3668
+ // Build the chain:
3669
+ while (prevIdx >= 0){
3670
+ if (newPosition[prevIdx] == -1) {
3671
+ prevIdx--;
3672
+ } else if (newPos > newPosition[prevIdx]) {
3673
+ // Yay, we're bigger than the previous!
3674
+ break;
3675
+ } else {
3676
+ // Nope, let's walk back the chain
3677
+ prevIdx = prevChain[prevIdx];
3678
+ };
3679
+ };
3680
+
3681
+ prevChain.push(prevIdx);
3682
+
3683
+ var currLength = (prevIdx == -1) ? (0) : (lengthChain[prevIdx] + 1);
3684
+
3685
+ if (currLength > maxChainLength) {
3686
+ maxChainLength = currLength;
3687
+ maxChainEnd = idx;
3688
+ };
3689
+
3690
+ lengthChain.push(currLength);
3691
+ };
3692
+
3693
+ var stickyNodes = [];
3694
+
3695
+ // Now we can walk the longest chain backwards and mark them as "sticky",
3696
+ // which implies that they should not be moved
3697
+ var cursor = newPosition.length - 1;
3698
+ while (cursor >= 0){
3699
+ if (cursor == maxChainEnd && newPosition[cursor] != -1) {
3700
+ stickyNodes[newPosition[cursor]] = true;
3701
+ maxChainEnd = prevChain[maxChainEnd];
3702
+ };
3703
+
3704
+ cursor -= 1;
3705
+ };
3706
+
3707
+ // And let's iterate forward, but only move non-sticky nodes
3708
+ for (var idx1 = 0, ary = iter$(new$), len = ary.length; idx1 < len; idx1++) {
3709
+ if (!stickyNodes[idx1]) {
3710
+ var after = new$[idx1 - 1];
3711
+ insertNestedAfter(root,ary[idx1],(after && after._dom) || caret);
3712
+ };
3713
+ };
3714
+
3715
+ // should trust that the last item in new list is the caret
3716
+ return lastNew && lastNew._dom || caret;
3717
+ };
3718
+
3719
+
3720
+ // expects a flat non-sparse array of nodes in both new and old, always
3721
+ function reconcileCollection(root,new$,old,caret){
3722
+ var k = new$.length;
3723
+ var i = k;
3724
+ var last = new$[k - 1];
3725
+
3726
+
3727
+ if (k == old.length && new$[0] === old[0]) {
3728
+ // running through to compare
3729
+ while (i--){
3730
+ if (new$[i] !== old[i]) { break; };
3731
+ };
3732
+ };
3733
+
3734
+ if (i == -1) {
3735
+ return last && last._dom || caret;
3736
+ } else {
3737
+ return reconcileCollectionChanges(root,new$,old,caret);
3738
+ };
3739
+ };
3740
+
3741
+ // the general reconciler that respects conditions etc
3742
+ // caret is the current node we want to insert things after
3743
+ function reconcileNested(root,new$,old,caret){
3744
+
3745
+ // if new == null or new === false or new === true
3746
+ // if new === old
3747
+ // return caret
3748
+ // if old && new != old
3749
+ // removeNested(root,old,caret) if old
3750
+ //
3751
+ // return caret
3752
+
3753
+ // var skipnew = new == null or new === false or new === true
3754
+ var newIsNull = new$ == null || new$ === false;
3755
+ var oldIsNull = old == null || old === false;
3756
+
3757
+
3758
+ if (new$ === old) {
3759
+ // remember that the caret must be an actual dom element
3760
+ // we should instead move the actual caret? - trust
3761
+ if (newIsNull) {
3762
+ return caret;
3763
+ } else if (new$ && new$._dom) {
3764
+ return new$._dom;
3765
+ } else {
3766
+ return caret ? (caret.nextSibling) : (root._dom.firstChild);
3767
+ };
3768
+ } else if (new$ instanceof Array) {
3769
+ if (old instanceof Array) {
3770
+ if (new$.static || old.static) {
3771
+ // if the static is not nested - we could get a hint from compiler
3772
+ // and just skip it
3773
+ if (new$.static == old.static) {
3774
+ for (var i = 0, ary = iter$(new$), len = ary.length; i < len; i++) {
3775
+ // this is where we could do the triple equal directly
3776
+ caret = reconcileNested(root,ary[i],old[i],caret);
3777
+ };
3778
+ return caret;
3779
+ } else {
3780
+ removeNested(root,old,caret);
3781
+ };
3782
+
3783
+ // if they are not the same we continue through to the default
3784
+ } else {
3785
+ return reconcileCollection(root,new$,old,caret);
3786
+ };
3787
+ } else if (old instanceof ImbaTag) {
3788
+ root.removeChild(old);
3789
+ } else if (!oldIsNull) {
3790
+ // old was a string-like object?
3791
+ root.removeChild(caret ? (caret.nextSibling) : (root._dom.firstChild));
3792
+ };
3793
+
3794
+ return insertNestedAfter(root,new$,caret);
3795
+ // remove old
3796
+ } else if (new$ instanceof ImbaTag) {
3797
+ if (!oldIsNull) { removeNested(root,old,caret) };
3798
+ insertNestedAfter(root,new$,caret);
3799
+ return new$;
3800
+ } else if (newIsNull) {
3801
+ if (!oldIsNull) { removeNested(root,old,caret) };
3802
+ return caret;
3803
+ } else {
3804
+ // if old did not exist we need to add a new directly
3805
+ var nextNode;
3806
+ // if old was array or imbatag we need to remove it and then add
3807
+ if (old instanceof Array) {
3808
+ removeNested(root,old,caret);
3809
+ } else if (old instanceof ImbaTag) {
3810
+ root.removeChild(old);
3811
+ } else if (!oldIsNull) {
3812
+ // ...
3813
+ nextNode = caret ? (caret.nextSibling) : (root._dom.firstChild);
3814
+ if ((nextNode instanceof Text) && nextNode.textContent != new$) {
3815
+ nextNode.textContent = new$;
3816
+ return nextNode;
3817
+ };
3818
+ };
3819
+
3820
+ // now add the textnode
3821
+ return insertNestedAfter(root,new$,caret);
3822
+ };
3823
+ };
3824
+
3825
+
3826
+ return tag$.extendTag('htmlelement', function(tag){
3827
+
3828
+ tag.prototype.setChildren = function (new$,typ){
3829
+ var old = this._children;
3830
+ // var isArray = nodes isa Array
3831
+ if (new$ === old) {
3832
+ return this;
3833
+ };
3834
+
3835
+ if (!old) {
3836
+ this.empty();
3837
+ appendNested(this,new$);
3838
+ } else if (typ == 2) {
3839
+ return this;
3840
+ } else if (typ == 1) {
3841
+ // here we _know _that it is an array with the same shape
3842
+ // every time
3843
+ var caret = null;
3844
+ for (var i = 0, ary = iter$(new$), len = ary.length; i < len; i++) {
3845
+ // prev = old[i]
3846
+ caret = reconcileNested(this,ary[i],old[i],caret);
3847
+ };
3848
+ } else if (typ == 3) {
3849
+ // this is possibly fully dynamic. It often is
3850
+ // but the old or new could be static while the other is not
3851
+ // this is not handled now
3852
+ // what if it was previously a static array? edgecase - but must work
3853
+ if (new$ instanceof ImbaTag) {
3854
+ this.empty();
3855
+ this.appendChild(new$);
3856
+ } else if (new$ instanceof Array) {
3857
+ if (old instanceof Array) {
3858
+ // is this not the same as setting staticChildren now but with the
3859
+ reconcileCollection(this,new$,old,null);
3860
+ } else {
3861
+ this.empty();
3862
+ appendNested(this,new$);
3863
+ };
3864
+ } else {
3865
+ this.setText(new$);
3866
+ return this;
3867
+ };
3868
+ } else if ((new$ instanceof Array) && (old instanceof Array)) {
3869
+ reconcileCollection(this,new$,old,null);
3870
+ } else {
3871
+ this.empty();
3872
+ appendNested(this,new$);
3873
+ };
3874
+
3875
+ this._children = new$;
3876
+ return this;
3877
+ };
3878
+
3879
+
3880
+ // only ever called with array as argument
3881
+ tag.prototype.setStaticChildren = function (new$){
3882
+ var old = this._children;
3883
+
3884
+ var caret = null;
3885
+ for (var i = 0, ary = iter$(new$), len = ary.length; i < len; i++) {
3886
+ // prev = old[i]
3887
+ caret = reconcileNested(this,ary[i],old[i],caret);
3888
+ };
3889
+
3890
+ this._children = new$;
3891
+ return this;
3892
+ };
3893
+
3894
+ tag.prototype.content = function (){
3895
+ return this._content || this.children().toArray();
3896
+ };
3897
+
3898
+ tag.prototype.setText = function (text){
3899
+ if (text != this._children) {
3900
+ this._children = text;
3901
+ this.dom().textContent = text == null || text === false ? ('') : (text);
3902
+ };
3903
+ this;
3904
+ return this;
3905
+ };
3906
+ });
3907
+
3908
+ })();
3909
+
3910
+ /***/ },
3911
+ /* 11 */
3912
+ /***/ function(module, exports) {
3913
+
3914
+ (function(){
3915
+ function iter$(a){ return a ? (a.toArray ? a.toArray() : a) : []; };
3916
+
3917
+ /*
3918
+ The special syntax for selectors in Imba creates Imba.Selector
3919
+ instances.
3920
+ */
3921
+
3922
+ Imba.Selector = function Selector(sel,scope,nodes){
3923
+
3924
+ this._query = sel instanceof Imba.Selector ? (sel.query()) : (sel);
3925
+ this._context = scope;
3926
+
3927
+ if (nodes) {
3928
+ for (var i = 0, ary = iter$(nodes), len = ary.length, res = []; i < len; i++) {
3929
+ res.push(tag$wrap(ary[i]));
3930
+ };
3931
+ this._nodes = res;
3932
+ };
3933
+
3934
+ this._lazy = !nodes;
3935
+ return this;
3936
+ };
3937
+
3938
+ Imba.Selector.one = function (sel,scope){
3939
+ var el = (scope || Imba.document()).querySelector(sel);
3940
+ return el && tag$wrap(el) || null;
3941
+ };
3942
+
3943
+ Imba.Selector.all = function (sel,scope){
3944
+ return new Imba.Selector(sel,scope);
3945
+ };
3946
+
3947
+ Imba.Selector.prototype.query = function(v){ return this._query; }
3948
+ Imba.Selector.prototype.setQuery = function(v){ this._query = v; return this; };
3949
+
3950
+ Imba.Selector.prototype.reload = function (){
3951
+ this._nodes = null;
3952
+ return this;
3953
+ };
3954
+
3955
+ Imba.Selector.prototype.scope = function (){
3956
+ var ctx;
3957
+ if (this._scope) { return this._scope };
3958
+ if (!(ctx = this._context)) { return Imba.document() };
3959
+ return this._scope = ctx.toScope ? (ctx.toScope()) : (ctx);
3960
+ };
3961
+
3962
+ /*
3963
+ @returns {Imba.Tag} first node matching this selector
3964
+ */
3965
+
3966
+ Imba.Selector.prototype.first = function (){
3967
+ if (this._lazy) { return tag$wrap(this._first || (this._first = this.scope().querySelector(this.query()))) } else {
3968
+ return this.nodes()[0];
3969
+ };
3970
+ };
3971
+
3972
+ /*
3973
+ @returns {Imba.Tag} last node matching this selector
3974
+ */
3975
+
3976
+ Imba.Selector.prototype.last = function (){
3977
+ return this.nodes()[this._nodes.length - 1];
3978
+ };
3979
+
3980
+ /*
3981
+ @returns [Imba.Tag] all nodes matching this selector
3982
+ */
3983
+
3984
+ Imba.Selector.prototype.nodes = function (){
3985
+ if (this._nodes) { return this._nodes };
3986
+ var items = this.scope().querySelectorAll(this.query());
3987
+ for (var i = 0, ary = iter$(items), len = ary.length, res = []; i < len; i++) {
3988
+ res.push(tag$wrap(ary[i]));
3989
+ };
3990
+ this._nodes = res;
3991
+ this._lazy = false;
3992
+ return this._nodes;
3993
+ };
3994
+
3995
+ /*
3996
+ The number of nodes matching this selector
3997
+ */
3998
+
3999
+ Imba.Selector.prototype.count = function (){
4000
+ return this.nodes().length;
4001
+ };
4002
+
4003
+ Imba.Selector.prototype.len = function (){
4004
+ return this.nodes().length;
4005
+ };
4006
+
4007
+ /*
4008
+ @todo Add support for block or selector?
4009
+ */
4010
+
4011
+ Imba.Selector.prototype.some = function (){
4012
+ return this.count() >= 1;
4013
+ };
4014
+
4015
+ /*
4016
+ Get node at index
4017
+ */
4018
+
4019
+ Imba.Selector.prototype.at = function (idx){
4020
+ return this.nodes()[idx];
4021
+ };
4022
+
4023
+ /*
4024
+ Loop through nodes
4025
+ */
4026
+
4027
+ Imba.Selector.prototype.forEach = function (block){
4028
+ this.nodes().forEach(block);
4029
+ return this;
4030
+ };
4031
+
4032
+ /*
4033
+ Map nodes
4034
+ */
4035
+
4036
+ Imba.Selector.prototype.map = function (block){
4037
+ return this.nodes().map(block);
4038
+ };
4039
+
4040
+ /*
4041
+ Returns a plain array containing nodes. Implicitly called
4042
+ when iterating over a selector in Imba `(node for node in $(selector))`
4043
+ */
4044
+
4045
+ Imba.Selector.prototype.toArray = function (){
4046
+ return this.nodes();
4047
+ };
4048
+
4049
+ // Get the first element that matches the selector,
4050
+ // beginning at the current element and progressing up through the DOM tree
4051
+ Imba.Selector.prototype.closest = function (sel){
4052
+ // seems strange that we alter this selector?
4053
+ this._nodes = this.map(function(node) { return node.closest(sel); });
4054
+ return this;
4055
+ };
4056
+
4057
+ // Get the siblings of each element in the set of matched elements,
4058
+ // optionally filtered by a selector.
4059
+ // TODO remove duplicates?
4060
+ Imba.Selector.prototype.siblings = function (sel){
4061
+ this._nodes = this.map(function(node) { return node.siblings(sel); });
4062
+ return this;
4063
+ };
4064
+
4065
+ // Get the descendants of each element in the current set of matched
4066
+ // elements, filtered by a selector.
4067
+ Imba.Selector.prototype.find = function (sel){
4068
+ this._nodes = this.__query__(sel.query(),this.nodes());
4069
+ return this;
4070
+ };
4071
+
4072
+ Imba.Selector.prototype.reject = function (blk){
4073
+ return this.filter(blk,false);
4074
+ };
4075
+
4076
+ /*
4077
+ Filter the nodes in selector by a function or other selector
4078
+ */
4079
+
4080
+ Imba.Selector.prototype.filter = function (blk,bool){
4081
+ if(bool === undefined) bool = true;
4082
+ var fn = (blk instanceof Function) && blk || function(n) { return n.matches(blk); };
4083
+ var ary = this.nodes().filter(function(n) { return fn(n) == bool; });
4084
+ // if we want to return a new selector for this, we should do that for
4085
+ // others as well
4086
+ return new Imba.Selector("",this._scope,ary);
4087
+ };
4088
+
4089
+ Imba.Selector.prototype.__query__ = function (query,contexts){
4090
+ var nodes = [];
4091
+ var i = 0;
4092
+ var l = contexts.length;
4093
+
4094
+ while (i < l){
4095
+ nodes.push.apply(nodes,contexts[i++].querySelectorAll(query));
4096
+ };
4097
+ return nodes;
4098
+ };
4099
+
4100
+ Imba.Selector.prototype.__matches__ = function (){
4101
+ return true;
4102
+ };
4103
+
4104
+ /*
4105
+ Add specified flag to all nodes in selector
4106
+ */
4107
+
4108
+ Imba.Selector.prototype.flag = function (flag){
4109
+ return this.forEach(function(n) { return n.flag(flag); });
4110
+ };
4111
+
4112
+ /*
4113
+ Remove specified flag from all nodes in selector
4114
+ */
4115
+
4116
+ Imba.Selector.prototype.unflag = function (flag){
4117
+ return this.forEach(function(n) { return n.unflag(flag); });
4118
+ };
4119
+
4120
+
4121
+ // def Imba.querySelectorAll
4122
+ q$ = function(sel,scope) { return new Imba.Selector(sel,scope); };
4123
+
4124
+ // def Imba.Selector.one
4125
+ q$$ = function(sel,scope) {
4126
+ var el = (scope || Imba.document()).querySelector(sel);
4127
+ return el && tag$wrap(el) || null;
4128
+ };
4129
+
4130
+
4131
+ // extending tags with query-methods
4132
+ // must be a better way to reopen classes
4133
+ return tag$.extendTag('element', function(tag){
4134
+ tag.prototype.querySelectorAll = function (q){
4135
+ return this._dom.querySelectorAll(q);
4136
+ };
4137
+ tag.prototype.querySelector = function (q){
4138
+ return this._dom.querySelector(q);
4139
+ };
4140
+
4141
+ // should be moved to Imba.Tag instead?
4142
+ // or we should implement all of them here
4143
+ tag.prototype.find = function (sel){
4144
+ return new Imba.Selector(sel,this);
4145
+ };
4146
+ });
4147
+
4148
+
4149
+ })();
4150
+
4151
+ /***/ }
4152
+ /******/ ]);