X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fcontextual%2Fjs%2Fviews%2FVisualView.js;fp=web%2Fcore%2Fmodules%2Fcontextual%2Fjs%2Fviews%2FVisualView.js;h=9861ad1754054a8b1401e8bf8a8260e2e06b2395;hp=b22bb373dd8da180f6a1078fd732f7e52014cb33;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/web/core/modules/contextual/js/views/VisualView.js b/web/core/modules/contextual/js/views/VisualView.js index b22bb373d..9861ad175 100644 --- a/web/core/modules/contextual/js/views/VisualView.js +++ b/web/core/modules/contextual/js/views/VisualView.js @@ -1,80 +1,50 @@ /** - * @file - * A Backbone View that provides the visual view of a contextual link. - */ +* DO NOT EDIT THIS FILE. +* See the following change record for more information, +* https://www.drupal.org/node/2815083 +* @preserve +**/ (function (Drupal, Backbone, Modernizr) { - - 'use strict'; - - 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: function () { - // Prevents delay and simulated mouse events. - var touchEndToClick = function (event) { + Drupal.contextual.VisualView = Backbone.View.extend({ + events: function events() { + var touchEndToClick = function touchEndToClick(event) { event.preventDefault(); event.target.click(); }; var mapping = { - 'click .trigger': function () { this.model.toggleOpen(); }, + 'click .trigger': function clickTrigger() { + this.model.toggleOpen(); + }, 'touchend .trigger': touchEndToClick, - 'click .contextual-links a': function () { this.model.close().blur(); }, + 'click .contextual-links a': function clickContextualLinksA() { + 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(); }; + 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: function () { + initialize: function initialize() { this.listenTo(this.model, 'change', this.render); }, - - /** - * @inheritdoc - * - * @return {Drupal.contextual.VisualView} - * The current contextual visual view. - */ - render: function () { + render: function render() { var 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. + var 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.toggleClass('open', isOpen).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); + this.$el.closest('.contextual-region').find('.contextual .trigger:not(:first)').toggle(!isOpen); } return this; } - }); - -})(Drupal, Backbone, Modernizr); +})(Drupal, Backbone, Modernizr); \ No newline at end of file