diff core/modules/quickedit/js/views/ContextualLinkView.js @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/modules/quickedit/js/views/ContextualLinkView.js	Thu Jul 05 14:24:15 2018 +0000
@@ -0,0 +1,39 @@
+/**
+* DO NOT EDIT THIS FILE.
+* See the following change record for more information,
+* https://www.drupal.org/node/2815083
+* @preserve
+**/
+
+(function ($, Backbone, Drupal) {
+  Drupal.quickedit.ContextualLinkView = Backbone.View.extend({
+    events: function events() {
+      function touchEndToClick(event) {
+        event.preventDefault();
+        event.target.click();
+      }
+
+      return {
+        'click a': function clickA(event) {
+          event.preventDefault();
+          this.model.set('state', 'launching');
+        },
+        'touchEnd a': touchEndToClick
+      };
+    },
+    initialize: function initialize(options) {
+      this.$el.find('a').text(options.strings.quickEdit);
+
+      this.render();
+
+      this.listenTo(this.model, 'change:isActive', this.render);
+    },
+    render: function render(entityModel, isActive) {
+      this.$el.find('a').attr('aria-pressed', isActive);
+
+      this.$el.closest('.contextual').toggle(!isActive);
+
+      return this;
+    }
+  });
+})(jQuery, Backbone, Drupal);
\ No newline at end of file