Mercurial > hg > isophonics-drupal-site
annotate core/modules/contextual/js/views/RegionView.es6.js @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 129ea1e6d783 |
children |
rev | line source |
---|---|
Chris@0 | 1 /** |
Chris@0 | 2 * @file |
Chris@0 | 3 * A Backbone View that renders the visual view of a contextual region element. |
Chris@0 | 4 */ |
Chris@0 | 5 |
Chris@17 | 6 (function(Drupal, Backbone, Modernizr) { |
Chris@17 | 7 Drupal.contextual.RegionView = Backbone.View.extend( |
Chris@17 | 8 /** @lends Drupal.contextual.RegionView# */ { |
Chris@17 | 9 /** |
Chris@17 | 10 * Events for the Backbone view. |
Chris@17 | 11 * |
Chris@17 | 12 * @return {object} |
Chris@17 | 13 * A mapping of events to be used in the view. |
Chris@17 | 14 */ |
Chris@17 | 15 events() { |
Chris@17 | 16 let mapping = { |
Chris@17 | 17 mouseenter() { |
Chris@17 | 18 this.model.set('regionIsHovered', true); |
Chris@17 | 19 }, |
Chris@17 | 20 mouseleave() { |
Chris@17 | 21 this.model |
Chris@17 | 22 .close() |
Chris@17 | 23 .blur() |
Chris@17 | 24 .set('regionIsHovered', false); |
Chris@17 | 25 }, |
Chris@17 | 26 }; |
Chris@17 | 27 // We don't want mouse hover events on touch. |
Chris@17 | 28 if (Modernizr.touchevents) { |
Chris@17 | 29 mapping = {}; |
Chris@17 | 30 } |
Chris@17 | 31 return mapping; |
Chris@17 | 32 }, |
Chris@0 | 33 |
Chris@17 | 34 /** |
Chris@17 | 35 * Renders the visual view of a contextual region element. |
Chris@17 | 36 * |
Chris@17 | 37 * @constructs |
Chris@17 | 38 * |
Chris@17 | 39 * @augments Backbone.View |
Chris@17 | 40 */ |
Chris@17 | 41 initialize() { |
Chris@17 | 42 this.listenTo(this.model, 'change:hasFocus', this.render); |
Chris@17 | 43 }, |
Chris@17 | 44 |
Chris@17 | 45 /** |
Chris@17 | 46 * @inheritdoc |
Chris@17 | 47 * |
Chris@17 | 48 * @return {Drupal.contextual.RegionView} |
Chris@17 | 49 * The current contextual region view. |
Chris@17 | 50 */ |
Chris@17 | 51 render() { |
Chris@17 | 52 this.$el.toggleClass('focus', this.model.get('hasFocus')); |
Chris@17 | 53 |
Chris@17 | 54 return this; |
Chris@17 | 55 }, |
Chris@0 | 56 }, |
Chris@17 | 57 ); |
Chris@17 | 58 })(Drupal, Backbone, Modernizr); |