Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176
This commit is contained in:
commit
9921556621
13277 changed files with 1459781 additions and 0 deletions
46
core/modules/toolbar/js/views/MenuVisualView.js
Normal file
46
core/modules/toolbar/js/views/MenuVisualView.js
Normal file
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* @file
|
||||
* A Backbone view for the collapsible menus.
|
||||
*/
|
||||
|
||||
(function ($, Backbone, Drupal) {
|
||||
|
||||
"use strict";
|
||||
|
||||
Drupal.toolbar.MenuVisualView = Backbone.View.extend(/** @lends Drupal.toolbar.MenuVisualView# */{
|
||||
|
||||
/**
|
||||
* Backbone View for collapsible menus.
|
||||
*
|
||||
* @constructs
|
||||
*
|
||||
* @augments Backbone.View
|
||||
*/
|
||||
initialize: function () {
|
||||
this.listenTo(this.model, 'change:subtrees', this.render);
|
||||
},
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
render: function () {
|
||||
var subtrees = this.model.get('subtrees');
|
||||
// Add subtrees.
|
||||
for (var id in subtrees) {
|
||||
if (subtrees.hasOwnProperty(id)) {
|
||||
this.$el
|
||||
.find('#toolbar-link-' + id)
|
||||
.once('toolbar-subtrees')
|
||||
.after(subtrees[id]);
|
||||
}
|
||||
}
|
||||
// Render the main menu as a nested, collapsible accordion.
|
||||
if ('drupalToolbarMenu' in $.fn) {
|
||||
this.$el
|
||||
.children('.toolbar-menu')
|
||||
.drupalToolbarMenu();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}(jQuery, Backbone, Drupal));
|
Reference in a new issue