riot-route
Advanced tools
Comparing version 3.1.2 to 3.1.3
@@ -16,3 +16,3 @@ define(function () { 'use strict'; | ||
var callbacks = {}, | ||
slice = Array.prototype.slice; | ||
slice = Array.prototype.slice;; | ||
@@ -103,3 +103,3 @@ /** | ||
fn, | ||
i; | ||
i;;;;; | ||
@@ -131,34 +131,30 @@ for (i = 0; i < arglen; i++) { | ||
/** | ||
* Simple client-side router | ||
* @module riot-route | ||
*/ | ||
var RE_ORIGIN = /^.+?\/\/+[^/]+/, | ||
EVENT_LISTENER = 'EventListener', | ||
REMOVE_EVENT_LISTENER = 'remove' + EVENT_LISTENER, | ||
ADD_EVENT_LISTENER = 'add' + EVENT_LISTENER, | ||
HAS_ATTRIBUTE = 'hasAttribute', | ||
POPSTATE = 'popstate', | ||
HASHCHANGE = 'hashchange', | ||
TRIGGER = 'trigger', | ||
MAX_EMIT_STACK_LEVEL = 3, | ||
win = typeof window != 'undefined' && window, | ||
doc = typeof document != 'undefined' && document, | ||
hist = win && history, | ||
loc = win && (hist.location || win.location), // see html5-history-api | ||
prot = Router.prototype, // to minify more | ||
clickEvent = doc && doc.ontouchstart ? 'touchstart' : 'click', | ||
central = observable();;;;;;;;;;;;;;;; | ||
var RE_ORIGIN = /^.+?\/\/+[^/]+/; | ||
var EVENT_LISTENER = 'EventListener'; | ||
var REMOVE_EVENT_LISTENER = 'remove' + EVENT_LISTENER; | ||
var ADD_EVENT_LISTENER = 'add' + EVENT_LISTENER; | ||
var HAS_ATTRIBUTE = 'hasAttribute'; | ||
var POPSTATE = 'popstate'; | ||
var HASHCHANGE = 'hashchange'; | ||
var TRIGGER = 'trigger'; | ||
var MAX_EMIT_STACK_LEVEL = 3; | ||
var win = typeof window != 'undefined' && window; | ||
var doc = typeof document != 'undefined' && document; | ||
var hist = win && history; | ||
var loc = win && (hist.location || win.location); | ||
var prot = Router.prototype; | ||
var clickEvent = doc && doc.ontouchstart ? 'touchstart' : 'click'; | ||
var central = observable(); | ||
var | ||
started = false, | ||
routeFound = false, | ||
debouncedEmit, | ||
base, | ||
current, | ||
parser, | ||
secondParser, | ||
emitStack = [], | ||
emitStackLevel = 0;;;;;;;;; | ||
var started = false; | ||
var routeFound = false; | ||
var debouncedEmit; | ||
var base; | ||
var current; | ||
var parser; | ||
var secondParser; | ||
var emitStack = []; | ||
var emitStackLevel = 0; | ||
/** | ||
@@ -165,0 +161,0 @@ * Default parser. You can replace it via router.parser method. |
@@ -1,1 +0,1 @@ | ||
define(function(){"use strict";var e=function(e){e=e||{};var t={},r=Array.prototype.slice;Object.defineProperties(e,{on:{value:function(r,n){if(typeof n=="function"){(t[r]=t[r]||[]).push(n)}return e},enumerable:false,writable:false,configurable:false},off:{value:function(r,n){if(r=="*"&&!n){t={}}else{if(n){var i=t[r];for(var a=0,f;f=i&&i[a];++a){if(f==n){i.splice(a--,1)}}}else{delete t[r]}}return e},enumerable:false,writable:false,configurable:false},one:{value:function(t,r){function n(){e.off(t,n);r.apply(e,arguments)}return e.on(t,n)},enumerable:false,writable:false,configurable:false},trigger:{value:function(n){var i=arguments;var a=arguments.length-1,f=new Array(a),u,o,c;for(c=0;c<a;c++){f[c]=i[c+1]}u=r.call(t[n]||[],0);for(c=0;o=u[c];++c){o.apply(e,f)}if(t["*"]&&n!="*"){e.trigger.apply(e,["*",n].concat(f))}return e},enumerable:false,writable:false,configurable:false}});return e};var t=/^.+?\/\/+[^/]+/;var r="EventListener";var n="remove"+r;var i="add"+r;var a="hasAttribute";var f="popstate";var u="hashchange";var o="trigger";var c=3;var l=typeof window!="undefined"&&window;var s=typeof document!="undefined"&&document;var v=l&&history;var h=l&&(v.location||l.location);var p=P.prototype;var d=s&&s.ontouchstart?"touchstart":"click";var m=e();var y=false;var b=false;var g;var w;var $;var A;var S;var x=[];var K=0;function N(e){return e.split(/[/?#]/)}function O(e,t){var r=t.replace(/\?/g,"\\?").replace(/\*/g,"([^/?#]+?)").replace(/\.\./,".*");var n=new RegExp("^"+r+"$");var i=e.match(n);if(i){return i.slice(1)}}function T(e,t){var r;return function(){clearTimeout(r);r=setTimeout(e,t)}}function E(e){g=T(L,1);l[i](f,g);l[i](u,g);s[i](d,R);if(e){L(true)}}function P(){this.$=[];e(this);m.on("stop",this.s.bind(this));m.on("emit",this.e.bind(this))}function j(e){return e.replace(/^\/|\/$/,"")}function k(e){return typeof e=="string"}function q(e){return(e||h.href).replace(t,"")}function D(e){return w[0]==="#"?(e||h.href||"").split(w)[1]||"":(h?q(e):e||"").replace(w,"")}function L(e){var t=K===0;if(c<=K){return}K++;x.push(function(){var t=D();if(e||t!==$){m[o]("emit",t);$=t}});if(t){var r;while(r=x.shift()){r()}K=0}}function R(e){if(e.which!==1||e.metaKey||e.ctrlKey||e.shiftKey||e.defaultPrevented){return}var r=e.target;while(r&&r.nodeName!=="A"){r=r.parentNode}if(!r||r.nodeName!=="A"||r[a]("download")||!r[a]("href")||r.target&&r.target!=="_self"||r.href.indexOf(h.href.match(t)[0])===-1){return}if(r.href!==h.href&&(r.href.split("#")[0]===h.href.split("#")[0]||w[0]!=="#"&&q(r.href).indexOf(w)!==0||w[0]==="#"&&r.href.split(w)[0]!==h.href.split(w)[0]||!_(D(r.href),r.title||s.title))){return}e.preventDefault()}function _(e,t,r){if(!v){return m[o]("emit",D(e))}e=w+j(e);t=t||s.title;r?v.replaceState(null,t,e):v.pushState(null,t,e);s.title=t;b=false;L();return b}p.m=function(e,t,r){if(k(e)&&(!t||k(t))){_(e,t,r||false)}else if(t){this.r(e,t)}else{this.r("@",e)}};p.s=function(){this.off("*");this.$=[]};p.e=function(e){this.$.concat("@").some(function(t){var r=(t==="@"?A:S)(j(e),j(t));if(typeof r!="undefined"){this[o].apply(null,[t].concat(r));return b=true}},this)};p.r=function(e,t){if(e!=="@"){e="/"+j(e);this.$.push(e)}this.on(e,t)};var z=new P;var B=z.m.bind(z);B.create=function(){var e=new P;var t=e.m.bind(e);t.stop=e.s.bind(e);return t};B.base=function(e){w=e||"#";$=D()};B.exec=function(){L(true)};B.parser=function(e,t){if(!e&&!t){A=N;S=O}if(e){A=e}if(t){S=t}};B.query=function(){var e={};var t=h.href||$;t.replace(/[?&](.+?)=([^&]*)/g,function(t,r,n){e[r]=n});return e};B.stop=function(){if(y){if(l){l[n](f,g);l[n](u,g);s[n](d,R)}m[o]("stop");y=false}};B.start=function(e){if(!y){if(l){if(document.readyState==="interactive"||document.readyState==="complete"){E(e)}else{document.onreadystatechange=function(){if(document.readyState==="interactive"){setTimeout(function(){E(e)},1)}}}}y=true}};B.base();B.parser();return B}); | ||
define(function(){"use strict";var e=function(e){e=e||{};var t={},n=Array.prototype.slice;Object.defineProperties(e,{on:{value:function(n,r){if(typeof r=="function"){(t[n]=t[n]||[]).push(r)}return e},enumerable:false,writable:false,configurable:false},off:{value:function(n,r){if(n=="*"&&!r){t={}}else{if(r){var i=t[n];for(var f=0,a;a=i&&i[f];++f){if(a==r){i.splice(f--,1)}}}else{delete t[n]}}return e},enumerable:false,writable:false,configurable:false},one:{value:function(t,n){function r(){e.off(t,r);n.apply(e,arguments)}return e.on(t,r)},enumerable:false,writable:false,configurable:false},trigger:{value:function(r){var i=arguments;var f=arguments.length-1,a=new Array(f),u,o,c;for(c=0;c<f;c++){a[c]=i[c+1]}u=n.call(t[r]||[],0);for(c=0;o=u[c];++c){o.apply(e,a)}if(t["*"]&&r!="*"){e.trigger.apply(e,["*",r].concat(a))}return e},enumerable:false,writable:false,configurable:false}});return e};var t=/^.+?\/\/+[^/]+/,n="EventListener",r="remove"+n,i="add"+n,f="hasAttribute",a="popstate",u="hashchange",o="trigger",c=3,l=typeof window!="undefined"&&window,s=typeof document!="undefined"&&document,h=l&&history,p=l&&(h.location||l.location),d=P.prototype,v=s&&s.ontouchstart?"touchstart":"click",m=e();var y=false,b=false,g,w,$,A,S,x=[],K=0;function N(e){return e.split(/[/?#]/)}function O(e,t){var n=t.replace(/\?/g,"\\?").replace(/\*/g,"([^/?#]+?)").replace(/\.\./,".*");var r=new RegExp("^"+n+"$");var i=e.match(r);if(i){return i.slice(1)}}function T(e,t){var n;return function(){clearTimeout(n);n=setTimeout(e,t)}}function E(e){g=T(L,1);l[i](a,g);l[i](u,g);s[i](v,R);if(e){L(true)}}function P(){this.$=[];e(this);m.on("stop",this.s.bind(this));m.on("emit",this.e.bind(this))}function j(e){return e.replace(/^\/|\/$/,"")}function k(e){return typeof e=="string"}function q(e){return(e||p.href).replace(t,"")}function D(e){return w[0]==="#"?(e||p.href||"").split(w)[1]||"":(p?q(e):e||"").replace(w,"")}function L(e){var t=K===0;if(c<=K){return}K++;x.push(function(){var t=D();if(e||t!==$){m[o]("emit",t);$=t}});if(t){var n;while(n=x.shift()){n()}K=0}}function R(e){if(e.which!==1||e.metaKey||e.ctrlKey||e.shiftKey||e.defaultPrevented){return}var n=e.target;while(n&&n.nodeName!=="A"){n=n.parentNode}if(!n||n.nodeName!=="A"||n[f]("download")||!n[f]("href")||n.target&&n.target!=="_self"||n.href.indexOf(p.href.match(t)[0])===-1){return}if(n.href!==p.href&&(n.href.split("#")[0]===p.href.split("#")[0]||w[0]!=="#"&&q(n.href).indexOf(w)!==0||w[0]==="#"&&n.href.split(w)[0]!==p.href.split(w)[0]||!_(D(n.href),n.title||s.title))){return}e.preventDefault()}function _(e,t,n){if(!h){return m[o]("emit",D(e))}e=w+j(e);t=t||s.title;n?h.replaceState(null,t,e):h.pushState(null,t,e);s.title=t;b=false;L();return b}d.m=function(e,t,n){if(k(e)&&(!t||k(t))){_(e,t,n||false)}else if(t){this.r(e,t)}else{this.r("@",e)}};d.s=function(){this.off("*");this.$=[]};d.e=function(e){this.$.concat("@").some(function(t){var n=(t==="@"?A:S)(j(e),j(t));if(typeof n!="undefined"){this[o].apply(null,[t].concat(n));return b=true}},this)};d.r=function(e,t){if(e!=="@"){e="/"+j(e);this.$.push(e)}this.on(e,t)};var z=new P;var B=z.m.bind(z);B.create=function(){var e=new P;var t=e.m.bind(e);t.stop=e.s.bind(e);return t};B.base=function(e){w=e||"#";$=D()};B.exec=function(){L(true)};B.parser=function(e,t){if(!e&&!t){A=N;S=O}if(e){A=e}if(t){S=t}};B.query=function(){var e={};var t=p.href||$;t.replace(/[?&](.+?)=([^&]*)/g,function(t,n,r){e[n]=r});return e};B.stop=function(){if(y){if(l){l[r](a,g);l[r](u,g);s[r](v,R)}m[o]("stop");y=false}};B.start=function(e){if(!y){if(l){if(document.readyState==="interactive"||document.readyState==="complete"){E(e)}else{document.onreadystatechange=function(){if(document.readyState==="interactive"){setTimeout(function(){E(e)},1)}}}}y=true}};B.base();B.parser();return B}); |
define(['riot'], function (riot) { 'use strict'; | ||
riot = riot && 'default' in riot ? riot['default'] : riot; | ||
riot = riot && riot.hasOwnProperty('default') ? riot['default'] : riot; | ||
@@ -18,3 +18,3 @@ var observable = function(el) { | ||
var callbacks = {}, | ||
slice = Array.prototype.slice; | ||
slice = Array.prototype.slice;; | ||
@@ -105,3 +105,3 @@ /** | ||
fn, | ||
i; | ||
i;;;;; | ||
@@ -133,34 +133,30 @@ for (i = 0; i < arglen; i++) { | ||
/** | ||
* Simple client-side router | ||
* @module riot-route | ||
*/ | ||
var RE_ORIGIN = /^.+?\/\/+[^/]+/, | ||
EVENT_LISTENER = 'EventListener', | ||
REMOVE_EVENT_LISTENER = 'remove' + EVENT_LISTENER, | ||
ADD_EVENT_LISTENER = 'add' + EVENT_LISTENER, | ||
HAS_ATTRIBUTE = 'hasAttribute', | ||
POPSTATE = 'popstate', | ||
HASHCHANGE = 'hashchange', | ||
TRIGGER = 'trigger', | ||
MAX_EMIT_STACK_LEVEL = 3, | ||
win = typeof window != 'undefined' && window, | ||
doc = typeof document != 'undefined' && document, | ||
hist = win && history, | ||
loc = win && (hist.location || win.location), // see html5-history-api | ||
prot = Router.prototype, // to minify more | ||
clickEvent = doc && doc.ontouchstart ? 'touchstart' : 'click', | ||
central = observable();;;;;;;;;;;;;;;; | ||
var RE_ORIGIN = /^.+?\/\/+[^/]+/; | ||
var EVENT_LISTENER = 'EventListener'; | ||
var REMOVE_EVENT_LISTENER = 'remove' + EVENT_LISTENER; | ||
var ADD_EVENT_LISTENER = 'add' + EVENT_LISTENER; | ||
var HAS_ATTRIBUTE = 'hasAttribute'; | ||
var POPSTATE = 'popstate'; | ||
var HASHCHANGE = 'hashchange'; | ||
var TRIGGER = 'trigger'; | ||
var MAX_EMIT_STACK_LEVEL = 3; | ||
var win = typeof window != 'undefined' && window; | ||
var doc = typeof document != 'undefined' && document; | ||
var hist = win && history; | ||
var loc = win && (hist.location || win.location); | ||
var prot = Router.prototype; | ||
var clickEvent = doc && doc.ontouchstart ? 'touchstart' : 'click'; | ||
var central = observable(); | ||
var | ||
started = false, | ||
routeFound = false, | ||
debouncedEmit, | ||
base, | ||
current, | ||
parser, | ||
secondParser, | ||
emitStack = [], | ||
emitStackLevel = 0;;;;;;;;; | ||
var started = false; | ||
var routeFound = false; | ||
var debouncedEmit; | ||
var base; | ||
var current; | ||
var parser; | ||
var secondParser; | ||
var emitStack = []; | ||
var emitStackLevel = 0; | ||
/** | ||
@@ -382,3 +378,3 @@ * Default parser. You can replace it via router.parser method. | ||
var mainRouter = new Router(); | ||
var route$1 = mainRouter.m.bind(mainRouter); | ||
var route = mainRouter.m.bind(mainRouter); | ||
@@ -389,3 +385,3 @@ /** | ||
*/ | ||
route$1.create = function() { | ||
route.create = function() { | ||
var newSubRouter = new Router(); | ||
@@ -403,3 +399,3 @@ // assign sub-router's main method | ||
*/ | ||
route$1.base = function(arg) { | ||
route.base = function(arg) { | ||
base = arg || '#'; | ||
@@ -410,3 +406,3 @@ current = getPathFromBase(); // recalculate current path | ||
/** Exec routing right now **/ | ||
route$1.exec = function() { | ||
route.exec = function() { | ||
emit(true); | ||
@@ -420,3 +416,3 @@ }; | ||
*/ | ||
route$1.parser = function(fn, fn2) { | ||
route.parser = function(fn, fn2) { | ||
if (!fn && !fn2) { | ||
@@ -435,3 +431,3 @@ // reset parser for testing... | ||
*/ | ||
route$1.query = function() { | ||
route.query = function() { | ||
var q = {}; | ||
@@ -444,3 +440,3 @@ var href = loc.href || current; | ||
/** Stop routing **/ | ||
route$1.stop = function () { | ||
route.stop = function () { | ||
if (started) { | ||
@@ -461,3 +457,3 @@ if (win) { | ||
*/ | ||
route$1.start = function (autoExec) { | ||
route.start = function (autoExec) { | ||
if (!started) { | ||
@@ -483,4 +479,4 @@ if (win) { | ||
/** Prepare the router **/ | ||
route$1.base(); | ||
route$1.parser(); | ||
route.base(); | ||
route.parser(); | ||
@@ -491,3 +487,3 @@ riot.tag2('router', '<yield></yield>', '', '', function(opts) { | ||
this.route = route$1.create(); | ||
this.route = route.create(); | ||
this.select = function (target) { | ||
@@ -500,3 +496,3 @@ [].concat(this$1.tags.route) | ||
window.setTimeout(function () { return route$1.start(true); }, 0); | ||
window.setTimeout(function () { return route.start(true); }, 0); | ||
}); | ||
@@ -535,4 +531,4 @@ | ||
return route$1; | ||
return route; | ||
}); |
@@ -1,1 +0,1 @@ | ||
define(["riot"],function(e){"use strict";e=e&&"default"in e?e["default"]:e;var t=function(e){e=e||{};var t={},r=Array.prototype.slice;Object.defineProperties(e,{on:{value:function(r,n){if(typeof n=="function"){(t[r]=t[r]||[]).push(n)}return e},enumerable:false,writable:false,configurable:false},off:{value:function(r,n){if(r=="*"&&!n){t={}}else{if(n){var i=t[r];for(var a=0,f;f=i&&i[a];++a){if(f==n){i.splice(a--,1)}}}else{delete t[r]}}return e},enumerable:false,writable:false,configurable:false},one:{value:function(t,r){function n(){e.off(t,n);r.apply(e,arguments)}return e.on(t,n)},enumerable:false,writable:false,configurable:false},trigger:{value:function(n){var i=arguments;var a=arguments.length-1,f=new Array(a),u,o,c;for(c=0;c<a;c++){f[c]=i[c+1]}u=r.call(t[n]||[],0);for(c=0;o=u[c];++c){o.apply(e,f)}if(t["*"]&&n!="*"){e.trigger.apply(e,["*",n].concat(f))}return e},enumerable:false,writable:false,configurable:false}});return e};var r=/^.+?\/\/+[^/]+/;var n="EventListener";var i="remove"+n;var a="add"+n;var f="hasAttribute";var u="popstate";var o="hashchange";var c="trigger";var s=3;var l=typeof window!="undefined"&&window;var h=typeof document!="undefined"&&document;var v=l&&history;var p=l&&(v.location||l.location);var d=k.prototype;var m=h&&h.ontouchstart?"touchstart":"click";var g=t();var y=false;var b=false;var w;var $;var A;var S;var x;var E=[];var O=0;function T(e){return e.split(/[/?#]/)}function K(e,t){var r=t.replace(/\?/g,"\\?").replace(/\*/g,"([^/?#]+?)").replace(/\.\./,".*");var n=new RegExp("^"+r+"$");var i=e.match(n);if(i){return i.slice(1)}}function N(e,t){var r;return function(){clearTimeout(r);r=setTimeout(e,t)}}function j(e){w=N(R,1);l[a](u,w);l[a](o,w);h[a](m,_);if(e){R(true)}}function k(){this.$=[];t(this);g.on("stop",this.s.bind(this));g.on("emit",this.e.bind(this))}function P(e){return e.replace(/^\/|\/$/,"")}function q(e){return typeof e=="string"}function D(e){return(e||p.href).replace(r,"")}function L(e){return $[0]==="#"?(e||p.href||"").split($)[1]||"":(p?D(e):e||"").replace($,"")}function R(e){var t=O===0;if(s<=O){return}O++;E.push(function(){var t=L();if(e||t!==A){g[c]("emit",t);A=t}});if(t){var r;while(r=E.shift()){r()}O=0}}function _(e){if(e.which!==1||e.metaKey||e.ctrlKey||e.shiftKey||e.defaultPrevented){return}var t=e.target;while(t&&t.nodeName!=="A"){t=t.parentNode}if(!t||t.nodeName!=="A"||t[f]("download")||!t[f]("href")||t.target&&t.target!=="_self"||t.href.indexOf(p.href.match(r)[0])===-1){return}if(t.href!==p.href&&(t.href.split("#")[0]===p.href.split("#")[0]||$[0]!=="#"&&D(t.href).indexOf($)!==0||$[0]==="#"&&t.href.split($)[0]!==p.href.split($)[0]||!z(L(t.href),t.title||h.title))){return}e.preventDefault()}function z(e,t,r){if(!v){return g[c]("emit",L(e))}e=$+P(e);t=t||h.title;r?v.replaceState(null,t,e):v.pushState(null,t,e);h.title=t;b=false;R();return b}d.m=function(e,t,r){if(q(e)&&(!t||q(t))){z(e,t,r||false)}else if(t){this.r(e,t)}else{this.r("@",e)}};d.s=function(){this.off("*");this.$=[]};d.e=function(e){this.$.concat("@").some(function(t){var r=(t==="@"?S:x)(P(e),P(t));if(typeof r!="undefined"){this[c].apply(null,[t].concat(r));return b=true}},this)};d.r=function(e,t){if(e!=="@"){e="/"+P(e);this.$.push(e)}this.on(e,t)};var B=new k;var C=B.m.bind(B);C.create=function(){var e=new k;var t=e.m.bind(e);t.stop=e.s.bind(e);return t};C.base=function(e){$=e||"#";A=L()};C.exec=function(){R(true)};C.parser=function(e,t){if(!e&&!t){S=T;x=K}if(e){S=e}if(t){x=t}};C.query=function(){var e={};var t=p.href||A;t.replace(/[?&](.+?)=([^&]*)/g,function(t,r,n){e[r]=n});return e};C.stop=function(){if(y){if(l){l[i](u,w);l[i](o,w);h[i](m,_)}g[c]("stop");y=false}};C.start=function(e){if(!y){if(l){if(document.readyState==="interactive"||document.readyState==="complete"){j(e)}else{document.onreadystatechange=function(){if(document.readyState==="interactive"){setTimeout(function(){j(e)},1)}}}}y=true}};C.base();C.parser();e.tag2("router","<yield></yield>","","",function(e){var t=this;this.route=C.create();this.select=function(e){[].concat(t.tags.route).forEach(function(t){return t.show=t===e})};this.on("mount",function(){window.setTimeout(function(){return C.start(true)},0)});this.on("unmount",function(){t.route.stop()})});e.tag2("route",'<virtual if="{show}"><yield></yield></virtual>',"","",function(e){var t=this;this.show=false;this.parent.route(e.path,function(){var e=[],n=arguments.length;while(n--)e[n]=arguments[n];t.one("updated",function(){r(t.tags).forEach(function(t){t.trigger.apply(t,["route"].concat(e));t.update()})});t.parent.select(t);t.parent.update()});function r(e){return Object.keys(e).map(function(t){return e[t]}).reduce(function(e,t){return e.concat(t)},[])}});return C}); | ||
define(["riot"],function(e){"use strict";e=e&&e.hasOwnProperty("default")?e["default"]:e;var t=function(e){e=e||{};var t={},n=Array.prototype.slice;Object.defineProperties(e,{on:{value:function(n,r){if(typeof r=="function"){(t[n]=t[n]||[]).push(r)}return e},enumerable:false,writable:false,configurable:false},off:{value:function(n,r){if(n=="*"&&!r){t={}}else{if(r){var i=t[n];for(var a=0,f;f=i&&i[a];++a){if(f==r){i.splice(a--,1)}}}else{delete t[n]}}return e},enumerable:false,writable:false,configurable:false},one:{value:function(t,n){function r(){e.off(t,r);n.apply(e,arguments)}return e.on(t,r)},enumerable:false,writable:false,configurable:false},trigger:{value:function(r){var i=arguments;var a=arguments.length-1,f=new Array(a),u,o,c;for(c=0;c<a;c++){f[c]=i[c+1]}u=n.call(t[r]||[],0);for(c=0;o=u[c];++c){o.apply(e,f)}if(t["*"]&&r!="*"){e.trigger.apply(e,["*",r].concat(f))}return e},enumerable:false,writable:false,configurable:false}});return e};var n=/^.+?\/\/+[^/]+/,r="EventListener",i="remove"+r,a="add"+r,f="hasAttribute",u="popstate",o="hashchange",c="trigger",s=3,l=typeof window!="undefined"&&window,h=typeof document!="undefined"&&document,p=l&&history,d=l&&(p.location||l.location),v=j.prototype,m=h&&h.ontouchstart?"touchstart":"click",y=t();var g=false,w=false,b,$,A,O,S,x=[],E=0;function T(e){return e.split(/[/?#]/)}function K(e,t){var n=t.replace(/\?/g,"\\?").replace(/\*/g,"([^/?#]+?)").replace(/\.\./,".*");var r=new RegExp("^"+n+"$");var i=e.match(r);if(i){return i.slice(1)}}function N(e,t){var n;return function(){clearTimeout(n);n=setTimeout(e,t)}}function P(e){b=N(R,1);l[a](u,b);l[a](o,b);h[a](m,_);if(e){R(true)}}function j(){this.$=[];t(this);y.on("stop",this.s.bind(this));y.on("emit",this.e.bind(this))}function k(e){return e.replace(/^\/|\/$/,"")}function q(e){return typeof e=="string"}function D(e){return(e||d.href).replace(n,"")}function L(e){return $[0]==="#"?(e||d.href||"").split($)[1]||"":(d?D(e):e||"").replace($,"")}function R(e){var t=E===0;if(s<=E){return}E++;x.push(function(){var t=L();if(e||t!==A){y[c]("emit",t);A=t}});if(t){var n;while(n=x.shift()){n()}E=0}}function _(e){if(e.which!==1||e.metaKey||e.ctrlKey||e.shiftKey||e.defaultPrevented){return}var t=e.target;while(t&&t.nodeName!=="A"){t=t.parentNode}if(!t||t.nodeName!=="A"||t[f]("download")||!t[f]("href")||t.target&&t.target!=="_self"||t.href.indexOf(d.href.match(n)[0])===-1){return}if(t.href!==d.href&&(t.href.split("#")[0]===d.href.split("#")[0]||$[0]!=="#"&&D(t.href).indexOf($)!==0||$[0]==="#"&&t.href.split($)[0]!==d.href.split($)[0]||!z(L(t.href),t.title||h.title))){return}e.preventDefault()}function z(e,t,n){if(!p){return y[c]("emit",L(e))}e=$+k(e);t=t||h.title;n?p.replaceState(null,t,e):p.pushState(null,t,e);h.title=t;w=false;R();return w}v.m=function(e,t,n){if(q(e)&&(!t||q(t))){z(e,t,n||false)}else if(t){this.r(e,t)}else{this.r("@",e)}};v.s=function(){this.off("*");this.$=[]};v.e=function(e){this.$.concat("@").some(function(t){var n=(t==="@"?O:S)(k(e),k(t));if(typeof n!="undefined"){this[c].apply(null,[t].concat(n));return w=true}},this)};v.r=function(e,t){if(e!=="@"){e="/"+k(e);this.$.push(e)}this.on(e,t)};var B=new j;var C=B.m.bind(B);C.create=function(){var e=new j;var t=e.m.bind(e);t.stop=e.s.bind(e);return t};C.base=function(e){$=e||"#";A=L()};C.exec=function(){R(true)};C.parser=function(e,t){if(!e&&!t){O=T;S=K}if(e){O=e}if(t){S=t}};C.query=function(){var e={};var t=d.href||A;t.replace(/[?&](.+?)=([^&]*)/g,function(t,n,r){e[n]=r});return e};C.stop=function(){if(g){if(l){l[i](u,b);l[i](o,b);h[i](m,_)}y[c]("stop");g=false}};C.start=function(e){if(!g){if(l){if(document.readyState==="interactive"||document.readyState==="complete"){P(e)}else{document.onreadystatechange=function(){if(document.readyState==="interactive"){setTimeout(function(){P(e)},1)}}}}g=true}};C.base();C.parser();e.tag2("router","<yield></yield>","","",function(e){var t=this;this.route=C.create();this.select=function(e){[].concat(t.tags.route).forEach(function(t){return t.show=t===e})};this.on("mount",function(){window.setTimeout(function(){return C.start(true)},0)});this.on("unmount",function(){t.route.stop()})});e.tag2("route",'<virtual if="{show}"><yield></yield></virtual>',"","",function(e){var t=this;this.show=false;this.parent.route(e.path,function(){var e=[],r=arguments.length;while(r--)e[r]=arguments[r];t.one("updated",function(){n(t.tags).forEach(function(t){t.trigger.apply(t,["route"].concat(e));t.update()})});t.parent.select(t);t.parent.update()});function n(e){return Object.keys(e).map(function(t){return e[t]}).reduce(function(e,t){return e.concat(t)},[])}});return C}); |
@@ -17,3 +17,3 @@ var route = (function () { | ||
var callbacks = {}, | ||
slice = Array.prototype.slice; | ||
slice = Array.prototype.slice;; | ||
@@ -104,3 +104,3 @@ /** | ||
fn, | ||
i; | ||
i;;;;; | ||
@@ -132,34 +132,30 @@ for (i = 0; i < arglen; i++) { | ||
/** | ||
* Simple client-side router | ||
* @module riot-route | ||
*/ | ||
var RE_ORIGIN = /^.+?\/\/+[^/]+/, | ||
EVENT_LISTENER = 'EventListener', | ||
REMOVE_EVENT_LISTENER = 'remove' + EVENT_LISTENER, | ||
ADD_EVENT_LISTENER = 'add' + EVENT_LISTENER, | ||
HAS_ATTRIBUTE = 'hasAttribute', | ||
POPSTATE = 'popstate', | ||
HASHCHANGE = 'hashchange', | ||
TRIGGER = 'trigger', | ||
MAX_EMIT_STACK_LEVEL = 3, | ||
win = typeof window != 'undefined' && window, | ||
doc = typeof document != 'undefined' && document, | ||
hist = win && history, | ||
loc = win && (hist.location || win.location), // see html5-history-api | ||
prot = Router.prototype, // to minify more | ||
clickEvent = doc && doc.ontouchstart ? 'touchstart' : 'click', | ||
central = observable();;;;;;;;;;;;;;;; | ||
var RE_ORIGIN = /^.+?\/\/+[^/]+/; | ||
var EVENT_LISTENER = 'EventListener'; | ||
var REMOVE_EVENT_LISTENER = 'remove' + EVENT_LISTENER; | ||
var ADD_EVENT_LISTENER = 'add' + EVENT_LISTENER; | ||
var HAS_ATTRIBUTE = 'hasAttribute'; | ||
var POPSTATE = 'popstate'; | ||
var HASHCHANGE = 'hashchange'; | ||
var TRIGGER = 'trigger'; | ||
var MAX_EMIT_STACK_LEVEL = 3; | ||
var win = typeof window != 'undefined' && window; | ||
var doc = typeof document != 'undefined' && document; | ||
var hist = win && history; | ||
var loc = win && (hist.location || win.location); | ||
var prot = Router.prototype; | ||
var clickEvent = doc && doc.ontouchstart ? 'touchstart' : 'click'; | ||
var central = observable(); | ||
var | ||
started = false, | ||
routeFound = false, | ||
debouncedEmit, | ||
base, | ||
current, | ||
parser, | ||
secondParser, | ||
emitStack = [], | ||
emitStackLevel = 0;;;;;;;;; | ||
var started = false; | ||
var routeFound = false; | ||
var debouncedEmit; | ||
var base; | ||
var current; | ||
var parser; | ||
var secondParser; | ||
var emitStack = []; | ||
var emitStackLevel = 0; | ||
/** | ||
@@ -166,0 +162,0 @@ * Default parser. You can replace it via router.parser method. |
@@ -1,1 +0,1 @@ | ||
var route=function(){"use strict";var e=function(e){e=e||{};var t={},r=Array.prototype.slice;Object.defineProperties(e,{on:{value:function(r,n){if(typeof n=="function"){(t[r]=t[r]||[]).push(n)}return e},enumerable:false,writable:false,configurable:false},off:{value:function(r,n){if(r=="*"&&!n){t={}}else{if(n){var i=t[r];for(var a=0,f;f=i&&i[a];++a){if(f==n){i.splice(a--,1)}}}else{delete t[r]}}return e},enumerable:false,writable:false,configurable:false},one:{value:function(t,r){function n(){e.off(t,n);r.apply(e,arguments)}return e.on(t,n)},enumerable:false,writable:false,configurable:false},trigger:{value:function(n){var i=arguments;var a=arguments.length-1,f=new Array(a),u,o,c;for(c=0;c<a;c++){f[c]=i[c+1]}u=r.call(t[n]||[],0);for(c=0;o=u[c];++c){o.apply(e,f)}if(t["*"]&&n!="*"){e.trigger.apply(e,["*",n].concat(f))}return e},enumerable:false,writable:false,configurable:false}});return e};var t=/^.+?\/\/+[^/]+/;var r="EventListener";var n="remove"+r;var i="add"+r;var a="hasAttribute";var f="popstate";var u="hashchange";var o="trigger";var c=3;var l=typeof window!="undefined"&&window;var s=typeof document!="undefined"&&document;var v=l&&history;var h=l&&(v.location||l.location);var p=P.prototype;var d=s&&s.ontouchstart?"touchstart":"click";var m=e();var y=false;var b=false;var g;var w;var $;var A;var S;var x=[];var K=0;function N(e){return e.split(/[/?#]/)}function O(e,t){var r=t.replace(/\?/g,"\\?").replace(/\*/g,"([^/?#]+?)").replace(/\.\./,".*");var n=new RegExp("^"+r+"$");var i=e.match(n);if(i){return i.slice(1)}}function T(e,t){var r;return function(){clearTimeout(r);r=setTimeout(e,t)}}function E(e){g=T(L,1);l[i](f,g);l[i](u,g);s[i](d,R);if(e){L(true)}}function P(){this.$=[];e(this);m.on("stop",this.s.bind(this));m.on("emit",this.e.bind(this))}function j(e){return e.replace(/^\/|\/$/,"")}function k(e){return typeof e=="string"}function q(e){return(e||h.href).replace(t,"")}function D(e){return w[0]==="#"?(e||h.href||"").split(w)[1]||"":(h?q(e):e||"").replace(w,"")}function L(e){var t=K===0;if(c<=K){return}K++;x.push(function(){var t=D();if(e||t!==$){m[o]("emit",t);$=t}});if(t){var r;while(r=x.shift()){r()}K=0}}function R(e){if(e.which!==1||e.metaKey||e.ctrlKey||e.shiftKey||e.defaultPrevented){return}var r=e.target;while(r&&r.nodeName!=="A"){r=r.parentNode}if(!r||r.nodeName!=="A"||r[a]("download")||!r[a]("href")||r.target&&r.target!=="_self"||r.href.indexOf(h.href.match(t)[0])===-1){return}if(r.href!==h.href&&(r.href.split("#")[0]===h.href.split("#")[0]||w[0]!=="#"&&q(r.href).indexOf(w)!==0||w[0]==="#"&&r.href.split(w)[0]!==h.href.split(w)[0]||!_(D(r.href),r.title||s.title))){return}e.preventDefault()}function _(e,t,r){if(!v){return m[o]("emit",D(e))}e=w+j(e);t=t||s.title;r?v.replaceState(null,t,e):v.pushState(null,t,e);s.title=t;b=false;L();return b}p.m=function(e,t,r){if(k(e)&&(!t||k(t))){_(e,t,r||false)}else if(t){this.r(e,t)}else{this.r("@",e)}};p.s=function(){this.off("*");this.$=[]};p.e=function(e){this.$.concat("@").some(function(t){var r=(t==="@"?A:S)(j(e),j(t));if(typeof r!="undefined"){this[o].apply(null,[t].concat(r));return b=true}},this)};p.r=function(e,t){if(e!=="@"){e="/"+j(e);this.$.push(e)}this.on(e,t)};var z=new P;var B=z.m.bind(z);B.create=function(){var e=new P;var t=e.m.bind(e);t.stop=e.s.bind(e);return t};B.base=function(e){w=e||"#";$=D()};B.exec=function(){L(true)};B.parser=function(e,t){if(!e&&!t){A=N;S=O}if(e){A=e}if(t){S=t}};B.query=function(){var e={};var t=h.href||$;t.replace(/[?&](.+?)=([^&]*)/g,function(t,r,n){e[r]=n});return e};B.stop=function(){if(y){if(l){l[n](f,g);l[n](u,g);s[n](d,R)}m[o]("stop");y=false}};B.start=function(e){if(!y){if(l){if(document.readyState==="interactive"||document.readyState==="complete"){E(e)}else{document.onreadystatechange=function(){if(document.readyState==="interactive"){setTimeout(function(){E(e)},1)}}}}y=true}};B.base();B.parser();return B}(); | ||
var route=function(){"use strict";var e=function(e){e=e||{};var t={},n=Array.prototype.slice;Object.defineProperties(e,{on:{value:function(n,r){if(typeof r=="function"){(t[n]=t[n]||[]).push(r)}return e},enumerable:false,writable:false,configurable:false},off:{value:function(n,r){if(n=="*"&&!r){t={}}else{if(r){var i=t[n];for(var f=0,a;a=i&&i[f];++f){if(a==r){i.splice(f--,1)}}}else{delete t[n]}}return e},enumerable:false,writable:false,configurable:false},one:{value:function(t,n){function r(){e.off(t,r);n.apply(e,arguments)}return e.on(t,r)},enumerable:false,writable:false,configurable:false},trigger:{value:function(r){var i=arguments;var f=arguments.length-1,a=new Array(f),u,o,c;for(c=0;c<f;c++){a[c]=i[c+1]}u=n.call(t[r]||[],0);for(c=0;o=u[c];++c){o.apply(e,a)}if(t["*"]&&r!="*"){e.trigger.apply(e,["*",r].concat(a))}return e},enumerable:false,writable:false,configurable:false}});return e};var t=/^.+?\/\/+[^/]+/,n="EventListener",r="remove"+n,i="add"+n,f="hasAttribute",a="popstate",u="hashchange",o="trigger",c=3,l=typeof window!="undefined"&&window,s=typeof document!="undefined"&&document,h=l&&history,p=l&&(h.location||l.location),d=P.prototype,v=s&&s.ontouchstart?"touchstart":"click",m=e();var y=false,b=false,g,w,$,A,S,x=[],K=0;function N(e){return e.split(/[/?#]/)}function O(e,t){var n=t.replace(/\?/g,"\\?").replace(/\*/g,"([^/?#]+?)").replace(/\.\./,".*");var r=new RegExp("^"+n+"$");var i=e.match(r);if(i){return i.slice(1)}}function T(e,t){var n;return function(){clearTimeout(n);n=setTimeout(e,t)}}function E(e){g=T(L,1);l[i](a,g);l[i](u,g);s[i](v,R);if(e){L(true)}}function P(){this.$=[];e(this);m.on("stop",this.s.bind(this));m.on("emit",this.e.bind(this))}function j(e){return e.replace(/^\/|\/$/,"")}function k(e){return typeof e=="string"}function q(e){return(e||p.href).replace(t,"")}function D(e){return w[0]==="#"?(e||p.href||"").split(w)[1]||"":(p?q(e):e||"").replace(w,"")}function L(e){var t=K===0;if(c<=K){return}K++;x.push(function(){var t=D();if(e||t!==$){m[o]("emit",t);$=t}});if(t){var n;while(n=x.shift()){n()}K=0}}function R(e){if(e.which!==1||e.metaKey||e.ctrlKey||e.shiftKey||e.defaultPrevented){return}var n=e.target;while(n&&n.nodeName!=="A"){n=n.parentNode}if(!n||n.nodeName!=="A"||n[f]("download")||!n[f]("href")||n.target&&n.target!=="_self"||n.href.indexOf(p.href.match(t)[0])===-1){return}if(n.href!==p.href&&(n.href.split("#")[0]===p.href.split("#")[0]||w[0]!=="#"&&q(n.href).indexOf(w)!==0||w[0]==="#"&&n.href.split(w)[0]!==p.href.split(w)[0]||!_(D(n.href),n.title||s.title))){return}e.preventDefault()}function _(e,t,n){if(!h){return m[o]("emit",D(e))}e=w+j(e);t=t||s.title;n?h.replaceState(null,t,e):h.pushState(null,t,e);s.title=t;b=false;L();return b}d.m=function(e,t,n){if(k(e)&&(!t||k(t))){_(e,t,n||false)}else if(t){this.r(e,t)}else{this.r("@",e)}};d.s=function(){this.off("*");this.$=[]};d.e=function(e){this.$.concat("@").some(function(t){var n=(t==="@"?A:S)(j(e),j(t));if(typeof n!="undefined"){this[o].apply(null,[t].concat(n));return b=true}},this)};d.r=function(e,t){if(e!=="@"){e="/"+j(e);this.$.push(e)}this.on(e,t)};var z=new P;var B=z.m.bind(z);B.create=function(){var e=new P;var t=e.m.bind(e);t.stop=e.s.bind(e);return t};B.base=function(e){w=e||"#";$=D()};B.exec=function(){L(true)};B.parser=function(e,t){if(!e&&!t){A=N;S=O}if(e){A=e}if(t){S=t}};B.query=function(){var e={};var t=p.href||$;t.replace(/[?&](.+?)=([^&]*)/g,function(t,n,r){e[n]=r});return e};B.stop=function(){if(y){if(l){l[r](a,g);l[r](u,g);s[r](v,R)}m[o]("stop");y=false}};B.start=function(e){if(!y){if(l){if(document.readyState==="interactive"||document.readyState==="complete"){E(e)}else{document.onreadystatechange=function(){if(document.readyState==="interactive"){setTimeout(function(){E(e)},1)}}}}y=true}};B.base();B.parser();return B}(); |
var route = (function (riot) { | ||
'use strict'; | ||
riot = riot && 'default' in riot ? riot['default'] : riot; | ||
riot = riot && riot.hasOwnProperty('default') ? riot['default'] : riot; | ||
@@ -19,3 +19,3 @@ var observable = function(el) { | ||
var callbacks = {}, | ||
slice = Array.prototype.slice; | ||
slice = Array.prototype.slice;; | ||
@@ -106,3 +106,3 @@ /** | ||
fn, | ||
i; | ||
i;;;;; | ||
@@ -134,34 +134,30 @@ for (i = 0; i < arglen; i++) { | ||
/** | ||
* Simple client-side router | ||
* @module riot-route | ||
*/ | ||
var RE_ORIGIN = /^.+?\/\/+[^/]+/, | ||
EVENT_LISTENER = 'EventListener', | ||
REMOVE_EVENT_LISTENER = 'remove' + EVENT_LISTENER, | ||
ADD_EVENT_LISTENER = 'add' + EVENT_LISTENER, | ||
HAS_ATTRIBUTE = 'hasAttribute', | ||
POPSTATE = 'popstate', | ||
HASHCHANGE = 'hashchange', | ||
TRIGGER = 'trigger', | ||
MAX_EMIT_STACK_LEVEL = 3, | ||
win = typeof window != 'undefined' && window, | ||
doc = typeof document != 'undefined' && document, | ||
hist = win && history, | ||
loc = win && (hist.location || win.location), // see html5-history-api | ||
prot = Router.prototype, // to minify more | ||
clickEvent = doc && doc.ontouchstart ? 'touchstart' : 'click', | ||
central = observable();;;;;;;;;;;;;;;; | ||
var RE_ORIGIN = /^.+?\/\/+[^/]+/; | ||
var EVENT_LISTENER = 'EventListener'; | ||
var REMOVE_EVENT_LISTENER = 'remove' + EVENT_LISTENER; | ||
var ADD_EVENT_LISTENER = 'add' + EVENT_LISTENER; | ||
var HAS_ATTRIBUTE = 'hasAttribute'; | ||
var POPSTATE = 'popstate'; | ||
var HASHCHANGE = 'hashchange'; | ||
var TRIGGER = 'trigger'; | ||
var MAX_EMIT_STACK_LEVEL = 3; | ||
var win = typeof window != 'undefined' && window; | ||
var doc = typeof document != 'undefined' && document; | ||
var hist = win && history; | ||
var loc = win && (hist.location || win.location); | ||
var prot = Router.prototype; | ||
var clickEvent = doc && doc.ontouchstart ? 'touchstart' : 'click'; | ||
var central = observable(); | ||
var | ||
started = false, | ||
routeFound = false, | ||
debouncedEmit, | ||
base, | ||
current, | ||
parser, | ||
secondParser, | ||
emitStack = [], | ||
emitStackLevel = 0;;;;;;;;; | ||
var started = false; | ||
var routeFound = false; | ||
var debouncedEmit; | ||
var base; | ||
var current; | ||
var parser; | ||
var secondParser; | ||
var emitStack = []; | ||
var emitStackLevel = 0; | ||
/** | ||
@@ -383,3 +379,3 @@ * Default parser. You can replace it via router.parser method. | ||
var mainRouter = new Router(); | ||
var route$1 = mainRouter.m.bind(mainRouter); | ||
var route = mainRouter.m.bind(mainRouter); | ||
@@ -390,3 +386,3 @@ /** | ||
*/ | ||
route$1.create = function() { | ||
route.create = function() { | ||
var newSubRouter = new Router(); | ||
@@ -404,3 +400,3 @@ // assign sub-router's main method | ||
*/ | ||
route$1.base = function(arg) { | ||
route.base = function(arg) { | ||
base = arg || '#'; | ||
@@ -411,3 +407,3 @@ current = getPathFromBase(); // recalculate current path | ||
/** Exec routing right now **/ | ||
route$1.exec = function() { | ||
route.exec = function() { | ||
emit(true); | ||
@@ -421,3 +417,3 @@ }; | ||
*/ | ||
route$1.parser = function(fn, fn2) { | ||
route.parser = function(fn, fn2) { | ||
if (!fn && !fn2) { | ||
@@ -436,3 +432,3 @@ // reset parser for testing... | ||
*/ | ||
route$1.query = function() { | ||
route.query = function() { | ||
var q = {}; | ||
@@ -445,3 +441,3 @@ var href = loc.href || current; | ||
/** Stop routing **/ | ||
route$1.stop = function () { | ||
route.stop = function () { | ||
if (started) { | ||
@@ -462,3 +458,3 @@ if (win) { | ||
*/ | ||
route$1.start = function (autoExec) { | ||
route.start = function (autoExec) { | ||
if (!started) { | ||
@@ -484,4 +480,4 @@ if (win) { | ||
/** Prepare the router **/ | ||
route$1.base(); | ||
route$1.parser(); | ||
route.base(); | ||
route.parser(); | ||
@@ -492,3 +488,3 @@ riot.tag2('router', '<yield></yield>', '', '', function(opts) { | ||
this.route = route$1.create(); | ||
this.route = route.create(); | ||
this.select = function (target) { | ||
@@ -501,3 +497,3 @@ [].concat(this$1.tags.route) | ||
window.setTimeout(function () { return route$1.start(true); }, 0); | ||
window.setTimeout(function () { return route.start(true); }, 0); | ||
}); | ||
@@ -536,4 +532,4 @@ | ||
return route$1; | ||
return route; | ||
}(riot)); |
@@ -1,1 +0,1 @@ | ||
var route=function(e){"use strict";e=e&&"default"in e?e["default"]:e;var t=function(e){e=e||{};var t={},r=Array.prototype.slice;Object.defineProperties(e,{on:{value:function(r,n){if(typeof n=="function"){(t[r]=t[r]||[]).push(n)}return e},enumerable:false,writable:false,configurable:false},off:{value:function(r,n){if(r=="*"&&!n){t={}}else{if(n){var i=t[r];for(var a=0,f;f=i&&i[a];++a){if(f==n){i.splice(a--,1)}}}else{delete t[r]}}return e},enumerable:false,writable:false,configurable:false},one:{value:function(t,r){function n(){e.off(t,n);r.apply(e,arguments)}return e.on(t,n)},enumerable:false,writable:false,configurable:false},trigger:{value:function(n){var i=arguments;var a=arguments.length-1,f=new Array(a),u,o,c;for(c=0;c<a;c++){f[c]=i[c+1]}u=r.call(t[n]||[],0);for(c=0;o=u[c];++c){o.apply(e,f)}if(t["*"]&&n!="*"){e.trigger.apply(e,["*",n].concat(f))}return e},enumerable:false,writable:false,configurable:false}});return e};var r=/^.+?\/\/+[^/]+/;var n="EventListener";var i="remove"+n;var a="add"+n;var f="hasAttribute";var u="popstate";var o="hashchange";var c="trigger";var s=3;var l=typeof window!="undefined"&&window;var h=typeof document!="undefined"&&document;var v=l&&history;var p=l&&(v.location||l.location);var d=k.prototype;var m=h&&h.ontouchstart?"touchstart":"click";var g=t();var y=false;var b=false;var w;var $;var A;var S;var x;var E=[];var O=0;function T(e){return e.split(/[/?#]/)}function K(e,t){var r=t.replace(/\?/g,"\\?").replace(/\*/g,"([^/?#]+?)").replace(/\.\./,".*");var n=new RegExp("^"+r+"$");var i=e.match(n);if(i){return i.slice(1)}}function N(e,t){var r;return function(){clearTimeout(r);r=setTimeout(e,t)}}function j(e){w=N(R,1);l[a](u,w);l[a](o,w);h[a](m,_);if(e){R(true)}}function k(){this.$=[];t(this);g.on("stop",this.s.bind(this));g.on("emit",this.e.bind(this))}function P(e){return e.replace(/^\/|\/$/,"")}function q(e){return typeof e=="string"}function D(e){return(e||p.href).replace(r,"")}function L(e){return $[0]==="#"?(e||p.href||"").split($)[1]||"":(p?D(e):e||"").replace($,"")}function R(e){var t=O===0;if(s<=O){return}O++;E.push(function(){var t=L();if(e||t!==A){g[c]("emit",t);A=t}});if(t){var r;while(r=E.shift()){r()}O=0}}function _(e){if(e.which!==1||e.metaKey||e.ctrlKey||e.shiftKey||e.defaultPrevented){return}var t=e.target;while(t&&t.nodeName!=="A"){t=t.parentNode}if(!t||t.nodeName!=="A"||t[f]("download")||!t[f]("href")||t.target&&t.target!=="_self"||t.href.indexOf(p.href.match(r)[0])===-1){return}if(t.href!==p.href&&(t.href.split("#")[0]===p.href.split("#")[0]||$[0]!=="#"&&D(t.href).indexOf($)!==0||$[0]==="#"&&t.href.split($)[0]!==p.href.split($)[0]||!z(L(t.href),t.title||h.title))){return}e.preventDefault()}function z(e,t,r){if(!v){return g[c]("emit",L(e))}e=$+P(e);t=t||h.title;r?v.replaceState(null,t,e):v.pushState(null,t,e);h.title=t;b=false;R();return b}d.m=function(e,t,r){if(q(e)&&(!t||q(t))){z(e,t,r||false)}else if(t){this.r(e,t)}else{this.r("@",e)}};d.s=function(){this.off("*");this.$=[]};d.e=function(e){this.$.concat("@").some(function(t){var r=(t==="@"?S:x)(P(e),P(t));if(typeof r!="undefined"){this[c].apply(null,[t].concat(r));return b=true}},this)};d.r=function(e,t){if(e!=="@"){e="/"+P(e);this.$.push(e)}this.on(e,t)};var B=new k;var C=B.m.bind(B);C.create=function(){var e=new k;var t=e.m.bind(e);t.stop=e.s.bind(e);return t};C.base=function(e){$=e||"#";A=L()};C.exec=function(){R(true)};C.parser=function(e,t){if(!e&&!t){S=T;x=K}if(e){S=e}if(t){x=t}};C.query=function(){var e={};var t=p.href||A;t.replace(/[?&](.+?)=([^&]*)/g,function(t,r,n){e[r]=n});return e};C.stop=function(){if(y){if(l){l[i](u,w);l[i](o,w);h[i](m,_)}g[c]("stop");y=false}};C.start=function(e){if(!y){if(l){if(document.readyState==="interactive"||document.readyState==="complete"){j(e)}else{document.onreadystatechange=function(){if(document.readyState==="interactive"){setTimeout(function(){j(e)},1)}}}}y=true}};C.base();C.parser();e.tag2("router","<yield></yield>","","",function(e){var t=this;this.route=C.create();this.select=function(e){[].concat(t.tags.route).forEach(function(t){return t.show=t===e})};this.on("mount",function(){window.setTimeout(function(){return C.start(true)},0)});this.on("unmount",function(){t.route.stop()})});e.tag2("route",'<virtual if="{show}"><yield></yield></virtual>',"","",function(e){var t=this;this.show=false;this.parent.route(e.path,function(){var e=[],n=arguments.length;while(n--)e[n]=arguments[n];t.one("updated",function(){r(t.tags).forEach(function(t){t.trigger.apply(t,["route"].concat(e));t.update()})});t.parent.select(t);t.parent.update()});function r(e){return Object.keys(e).map(function(t){return e[t]}).reduce(function(e,t){return e.concat(t)},[])}});return C}(riot); | ||
var route=function(e){"use strict";e=e&&e.hasOwnProperty("default")?e["default"]:e;var t=function(e){e=e||{};var t={},n=Array.prototype.slice;Object.defineProperties(e,{on:{value:function(n,r){if(typeof r=="function"){(t[n]=t[n]||[]).push(r)}return e},enumerable:false,writable:false,configurable:false},off:{value:function(n,r){if(n=="*"&&!r){t={}}else{if(r){var i=t[n];for(var a=0,f;f=i&&i[a];++a){if(f==r){i.splice(a--,1)}}}else{delete t[n]}}return e},enumerable:false,writable:false,configurable:false},one:{value:function(t,n){function r(){e.off(t,r);n.apply(e,arguments)}return e.on(t,r)},enumerable:false,writable:false,configurable:false},trigger:{value:function(r){var i=arguments;var a=arguments.length-1,f=new Array(a),u,o,c;for(c=0;c<a;c++){f[c]=i[c+1]}u=n.call(t[r]||[],0);for(c=0;o=u[c];++c){o.apply(e,f)}if(t["*"]&&r!="*"){e.trigger.apply(e,["*",r].concat(f))}return e},enumerable:false,writable:false,configurable:false}});return e};var n=/^.+?\/\/+[^/]+/,r="EventListener",i="remove"+r,a="add"+r,f="hasAttribute",u="popstate",o="hashchange",c="trigger",s=3,l=typeof window!="undefined"&&window,h=typeof document!="undefined"&&document,p=l&&history,d=l&&(p.location||l.location),v=j.prototype,m=h&&h.ontouchstart?"touchstart":"click",y=t();var g=false,w=false,b,$,A,O,S,x=[],E=0;function T(e){return e.split(/[/?#]/)}function K(e,t){var n=t.replace(/\?/g,"\\?").replace(/\*/g,"([^/?#]+?)").replace(/\.\./,".*");var r=new RegExp("^"+n+"$");var i=e.match(r);if(i){return i.slice(1)}}function N(e,t){var n;return function(){clearTimeout(n);n=setTimeout(e,t)}}function P(e){b=N(R,1);l[a](u,b);l[a](o,b);h[a](m,_);if(e){R(true)}}function j(){this.$=[];t(this);y.on("stop",this.s.bind(this));y.on("emit",this.e.bind(this))}function k(e){return e.replace(/^\/|\/$/,"")}function q(e){return typeof e=="string"}function D(e){return(e||d.href).replace(n,"")}function L(e){return $[0]==="#"?(e||d.href||"").split($)[1]||"":(d?D(e):e||"").replace($,"")}function R(e){var t=E===0;if(s<=E){return}E++;x.push(function(){var t=L();if(e||t!==A){y[c]("emit",t);A=t}});if(t){var n;while(n=x.shift()){n()}E=0}}function _(e){if(e.which!==1||e.metaKey||e.ctrlKey||e.shiftKey||e.defaultPrevented){return}var t=e.target;while(t&&t.nodeName!=="A"){t=t.parentNode}if(!t||t.nodeName!=="A"||t[f]("download")||!t[f]("href")||t.target&&t.target!=="_self"||t.href.indexOf(d.href.match(n)[0])===-1){return}if(t.href!==d.href&&(t.href.split("#")[0]===d.href.split("#")[0]||$[0]!=="#"&&D(t.href).indexOf($)!==0||$[0]==="#"&&t.href.split($)[0]!==d.href.split($)[0]||!z(L(t.href),t.title||h.title))){return}e.preventDefault()}function z(e,t,n){if(!p){return y[c]("emit",L(e))}e=$+k(e);t=t||h.title;n?p.replaceState(null,t,e):p.pushState(null,t,e);h.title=t;w=false;R();return w}v.m=function(e,t,n){if(q(e)&&(!t||q(t))){z(e,t,n||false)}else if(t){this.r(e,t)}else{this.r("@",e)}};v.s=function(){this.off("*");this.$=[]};v.e=function(e){this.$.concat("@").some(function(t){var n=(t==="@"?O:S)(k(e),k(t));if(typeof n!="undefined"){this[c].apply(null,[t].concat(n));return w=true}},this)};v.r=function(e,t){if(e!=="@"){e="/"+k(e);this.$.push(e)}this.on(e,t)};var B=new j;var C=B.m.bind(B);C.create=function(){var e=new j;var t=e.m.bind(e);t.stop=e.s.bind(e);return t};C.base=function(e){$=e||"#";A=L()};C.exec=function(){R(true)};C.parser=function(e,t){if(!e&&!t){O=T;S=K}if(e){O=e}if(t){S=t}};C.query=function(){var e={};var t=d.href||A;t.replace(/[?&](.+?)=([^&]*)/g,function(t,n,r){e[n]=r});return e};C.stop=function(){if(g){if(l){l[i](u,b);l[i](o,b);h[i](m,_)}y[c]("stop");g=false}};C.start=function(e){if(!g){if(l){if(document.readyState==="interactive"||document.readyState==="complete"){P(e)}else{document.onreadystatechange=function(){if(document.readyState==="interactive"){setTimeout(function(){P(e)},1)}}}}g=true}};C.base();C.parser();e.tag2("router","<yield></yield>","","",function(e){var t=this;this.route=C.create();this.select=function(e){[].concat(t.tags.route).forEach(function(t){return t.show=t===e})};this.on("mount",function(){window.setTimeout(function(){return C.start(true)},0)});this.on("unmount",function(){t.route.stop()})});e.tag2("route",'<virtual if="{show}"><yield></yield></virtual>',"","",function(e){var t=this;this.show=false;this.parent.route(e.path,function(){var e=[],r=arguments.length;while(r--)e[r]=arguments[r];t.one("updated",function(){n(t.tags).forEach(function(t){t.trigger.apply(t,["route"].concat(e));t.update()})});t.parent.select(t);t.parent.update()});function n(e){return Object.keys(e).map(function(t){return e[t]}).reduce(function(e,t){return e.concat(t)},[])}});return C}(riot); |
56
index.js
@@ -7,34 +7,30 @@ 'use strict'; | ||
/** | ||
* Simple client-side router | ||
* @module riot-route | ||
*/ | ||
var RE_ORIGIN = /^.+?\/\/+[^/]+/, | ||
EVENT_LISTENER = 'EventListener', | ||
REMOVE_EVENT_LISTENER = 'remove' + EVENT_LISTENER, | ||
ADD_EVENT_LISTENER = 'add' + EVENT_LISTENER, | ||
HAS_ATTRIBUTE = 'hasAttribute', | ||
POPSTATE = 'popstate', | ||
HASHCHANGE = 'hashchange', | ||
TRIGGER = 'trigger', | ||
MAX_EMIT_STACK_LEVEL = 3, | ||
win = typeof window != 'undefined' && window, | ||
doc = typeof document != 'undefined' && document, | ||
hist = win && history, | ||
loc = win && (hist.location || win.location), // see html5-history-api | ||
prot = Router.prototype, // to minify more | ||
clickEvent = doc && doc.ontouchstart ? 'touchstart' : 'click', | ||
central = observable();;;;;;;;;;;;;;;; | ||
var RE_ORIGIN = /^.+?\/\/+[^/]+/; | ||
var EVENT_LISTENER = 'EventListener'; | ||
var REMOVE_EVENT_LISTENER = 'remove' + EVENT_LISTENER; | ||
var ADD_EVENT_LISTENER = 'add' + EVENT_LISTENER; | ||
var HAS_ATTRIBUTE = 'hasAttribute'; | ||
var POPSTATE = 'popstate'; | ||
var HASHCHANGE = 'hashchange'; | ||
var TRIGGER = 'trigger'; | ||
var MAX_EMIT_STACK_LEVEL = 3; | ||
var win = typeof window != 'undefined' && window; | ||
var doc = typeof document != 'undefined' && document; | ||
var hist = win && history; | ||
var loc = win && (hist.location || win.location); | ||
var prot = Router.prototype; | ||
var clickEvent = doc && doc.ontouchstart ? 'touchstart' : 'click'; | ||
var central = observable(); | ||
var | ||
started = false, | ||
routeFound = false, | ||
debouncedEmit, | ||
base, | ||
current, | ||
parser, | ||
secondParser, | ||
emitStack = [], | ||
emitStackLevel = 0;;;;;;;;; | ||
var started = false; | ||
var routeFound = false; | ||
var debouncedEmit; | ||
var base; | ||
var current; | ||
var parser; | ||
var secondParser; | ||
var emitStack = []; | ||
var emitStackLevel = 0; | ||
/** | ||
@@ -41,0 +37,0 @@ * Default parser. You can replace it via router.parser method. |
import observable from 'riot-observable'; | ||
/** | ||
* Simple client-side router | ||
* @module riot-route | ||
*/ | ||
var RE_ORIGIN = /^.+?\/\/+[^/]+/, | ||
EVENT_LISTENER = 'EventListener', | ||
REMOVE_EVENT_LISTENER = 'remove' + EVENT_LISTENER, | ||
ADD_EVENT_LISTENER = 'add' + EVENT_LISTENER, | ||
HAS_ATTRIBUTE = 'hasAttribute', | ||
POPSTATE = 'popstate', | ||
HASHCHANGE = 'hashchange', | ||
TRIGGER = 'trigger', | ||
MAX_EMIT_STACK_LEVEL = 3, | ||
win = typeof window != 'undefined' && window, | ||
doc = typeof document != 'undefined' && document, | ||
hist = win && history, | ||
loc = win && (hist.location || win.location), // see html5-history-api | ||
prot = Router.prototype, // to minify more | ||
clickEvent = doc && doc.ontouchstart ? 'touchstart' : 'click', | ||
central = observable();;;;;;;;;;;;;;;; | ||
var RE_ORIGIN = /^.+?\/\/+[^/]+/; | ||
var EVENT_LISTENER = 'EventListener'; | ||
var REMOVE_EVENT_LISTENER = 'remove' + EVENT_LISTENER; | ||
var ADD_EVENT_LISTENER = 'add' + EVENT_LISTENER; | ||
var HAS_ATTRIBUTE = 'hasAttribute'; | ||
var POPSTATE = 'popstate'; | ||
var HASHCHANGE = 'hashchange'; | ||
var TRIGGER = 'trigger'; | ||
var MAX_EMIT_STACK_LEVEL = 3; | ||
var win = typeof window != 'undefined' && window; | ||
var doc = typeof document != 'undefined' && document; | ||
var hist = win && history; | ||
var loc = win && (hist.location || win.location); | ||
var prot = Router.prototype; | ||
var clickEvent = doc && doc.ontouchstart ? 'touchstart' : 'click'; | ||
var central = observable(); | ||
var | ||
started = false, | ||
routeFound = false, | ||
debouncedEmit, | ||
base, | ||
current, | ||
parser, | ||
secondParser, | ||
emitStack = [], | ||
emitStackLevel = 0;;;;;;;;; | ||
var started = false; | ||
var routeFound = false; | ||
var debouncedEmit; | ||
var base; | ||
var current; | ||
var parser; | ||
var secondParser; | ||
var emitStack = []; | ||
var emitStackLevel = 0; | ||
/** | ||
@@ -36,0 +32,0 @@ * Default parser. You can replace it via router.parser method. |
@@ -0,3 +1,3 @@ | ||
import riot from 'riot'; | ||
import route from 'riot-route'; | ||
import riot from 'riot'; | ||
@@ -4,0 +4,0 @@ riot.tag2('router', '<yield></yield>', '', '', function(opts) { |
{ | ||
"name": "riot-route", | ||
"version": "3.1.2", | ||
"version": "3.1.3", | ||
"description": "Simple isomorphic router", | ||
@@ -43,21 +43,20 @@ "main": "index.js", | ||
"chokidar-cli": "^1.2.0", | ||
"coveralls": "^2.13.1", | ||
"electron": "^1.6.11", | ||
"eslint": "^4.1.1", | ||
"coveralls": "^3.0.0", | ||
"eslint": "^4.17.0", | ||
"eslint-config-riot": "^1.0.0", | ||
"expect.js": "^0.3.1", | ||
"karma": "^1.7.0", | ||
"karma": "^2.0.0", | ||
"karma-browserstack-launcher": "^1.3.0", | ||
"karma-chrome-launcher": "^2.2.0", | ||
"karma-coverage": "^1.1.1", | ||
"karma-electron": "^5.2.1", | ||
"karma-mocha": "^1.3.0", | ||
"karma-mocha-reporter": "^2.2.3", | ||
"karma-mocha-reporter": "^2.2.5", | ||
"karma-riot": "^2.0.0", | ||
"mocha": "^3.4.2", | ||
"riot": "^3.6.1", | ||
"rollup": "^0.43.0", | ||
"rollup-plugin-alias": "^1.3.1", | ||
"rollup-plugin-buble": "^0.15.0", | ||
"rollup-plugin-riot": "^1.1.0", | ||
"uglify-js": "^3.0.23" | ||
"mocha": "^5.0.1", | ||
"riot": "^3.9.0", | ||
"rollup": "^0.56.1", | ||
"rollup-plugin-alias": "^1.4.0", | ||
"rollup-plugin-buble": "^0.19.2", | ||
"rollup-plugin-riot": "^2.0.0", | ||
"uglify-js": "^3.3.11" | ||
}, | ||
@@ -64,0 +63,0 @@ "author": "Muut, Inc. and other contributors", |
@@ -38,3 +38,3 @@ # Riot Router | ||
```html | ||
<script src="https://cdn.jsdelivr.net/riot-route/x.x.x/route.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/riot-route@x.x.x/dist/route.min.js"></script> | ||
``` | ||
@@ -41,0 +41,0 @@ |
@@ -9,3 +9,3 @@ const | ||
.rollup({ | ||
entry: 'src/index.js', | ||
input: 'src/index.js', | ||
plugins: [ | ||
@@ -17,4 +17,4 @@ alias({ 'riot-observable': 'node_modules/riot-observable/dist/es6.observable.js' }), | ||
.then(bundle => { | ||
bundle.write({ format: 'iife', moduleName: 'route', dest: 'dist/route.js' }) | ||
bundle.write({ format: 'amd', dest: 'dist/amd.route.js' }) | ||
bundle.write({ format: 'iife', name: 'route', file: 'dist/route.js' }) | ||
bundle.write({ format: 'amd', file: 'dist/amd.route.js' }) | ||
}) | ||
@@ -27,3 +27,3 @@ .catch(error => { | ||
.rollup({ | ||
entry: 'src/index.js', | ||
input: 'src/index.js', | ||
external: ['riot-observable'], | ||
@@ -33,4 +33,4 @@ plugins: [buble()] | ||
.then(bundle => { | ||
bundle.write({ format: 'es', dest: 'lib/index.js' }) | ||
bundle.write({ format: 'cjs', dest: 'index.js' }) | ||
bundle.write({ format: 'es', file: 'lib/index.js' }) | ||
bundle.write({ format: 'cjs', file: 'index.js' }) | ||
}) | ||
@@ -43,3 +43,3 @@ .catch(error => { | ||
.rollup({ | ||
entry: 'src/tag.js', | ||
input: 'src/tag.js', | ||
external: ['riot'], | ||
@@ -58,7 +58,7 @@ plugins: [ | ||
format: 'iife', | ||
moduleName: 'route', | ||
name: 'route', | ||
globals: { riot: 'riot' }, | ||
dest: 'dist/route+tag.js' | ||
file: 'dist/route+tag.js' | ||
}) | ||
bundle.write({ format: 'amd', dest: 'dist/amd.route+tag.js' }) | ||
bundle.write({ format: 'amd', file: 'dist/amd.route+tag.js' }) | ||
}) | ||
@@ -71,3 +71,3 @@ .catch(error => { | ||
.rollup({ | ||
entry: 'src/tag.js', | ||
input: 'src/tag.js', | ||
external: ['riot', 'riot-observable', 'riot-route'], | ||
@@ -77,4 +77,4 @@ plugins: [riot(), buble()] | ||
.then(bundle => { | ||
bundle.write({ format: 'es', dest: 'lib/tag.js' }) | ||
bundle.write({ format: 'cjs', dest: 'tag.js' }) | ||
bundle.write({ format: 'es', file: 'lib/tag.js' }) | ||
bundle.write({ format: 'cjs', file: 'tag.js' }) | ||
}) | ||
@@ -81,0 +81,0 @@ .catch(error => { |
@@ -5,4 +5,4 @@ 'use strict'; | ||
var riot = _interopDefault(require('riot')); | ||
var route = _interopDefault(require('riot-route')); | ||
var riot = _interopDefault(require('riot')); | ||
@@ -9,0 +9,0 @@ riot.tag2('router', '<yield></yield>', '', '', function(opts) { |
module.exports = function(config) { | ||
var browsers, | ||
customLaunchers = [] | ||
let browsers | ||
let customLaunchers = { | ||
ChromeHeadlessNoSandbox: { | ||
base: 'ChromeHeadless', | ||
flags: ['--no-sandbox'], | ||
} | ||
} | ||
if (process.env.BROWSERSTACK) { | ||
@@ -11,3 +17,3 @@ customLaunchers = require('./browsers') | ||
} else | ||
browsers = ['Electron'] | ||
browsers = ['ChromeHeadlessNoSandbox'] | ||
@@ -17,10 +23,2 @@ config.set({ | ||
frameworks: ['mocha', 'riot'], | ||
plugins: [ | ||
'karma-mocha', | ||
'karma-mocha-reporter', | ||
'karma-coverage', | ||
'karma-browserstack-launcher', | ||
'karma-electron', | ||
'karma-riot' | ||
], | ||
files: [ | ||
@@ -27,0 +25,0 @@ '../node_modules/expect.js/index.js', |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19
140895
41
3507