diff options
| author | rr- | 2016-06-14 10:31:48 +0200 |
|---|---|---|
| committer | rr- | 2016-06-18 10:35:20 +0200 |
| commit | 54e3099c5696e0b4fc7b05fb5ecc41ab4726628b (patch) | |
| tree | 29127e1c3d3d3d9bebfccefdf148da7305e2d5b3 /client/js/controllers/help_controller.js | |
| parent | c74f06da35af3c35d565a3c96e3d048f7a1ec011 (diff) | |
client/general: refactor control flow
- Controller lifetime is bound to route lifetime
- View lifetime is bound to controller lifetime
- Control lifetime is bound to view lifetime
- Enhanced event dispatching
- Enhanced responsiveness in some places
- Views communicate user input to controllers via new event system
Diffstat (limited to 'client/js/controllers/help_controller.js')
| -rw-r--r-- | client/js/controllers/help_controller.js | 42 |
1 files changed, 15 insertions, 27 deletions
diff --git a/client/js/controllers/help_controller.js b/client/js/controllers/help_controller.js index 9c199a6..f7dcafa 100644 --- a/client/js/controllers/help_controller.js +++ b/client/js/controllers/help_controller.js @@ -1,35 +1,23 @@ 'use strict'; -const router = require('../router.js'); -const TopNavigation = require('../models/top_navigation.js'); +const topNavigation = require('../models/top_navigation.js'); const HelpView = require('../views/help_view.js'); class HelpController { - constructor() { - this._helpView = new HelpView(); - } - - registerRoutes() { - router.enter( - '/help', - (ctx, next) => { this._showHelpRoute(); }); - router.enter( - '/help/:section', - (ctx, next) => { this._showHelpRoute(ctx.params.section); }); - router.enter( - '/help/:section/:subsection', - (ctx, next) => { - this._showHelpRoute(ctx.params.section, ctx.params.subsection); - }); - } - - _showHelpRoute(section, subsection) { - TopNavigation.activate('help'); - this._helpView.render({ - section: section, - subsection: subsection, - }); + constructor(section, subsection) { + topNavigation.activate('help'); + this._helpView = new HelpView(section, subsection); } } -module.exports = new HelpController(); +module.exports = router => { + router.enter('/help', (ctx, next) => { + new HelpController(); + }); + router.enter('/help/:section', (ctx, next) => { + new HelpController(ctx.params.section); + }); + router.enter('/help/:section/:subsection', (ctx, next) => { + new HelpController(ctx.params.section, ctx.params.subsection); + }); +}; |