Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Sync with pull 29.

  • Loading branch information...
commit 829644d4ad7fba24a33b17c203f6700b4c9fc0b3 1 parent 2e2fa6c
@paulmillr authored
View
4 app/chaplin/application.coffee
@@ -32,10 +32,10 @@ module.exports = class Application
# ----------------------
# Pass the function typically returned by routes.coffee
- initRouter: (routes) ->
+ initRouter: (routes, options) ->
# Save the reference for testing introspection only.
# Module should communicate with each other via Pub/Sub.
- @router = new Router()
+ @router = new Router(options)
# Register all routes declared in routes.coffee
routes? @router.match
View
5 app/chaplin/lib/router.coffee
@@ -10,7 +10,7 @@ module.exports = class Router # This class does not extend Backbone.Router
_(Router.prototype).extend Subscriber
- constructor: ->
+ constructor: (@options = {}) ->
@subscribeEvent '!router:route', @routeHandler
@subscribeEvent '!router:changeURL', @changeURLHandler
@@ -21,9 +21,10 @@ module.exports = class Router # This class does not extend Backbone.Router
Backbone.history or= new Backbone.History()
startHistory: ->
+ pushState = @options.pushState ? true
# Start the Backbone.History instance to start routing
# This should be called after all routes have been registered
- Backbone.history.start pushState: true
+ Backbone.history.start {pushState}
# Stop the current Backbone.History instance from observing URL changes
stopHistory: ->
View
14 public/chaplin.js
@@ -112,8 +112,8 @@
});
};
- Application.prototype.initRouter = function(routes) {
- this.router = new Router();
+ Application.prototype.initRouter = function(routes, options) {
+ this.router = new Router(options);
if (typeof routes === "function") routes(this.router.match);
return this.router.startHistory();
};
@@ -525,9 +525,11 @@
_(Router.prototype).extend(Subscriber);
- function Router() {
+ function Router(options) {
+ this.options = options != null ? options : {};
this.route = __bind(this.route, this);
- this.match = __bind(this.match, this); this.subscribeEvent('!router:route', this.routeHandler);
+ this.match = __bind(this.match, this);
+ this.subscribeEvent('!router:route', this.routeHandler);
this.subscribeEvent('!router:changeURL', this.changeURLHandler);
this.createHistory();
}
@@ -537,8 +539,10 @@
};
Router.prototype.startHistory = function() {
+ var pushState, _ref;
+ pushState = (_ref = this.options.pushState) != null ? _ref : true;
return Backbone.history.start({
- pushState: true
+ pushState: pushState
});
};
Please sign in to comment.
Something went wrong with that request. Please try again.