Refactored template loading

This commit is contained in:
Marcin Kurczewski
2014-10-05 10:41:12 +02:00
parent 688b5b1281
commit 784ff22050
18 changed files with 107 additions and 149 deletions

View File

@ -2,7 +2,6 @@ var App = App || {};
App.Presenters = App.Presenters || {};
App.Presenters.UserBrowsingSettingsPresenter = function(
_,
jQuery,
util,
promise,
@ -11,7 +10,7 @@ App.Presenters.UserBrowsingSettingsPresenter = function(
messagePresenter) {
var target;
var template;
var templates = {};
var user;
var privileges = {};
@ -22,8 +21,8 @@ App.Presenters.UserBrowsingSettingsPresenter = function(
privileges.canChangeBrowsingSettings = auth.isLoggedIn(user.name) && user.name === auth.getCurrentUser().name;
promise.wait(util.promiseTemplate('browsing-settings'))
.then(function(html) {
template = _.template(html);
.then(function(template) {
templates.browsingSettings = template;
render();
loaded();
});
@ -31,7 +30,7 @@ App.Presenters.UserBrowsingSettingsPresenter = function(
function render() {
var $el = jQuery(target);
$el.html(template({user: user, settings: browsingSettings.getSettings()}));
$el.html(templates.browsingSettings({user: user, settings: browsingSettings.getSettings()}));
$el.find('form').submit(browsingSettingsFormSubmitted);
}
@ -69,4 +68,4 @@ App.Presenters.UserBrowsingSettingsPresenter = function(
};
App.DI.register('userBrowsingSettingsPresenter', ['_', 'jQuery', 'util', 'promise', 'auth', 'browsingSettings', 'messagePresenter'], App.Presenters.UserBrowsingSettingsPresenter);
App.DI.register('userBrowsingSettingsPresenter', ['jQuery', 'util', 'promise', 'auth', 'browsingSettings', 'messagePresenter'], App.Presenters.UserBrowsingSettingsPresenter);