Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove inline handlers in cart, payment account page #2536

Merged
merged 5 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Draft
- Refactor cart, payment account page inline event handlers to event listeners [#2536](https://github.com/bigcommerce/cornerstone/pull/2536)

## 6.16.0 (01-15-2025)
- Remove escaping of "=" symbol for <head> for blog and brand [#2528](https://github.com/bigcommerce/cornerstone/pull/2528)
Expand Down
4 changes: 4 additions & 0 deletions assets/js/theme/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ export default class Cart extends PageManager {
this.bindGiftWrappingForm();
});
});

$('.cart-item-option-remove').on('click', () => {
window.confirm(this.context.giftWrappingRemoveMessage);
});
}

bindGiftWrappingForm() {
Expand Down
2 changes: 1 addition & 1 deletion templates/components/cart/item-giftwrap.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<dd class="cart-item-option-description">
{{gift_wrapping.name}}: {{gift_wrapping.price.formatted}}
<span class="cart-item-option-actions">
(<a href="" data-item-giftwrap="{{id}}">{{lang 'cart.gift_wrapping.change'}}</a> or <a href="{{gift_wrapping.remove_url}}" onclick="return confirm('{{lang 'cart.gift_wrapping.remove_confirm'}}')">{{lang 'cart.gift_wrapping.remove'}}</a>)
(<a href="" data-item-giftwrap="{{id}}">{{lang 'cart.gift_wrapping.change'}}</a> or <a class="cart-item-option-remove" href="{{gift_wrapping.remove_url}}">{{lang 'cart.gift_wrapping.remove'}}</a>)
</span>
</dd>
{{#if gift_wrapping.message}}
Expand Down
2 changes: 1 addition & 1 deletion templates/components/common/quick-search.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="container">
<form class="form" onsubmit="return false" data-url="{{urls.search}}" data-quick-search-form>
<form class="form" data-url="{{urls.search}}" data-quick-search-form>
<fieldset class="form-fieldset">
<div class="form-field">
<label class="is-srOnly" for="{{name}}">{{lang "search.quick_search.input_label"}}</label>
Expand Down
12 changes: 11 additions & 1 deletion templates/layout/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
{{~inject 'carouselArrowAndDotAriaLabel' (lang 'carousel.arrow_and_dot_aria_label')}}
{{~inject 'carouselActiveDotAriaLabel' (lang 'carousel.active_dot_aria_label')}}
{{~inject 'carouselContentAnnounceMessage' (lang 'carousel.content_announce_message')}}
{{~inject 'giftWrappingRemoveMessage' (lang 'cart.gift_wrapping.remove_confirm')}}
</head>
<body>
<svg data-src="{{cdn 'img/icon-sprite.svg'}}" class="icons-svg-sprite"></svg>
Expand Down Expand Up @@ -79,7 +80,16 @@
}
}
</script>
<script nonce="{{nonce}}" async defer src="{{cdn 'assets/dist/theme-bundle.main.js' resourceHint='preload' as='script'}}" onload="onThemeBundleMain()"></script>
<script id="theme-bundle-main" nonce="{{nonce}}" async defer src="{{cdn 'assets/dist/theme-bundle.main.js' resourceHint='preload' as='script'}}"></script>
<script nonce="{{nonce}}">
const scriptElement = document.getElementById('theme-bundle-main');

if (scriptElement) {
addEventListener('load', onThemeBundleMain);
} else {
console.error('Could not find script element with id "theme-bundle-main"');
}
</script>

{{{footer.scripts}}}
</body>
Expand Down