diff options
author | Alex Pott <alex.a.pott@googlemail.com> | 2020-01-28 13:12:54 +0000 |
---|---|---|
committer | Alex Pott <alex.a.pott@googlemail.com> | 2020-01-28 13:14:16 +0000 |
commit | 5b657b15b810a9d6e7518b4bbdca6ff42b561dec (patch) | |
tree | 233b6e0726929081e59ec5900b5d4acfd0d6a28f /core/misc/dropbutton/dropbutton.js | |
parent | f791e7673609ffd2a43fd3822e09e1d3d2bc65a0 (diff) | |
download | drupal-5b657b15b810a9d6e7518b4bbdca6ff42b561dec.tar.gz drupal-5b657b15b810a9d6e7518b4bbdca6ff42b561dec.zip |
Revert "Issue #3101543 by lauriii, bnjmnm, ravi.shankar: Update core JavaScript dependencies listed in package.json"
This reverts commit 2dadb738bfd48510db2174323528fe769731c05a.
Diffstat (limited to 'core/misc/dropbutton/dropbutton.js')
-rw-r--r-- | core/misc/dropbutton/dropbutton.js | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/core/misc/dropbutton/dropbutton.js b/core/misc/dropbutton/dropbutton.js index 54b8a627605..166eab58452 100644 --- a/core/misc/dropbutton/dropbutton.js +++ b/core/misc/dropbutton/dropbutton.js @@ -7,23 +7,30 @@ (function ($, Drupal) { function DropButton(dropbutton, settings) { - var options = $.extend({ - title: Drupal.t('List additional actions') - }, settings); + var options = $.extend({ title: Drupal.t('List additional actions') }, settings); var $dropbutton = $(dropbutton); + this.$dropbutton = $dropbutton; + this.$list = $dropbutton.find('.dropbutton'); + this.$actions = this.$list.find('li').addClass('dropbutton-action'); if (this.$actions.length > 1) { var $primary = this.$actions.slice(0, 1); + var $secondary = this.$actions.slice(1); $secondary.addClass('secondary-action'); + $primary.after(Drupal.theme('dropbuttonToggle', options)); + this.$dropbutton.addClass('dropbutton-multiple').on({ 'mouseleave.dropbutton': $.proxy(this.hoverOut, this), + 'mouseenter.dropbutton': $.proxy(this.hoverIn, this), + 'focusout.dropbutton': $.proxy(this.focusOut, this), + 'focusin.dropbutton': $.proxy(this.focusIn, this) }); } else { @@ -39,25 +46,24 @@ Drupal.behaviors.dropButton = { attach: function attach(context, settings) { var $dropbuttons = $(context).find('.dropbutton-wrapper').once('dropbutton'); - if ($dropbuttons.length) { var $body = $('body').once('dropbutton-click'); - if ($body.length) { $body.on('click', '.dropbutton-toggle', dropbuttonClickHandler); } var il = $dropbuttons.length; - for (var i = 0; i < il; i++) { DropButton.dropbuttons.push(new DropButton($dropbuttons[i], settings.dropbutton)); } } } }; + $.extend(DropButton, { dropbuttons: [] }); + $.extend(DropButton.prototype, { toggle: function toggle(show) { var isBool = typeof show === 'boolean'; @@ -85,10 +91,12 @@ this.hoverIn.call(this, e); } }); + $.extend(Drupal.theme, { dropbuttonToggle: function dropbuttonToggle(options) { - return "<li class=\"dropbutton-toggle\"><button type=\"button\"><span class=\"dropbutton-arrow\"><span class=\"visually-hidden\">".concat(options.title, "</span></span></button></li>"); + return '<li class="dropbutton-toggle"><button type="button"><span class="dropbutton-arrow"><span class="visually-hidden">' + options.title + '</span></span></button></li>'; } }); + Drupal.DropButton = DropButton; })(jQuery, Drupal);
\ No newline at end of file |