front/general: resolve handlebars with browserify
This commit is contained in:
parent
4eac02e938
commit
8f375a4163
|
@ -3,9 +3,6 @@
|
||||||
// ------------------
|
// ------------------
|
||||||
// - import objects -
|
// - import objects -
|
||||||
// ------------------
|
// ------------------
|
||||||
const page = require('page');
|
|
||||||
const handlebars = require('handlebars');
|
|
||||||
|
|
||||||
const Api = require('./api.js');
|
const Api = require('./api.js');
|
||||||
const LoginView = require('./views/login_view.js');
|
const LoginView = require('./views/login_view.js');
|
||||||
const RegistrationView = require('./views/registration_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 api = new Api();
|
||||||
|
|
||||||
const topNavigationView = new TopNavigationView(handlebars);
|
const topNavigationView = new TopNavigationView();
|
||||||
const loginView = new LoginView(handlebars);
|
const loginView = new LoginView();
|
||||||
const registrationView = new RegistrationView(handlebars);
|
const registrationView = new RegistrationView();
|
||||||
|
|
||||||
const authController = new AuthController(api, null, loginView);
|
const authController = new AuthController(api, null, loginView);
|
||||||
const topNavigationController
|
const topNavigationController
|
||||||
|
@ -52,6 +49,8 @@ const tagsController = new TagsController(topNavigationController);
|
||||||
// -----------------
|
// -----------------
|
||||||
// - setup routing -
|
// - setup routing -
|
||||||
// -----------------
|
// -----------------
|
||||||
|
const page = require('page');
|
||||||
|
|
||||||
page('/', () => { homeController.indexRoute(); });
|
page('/', () => { homeController.indexRoute(); });
|
||||||
|
|
||||||
page('/upload', () => { postsController.uploadPostsRoute(); });
|
page('/upload', () => { postsController.uploadPostsRoute(); });
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const handlebars = require('handlebars');
|
||||||
|
|
||||||
// fix iterating over NodeList in Chrome and Opera
|
// fix iterating over NodeList in Chrome and Opera
|
||||||
NodeList.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
|
NodeList.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
|
||||||
|
|
||||||
class BaseView {
|
class BaseView {
|
||||||
constructor(handlebars) {
|
constructor() {
|
||||||
this.handlebars = handlebars;
|
|
||||||
this.contentHolder = document.getElementById('content-holder');
|
this.contentHolder = document.getElementById('content-holder');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +17,7 @@ class BaseView {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const templateText = templateElement.innerHTML;
|
const templateText = templateElement.innerHTML;
|
||||||
return this.handlebars.compile(templateText);
|
return handlebars.compile(templateText);
|
||||||
}
|
}
|
||||||
|
|
||||||
showError(messagesHolder, errorMessage) {
|
showError(messagesHolder, errorMessage) {
|
||||||
|
|
|
@ -4,8 +4,8 @@ const config = require('../config.js');
|
||||||
const BaseView = require('./base_view.js');
|
const BaseView = require('./base_view.js');
|
||||||
|
|
||||||
class LoginView extends BaseView {
|
class LoginView extends BaseView {
|
||||||
constructor(handlebars) {
|
constructor() {
|
||||||
super(handlebars);
|
super();
|
||||||
this.template = this.getTemplate('login-template');
|
this.template = this.getTemplate('login-template');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ const config = require('../config.js');
|
||||||
const BaseView = require('./base_view.js');
|
const BaseView = require('./base_view.js');
|
||||||
|
|
||||||
class RegistrationView extends BaseView {
|
class RegistrationView extends BaseView {
|
||||||
constructor(handlebars) {
|
constructor() {
|
||||||
super(handlebars);
|
super();
|
||||||
this.template = this.getTemplate('user-registration-template');
|
this.template = this.getTemplate('user-registration-template');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
const BaseView = require('./base_view.js');
|
const BaseView = require('./base_view.js');
|
||||||
|
|
||||||
class TopNavigationView extends BaseView {
|
class TopNavigationView extends BaseView {
|
||||||
constructor(handlebars) {
|
constructor() {
|
||||||
super(handlebars);
|
super();
|
||||||
this.template = this.getTemplate('top-navigation-template');
|
this.template = this.getTemplate('top-navigation-template');
|
||||||
this.navHolder = document.getElementById('top-nav-holder');
|
this.navHolder = document.getElementById('top-nav-holder');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue