front/general: resolve handlebars with browserify

This commit is contained in:
rr- 2016-03-29 12:32:51 +02:00
parent 4eac02e938
commit 8f375a4163
5 changed files with 15 additions and 15 deletions

View file

@ -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(); });

View file

@ -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) {

View file

@ -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');
}

View file

@ -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');
}

View file

@ -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');
}