mirror of
https://github.com/tag1consulting/d7_to_d10_migration.git
synced 2024-11-25 07:33:26 +00:00
52 lines
1.8 KiB
JavaScript
52 lines
1.8 KiB
JavaScript
/**
|
|
* @file
|
|
* Attaches behaviors for the Contextual module.
|
|
*/
|
|
|
|
(function ($) {
|
|
|
|
Drupal.contextualLinks = Drupal.contextualLinks || {};
|
|
|
|
/**
|
|
* Attaches outline behavior for regions associated with contextual links.
|
|
*/
|
|
Drupal.behaviors.contextualLinks = {
|
|
attach: function (context) {
|
|
$('div.contextual-links-wrapper', context).once('contextual-links', function () {
|
|
var $wrapper = $(this);
|
|
var $region = $wrapper.closest('.contextual-links-region');
|
|
var $links = $wrapper.find('ul.contextual-links');
|
|
var $trigger = $('<a class="contextual-links-trigger" href="#" />').text(Drupal.t('Configure')).click(
|
|
function () {
|
|
$links.stop(true, true).slideToggle(100);
|
|
$wrapper.toggleClass('contextual-links-active');
|
|
return false;
|
|
}
|
|
);
|
|
// Attach hover behavior to trigger and ul.contextual-links.
|
|
$trigger.add($links).hover(
|
|
function () { $region.addClass('contextual-links-region-active'); },
|
|
function () { $region.removeClass('contextual-links-region-active'); }
|
|
);
|
|
// Hide the contextual links when user clicks a link or rolls out of the .contextual-links-region.
|
|
$region.bind('mouseleave click', Drupal.contextualLinks.mouseleave);
|
|
$region.hover(
|
|
function() { $trigger.addClass('contextual-links-trigger-active'); },
|
|
function() { $trigger.removeClass('contextual-links-trigger-active'); }
|
|
);
|
|
// Prepend the trigger.
|
|
$wrapper.prepend($trigger);
|
|
});
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Disables outline for the region contextual links are associated with.
|
|
*/
|
|
Drupal.contextualLinks.mouseleave = function () {
|
|
$(this)
|
|
.find('.contextual-links-active').removeClass('contextual-links-active')
|
|
.find('ul.contextual-links').hide();
|
|
};
|
|
|
|
})(jQuery);
|