mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
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
This commit is contained in:
@ -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);
|
||||
});
|
||||
};
|
||||
|
Reference in New Issue
Block a user