MenuVisualView.js 765 B

123456789101112131415161718192021222324252627
  1. /**
  2. * DO NOT EDIT THIS FILE.
  3. * See the following change record for more information,
  4. * https://www.drupal.org/node/2815083
  5. * @preserve
  6. **/
  7. (function ($, Backbone, Drupal) {
  8. Drupal.toolbar.MenuVisualView = Backbone.View.extend({
  9. initialize: function initialize() {
  10. this.listenTo(this.model, 'change:subtrees', this.render);
  11. },
  12. render: function render() {
  13. var _this = this;
  14. var subtrees = this.model.get('subtrees');
  15. Object.keys(subtrees || {}).forEach(function (id) {
  16. _this.$el.find('#toolbar-link-' + id).once('toolbar-subtrees').after(subtrees[id]);
  17. });
  18. if ('drupalToolbarMenu' in $.fn) {
  19. this.$el.children('.toolbar-menu').drupalToolbarMenu();
  20. }
  21. }
  22. });
  23. })(jQuery, Backbone, Drupal);