annotate 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 |
rev |
line source |
Chris@0
|
1 /**
|
Chris@0
|
2 * @file
|
Chris@0
|
3 * A Backbone view for the body element.
|
Chris@0
|
4 */
|
Chris@0
|
5
|
Chris@0
|
6 (function ($, Drupal, Backbone) {
|
Chris@0
|
7 Drupal.toolbar.BodyVisualView = Backbone.View.extend(/** @lends Drupal.toolbar.BodyVisualView# */{
|
Chris@0
|
8 /**
|
Chris@0
|
9 * Adjusts the body element with the toolbar position and dimension changes.
|
Chris@0
|
10 *
|
Chris@0
|
11 * @constructs
|
Chris@0
|
12 *
|
Chris@0
|
13 * @augments Backbone.View
|
Chris@0
|
14 */
|
Chris@0
|
15 initialize() {
|
Chris@0
|
16 this.listenTo(this.model, 'change:activeTray ', this.render);
|
Chris@0
|
17 this.listenTo(this.model, 'change:isFixed change:isViewportOverflowConstrained', this.isToolbarFixed);
|
Chris@0
|
18 },
|
Chris@0
|
19
|
Chris@0
|
20 isToolbarFixed() {
|
Chris@0
|
21 // When the toolbar is fixed, it will not scroll with page scrolling.
|
Chris@0
|
22 const isViewportOverflowConstrained = this.model.get('isViewportOverflowConstrained');
|
Chris@0
|
23 $('body').toggleClass('toolbar-fixed', (isViewportOverflowConstrained || this.model.get('isFixed')));
|
Chris@0
|
24 },
|
Chris@0
|
25
|
Chris@0
|
26 /**
|
Chris@0
|
27 * @inheritdoc
|
Chris@0
|
28 */
|
Chris@0
|
29 render() {
|
Chris@0
|
30 $('body')
|
Chris@0
|
31 // Toggle the toolbar-tray-open class on the body element. The class is
|
Chris@0
|
32 // applied when a toolbar tray is active. Padding might be applied to
|
Chris@0
|
33 // the body element to prevent the tray from overlapping content.
|
Chris@0
|
34 .toggleClass('toolbar-tray-open', !!this.model.get('activeTray'));
|
Chris@0
|
35 },
|
Chris@0
|
36 });
|
Chris@0
|
37 }(jQuery, Drupal, Backbone));
|