mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
Restructured presenters code
This commit is contained in:
@ -4,21 +4,18 @@ App.Presenters = App.Presenters || {};
|
||||
App.Presenters.TopNavigationPresenter = function(util, jQuery, appState) {
|
||||
|
||||
var selectedElement = null;
|
||||
var $el = jQuery('#top-navigation');
|
||||
var template;
|
||||
|
||||
util.loadTemplate('top-navigation').then(function(html) {
|
||||
template = _.template(html);
|
||||
render();
|
||||
init();
|
||||
});
|
||||
var $el = jQuery('#top-navigation');
|
||||
|
||||
var eventHandlers = {
|
||||
loginStateChanged: function() {
|
||||
render();
|
||||
},
|
||||
};
|
||||
|
||||
appState.startObserving('loggedIn', 'top-navigation', eventHandlers.loginStateChanged);
|
||||
function init() {
|
||||
render();
|
||||
appState.startObserving('loggedIn', 'top-navigation', loginStateChanged);
|
||||
}
|
||||
|
||||
function select(newSelectedElement) {
|
||||
selectedElement = newSelectedElement;
|
||||
@ -26,6 +23,10 @@ App.Presenters.TopNavigationPresenter = function(util, jQuery, appState) {
|
||||
$el.find('li.' + selectedElement).addClass('active');
|
||||
};
|
||||
|
||||
function loginStateChanged() {
|
||||
render();
|
||||
}
|
||||
|
||||
function render() {
|
||||
$el.html(template({loggedIn: appState.get('loggedIn')}));
|
||||
$el.find('li.' + selectedElement).addClass('active');
|
||||
|
Reference in New Issue
Block a user