X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fparagraphs%2Fjs%2Fparagraphs.actions.js;fp=web%2Fmodules%2Fcontrib%2Fparagraphs%2Fjs%2Fparagraphs.actions.js;h=3fe7a6cbacd6c3e1768550128b8c81ff070b462f;hp=0000000000000000000000000000000000000000;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/web/modules/contrib/paragraphs/js/paragraphs.actions.js b/web/modules/contrib/paragraphs/js/paragraphs.actions.js new file mode 100644 index 000000000..3fe7a6cba --- /dev/null +++ b/web/modules/contrib/paragraphs/js/paragraphs.actions.js @@ -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);