diff --git a/bower.json b/bower.json index ffa4c8c..24423f4 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "backbone.base-router", - "version": "0.2.0", + "version": "0.3.0", "homepage": "https://github.com/jmeas/backbone.base-router", "authors": [ "Jmeas " diff --git a/dist/backbone.base-router.js b/dist/backbone.base-router.js index 124bd84..760804b 100644 --- a/dist/backbone.base-router.js +++ b/dist/backbone.base-router.js @@ -1,4 +1,4 @@ -// Backbone.BaseRouter v0.2.0 +// Backbone.BaseRouter v0.3.0 (function(root, factory) { if (typeof define === 'function' && define.amd) { define(['backbone', 'underscore'], function(Backbone, _) { @@ -30,9 +30,6 @@ Backbone.BaseRouter = Backbone.Router.extend({ - // The instance of history that this Router uses - history: Backbone.history, - // The single point of entry. This is called whenever a // route is matched. The routeData argument contains lots of // useful information. @@ -54,7 +51,7 @@ // Register a callback with history var router = this; - this.history.route(route, function(fragment, navOptions) { + Backbone.history.route(route, function(fragment, navOptions) { var routeParams = router._extractParameters(route, fragment); var queryString = routeParams.pop(); diff --git a/dist/backbone.base-router.min.js b/dist/backbone.base-router.min.js index 270af96..909ac7d 100644 --- a/dist/backbone.base-router.min.js +++ b/dist/backbone.base-router.min.js @@ -1,4 +1,4 @@ -// Backbone.BaseRouter v0.2.0 +// Backbone.BaseRouter v0.3.0 -!function(a,b){if("function"==typeof define&&define.amd)define(["backbone","underscore"],function(a,c){return b(a,c)});else if("undefined"!=typeof exports){var c=require("backbone"),d=require("underscore");module.exports=b(c,d)}else b(a.Backbone,a._)}(this,function(a,b){"use strict";var c=/\((.*?)\)/g,d=/(\(\?)?:\w+/g,e=/\*\w+/g,f=/[\-{}\[\]+?.,\\\^$|#\s]/g;return a.BaseRouter=a.Router.extend({history:a.history,onNavigate:function(){},route:function(a,c){var d=b.isRegExp(a)?a:this._routeToRegExp(a),e={route:d,router:this,linked:c};b.isRegExp(a)||(e.originalRoute=a);var f=this;return this.history.route(d,function(a,b){var c=f._extractParameters(d,a),g=c.pop();b&&(e.navOptions=b),e.query=f._getQueryParameters(g),e.params=f._getNamedParams(d,c),e.uriFragment=a,f.onNavigate(e)}),this},_routeToRegExp:function(a){this.routeParams=this.routeParams||{};var b=[],g=a.replace(f,"\\$&").replace(c,"(?:$1)?").replace(d,function(a,c){return b.push(a.substr(1)),c?a:"([^/?]+)"}).replace(e,"([^?]*?)"),h="^"+g+"(?:\\?([\\s\\S]*))?$";return this.routeParams[h]=b,new RegExp(h)},_getQueryParameters:function(a){if(!a)return{};for(var b,c=/\+/g,d=/([^&=]+)=?([^&]*)/g,e=function(a){return decodeURIComponent(a.replace(c," "))},f=a,g={};b=d.exec(f);)g[e(b[1])]=e(b[2]);return g},_getNamedParams:function(a,c){if(0===c.length)return{};var d=a.toString();d=d.substr(1,d.length-2);var e=this.routeParams[d],f={};return b.each(e,function(a,b){f[a]=c[b]}),f}}),a.BaseRouter}); +!function(a,b){if("function"==typeof define&&define.amd)define(["backbone","underscore"],function(a,c){return b(a,c)});else if("undefined"!=typeof exports){var c=require("backbone"),d=require("underscore");module.exports=b(c,d)}else b(a.Backbone,a._)}(this,function(a,b){"use strict";var c=/\((.*?)\)/g,d=/(\(\?)?:\w+/g,e=/\*\w+/g,f=/[\-{}\[\]+?.,\\\^$|#\s]/g;return a.BaseRouter=a.Router.extend({onNavigate:function(){},route:function(c,d){var e=b.isRegExp(c)?c:this._routeToRegExp(c),f={route:e,router:this,linked:d};b.isRegExp(c)||(f.originalRoute=c);var g=this;return a.history.route(e,function(a,b){var c=g._extractParameters(e,a),d=c.pop();b&&(f.navOptions=b),f.query=g._getQueryParameters(d),f.params=g._getNamedParams(e,c),f.uriFragment=a,g.onNavigate(f)}),this},_routeToRegExp:function(a){this.routeParams=this.routeParams||{};var b=[],g=a.replace(f,"\\$&").replace(c,"(?:$1)?").replace(d,function(a,c){return b.push(a.substr(1)),c?a:"([^/?]+)"}).replace(e,"([^?]*?)"),h="^"+g+"(?:\\?([\\s\\S]*))?$";return this.routeParams[h]=b,new RegExp(h)},_getQueryParameters:function(a){if(!a)return{};for(var b,c=/\+/g,d=/([^&=]+)=?([^&]*)/g,e=function(a){return decodeURIComponent(a.replace(c," "))},f=a,g={};b=d.exec(f);)g[e(b[1])]=e(b[2]);return g},_getNamedParams:function(a,c){if(0===c.length)return{};var d=a.toString();d=d.substr(1,d.length-2);var e=this.routeParams[d],f={};return b.each(e,function(a,b){f[a]=c[b]}),f}}),a.BaseRouter}); //# sourceMappingURL=backbone.base-router.min.js.map \ No newline at end of file diff --git a/dist/backbone.base-router.min.js.map b/dist/backbone.base-router.min.js.map index c2f45f1..9f9b6f4 100644 --- a/dist/backbone.base-router.min.js.map +++ b/dist/backbone.base-router.min.js.map @@ -1 +1 @@ -{"version":3,"file":"backbone.base-router.min.js","sources":["backbone.base-router.js"],"names":["root","factory","define","amd","Backbone","_","exports","require","module","this","optionalParam","namedParam","splatParam","escapeRegExp","BaseRouter","Router","extend","history","onNavigate","route","origRoute","linked","isRegExp","_routeToRegExp","routeData","router","originalRoute","fragment","navOptions","routeParams","_extractParameters","queryString","pop","query","_getQueryParameters","params","_getNamedParams","uriFragment","namedParams","newRoute","replace","match","optional","push","substr","regexStr","RegExp","pl","search","decode","s","decodeURIComponent","urlParams","exec","length","routeString","toString","routeArr","paramObj","each","arrVal","i"],"mappings":";;CACC,SAASA,EAAMC,GACd,GAAsB,kBAAXC,SAAyBA,OAAOC,IACzCD,QAAQ,WAAY,cAAe,SAASE,EAAUC,GACpD,MAAOJ,GAAQG,EAAUC,SAGxB,IAAuB,mBAAZC,SAAyB,CACvC,GAAIF,GAAWG,QAAQ,YACnBF,EAAIE,QAAQ,aAChBC,QAAOF,QAAUL,EAAQG,EAAUC,OAGnCJ,GAAQD,EAAKI,SAAUJ,EAAKK,IAE9BI,KAAM,SAASL,EAAUC,GACzB,YASA,IAAIK,GAAgB,aAChBC,EAAgB,eAChBC,EAAgB,SAChBC,EAAgB,0BA6FpB,OA3FAT,GAASU,WAAaV,EAASW,OAAOC,QAGpCC,Q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EAAMqC,UACxBD,GAAcA,EAAYX,OAAO,EAAGW,EAAYD,OAAS,EACzD,IAAIG,GAAWhD,KAAKoB,YAAY0B,GAC5BG,IAIJ,OAHArD,GAAEsD,KAAKF,EAAU,SAASG,EAAQC,GAChCH,EAASE,GAAU/B,EAAYgC,KAE1BH,KAKJtD,EAASU"} \ No newline at end of file +{"version":3,"file":"backbone.base-router.min.js","sources":["backbone.base-router.js"],"names":["root","factory","define","amd","Backbone","_","exports","require","module","this","optionalParam","namedParam","splatParam","escapeRegExp","BaseRouter","Router","extend","onNavigate","route","origRoute","linked","isRegExp","_routeToRegExp","routeData","router","originalRoute","history","fragment","navOptions","routeParams","_extractParameters","queryString","pop","query","_getQueryParameters","params","_getNamedParams","uriFragment","namedParams","newRoute","replace","match","optional","push","substr","regexStr","RegExp","pl","search","decode","s","decodeURIComponent","urlParams","exec","length","routeString","toString","routeArr","paramObj","each","arrVal","i"],"mappings":";;CACC,SAASA,EAAMC,GACd,GAAsB,kBAAXC,SAAyBA,OAAOC,IACzCD,QAAQ,WAAY,cAAe,SAASE,EAAUC,GACpD,MAAOJ,GAAQG,EAAUC,SAGxB,IAAuB,mBAAZC,SAAyB,CACvC,GAAIF,GAAWG,QAAQ,YACnBF,EAAIE,QAAQ,aAChBC,QAAOF,QAAUL,EAAQG,EAAUC,OAGnCJ,GAAQD,EAAKI,SAAUJ,EAAKK,IAE9BI,KAAM,SAASL,EAAUC,GACzB,YASA,IAAIK,GAAgB,aAChBC,EAAgB,eAChBC,EAAgB,SAChBC,EAAgB,0BA0FpB,OAxFAT,GAASU,WAAaV,EAASW,OAAOC,QAKpCC,WAAY,aAEZC,MAAO,SAASC,EAAWC,GACzB,GAAIF,GAAQb,EAAEgB,SAASF,GAAaA,EAAYV,KAAKa,eAAeH,GAIhEI,GACFL,MAAOA,EACPM,OAAQf,KACRW,OAAQA,EAILf,GAAEgB,SAASF,KAAcI,EAAUE,cAAgBN,EAGxD,IAAIK,GAASf,IAcb,OAbAL,GAAS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- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "backbone.base-router", - "version": "0.2.0", + "version": "0.3.0", "description": "A better starting point for a new Backbone Router.", "main": "dist/backbone.base-router.js", "directories": {