Skip to content

Commit 0f00074

Browse files
committed
MC-3934: Slide/Banner Overlay & Button Do Not Show On Storefront When Set To On Hover
Refactor bindClickWidget
1 parent 6f07be0 commit 0f00074

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

app/code/Magento/PageBuilder/view/base/web/js/widget/bind-click-to-data-link-element.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,21 @@
66
define(['jquery'], function ($) {
77
'use strict';
88

9-
return function (config, element) {
9+
/**
10+
* Binds window navigation event handler to non-anchor elements to facilitate simulated nested anchor functionality
11+
* @param {Object|null} config
12+
* @param {Node} element
13+
*/
14+
function bindClickWidget(config, element) {
1015
var $linkElements = $(element).find('[data-link-type]');
1116

1217
$linkElements.each(function (idx, linkElement) {
13-
var $linkElement = $(linkElement);
18+
var $linkElement = $(linkElement),
19+
isActualAnchorElement = $linkElement.prop('nodeName') === 'A',
20+
href = ($linkElement.attr('href') || '').trim(),
21+
isValidHref = ['javascript:void(0)', ''].indexOf(href) === -1;
1422

15-
if ($linkElement.prop('nodeName') === 'A' || !$linkElement.attr('href')) {
23+
if (isActualAnchorElement || !isValidHref) {
1624
return;
1725
}
1826

@@ -23,8 +31,18 @@ define(['jquery'], function ($) {
2331
return;
2432
}
2533

26-
window.location.href = $linkElement.attr('href');
34+
bindClickWidget.redirectTo($linkElement.attr('href'));
2735
});
2836
});
37+
}
38+
39+
/**
40+
* Navigate to href in browser
41+
* @param {String} href
42+
*/
43+
bindClickWidget.redirectTo = function (href) {
44+
window.location.href = href;
2945
};
46+
47+
return bindClickWidget;
3048
});

0 commit comments

Comments
 (0)