This repository has been archived on 2025-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
drupalcampbristol/web/modules/contrib/webform/js/webform.contextual.js
2018-11-23 12:29:20 +00:00

26 lines
717 B
JavaScript

/**
* @file
* JavaScript behavior to remove destination from contextual links.
*/
(function ($) {
'use strict';
// Bind click event to all .contextual links which are
// dynamically inserted via Ajax.
// @see webform_contextual_links_view_alter()
// @see Drupal.behaviors.contextual
$(document).on('click', '.contextual', function () {
$(this).find('a.webform-contextual').once('webform-contextual').each(function () {
this.href = this.href.split('?')[0];
// Add ?_webform_test={webform} to the current page's URL.
if (/webform\/([^/]+)\/test/.test(this.href)) {
this.href = window.location.pathname + '?_webform_test=' + RegExp.$1;
}
});
});
})(jQuery);