arma-server-web-admin/public/js/app/views/navigation.js

49 lines
1.4 KiB
JavaScript
Raw Normal View History

2014-02-09 03:19:48 +00:00
define(function (require) {
2014-02-09 03:19:48 +00:00
"use strict";
2014-02-09 03:19:48 +00:00
var $ = require('jquery'),
_ = require('underscore'),
Backbone = require('backbone'),
Marionette = require('marionette'),
BootstrapModal = require('backbone.bootstrap-modal'),
ServersListView = require('app/views/navigation/servers/list'),
2017-10-05 22:01:55 +00:00
SettingsView = require('app/views/settings'),
2014-02-09 03:19:48 +00:00
tpl = require('text!tpl/navigation.html');
2014-02-09 03:19:48 +00:00
return Marionette.ItemView.extend({
template: _.template(tpl),
templateHelpers: function() {
return {
isActiveRoute: function (route) {
return Backbone.history.fragment === route ? 'active' : ''
}
}
},
2014-02-09 03:19:48 +00:00
events: {
"click #settings": "settings"
},
2014-02-09 03:19:48 +00:00
initialize: function (options) {
this.settings = options.settings;
2014-02-09 03:19:48 +00:00
this.servers = options.servers;
this.serversListView = new ServersListView({ collection: this.servers })
Backbone.history.on('route', this.render);
2014-02-09 03:19:48 +00:00
},
2014-02-09 03:19:48 +00:00
onDomRefresh: function () {
this.serversListView.setElement('#servers-list');
this.serversListView.render();
},
2014-02-09 03:19:48 +00:00
settings: function (event) {
event.preventDefault();
var view = new SettingsView({ model: this.settings });
2015-04-03 10:16:19 +00:00
new Backbone.BootstrapModal({ content: view, animate: true, cancelText: false }).open();
2014-02-09 03:19:48 +00:00
}
});
});