X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fcore%2Fmodules%2Fcontextual%2Fjs%2Fviews%2FVisualView.es6.js;fp=web%2Fcore%2Fmodules%2Fcontextual%2Fjs%2Fviews%2FVisualView.es6.js;h=57f68cacc3791ec95be06424a9f0feccdcbf2ea8;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hp=385fa7deca35812300f51f11c76e262f16add798;hpb=74df008bdbb3a11eeea356744f39b802369bda3c;p=yaffs-website diff --git a/web/core/modules/contextual/js/views/VisualView.es6.js b/web/core/modules/contextual/js/views/VisualView.es6.js index 385fa7dec..57f68cacc 100644 --- a/web/core/modules/contextual/js/views/VisualView.es6.js +++ b/web/core/modules/contextual/js/views/VisualView.es6.js @@ -3,80 +3,85 @@ * A Backbone View that provides the visual view of a contextual link. */ -(function (Drupal, Backbone, Modernizr) { - Drupal.contextual.VisualView = Backbone.View.extend(/** @lends Drupal.contextual.VisualView# */{ - - /** - * Events for the Backbone view. - * - * @return {object} - * A mapping of events to be used in the view. - */ - events() { - // Prevents delay and simulated mouse events. - const touchEndToClick = function (event) { - event.preventDefault(); - event.target.click(); - }; - const mapping = { - 'click .trigger': function () { - this.model.toggleOpen(); - }, - 'touchend .trigger': touchEndToClick, - 'click .contextual-links a': function () { - this.model.close().blur(); - }, - 'touchend .contextual-links a': touchEndToClick, - }; - // We only want mouse hover events on non-touch. - if (!Modernizr.touchevents) { - mapping.mouseenter = function () { - this.model.focus(); +(function(Drupal, Backbone, Modernizr) { + Drupal.contextual.VisualView = Backbone.View.extend( + /** @lends Drupal.contextual.VisualView# */ { + /** + * Events for the Backbone view. + * + * @return {object} + * A mapping of events to be used in the view. + */ + events() { + // Prevents delay and simulated mouse events. + const touchEndToClick = function(event) { + event.preventDefault(); + event.target.click(); }; - } - return mapping; - }, + const mapping = { + 'click .trigger': function() { + this.model.toggleOpen(); + }, + 'touchend .trigger': touchEndToClick, + 'click .contextual-links a': function() { + this.model.close().blur(); + }, + 'touchend .contextual-links a': touchEndToClick, + }; + // We only want mouse hover events on non-touch. + if (!Modernizr.touchevents) { + mapping.mouseenter = function() { + this.model.focus(); + }; + } + return mapping; + }, - /** - * Renders the visual view of a contextual link. Listens to mouse & touch. - * - * @constructs - * - * @augments Backbone.View - */ - initialize() { - this.listenTo(this.model, 'change', this.render); - }, + /** + * Renders the visual view of a contextual link. Listens to mouse & touch. + * + * @constructs + * + * @augments Backbone.View + */ + initialize() { + this.listenTo(this.model, 'change', this.render); + }, - /** - * @inheritdoc - * - * @return {Drupal.contextual.VisualView} - * The current contextual visual view. - */ - render() { - const isOpen = this.model.get('isOpen'); - // The trigger should be visible when: - // - the mouse hovered over the region, - // - the trigger is locked, - // - and for as long as the contextual menu is open. - const isVisible = this.model.get('isLocked') || this.model.get('regionIsHovered') || isOpen; + /** + * @inheritdoc + * + * @return {Drupal.contextual.VisualView} + * The current contextual visual view. + */ + render() { + const isOpen = this.model.get('isOpen'); + // The trigger should be visible when: + // - the mouse hovered over the region, + // - the trigger is locked, + // - and for as long as the contextual menu is open. + const isVisible = + this.model.get('isLocked') || + this.model.get('regionIsHovered') || + isOpen; - this.$el - // The open state determines if the links are visible. - .toggleClass('open', isOpen) - // Update the visibility of the trigger. - .find('.trigger').toggleClass('visually-hidden', !isVisible); + this.$el + // The open state determines if the links are visible. + .toggleClass('open', isOpen) + // Update the visibility of the trigger. + .find('.trigger') + .toggleClass('visually-hidden', !isVisible); - // Nested contextual region handling: hide any nested contextual triggers. - if ('isOpen' in this.model.changed) { - this.$el.closest('.contextual-region') - .find('.contextual .trigger:not(:first)') - .toggle(!isOpen); - } + // Nested contextual region handling: hide any nested contextual triggers. + if ('isOpen' in this.model.changed) { + this.$el + .closest('.contextual-region') + .find('.contextual .trigger:not(:first)') + .toggle(!isOpen); + } - return this; + return this; + }, }, - - }); -}(Drupal, Backbone, Modernizr)); + ); +})(Drupal, Backbone, Modernizr);