comparison core/modules/toolbar/js/views/BodyVisualView.es6.js @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 129ea1e6d783
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 /**
2 * @file
3 * A Backbone view for the body element.
4 */
5
6 (function ($, Drupal, Backbone) {
7 Drupal.toolbar.BodyVisualView = Backbone.View.extend(/** @lends Drupal.toolbar.BodyVisualView# */{
8 /**
9 * Adjusts the body element with the toolbar position and dimension changes.
10 *
11 * @constructs
12 *
13 * @augments Backbone.View
14 */
15 initialize() {
16 this.listenTo(this.model, 'change:activeTray ', this.render);
17 this.listenTo(this.model, 'change:isFixed change:isViewportOverflowConstrained', this.isToolbarFixed);
18 },
19
20 isToolbarFixed() {
21 // When the toolbar is fixed, it will not scroll with page scrolling.
22 const isViewportOverflowConstrained = this.model.get('isViewportOverflowConstrained');
23 $('body').toggleClass('toolbar-fixed', (isViewportOverflowConstrained || this.model.get('isFixed')));
24 },
25
26 /**
27 * @inheritdoc
28 */
29 render() {
30 $('body')
31 // Toggle the toolbar-tray-open class on the body element. The class is
32 // applied when a toolbar tray is active. Padding might be applied to
33 // the body element to prevent the tray from overlapping content.
34 .toggleClass('toolbar-tray-open', !!this.model.get('activeTray'));
35 },
36 });
37 }(jQuery, Drupal, Backbone));