Created
March 1, 2012 07:43
-
-
Save amccloud/1948094 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(function(require, exports) { | |
var _ = require('underscore'), | |
Backbone = require('backbone'); | |
_.extend(exports, Backbone.Events, { | |
initialize: function(options) { | |
this.settings = options && options.settings || {}; | |
this.preload = options && options.preload || {}; | |
this.layout = require('./core/views/workspace'); | |
_.each([ | |
require('./drops/router'), | |
require('./teams/router'), | |
require('./accounts/router') | |
], function(router) { | |
router.application = this; | |
router.on('all', this._routeChanged, this); | |
}, this); | |
$(document).on('click', 'a:not([rel="external"])', function(event) { | |
var href = $(this).attr('href'); | |
protocol = this.protocol + '//'; | |
if (href && href.slice(0, protocol.length) !== protocol) { | |
event.preventDefault(); | |
Backbone.history.navigate(href, true); | |
} | |
}); | |
this.layout.render(function(el) { | |
$('body').append(el); | |
}); | |
Backbone.history.start({ | |
pushState: true | |
}); | |
}, | |
setTitle: function(title) { | |
$('title').html(title); | |
}, | |
_routeChanged: function(route) { | |
this._lastFragment = Backbone.history.fragment; | |
this.trigger.apply(this, arguments); | |
}, | |
getLastFragment: function(index) { | |
return this._lastFragment || ''; | |
} | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(function(require) { | |
var Backbone = require('backbone'); | |
return new (Backbone.Router.extend({ | |
routes: { | |
'': 'index' | |
}, | |
index: function() { | |
this.application.layout.view('.main', new Backbone.View({})); | |
}, | |
}))(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment