Created
February 19, 2017 13:09
-
-
Save anatooly/5e0fc5679730af07cd39e86ebf683bee to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(function (window) { | |
var app = { | |
defaults: { | |
layout: '#layout' | |
}, | |
init: function (opts) { | |
new TabsView(); | |
new SearchView(); | |
var options = _.extend({}, this.defaults, opts); | |
var template = $(options.layout).text(); | |
this.$layout = $(template).appendTo('body'); | |
for (var key in this.data) { | |
this.data[key] = new this[key].Collection(this.data[key]); | |
} | |
for (var key in this) { | |
if (this[key].Router) { | |
new (this[key].Router); | |
} | |
} | |
new Router(); | |
Backbone.history.start({pushState: true}); | |
}, | |
bootstrap: function (key, val) { | |
this.data = this.data || {}; | |
this.data[key] = val; | |
}, | |
show: function (selector, view) { | |
this.$layout.find(selector).empty().append(view.el); | |
}, | |
navigate: function (path) { | |
this.trigger('app:navigate', path); | |
Backbone.history.navigate(path, { trigger: true }); | |
} | |
}; | |
_.extend(app, Backbone.Events); | |
window.Application = app; | |
})(this); | |
jQuery(document).ready(function ($) { | |
Application.init({ | |
isMobile: (screen.width < 600) | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment