Skip to content

Commit

Permalink
Merge pull request #12363 from jdalsem/breadcrumb-toggle
Browse files Browse the repository at this point in the history
fix(menus): you can now have a link with toggleable features combined
  • Loading branch information
jdalsem committed Jan 8, 2019
2 parents f4c8d8c + 097b01f commit 88158fe
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions views/default/elgg/menus/dropdown.js
Expand Up @@ -11,6 +11,7 @@ define(function (require) {
var dropdown = {

init: function () {
// handles clicking on a menu item that has a dropdown menu
$(document).on('click', '.elgg-menu-item-has-dropdown > a', function (e) {
var $trigger = $(this);
if ($trigger.data('dropdownMenu')) {
Expand Down Expand Up @@ -48,6 +49,21 @@ define(function (require) {

popup.open($trigger, $target, position);
});

// if an anchor also has its own link the text acts as the link, the before pseudo element handles the toggle
$(document).on('click', '.elgg-menu-item-has-dropdown > a > .elgg-anchor-label', function (e) {
var $anchor = $(this).closest('a');
var href = $anchor.attr('href');

if ($anchor.hasClass('elgg-non-link') || !href) {
return;
}

document.location = href;

e.preventDefault();
e.stopImmediatePropagation();
});

dropdown.init = elgg.nullFunction;
}
Expand Down
16 changes: 16 additions & 0 deletions views/default/elgg/menus/toggle.js
Expand Up @@ -10,6 +10,7 @@ define(function (require) {
var toggle = {

init: function () {
// handles clicking on a menu item that has toggleable childmenu
$(document).on('click', '.elgg-menu-item-has-toggle > a', function (e) {

e.preventDefault();
Expand All @@ -32,6 +33,21 @@ define(function (require) {
}
});
});

// if an anchor also has its own link the text acts as the link, the before pseudo element handles the toggle
$(document).on('click', '.elgg-menu-item-has-toggle > a > .elgg-anchor-label', function (e) {
var $anchor = $(this).closest('a');
var href = $anchor.attr('href');

if ($anchor.hasClass('elgg-non-link') || !href) {
return;
}

document.location = href;

e.preventDefault();
e.stopImmediatePropagation();
});

toggle.init = elgg.nullFunction;
}
Expand Down

0 comments on commit 88158fe

Please sign in to comment.