X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fquickedit%2Fjs%2Fviews%2FContextualLinkView.js;fp=web%2Fcore%2Fmodules%2Fquickedit%2Fjs%2Fviews%2FContextualLinkView.js;h=e98a95fb37434f81743c79ff18eb0b6dc8f01389;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=bf50f616c7dcca3b53199471cc84b266433049ba;hpb=aea91e65e895364e460983b890e295aa5d5540a5;p=yaffs-website diff --git a/web/core/modules/quickedit/js/views/ContextualLinkView.js b/web/core/modules/quickedit/js/views/ContextualLinkView.js index bf50f616c..e98a95fb3 100644 --- a/web/core/modules/quickedit/js/views/ContextualLinkView.js +++ b/web/core/modules/quickedit/js/views/ContextualLinkView.js @@ -1,81 +1,39 @@ /** - * @file - * A Backbone View that provides a dynamic contextual link. - */ +* DO NOT EDIT THIS FILE. +* See the following change record for more information, +* https://www.drupal.org/node/2815083 +* @preserve +**/ (function ($, Backbone, Drupal) { - - 'use strict'; - - Drupal.quickedit.ContextualLinkView = Backbone.View.extend(/** @lends Drupal.quickedit.ContextualLinkView# */{ - - /** - * Define all events to listen to. - * - * @return {object} - * A map of events. - */ - events: function () { - // Prevents delay and simulated mouse events. + Drupal.quickedit.ContextualLinkView = Backbone.View.extend({ + events: function events() { function touchEndToClick(event) { event.preventDefault(); event.target.click(); } return { - 'click a': function (event) { + 'click a': function clickA(event) { event.preventDefault(); this.model.set('state', 'launching'); }, 'touchEnd a': touchEndToClick }; }, - - /** - * Create a new contextual link view. - * - * @constructs - * - * @augments Backbone.View - * - * @param {object} options - * An object with the following keys: - * @param {Drupal.quickedit.EntityModel} options.model - * The associated entity's model. - * @param {Drupal.quickedit.AppModel} options.appModel - * The application state model. - * @param {object} options.strings - * The strings for the "Quick edit" link. - */ - initialize: function (options) { - // Insert the text of the quick edit toggle. + initialize: function initialize(options) { this.$el.find('a').text(options.strings.quickEdit); - // Initial render. + this.render(); - // Re-render whenever this entity's isActive attribute changes. + this.listenTo(this.model, 'change:isActive', this.render); }, - - /** - * Render function for the contextual link view. - * - * @param {Drupal.quickedit.EntityModel} entityModel - * The associated `EntityModel`. - * @param {bool} isActive - * Whether the in-place editor is active or not. - * - * @return {Drupal.quickedit.ContextualLinkView} - * The `ContextualLinkView` in question. - */ - render: function (entityModel, isActive) { + render: function render(entityModel, isActive) { this.$el.find('a').attr('aria-pressed', isActive); - // Hides the contextual links if an in-place editor is active. this.$el.closest('.contextual').toggle(!isActive); return this; } - }); - -})(jQuery, Backbone, Drupal); +})(jQuery, Backbone, Drupal); \ No newline at end of file