2017-05-19 22:12:53 +00:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* A Backbone view for the body element.
|
|
|
|
*/
|
|
|
|
|
2020-10-21 10:41:33 +00:00
|
|
|
(function ($, Drupal, Backbone) {
|
2018-08-09 15:49:18 +00:00
|
|
|
Drupal.toolbar.BodyVisualView = Backbone.View.extend(
|
|
|
|
/** @lends Drupal.toolbar.BodyVisualView# */ {
|
|
|
|
/**
|
|
|
|
* Adjusts the body element with the toolbar position and dimension changes.
|
|
|
|
*
|
|
|
|
* @constructs
|
|
|
|
*
|
|
|
|
* @augments Backbone.View
|
|
|
|
*/
|
|
|
|
initialize() {
|
|
|
|
this.listenTo(this.model, 'change:activeTray ', this.render);
|
|
|
|
this.listenTo(
|
|
|
|
this.model,
|
|
|
|
'change:isFixed change:isViewportOverflowConstrained',
|
|
|
|
this.isToolbarFixed,
|
|
|
|
);
|
|
|
|
},
|
Issue #2542050 by droplet, nod_, dpacassi, Wim Leers, Sam152, andrewmacpherson, tameeshb, jonathanshaw, lokapujya, Daniel Schaefer, Chi, geerlingguy, tarekdj: Toolbar implementation creates super annoying re-rendering
2017-06-19 16:37:48 +00:00
|
|
|
|
2018-08-09 15:49:18 +00:00
|
|
|
isToolbarFixed() {
|
|
|
|
// When the toolbar is fixed, it will not scroll with page scrolling.
|
|
|
|
const isViewportOverflowConstrained = this.model.get(
|
|
|
|
'isViewportOverflowConstrained',
|
|
|
|
);
|
|
|
|
$('body').toggleClass(
|
|
|
|
'toolbar-fixed',
|
|
|
|
isViewportOverflowConstrained || this.model.get('isFixed'),
|
|
|
|
);
|
|
|
|
},
|
2017-05-19 22:12:53 +00:00
|
|
|
|
2018-08-09 15:49:18 +00:00
|
|
|
/**
|
2020-04-29 22:45:17 +00:00
|
|
|
* {@inheritdoc}
|
2018-08-09 15:49:18 +00:00
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
$('body')
|
|
|
|
// Toggle the toolbar-tray-open class on the body element. The class is
|
|
|
|
// applied when a toolbar tray is active. Padding might be applied to
|
|
|
|
// the body element to prevent the tray from overlapping content.
|
|
|
|
.toggleClass('toolbar-tray-open', !!this.model.get('activeTray'));
|
|
|
|
},
|
2017-07-06 06:21:40 +00:00
|
|
|
},
|
2018-08-09 15:49:18 +00:00
|
|
|
);
|
|
|
|
})(jQuery, Drupal, Backbone);
|