UNPKG

brave

Version:
1 lines 7.81 kB
(function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var t;if(typeof window!=="undefined"){t=window}else if(typeof global!=="undefined"){t=global}else if(typeof self!=="undefined"){t=self}else{t=this}t.Brave=e()}})(function(){var e,t,r;return function e(t,r,n){function i(a,f){if(!r[a]){if(!t[a]){var s=typeof require=="function"&&require;if(!f&&s)return s(a,!0);if(o)return o(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var u=r[a]={exports:{}};t[a][0].call(u.exports,function(e){var r=t[a][1][e];return i(r?r:e)},u,u.exports,e,t,r,n)}return r[a].exports}var o=typeof require=="function"&&require;for(var a=0;a<n.length;a++)i(n[a]);return i}({1:[function(e,t,r){var n=e("get-object-path");var i=e("dom-delegate").Delegate;var o=Object.getOwnPropertyNames(document).concat(Object.getOwnPropertyNames(Object.getPrototypeOf(Object.getPrototypeOf(document)))).concat(Object.getOwnPropertyNames(Object.getPrototypeOf(window))).filter(function(e){return!e.indexOf("on")&&(document[e]==null||typeof document[e]=="function")}).filter(function(e,t,r){return r.indexOf(e)==t});var a=o.map(function(e){return"["+e+"]:not(["+e+'=""])'}).join(",");function f(){}Object.defineProperties(f.prototype,{selector:{get:function(){var e=Object.keys(this);return e.map(function(e){return"["+e+"]"}).join(", ")}},keys:{get:function(){return Object.keys(this)}}});var s=new f;function l(e,t,r,n){var i=Object.create(r.isolate?{}:n||{});var o=Object.create({},{component:{value:r}});Object.defineProperties(i,{__:{value:o},el:{value:e}});i.data=t;return i}var u=["on","template","initialize","isolate"];function c(e){Array.prototype.slice.call(arguments,1).forEach(function(t){var r,n;if(t){for(n in t){if(t.hasOwnProperty(n)&&u.indexOf(n)===-1){r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r)}}}});return e}function h(e){var t=s.keys;for(var r=0;r<e.attributes.length;r++){var n=t.indexOf(e.attributes[r].name);if(n>-1){return{key:t[n],component:s[t[n]]}}}}function p(e,t,r){var n=new i(e);var o=function(e){return function(r){e.call(t,r)}};for(var a in r.on){if(r.on.hasOwnProperty(a)){var f=a.indexOf(":");var s,l;if(f===-1){s=a;n.on(s,o(r.on[a]))}else{s=a.substr(0,f);l=a.substr(f+1);n.on(s,l,o(r.on[a]))}}}return n}function v(e,t,r){var i=e.getAttribute(t);return i&&n(r,i)}function d(e,t){if(typeof e==="object"){for(var r in e){if(e.hasOwnProperty(r)){s[r]=e[r]}}}else{s[e]=t}}function y(e){var t=[];for(var r=0;r<e.length;r++){t.push(e[r])}return t}function m(e,t){var r=x._register.selector;var n=y(e.querySelectorAll(r));if(!t){var i=h(e);if(i){n.unshift(e)}}return n}function g(e,t){do{e=e.parentNode;if(e){for(var r=t.length-1;r>-1;r--){if(t[r].ctx.el===e){return t[r].ctx}}}}while(e)}function O(e,t,r){var n=typeof t.template==="function"?t.template.call(r,r):t.template;e.innerHTML=n}function b(e,t,r){return function(){O(e,t,r);x.scan(e,r.data,r,true)}}function w(e,t,r,n){var i=m(e,n);var f=[];if(r){f.push({ctx:r})}var s;while(i.length){s=i.shift();var u=h(s);var d=u.component;var O=g(s,f)||r;var w=O?O.data:t;var x=v(s,u.key,w)||w;var E=l(s,x,d,O);var j=p(s,E,d);Object.defineProperty(E.__,"del",{value:j});c(E,d);f.push({key:u.key,ctx:E,initialize:d.initialize,template:d.template,component:d,el:s})}var P,M;var k=[];for(P=f.length-1;P>=0;P--){var L=f[P].ctx;var z=L.el;var _=z.querySelectorAll('[as]:not([as=""])');for(M=0;M<_.length;M++){if(k.indexOf(_[M])<0){var N=_[M].getAttribute("as");L[N]=_[M];k.push(_[M])}}}k=[];for(P=f.length-1;P>=0;P--){var S=f[P].ctx;var T=S.el;var q=y(T.querySelectorAll(a));q.unshift(T);for(M=0;M<q.length;M++){if(k.indexOf(q[M])<0){k.push(q[M]);for(var D=0;D<o.length;D++){if(q[M].attributes[o[D]]){N=q[M].attributes[o[D]].value;function A(e,t){return function(r){return e.call(this,r,t)}}var F=new Function("e, ctx","with (ctx) {\n return "+N+"\n}");q[M][o[D]]=A(F,S)}}}}}for(P=0;P<f.length;P++){if(f[P].initialize){f[P].initialize.call(f[P].ctx)}}for(P=0;P<f.length;P++){if(f[P].template){var C=b(f[P].ctx.el,f[P].component,f[P].ctx);C();f[P].ctx.render=C}}}var x=Object.create({},{_register:{value:s},register:{value:d},scan:{value:w}});t.exports=x},{"dom-delegate":3,"get-object-path":4}],2:[function(e,t,r){"use strict";t.exports=n;function n(e){this.listenerMap=[{},{}];if(e){this.root(e)}this.handle=n.prototype.handle.bind(this)}n.prototype.root=function(e){var t=this.listenerMap;var r;if(this.rootElement){for(r in t[1]){if(t[1].hasOwnProperty(r)){this.rootElement.removeEventListener(r,this.handle,true)}}for(r in t[0]){if(t[0].hasOwnProperty(r)){this.rootElement.removeEventListener(r,this.handle,false)}}}if(!e||!e.addEventListener){if(this.rootElement){delete this.rootElement}return this}this.rootElement=e;for(r in t[1]){if(t[1].hasOwnProperty(r)){this.rootElement.addEventListener(r,this.handle,true)}}for(r in t[0]){if(t[0].hasOwnProperty(r)){this.rootElement.addEventListener(r,this.handle,false)}}return this};n.prototype.captureForType=function(e){return["blur","error","focus","load","resize","scroll"].indexOf(e)!==-1};n.prototype.on=function(e,t,r,n){var s,l,u,c;if(!e){throw new TypeError("Invalid event type: "+e)}if(typeof t==="function"){n=r;r=t;t=null}if(n===undefined){n=this.captureForType(e)}if(typeof r!=="function"){throw new TypeError("Handler must be a type of Function")}s=this.rootElement;l=this.listenerMap[n?1:0];if(!l[e]){if(s){s.addEventListener(e,this.handle,n)}l[e]=[]}if(!t){c=null;u=a.bind(this)}else if(/^[a-z]+$/i.test(t)){c=t;u=o}else if(/^#[a-z0-9\-_]+$/i.test(t)){c=t.slice(1);u=f}else{c=t;u=i}l[e].push({selector:t,handler:r,matcher:u,matcherParam:c});return this};n.prototype.off=function(e,t,r,n){var i,o,a,f,s;if(typeof t==="function"){n=r;r=t;t=null}if(n===undefined){this.off(e,t,r,true);this.off(e,t,r,false);return this}a=this.listenerMap[n?1:0];if(!e){for(s in a){if(a.hasOwnProperty(s)){this.off(s,t,r)}}return this}f=a[e];if(!f||!f.length){return this}for(i=f.length-1;i>=0;i--){o=f[i];if((!t||t===o.selector)&&(!r||r===o.handler)){f.splice(i,1)}}if(!f.length){delete a[e];if(this.rootElement){this.rootElement.removeEventListener(e,this.handle,n)}}return this};n.prototype.handle=function(e){var t,r,n=e.type,i,o,a,f,s=[],l,u="ftLabsDelegateIgnore";if(e[u]===true){return}l=e.target;if(l.nodeType===3){l=l.parentNode}i=this.rootElement;o=e.eventPhase||(e.target!==e.currentTarget?3:2);switch(o){case 1:s=this.listenerMap[1][n];break;case 2:if(this.listenerMap[0]&&this.listenerMap[0][n])s=s.concat(this.listenerMap[0][n]);if(this.listenerMap[1]&&this.listenerMap[1][n])s=s.concat(this.listenerMap[1][n]);break;case 3:s=this.listenerMap[0][n];break}r=s.length;while(l&&r){for(t=0;t<r;t++){a=s[t];if(!a){break}if(a.matcher.call(l,a.matcherParam,l)){f=this.fire(e,l,a)}if(f===false){e[u]=true;e.preventDefault();return}}if(l===i){break}r=s.length;l=l.parentElement}};n.prototype.fire=function(e,t,r){return r.handler.call(t,e,t)};var i=function(e){if(!e)return;var t=e.prototype;return t.matches||t.matchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector||t.msMatchesSelector||t.oMatchesSelector}(Element);function o(e,t){return e.toLowerCase()===t.tagName.toLowerCase()}function a(e,t){if(this.rootElement===window)return t===document;return this.rootElement===t}function f(e,t){return e===t.id}n.prototype.destroy=function(){this.off();this.root()}},{}],3:[function(e,t,r){"use strict";var n=e("./delegate");t.exports=function(e){return new n(e)};t.exports.Delegate=n},{"./delegate":2}],4:[function(e,t,r){t.exports=n;function n(e,t){if(t.indexOf(".")==-1&&t.indexOf("[")==-1){return e[t]}var r=t.split(/\.|\[|\]/g);var n=-1;var i=r.length;var o;while(++n<i){if(n==0)o=e;if(!r[n])continue;if(o==undefined)break;o=o[r[n]]}return o}},{}]},{},[1])(1)});