-
Notifications
You must be signed in to change notification settings - Fork 363
Add cart cookies disabled message #101
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Cart Template Script | ||
* ------------------------------------------------------------------------------ | ||
* A file that contains scripts highly couple code to the Cart template. | ||
* | ||
* @namespace cart | ||
*/ | ||
|
||
slate.cart = { | ||
|
||
/** | ||
* Check if cookies are enabled in the browser | ||
*/ | ||
cookiesEnabled: function() { | ||
var cookieEnabled = navigator.cookieEnabled; | ||
|
||
if (!cookieEnabled){ | ||
document.cookie = 'testcookie'; | ||
cookieEnabled = (document.cookie.indexOf('testcookie') !== -1); | ||
} | ||
return cookieEnabled; | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ window.theme = window.theme || {}; | |
|
||
/*================ Slate ================*/ | ||
// =require slate/a11y.js | ||
// =require slate/cart.js | ||
// =require slate/utils.js | ||
// =require slate/rte.js | ||
// =require slate/sections.js | ||
|
@@ -31,4 +32,9 @@ $(document).ready(function() { | |
// Wrap videos in div to force responsive layout. | ||
slate.rte.wrapTable(); | ||
slate.rte.iframeReset(); | ||
|
||
// Add a message to the cart if cookies are disabled. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function won't directly display the message, that's taken care of by CSS. Suggested reword:
|
||
if (slate.cart.cookiesEnabled()) { | ||
document.documentElement.className = document.documentElement.className.replace('no-cookies', 'cookies'); | ||
} | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,22 @@ | |
} | ||
} | ||
|
||
// Only show when cookies are not supported | ||
.no-cookies:not(html) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel that a Following the same logic: // Only show when browser cookies are not supported
.supports-no-cookies:not(html) {
display: none;
html.supports-no-cookies & {
display: block;
}
}
// Only show when browser cookies are supported
.supports-cookies {
html.supports-no-cookies & {
display: none;
}
} |
||
display: none; | ||
|
||
.no-cookies & { | ||
display: block; | ||
} | ||
} | ||
|
||
// Only show when cookies are supported | ||
.cookies { | ||
.no-cookies & { | ||
display: none; | ||
} | ||
} | ||
|
||
/*============================================================================ | ||
Skip to content button | ||
- Overrides .visually-hidden when focused | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,19 @@ | |
</form> | ||
{% else %} | ||
<h1>{{ 'cart.general.title' | t }}</h1> | ||
<p>{{ 'cart.general.empty' | t }}</p> | ||
<p>{{ 'cart.general.continue_browsing_html' | t }}</p> | ||
|
||
{% comment %} | ||
Cart Empty State | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
^ letter-casing |
||
{% endcomment %} | ||
<div class="cookies"> | ||
<p>{{ 'cart.general.empty' | t }}</p> | ||
<p>{{ 'cart.general.continue_browsing_html' | t }}</p> | ||
</div> | ||
|
||
{% comment %} | ||
Cart no cookies state | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please put a small blurb in here that explains browser cookies are required to build a cart |
||
{% endcomment %} | ||
<div class="no-cookies"> | ||
<p>{{ 'cart.general.cookies_required' | t }}</p> | ||
</div> | ||
{% endif %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put a small blurb in here that explains browser cookies are required to build a cart