db backup prior to drupal security update
[yaffs-website] / web / core / modules / toolbar / js / views / MenuVisualView.js
1 /**
2  * @file
3  * A Backbone view for the collapsible menus.
4  */
5
6 (function ($, Backbone, Drupal) {
7
8   'use strict';
9
10   Drupal.toolbar.MenuVisualView = Backbone.View.extend(/** @lends Drupal.toolbar.MenuVisualView# */{
11
12     /**
13      * Backbone View for collapsible menus.
14      *
15      * @constructs
16      *
17      * @augments Backbone.View
18      */
19     initialize: function () {
20       this.listenTo(this.model, 'change:subtrees', this.render);
21     },
22
23     /**
24      * @inheritdoc
25      */
26     render: function () {
27       var subtrees = this.model.get('subtrees');
28       // Add subtrees.
29       for (var id in subtrees) {
30         if (subtrees.hasOwnProperty(id)) {
31           this.$el
32             .find('#toolbar-link-' + id)
33             .once('toolbar-subtrees')
34             .after(subtrees[id]);
35         }
36       }
37       // Render the main menu as a nested, collapsible accordion.
38       if ('drupalToolbarMenu' in $.fn) {
39         this.$el
40           .children('.toolbar-menu')
41           .drupalToolbarMenu();
42       }
43     }
44   });
45
46 }(jQuery, Backbone, Drupal));