Mercurial > hg > isophonics-drupal-site
comparison core/modules/toolbar/js/views/MenuVisualView.es6.js @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 1fec387a4317 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 /** | |
2 * @file | |
3 * A Backbone view for the collapsible menus. | |
4 */ | |
5 | |
6 (function ($, Backbone, Drupal) { | |
7 Drupal.toolbar.MenuVisualView = Backbone.View.extend(/** @lends Drupal.toolbar.MenuVisualView# */{ | |
8 | |
9 /** | |
10 * Backbone View for collapsible menus. | |
11 * | |
12 * @constructs | |
13 * | |
14 * @augments Backbone.View | |
15 */ | |
16 initialize() { | |
17 this.listenTo(this.model, 'change:subtrees', this.render); | |
18 }, | |
19 | |
20 /** | |
21 * @inheritdoc | |
22 */ | |
23 render() { | |
24 const subtrees = this.model.get('subtrees'); | |
25 // Add subtrees. | |
26 for (const id in subtrees) { | |
27 if (subtrees.hasOwnProperty(id)) { | |
28 this.$el | |
29 .find(`#toolbar-link-${id}`) | |
30 .once('toolbar-subtrees') | |
31 .after(subtrees[id]); | |
32 } | |
33 } | |
34 // Render the main menu as a nested, collapsible accordion. | |
35 if ('drupalToolbarMenu' in $.fn) { | |
36 this.$el | |
37 .children('.toolbar-menu') | |
38 .drupalToolbarMenu(); | |
39 } | |
40 }, | |
41 }); | |
42 }(jQuery, Backbone, Drupal)); |