diff --git a/bower.json b/bower.json index ceeab80..af24d8b 100644 --- a/bower.json +++ b/bower.json @@ -3,7 +3,7 @@ "description": "Extends the Backbone.Router to make it easier to construct a large number of routes for your app.", "homepage": "https://marionettejs.com/", "main": "./lib/marionette.approuter.js", - "version": "0.1.0", + "version": "1.0.0", "license": "MIT", "keywords": [ "backbone", diff --git a/lib/marionette.approuter.esm.js b/lib/marionette.approuter.esm.js index 86ae6b0..2516c98 100644 --- a/lib/marionette.approuter.esm.js +++ b/lib/marionette.approuter.esm.js @@ -2,9 +2,9 @@ * @license * MarionetteJS (Marionette.AppRouter) * ---------------------------------- -* v0.1.0 +* v1.0.0 * -* Copyright (c)2017 Derick Bailey, Muted Solutions, LLC. +* Copyright (c)2018 Derick Bailey, Muted Solutions, LLC. * Distributed under MIT license * * http://marionettejs.com @@ -13,7 +13,7 @@ import Backbone from 'backbone'; import _ from 'underscore'; -import Marionette from 'backbone.marionette'; +import Marionette, { MnObject } from 'backbone.marionette'; // App Router // ---------- @@ -107,8 +107,9 @@ var AppRouter = Backbone.Router.extend({ } }); -_.extend(AppRouter.prototype, _.pick(Marionette.Object.prototype, ObjectAPI)); +_.extend(AppRouter.prototype, _.pick(MnObject.prototype, ObjectAPI)); +// For Backwards compatibility Marionette.AppRouter = AppRouter; export default AppRouter; diff --git a/lib/marionette.approuter.esm.js.map b/lib/marionette.approuter.esm.js.map index cf7db55..853af96 100644 --- a/lib/marionette.approuter.esm.js.map +++ b/lib/marionette.approuter.esm.js.map @@ -1 +1 @@ -{"version":3,"file":"marionette.approuter.esm.js","sources":["src/marionette.approuter.js"],"sourcesContent":["// App Router\n// ----------\n\n// Reduce the boilerplate code of handling route events\n// and then calling a single method on another object,\n// called a controller.\n// Have your routers configured to call the method on\n// your controller, directly.\n//\n// Configure an AppRouter with `appRoutes`.\n//\n// App routers can only take one `controller` object.\n// It is recommended that you divide your controller\n// objects in to smaller pieces of related functionality\n// and have multiple routers / controllers, instead of\n// just one giant router and controller.\n//\n// You can also add standard routes to an AppRouter.\n\nimport Backbone from 'backbone';\nimport _ from 'underscore';\nimport Marionette from 'backbone.marionette';\n\n// API borrowed from Marionette.Object\nconst ObjectAPI = [\n 'triggerMethod',\n 'normalizeMethods',\n '_setOptions',\n 'mergeOptions',\n 'getOption',\n 'bindEvents',\n 'unbindEvents'\n];\n\nconst ClassOptions = [\n 'appRoutes',\n 'controller'\n];\n\nconst AppRouter = Backbone.Router.extend({\n\n constructor(options) {\n this._setOptions(options);\n\n this.mergeOptions(options, ClassOptions);\n\n Backbone.Router.apply(this, arguments);\n\n const appRoutes = this.appRoutes;\n const controller = this._getController();\n this.processAppRoutes(controller, appRoutes);\n this.on('route', this._processOnRoute, this);\n },\n\n // Similar to route method on a Backbone Router but\n // method is called on the controller\n appRoute(route, methodName) {\n const controller = this._getController();\n this._addAppRoute(controller, route, methodName);\n return this;\n },\n\n // process the route event and trigger the onRoute\n // method call, if it exists\n _processOnRoute(routeName, routeArgs) {\n // make sure an onRoute before trying to call it\n if (_.isFunction(this.onRoute)) {\n // find the path that matches the current route\n const routePath = _.invert(this.appRoutes)[routeName];\n this.onRoute(routeName, routePath, routeArgs);\n }\n },\n\n // Internal method to process the `appRoutes` for the\n // router, and turn them in to routes that trigger the\n // specified method on the specified `controller`.\n processAppRoutes(controller, appRoutes) {\n if (!appRoutes) { return this; }\n\n const routeNames = _.keys(appRoutes).reverse(); // Backbone requires reverted order of routes\n\n _.each(routeNames, route => {\n this._addAppRoute(controller, route, appRoutes[route]);\n });\n\n return this;\n },\n\n _getController() {\n return this.controller;\n },\n\n _addAppRoute(controller, route, methodName) {\n const method = controller[methodName];\n\n if (!method) {\n throw new Error(`Method \"${methodName}\" was not found on the controller`);\n }\n\n this.route(route, methodName, _.bind(method, controller));\n }\n});\n\n_.extend(AppRouter.prototype, _.pick(Marionette.Object.prototype, ObjectAPI));\n\nMarionette.AppRouter = AppRouter;\n\nexport default AppRouter;\n"],"names":["ObjectAPI","ClassOptions","AppRouter","Backbone","Router","extend","options","_setOptions","mergeOptions","apply","arguments","appRoutes","controller","_getController","processAppRoutes","on","_processOnRoute","route","methodName","_addAppRoute","routeName","routeArgs","_","isFunction","onRoute","routePath","invert","routeNames","keys","reverse","each","method","Error","bind","prototype","pick","Marionette","Object"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;AAmBA,AAIA;AACA,IAAMA,YAAY,CAChB,eADgB,EAEhB,kBAFgB,EAGhB,aAHgB,EAIhB,cAJgB,EAKhB,WALgB,EAMhB,YANgB,EAOhB,cAPgB,CAAlB;;AAUA,IAAMC,eAAe,CACnB,WADmB,EAEnB,YAFmB,CAArB;;AAKA,IAAMC,YAAYC,SAASC,MAAT,CAAgBC,MAAhB,CAAuB;aAAA,uBAE3BC,OAF2B,EAElB;SACdC,WAAL,CAAiBD,OAAjB;;SAEKE,YAAL,CAAkBF,OAAlB,EAA2BL,YAA3B;;aAESG,MAAT,CAAgBK,KAAhB,CAAsB,IAAtB,EAA4BC,SAA5B;;QAEMC,YAAY,KAAKA,SAAvB;QACMC,aAAa,KAAKC,cAAL,EAAnB;SACKC,gBAAL,CAAsBF,UAAtB,EAAkCD,SAAlC;SACKI,EAAL,CAAQ,OAAR,EAAiB,KAAKC,eAAtB,EAAuC,IAAvC;GAZqC;;;;;UAAA,oBAiB9BC,KAjB8B,EAiBvBC,UAjBuB,EAiBX;QACpBN,aAAa,KAAKC,cAAL,EAAnB;SACKM,YAAL,CAAkBP,UAAlB,EAA8BK,KAA9B,EAAqCC,UAArC;WACO,IAAP;GApBqC;;;;;iBAAA,2BAyBvBE,SAzBuB,EAyBZC,SAzBY,EAyBD;;QAEhCC,EAAEC,UAAF,CAAa,KAAKC,OAAlB,CAAJ,EAAgC;;UAExBC,YAAYH,EAAEI,MAAF,CAAS,KAAKf,SAAd,EAAyBS,SAAzB,CAAlB;WACKI,OAAL,CAAaJ,SAAb,EAAwBK,SAAxB,EAAmCJ,SAAnC;;GA9BmC;;;;;;kBAAA,4BAqCtBT,UArCsB,EAqCVD,SArCU,EAqCC;;;QAClC,CAACA,SAAL,EAAgB;aAAS,IAAP;;;QAEZgB,aAAaL,EAAEM,IAAF,CAAOjB,SAAP,EAAkBkB,OAAlB,EAAnB,CAHsC;;MAKpCC,IAAF,CAAOH,UAAP,EAAmB,iBAAS;YACrBR,YAAL,CAAkBP,UAAlB,EAA8BK,KAA9B,EAAqCN,UAAUM,KAAV,CAArC;KADF;;WAIO,IAAP;GA9CqC;gBAAA,4BAiDtB;WACR,KAAKL,UAAZ;GAlDqC;cAAA,wBAqD1BA,UArD0B,EAqDdK,KArDc,EAqDPC,UArDO,EAqDK;QACpCa,SAASnB,WAAWM,UAAX,CAAf;;QAEI,CAACa,MAAL,EAAa;YACL,IAAIC,KAAJ,cAAqBd,UAArB,uCAAN;;;SAGGD,KAAL,CAAWA,KAAX,EAAkBC,UAAlB,EAA8BI,EAAEW,IAAF,CAAOF,MAAP,EAAenB,UAAf,CAA9B;;CA5Dc,CAAlB;;AAgEAU,EAAEjB,MAAF,CAASH,UAAUgC,SAAnB,EAA8BZ,EAAEa,IAAF,CAAOC,WAAWC,MAAX,CAAkBH,SAAzB,EAAoClC,SAApC,CAA9B;;AAEAoC,WAAWlC,SAAX,GAAuBA,SAAvB;;;;"} \ No newline at end of file +{"version":3,"file":"marionette.approuter.esm.js","sources":["src/marionette.approuter.js"],"sourcesContent":["// App Router\n// ----------\n\n// Reduce the boilerplate code of handling route events\n// and then calling a single method on another object,\n// called a controller.\n// Have your routers configured to call the method on\n// your controller, directly.\n//\n// Configure an AppRouter with `appRoutes`.\n//\n// App routers can only take one `controller` object.\n// It is recommended that you divide your controller\n// objects in to smaller pieces of related functionality\n// and have multiple routers / controllers, instead of\n// just one giant router and controller.\n//\n// You can also add standard routes to an AppRouter.\n\nimport Backbone from 'backbone';\nimport _ from 'underscore';\nimport Marionette, { MnObject } from 'backbone.marionette';\n\n// API borrowed from Marionette.Object\nconst ObjectAPI = [\n 'triggerMethod',\n 'normalizeMethods',\n '_setOptions',\n 'mergeOptions',\n 'getOption',\n 'bindEvents',\n 'unbindEvents'\n];\n\nconst ClassOptions = [\n 'appRoutes',\n 'controller'\n];\n\nconst AppRouter = Backbone.Router.extend({\n\n constructor(options) {\n this._setOptions(options);\n\n this.mergeOptions(options, ClassOptions);\n\n Backbone.Router.apply(this, arguments);\n\n const appRoutes = this.appRoutes;\n const controller = this._getController();\n this.processAppRoutes(controller, appRoutes);\n this.on('route', this._processOnRoute, this);\n },\n\n // Similar to route method on a Backbone Router but\n // method is called on the controller\n appRoute(route, methodName) {\n const controller = this._getController();\n this._addAppRoute(controller, route, methodName);\n return this;\n },\n\n // process the route event and trigger the onRoute\n // method call, if it exists\n _processOnRoute(routeName, routeArgs) {\n // make sure an onRoute before trying to call it\n if (_.isFunction(this.onRoute)) {\n // find the path that matches the current route\n const routePath = _.invert(this.appRoutes)[routeName];\n this.onRoute(routeName, routePath, routeArgs);\n }\n },\n\n // Internal method to process the `appRoutes` for the\n // router, and turn them in to routes that trigger the\n // specified method on the specified `controller`.\n processAppRoutes(controller, appRoutes) {\n if (!appRoutes) { return this; }\n\n const routeNames = _.keys(appRoutes).reverse(); // Backbone requires reverted order of routes\n\n _.each(routeNames, route => {\n this._addAppRoute(controller, route, appRoutes[route]);\n });\n\n return this;\n },\n\n _getController() {\n return this.controller;\n },\n\n _addAppRoute(controller, route, methodName) {\n const method = controller[methodName];\n\n if (!method) {\n throw new Error(`Method \"${methodName}\" was not found on the controller`);\n }\n\n this.route(route, methodName, _.bind(method, controller));\n }\n});\n\n_.extend(AppRouter.prototype, _.pick(MnObject.prototype, ObjectAPI));\n\n// For Backwards compatibility\nMarionette.AppRouter = AppRouter;\n\nexport default AppRouter;\n"],"names":["ObjectAPI","ClassOptions","AppRouter","Backbone","Router","extend","options","_setOptions","mergeOptions","apply","arguments","appRoutes","controller","_getController","processAppRoutes","on","_processOnRoute","route","methodName","_addAppRoute","routeName","routeArgs","_","isFunction","onRoute","routePath","invert","routeNames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,EAAkBkB,OAAlB,EAAnB,CAHsC;;MAKpCC,IAAF,CAAOH,UAAP,EAAmB,iBAAS;YACrBR,YAAL,CAAkBP,UAAlB,EAA8BK,KAA9B,EAAqCN,UAAUM,KAAV,CAArC;KADF;;WAIO,IAAP;GA9CqC;gBAAA,4BAiDtB;WACR,KAAKL,UAAZ;GAlDqC;cAAA,wBAqD1BA,UArD0B,EAqDdK,KArDc,EAqDPC,UArDO,EAqDK;QACpCa,SAASnB,WAAWM,UAAX,CAAf;;QAEI,CAACa,MAAL,EAAa;YACL,IAAIC,KAAJ,cAAqBd,UAArB,uCAAN;;;SAGGD,KAAL,CAAWA,KAAX,EAAkBC,UAAlB,EAA8BI,EAAEW,IAAF,CAAOF,MAAP,EAAenB,UAAf,CAA9B;;CA5Dc,CAAlB;;AAgEAU,EAAEjB,MAAF,CAASH,UAAUgC,SAAnB,EAA8BZ,EAAEa,IAAF,CAAOC,SAASF,SAAhB,EAA2BlC,SAA3B,CAA9B;;;AAGAqC,WAAWnC,SAAX,GAAuBA,SAAvB;;;;"} \ No newline at end of file diff --git a/lib/marionette.approuter.js b/lib/marionette.approuter.js index bd58a3d..250d5e3 100644 --- a/lib/marionette.approuter.js +++ b/lib/marionette.approuter.js @@ -2,9 +2,9 @@ * @license * MarionetteJS (Marionette.AppRouter) * ---------------------------------- -* v0.1.0 +* v1.0.0 * -* Copyright (c)2017 Derick Bailey, Muted Solutions, LLC. +* Copyright (c)2018 Derick Bailey, Muted Solutions, LLC. * Distributed under MIT license * * http://marionettejs.com @@ -19,7 +19,7 @@ Backbone = Backbone && Backbone.hasOwnProperty('default') ? Backbone['default'] : Backbone; _ = _ && _.hasOwnProperty('default') ? _['default'] : _; -Marionette = Marionette && Marionette.hasOwnProperty('default') ? Marionette['default'] : Marionette; +var Marionette__default = 'default' in Marionette ? Marionette['default'] : Marionette; // App Router // ---------- @@ -113,9 +113,10 @@ var AppRouter = Backbone.Router.extend({ } }); -_.extend(AppRouter.prototype, _.pick(Marionette.Object.prototype, ObjectAPI)); +_.extend(AppRouter.prototype, _.pick(Marionette.MnObject.prototype, ObjectAPI)); -Marionette.AppRouter = AppRouter; +// For Backwards compatibility +Marionette__default.AppRouter = AppRouter; return AppRouter; diff --git a/lib/marionette.approuter.js.map b/lib/marionette.approuter.js.map index 57439eb..84173fb 100644 --- a/lib/marionette.approuter.js.map +++ b/lib/marionette.approuter.js.map @@ -1 +1 @@ -{"version":3,"file":"marionette.approuter.js","sources":["src/marionette.approuter.js"],"sourcesContent":["// App Router\n// ----------\n\n// Reduce the boilerplate code of handling route events\n// and then calling a single method on another object,\n// called a controller.\n// Have your routers configured to call the method on\n// your controller, directly.\n//\n// Configure an AppRouter with `appRoutes`.\n//\n// App routers can only take one `controller` object.\n// It is recommended that you divide your controller\n// objects in to smaller pieces of related functionality\n// and have multiple routers / controllers, instead of\n// just one giant router and controller.\n//\n// You can also add standard routes to an AppRouter.\n\nimport Backbone from 'backbone';\nimport _ from 'underscore';\nimport Marionette from 'backbone.marionette';\n\n// API borrowed from Marionette.Object\nconst ObjectAPI = [\n 'triggerMethod',\n 'normalizeMethods',\n '_setOptions',\n 'mergeOptions',\n 'getOption',\n 'bindEvents',\n 'unbindEvents'\n];\n\nconst ClassOptions = [\n 'appRoutes',\n 'controller'\n];\n\nconst AppRouter = Backbone.Router.extend({\n\n constructor(options) {\n this._setOptions(options);\n\n this.mergeOptions(options, ClassOptions);\n\n Backbone.Router.apply(this, arguments);\n\n const appRoutes = this.appRoutes;\n const controller = this._getController();\n this.processAppRoutes(controller, appRoutes);\n this.on('route', this._processOnRoute, this);\n },\n\n // Similar to route method on a Backbone Router but\n // method is called on the controller\n appRoute(route, methodName) {\n const controller = this._getController();\n this._addAppRoute(controller, route, methodName);\n return this;\n },\n\n // process the route event and trigger the onRoute\n // method call, if it exists\n _processOnRoute(routeName, routeArgs) {\n // make sure an onRoute before trying to call it\n if (_.isFunction(this.onRoute)) {\n // find the path that matches the current route\n const routePath = _.invert(this.appRoutes)[routeName];\n this.onRoute(routeName, routePath, routeArgs);\n }\n },\n\n // Internal method to process the `appRoutes` for the\n // router, and turn them in to routes that trigger the\n // specified method on the specified `controller`.\n processAppRoutes(controller, appRoutes) {\n if (!appRoutes) { return this; }\n\n const routeNames = _.keys(appRoutes).reverse(); // Backbone requires reverted order of routes\n\n _.each(routeNames, route => {\n this._addAppRoute(controller, route, appRoutes[route]);\n });\n\n return this;\n },\n\n _getController() {\n return this.controller;\n },\n\n _addAppRoute(controller, route, methodName) {\n const method = controller[methodName];\n\n if (!method) {\n throw new Error(`Method \"${methodName}\" was not found on the controller`);\n }\n\n this.route(route, methodName, _.bind(method, controller));\n }\n});\n\n_.extend(AppRouter.prototype, _.pick(Marionette.Object.prototype, ObjectAPI));\n\nMarionette.AppRouter = AppRouter;\n\nexport default AppRouter;\n"],"names":["ObjectAPI","ClassOptions","AppRouter","Backbone","Router","extend","options","_setOptions","mergeOptions","apply","arguments","appRoutes","controller","_getController","processAppRoutes","on","_processOnRoute","route","methodName","_addAppRoute","routeName","routeArgs","_","isFunction","onRoute","routePath","invert","routeNames","keys","reverse","each","method","Error","bind","prototype","pick","Marionette","Object"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;AAmBA,AAIA;AACA,IAAMA,YAAY,CAChB,eADgB,EAEhB,kBAFgB,EAGhB,aAHgB,EAIhB,cAJgB,EAKhB,WALgB,EAMhB,YANgB,EAOhB,cAPgB,CAAlB;;AAUA,IAAMC,eAAe,CACnB,WADmB,EAEnB,YAFmB,CAArB;;AAKA,IAAMC,YAAYC,SAASC,MAAT,CAAgBC,MAAhB,CAAuB;aAAA,uBAE3BC,OAF2B,EAElB;SACdC,WAAL,CAAiBD,OAAjB;;SAEKE,YAAL,CAAkBF,OAAlB,EAA2BL,YAA3B;;aAESG,MAAT,CAAgBK,KAAhB,CAAsB,IAAtB,EAA4BC,SAA5B;;QAEMC,YAAY,KAAKA,SAAvB;QACMC,aAAa,KAAKC,cA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Ea,IAAF,CAAOC,WAAWC,MAAX,CAAkBH,SAAzB,EAAoClC,SAApC,CAA9B;;AAEAoC,WAAWlC,SAAX,GAAuBA,SAAvB;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"marionette.approuter.js","sources":["src/marionette.approuter.js"],"sourcesContent":["// App Router\n// ----------\n\n// Reduce the boilerplate code of handling route events\n// and then calling a single method on another object,\n// called a controller.\n// Have your routers configured to call the method on\n// your controller, directly.\n//\n// Configure an AppRouter with `appRoutes`.\n//\n// App routers can only take one `controller` object.\n// It is recommended that you divide your controller\n// objects in to smaller pieces of related functionality\n// and have multiple routers / controllers, instead of\n// just one giant router and controller.\n//\n// You can also add standard routes to an AppRouter.\n\nimport Backbone from 'backbone';\nimport _ from 'underscore';\nimport Marionette, { MnObject } from 'backbone.marionette';\n\n// API borrowed from Marionette.Object\nconst ObjectAPI = [\n 'triggerMethod',\n 'normalizeMethods',\n '_setOptions',\n 'mergeOptions',\n 'getOption',\n 'bindEvents',\n 'unbindEvents'\n];\n\nconst ClassOptions = [\n 'appRoutes',\n 'controller'\n];\n\nconst AppRouter = Backbone.Router.extend({\n\n constructor(options) {\n this._setOptions(options);\n\n this.mergeOptions(options, ClassOptions);\n\n Backbone.Router.apply(this, arguments);\n\n const appRoutes = this.appRoutes;\n const controller = this._getController();\n this.processAppRoutes(controller, appRoutes);\n this.on('route', this._processOnRoute, this);\n },\n\n // Similar to route method on a Backbone Router but\n // method is called on the controller\n appRoute(route, methodName) {\n const controller = this._getController();\n this._addAppRoute(controller, route, methodName);\n return this;\n },\n\n // process the route event and trigger the onRoute\n // method call, if it exists\n _processOnRoute(routeName, routeArgs) {\n // make sure an onRoute before trying to call it\n if (_.isFunction(this.onRoute)) {\n // find the path that matches the current route\n const routePath = _.invert(this.appRoutes)[routeName];\n this.onRoute(routeName, routePath, routeArgs);\n }\n },\n\n // Internal method to process the `appRoutes` for the\n // router, and turn them in to routes that trigger the\n // specified method on the specified `controller`.\n processAppRoutes(controller, appRoutes) {\n if (!appRoutes) { return this; }\n\n const routeNames = _.keys(appRoutes).reverse(); // Backbone requires reverted order of routes\n\n _.each(routeNames, route => {\n this._addAppRoute(controller, route, appRoutes[route]);\n });\n\n return this;\n },\n\n _getController() {\n return this.controller;\n },\n\n _addAppRoute(controller, route, methodName) {\n const method = controller[methodName];\n\n if (!method) {\n throw new Error(`Method \"${methodName}\" was not found on the controller`);\n }\n\n this.route(route, methodName, _.bind(method, controller));\n }\n});\n\n_.extend(AppRouter.prototype, _.pick(MnObject.prototype, ObjectAPI));\n\n// For Backwards compatibility\nMarionette.AppRouter = AppRouter;\n\nexport default AppRouter;\n"],"names":["ObjectAPI","ClassOptions","AppRouter","Backbone","Router","extend","options","_setOptions","mergeOptions","apply","arguments","appRoutes","controller","_getController","processAppRoutes","on","_processOnRoute","route","methodName","_addAppRoute","routeName","routeArgs","_","isFunction","onRoute","routePath","invert","routeNames","keys","reverse","each","method","Error","bind","prototype","pick","MnObject","Marionette"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;AAmBA,AAIA;AACA,IAAMA,YAAY,CAChB,eADgB,EAEhB,kBAFgB,EAGhB,aAHgB,EAIhB,cAJgB,EAKhB,WALgB,EAMhB,YANgB,EAOhB,cAPgB,CAAlB;;AAUA,IAAMC,eAAe,CACnB,WADmB,EAEnB,YAFmB,CAArB;;AAKA,IAAMC,YAAYC,SAASC,MAAT,CAAgBC,MAAhB,CAAuB;aAAA,uBAE3BC,OAF2B,EAElB;SACdC,WAAL,CAAiBD,OAAjB;;SAEKE,YAAL,CAAkBF,OAAlB,EAA2BL,YAA3B;;aAESG,MAAT,CAAgBK,KAAhB,CAAsB,IAAtB,EAA4BC,SAA5B;;QAEMC,YAAY,KAAKA,SAAvB;QACMC,aAAa,KAAKC,cAAL,EAAnB;SACKC,gBAAL,CAAsBF,UAAtB,EAAkCD,SAAlC;SACKI,EAAL,CAAQ,OAAR,EAAiB,KAAKC,eAAtB,EAAuC,I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No newline at end of file diff --git a/lib/marionette.approuter.min.js b/lib/marionette.approuter.min.js index c66da89..bd60dbd 100644 --- a/lib/marionette.approuter.min.js +++ b/lib/marionette.approuter.min.js @@ -2,12 +2,12 @@ * @license * MarionetteJS (Marionette.AppRouter) * ---------------------------------- -* v0.1.0 +* v1.0.0 * -* Copyright (c)2017 Derick Bailey, Muted Solutions, LLC. +* Copyright (c)2018 Derick Bailey, Muted Solutions, LLC. * Distributed under MIT license * * http://marionettejs.com */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("backbone"),require("underscore"),require("backbone.marionette")):"function"==typeof define&&define.amd?define(["backbone","underscore","backbone.marionette"],e):(t.Marionette=t.Marionette||{},t.Marionette.AppRouter=e(t.Backbone,t._,t.Backbone.Marionette))}(this,function(t,e,o){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t,e=e&&e.hasOwnProperty("default")?e.default:e,o=o&&o.hasOwnProperty("default")?o.default:o;var n=["triggerMethod","normalizeMethods","_setOptions","mergeOptions","getOption","bindEvents","unbindEvents"],r=["appRoutes","controller"],i=t.Router.extend({constructor:function(e){this._setOptions(e),this.mergeOptions(e,r),t.Router.apply(this,arguments);var o=this.appRoutes,n=this._getController();this.processAppRoutes(n,o),this.on("route",this._processOnRoute,this)},appRoute:function(t,e){var o=this._getController();return this._addAppRoute(o,t,e),this},_processOnRoute:function(t,o){if(e.isFunction(this.onRoute)){var n=e.invert(this.appRoutes)[t];this.onRoute(t,n,o)}},processAppRoutes:function(t,o){var n=this;if(!o)return this;var r=e.keys(o).reverse();return e.each(r,function(e){n._addAppRoute(t,e,o[e])}),this},_getController:function(){return this.controller},_addAppRoute:function(t,o,n){var r=t[n];if(!r)throw new Error('Method "'+n+'" was not found on the controller');this.route(o,n,e.bind(r,t))}});return e.extend(i.prototype,e.pick(o.Object.prototype,n)),o.AppRouter=i,i}); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("backbone"),require("underscore"),require("backbone.marionette")):"function"==typeof define&&define.amd?define(["backbone","underscore","backbone.marionette"],e):(t.Marionette=t.Marionette||{},t.Marionette.AppRouter=e(t.Backbone,t._,t.Backbone.Marionette))}(this,function(t,e,o){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t,e=e&&e.hasOwnProperty("default")?e.default:e;var n="default"in o?o.default:o,r=["triggerMethod","normalizeMethods","_setOptions","mergeOptions","getOption","bindEvents","unbindEvents"],i=["appRoutes","controller"],s=t.Router.extend({constructor:function(e){this._setOptions(e),this.mergeOptions(e,i),t.Router.apply(this,arguments);var o=this.appRoutes,n=this._getController();this.processAppRoutes(n,o),this.on("route",this._processOnRoute,this)},appRoute:function(t,e){var o=this._getController();return this._addAppRoute(o,t,e),this},_processOnRoute:function(t,o){if(e.isFunction(this.onRoute)){var n=e.invert(this.appRoutes)[t];this.onRoute(t,n,o)}},processAppRoutes:function(t,o){var n=this;if(!o)return this;var r=e.keys(o).reverse();return e.each(r,function(e){n._addAppRoute(t,e,o[e])}),this},_getController:function(){return this.controller},_addAppRoute:function(t,o,n){var r=t[n];if(!r)throw new Error('Method "'+n+'" was not found on the controller');this.route(o,n,e.bind(r,t))}});return e.extend(s.prototype,e.pick(o.MnObject.prototype,r)),n.AppRouter=s,s}); //# sourceMappingURL=marionette.approuter.min.js.map \ No newline at end of file diff --git a/lib/marionette.approuter.min.js.map b/lib/marionette.approuter.min.js.map index 1d4cd39..859a8b8 100644 --- a/lib/marionette.approuter.min.js.map +++ b/lib/marionette.approuter.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["src/marionette.approuter.js"],"names":["ObjectAPI","ClassOptions","AppRouter","Backbone","Router","extend","options","_setOptions","mergeOptions","apply","this","arguments","appRoutes","controller","_getController","processAppRoutes","on","_processOnRoute","route","methodName","_addAppRoute","routeName","routeArgs","_","isFunction","onRoute","routePath","invert","routeNames","keys","reverse","each","method","Error","bind","prototype","pick","Marionette","Object"],"mappings":";;;;;;;;;;;wgBAwBA,IAAMA,GACJ,gBACA,mBACA,cACA,eACA,YACA,aACA,gBAGIC,GACJ,YACA,cAGIC,EAAYC,EAASC,OAAOC,oBAAO,SAE3BC,QACLC,YAAYD,QAEZE,aAAaF,EAASL,KAElBG,OAAOK,MAAMC,KAAMC,eAEtBC,EAAYF,KAAKE,UACjBC,EAAaH,KAAKI,sBACnBC,iBAAiBF,EAAYD,QAC7BI,GAAG,QAASN,KAAKO,gBAAiBP,gBAZF,SAiB9BQ,EAAOC,OACRN,EAAaH,KAAKI,6BACnBM,aAAaP,EAAYK,EAAOC,GAC9BT,sBApB8B,SAyBvBW,EAAWC,MAErBC,EAAEC,WAAWd,KAAKe,SAAU,KAExBC,EAAYH,EAAEI,OAAOjB,KAAKE,WAAWS,QACtCI,QAAQJ,EAAWK,EAAWJ,sBA9BA,SAqCtBT,EAAYD,kBACtBA,SAAoBF,SAEnBkB,EAAaL,EAAEM,KAAKjB,GAAWkB,mBAEnCC,KAAKH,EAAY,SAAAV,KACZE,aAAaP,EAAYK,EAAON,EAAUM,MAG1CR,qBA9C8B,kBAkD9BA,KAAKG,yBAlDyB,SAqD1BA,EAAYK,EAAOC,OACxBa,EAASnB,EAAWM,OAErBa,QACG,IAAIC,MAAJ,WAAqBd,EAArB,0CAGHD,MAAMA,EAAOC,EAAYI,EAAEW,KAAKF,EAAQnB,cAIjDU,EAAElB,OAAOH,EAAUiC,UAAWZ,EAAEa,KAAKC,EAAWC,OAAOH,UAAWnC,IAElEqC,EAAWnC,UAAYA","file":"marionette.approuter.min.js","sourcesContent":["// App Router\n// ----------\n\n// Reduce the boilerplate code of handling route events\n// and then calling a single method on another object,\n// called a controller.\n// Have your routers configured to call the method on\n// your controller, directly.\n//\n// Configure an AppRouter with `appRoutes`.\n//\n// App routers can only take one `controller` object.\n// It is recommended that you divide your controller\n// objects in to smaller pieces of related functionality\n// and have multiple routers / controllers, instead of\n// just one giant router and controller.\n//\n// You can also add standard routes to an AppRouter.\n\nimport Backbone from 'backbone';\nimport _ from 'underscore';\nimport Marionette from 'backbone.marionette';\n\n// API borrowed from Marionette.Object\nconst ObjectAPI = [\n 'triggerMethod',\n 'normalizeMethods',\n '_setOptions',\n 'mergeOptions',\n 'getOption',\n 'bindEvents',\n 'unbindEvents'\n];\n\nconst ClassOptions = [\n 'appRoutes',\n 'controller'\n];\n\nconst AppRouter = Backbone.Router.extend({\n\n constructor(options) {\n this._setOptions(options);\n\n this.mergeOptions(options, ClassOptions);\n\n Backbone.Router.apply(this, arguments);\n\n const appRoutes = this.appRoutes;\n const controller = this._getController();\n this.processAppRoutes(controller, appRoutes);\n this.on('route', this._processOnRoute, this);\n },\n\n // Similar to route method on a Backbone Router but\n // method is called on the controller\n appRoute(route, methodName) {\n const controller = this._getController();\n this._addAppRoute(controller, route, methodName);\n return this;\n },\n\n // process the route event and trigger the onRoute\n // method call, if it exists\n _processOnRoute(routeName, routeArgs) {\n // make sure an onRoute before trying to call it\n if (_.isFunction(this.onRoute)) {\n // find the path that matches the current route\n const routePath = _.invert(this.appRoutes)[routeName];\n this.onRoute(routeName, routePath, routeArgs);\n }\n },\n\n // Internal method to process the `appRoutes` for the\n // router, and turn them in to routes that trigger the\n // specified method on the specified `controller`.\n processAppRoutes(controller, appRoutes) {\n if (!appRoutes) { return this; }\n\n const routeNames = _.keys(appRoutes).reverse(); // Backbone requires reverted order of routes\n\n _.each(routeNames, route => {\n this._addAppRoute(controller, route, appRoutes[route]);\n });\n\n return this;\n },\n\n _getController() {\n return this.controller;\n },\n\n _addAppRoute(controller, route, methodName) {\n const method = controller[methodName];\n\n if (!method) {\n throw new Error(`Method \"${methodName}\" was not found on the controller`);\n }\n\n this.route(route, methodName, _.bind(method, controller));\n }\n});\n\n_.extend(AppRouter.prototype, _.pick(Marionette.Object.prototype, ObjectAPI));\n\nMarionette.AppRouter = AppRouter;\n\nexport default AppRouter;\n"]} \ No newline at end of file +{"version":3,"sources":["src/marionette.approuter.js"],"names":["ObjectAPI","ClassOptions","AppRouter","Backbone","Router","extend","options","_setOptions","mergeOptions","apply","this","arguments","appRoutes","controller","_getController","processAppRoutes","on","_processOnRoute","route","methodName","_addAppRoute","routeName","routeArgs","_","isFunction","onRoute","routePath","invert","routeNames","keys","reverse","each","method","Error","bind","prototype","pick","MnObject","Marionette"],"mappings":";;;;;;;;;;;2fAwBMA,GACJ,gBACA,mBACA,cACA,eACA,YACA,aACA,gBAGIC,GACJ,YACA,cAGIC,EAAYC,EAASC,OAAOC,oBAAO,SAE3BC,QACLC,YAAYD,QAEZE,aAAaF,EAASL,KAElBG,OAAOK,MAAMC,KAAMC,eAEtBC,EAAYF,KAAKE,UACjBC,EAAaH,KAAKI,sBACnBC,iBAAiBF,EAAYD,QAC7BI,GAAG,QAASN,KAAKO,gBAAiBP,gBAZF,SAiB9BQ,EAAOC,OACRN,EAAaH,KAAKI,6BACnBM,aAAaP,EAAYK,EAAOC,GAC9BT,sBApB8B,SAyBvBW,EAAWC,MAErBC,EAAEC,WAAWd,KAAKe,SAAU,KAExBC,EAAYH,EAAEI,OAAOjB,KAAKE,WAAWS,QACtCI,QAAQJ,EAAWK,EAAWJ,sBA9BA,SAqCtBT,EAAYD,kBACtBA,SAAoBF,SAEnBkB,EAAaL,EAAEM,KAAKjB,GAAWkB,mBAEnCC,KAAKH,EAAY,SAAAV,KACZE,aAAaP,EAAYK,EAAON,EAAUM,MAG1CR,qBA9C8B,kBAkD9BA,KAAKG,yBAlDyB,SAqD1BA,EAAYK,EAAOC,OACxBa,EAASnB,EAAWM,OAErBa,QACG,IAAIC,MAAJ,WAAqBd,EAArB,0CAGHD,MAAMA,EAAOC,EAAYI,EAAEW,KAAKF,EAAQnB,cAIjDU,EAAElB,OAAOH,EAAUiC,UAAWZ,EAAEa,KAAKC,EAAAA,SAASF,UAAWnC,IAGzDsC,EAAWpC,UAAYA","file":"marionette.approuter.min.js","sourcesContent":["// App Router\n// ----------\n\n// Reduce the boilerplate code of handling route events\n// and then calling a single method on another object,\n// called a controller.\n// Have your routers configured to call the method on\n// your controller, directly.\n//\n// Configure an AppRouter with `appRoutes`.\n//\n// App routers can only take one `controller` object.\n// It is recommended that you divide your controller\n// objects in to smaller pieces of related functionality\n// and have multiple routers / controllers, instead of\n// just one giant router and controller.\n//\n// You can also add standard routes to an AppRouter.\n\nimport Backbone from 'backbone';\nimport _ from 'underscore';\nimport Marionette, { MnObject } from 'backbone.marionette';\n\n// API borrowed from Marionette.Object\nconst ObjectAPI = [\n 'triggerMethod',\n 'normalizeMethods',\n '_setOptions',\n 'mergeOptions',\n 'getOption',\n 'bindEvents',\n 'unbindEvents'\n];\n\nconst ClassOptions = [\n 'appRoutes',\n 'controller'\n];\n\nconst AppRouter = Backbone.Router.extend({\n\n constructor(options) {\n this._setOptions(options);\n\n this.mergeOptions(options, ClassOptions);\n\n Backbone.Router.apply(this, arguments);\n\n const appRoutes = this.appRoutes;\n const controller = this._getController();\n this.processAppRoutes(controller, appRoutes);\n this.on('route', this._processOnRoute, this);\n },\n\n // Similar to route method on a Backbone Router but\n // method is called on the controller\n appRoute(route, methodName) {\n const controller = this._getController();\n this._addAppRoute(controller, route, methodName);\n return this;\n },\n\n // process the route event and trigger the onRoute\n // method call, if it exists\n _processOnRoute(routeName, routeArgs) {\n // make sure an onRoute before trying to call it\n if (_.isFunction(this.onRoute)) {\n // find the path that matches the current route\n const routePath = _.invert(this.appRoutes)[routeName];\n this.onRoute(routeName, routePath, routeArgs);\n }\n },\n\n // Internal method to process the `appRoutes` for the\n // router, and turn them in to routes that trigger the\n // specified method on the specified `controller`.\n processAppRoutes(controller, appRoutes) {\n if (!appRoutes) { return this; }\n\n const routeNames = _.keys(appRoutes).reverse(); // Backbone requires reverted order of routes\n\n _.each(routeNames, route => {\n this._addAppRoute(controller, route, appRoutes[route]);\n });\n\n return this;\n },\n\n _getController() {\n return this.controller;\n },\n\n _addAppRoute(controller, route, methodName) {\n const method = controller[methodName];\n\n if (!method) {\n throw new Error(`Method \"${methodName}\" was not found on the controller`);\n }\n\n this.route(route, methodName, _.bind(method, controller));\n }\n});\n\n_.extend(AppRouter.prototype, _.pick(MnObject.prototype, ObjectAPI));\n\n// For Backwards compatibility\nMarionette.AppRouter = AppRouter;\n\nexport default AppRouter;\n"]} \ No newline at end of file diff --git a/package.json b/package.json index 53f9386..8b6bd00 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "marionette.approuter", "description": "Extends the Backbone.Router to make it easier to construct a large number of routes for your app.", - "version": "0.1.0", + "version": "1.0.0", "homepage": "https://marionettejs.com/", "main": "lib/marionette.approuter.js", "module": "lib/marionette.approuter.esm.js",