Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / paragraphs / js / paragraphs.actions.js
diff --git a/web/modules/contrib/paragraphs/js/paragraphs.actions.js b/web/modules/contrib/paragraphs/js/paragraphs.actions.js
new file mode 100644 (file)
index 0000000..3fe7a6c
--- /dev/null
@@ -0,0 +1,38 @@
+/**
+ * @file
+ * Paragraphs actions JS code for paragraphs actions button.
+ */
+
+(function ($, Drupal) {
+
+  'use strict';
+
+  /**
+   * Process paragraph_actions elements.
+   *
+   * @type {Drupal~behavior}
+   *
+   * @prop {Drupal~behaviorAttach} attach
+   *   Attaches paragraphsActions behaviors.
+   */
+  Drupal.behaviors.paragraphsActions = {
+    attach: function (context, settings) {
+      var $actionsElement = $(context).find('.paragraphs-dropdown').once('paragraphs-dropdown');
+      // Attach event handlers to toggle button.
+      $actionsElement.each(function () {
+        var $this = $(this);
+        var $toggle = $this.find('.paragraphs-dropdown-toggle');
+
+        $toggle.on('click', function (e) {
+          e.preventDefault();
+          $this.toggleClass('open');
+        });
+
+        $toggle.on('focusout', function (e) {
+          $this.removeClass('open');
+        });
+      });
+    }
+  };
+
+})(jQuery, Drupal);