Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / contextual / js / views / RegionView.es6.js
1 /**
2  * @file
3  * A Backbone View that renders the visual view of a contextual region element.
4  */
5
6 (function (Drupal, Backbone, Modernizr) {
7   Drupal.contextual.RegionView = Backbone.View.extend(/** @lends Drupal.contextual.RegionView# */{
8
9     /**
10      * Events for the Backbone view.
11      *
12      * @return {object}
13      *   A mapping of events to be used in the view.
14      */
15     events() {
16       let mapping = {
17         mouseenter() {
18           this.model.set('regionIsHovered', true);
19         },
20         mouseleave() {
21           this.model.close().blur().set('regionIsHovered', false);
22         },
23       };
24       // We don't want mouse hover events on touch.
25       if (Modernizr.touchevents) {
26         mapping = {};
27       }
28       return mapping;
29     },
30
31     /**
32      * Renders the visual view of a contextual region element.
33      *
34      * @constructs
35      *
36      * @augments Backbone.View
37      */
38     initialize() {
39       this.listenTo(this.model, 'change:hasFocus', this.render);
40     },
41
42     /**
43      * @inheritdoc
44      *
45      * @return {Drupal.contextual.RegionView}
46      *   The current contextual region view.
47      */
48     render() {
49       this.$el.toggleClass('focus', this.model.get('hasFocus'));
50
51       return this;
52     },
53
54   });
55 }(Drupal, Backbone, Modernizr));