From 8f375a416306013d21ead87faba77697b12eecb2 Mon Sep 17 00:00:00 2001 From: rr- Date: Tue, 29 Mar 2016 12:32:51 +0200 Subject: [PATCH] front/general: resolve handlebars with browserify --- static/js/main.js | 11 +++++------ static/js/views/base_view.js | 7 ++++--- static/js/views/login_view.js | 4 ++-- static/js/views/registration_view.js | 4 ++-- static/js/views/top_navigation_view.js | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/static/js/main.js b/static/js/main.js index ce1e73c..e9b5f72 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -3,9 +3,6 @@ // ------------------ // - import objects - // ------------------ -const page = require('page'); -const handlebars = require('handlebars'); - const Api = require('./api.js'); const LoginView = require('./views/login_view.js'); const RegistrationView = require('./views/registration_view.js'); @@ -27,9 +24,9 @@ const TagsController = require('./controllers/tags_controller.js'); // ------------------- const api = new Api(); -const topNavigationView = new TopNavigationView(handlebars); -const loginView = new LoginView(handlebars); -const registrationView = new RegistrationView(handlebars); +const topNavigationView = new TopNavigationView(); +const loginView = new LoginView(); +const registrationView = new RegistrationView(); const authController = new AuthController(api, null, loginView); const topNavigationController @@ -52,6 +49,8 @@ const tagsController = new TagsController(topNavigationController); // ----------------- // - setup routing - // ----------------- +const page = require('page'); + page('/', () => { homeController.indexRoute(); }); page('/upload', () => { postsController.uploadPostsRoute(); }); diff --git a/static/js/views/base_view.js b/static/js/views/base_view.js index 694e44f..4f23e84 100644 --- a/static/js/views/base_view.js +++ b/static/js/views/base_view.js @@ -1,11 +1,12 @@ 'use strict'; +const handlebars = require('handlebars'); + // fix iterating over NodeList in Chrome and Opera NodeList.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator]; class BaseView { - constructor(handlebars) { - this.handlebars = handlebars; + constructor() { this.contentHolder = document.getElementById('content-holder'); } @@ -16,7 +17,7 @@ class BaseView { return null; } const templateText = templateElement.innerHTML; - return this.handlebars.compile(templateText); + return handlebars.compile(templateText); } showError(messagesHolder, errorMessage) { diff --git a/static/js/views/login_view.js b/static/js/views/login_view.js index e2b08c0..3082cda 100644 --- a/static/js/views/login_view.js +++ b/static/js/views/login_view.js @@ -4,8 +4,8 @@ const config = require('../config.js'); const BaseView = require('./base_view.js'); class LoginView extends BaseView { - constructor(handlebars) { - super(handlebars); + constructor() { + super(); this.template = this.getTemplate('login-template'); } diff --git a/static/js/views/registration_view.js b/static/js/views/registration_view.js index fb5841c..b2dcd36 100644 --- a/static/js/views/registration_view.js +++ b/static/js/views/registration_view.js @@ -4,8 +4,8 @@ const config = require('../config.js'); const BaseView = require('./base_view.js'); class RegistrationView extends BaseView { - constructor(handlebars) { - super(handlebars); + constructor() { + super(); this.template = this.getTemplate('user-registration-template'); } diff --git a/static/js/views/top_navigation_view.js b/static/js/views/top_navigation_view.js index 45c440d..3d77882 100644 --- a/static/js/views/top_navigation_view.js +++ b/static/js/views/top_navigation_view.js @@ -3,8 +3,8 @@ const BaseView = require('./base_view.js'); class TopNavigationView extends BaseView { - constructor(handlebars) { - super(handlebars); + constructor() { + super(); this.template = this.getTemplate('top-navigation-template'); this.navHolder = document.getElementById('top-nav-holder'); }