Skip to content

Commit b6bd937

Browse files
#13865 create a popup to advice about navigator blocked cookies
1 parent 68d2137 commit b6bd937

File tree

4 files changed

+61
-1
lines changed

4 files changed

+61
-1
lines changed

app/code/Magento/Theme/view/frontend/layout/default_head_blocks.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
</referenceBlock>
2424
<referenceContainer name="after.body.start">
2525
<block class="Magento\Framework\View\Element\Js\Components" name="head.components" as="components" template="Magento_Theme::js/components.phtml" before="-"/>
26+
<block class="Magento\Framework\View\Element\Template" name="cookie-status-check" as="cookie-status" template="Magento_Theme::js/cookie_status.phtml" />
2627
</referenceContainer>
2728
</body>
2829
</page>

app/code/Magento/Theme/view/frontend/requirejs-config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ var config = {
3030
'welcome': 'Magento_Theme/js/view/welcome',
3131
'breadcrumbs': 'Magento_Theme/js/view/breadcrumbs',
3232
'criticalCssLoader': 'Magento_Theme/js/view/critical-css-loader',
33-
'jquery/ui': 'jquery/compat'
33+
'jquery/ui': 'jquery/compat',
34+
'cookieStatus': 'Magento_Theme/js/cookie-status'
3435
}
3536
},
3637
deps: [
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
?>
7+
8+
<div id="cookie-status" style="display: none">
9+
<?= __('The store will not work correctly in the case when cookies are disabled.') ?>
10+
</div>
11+
12+
<script type="text/x-magento-init">
13+
{
14+
"*": {
15+
"cookieStatus": {}
16+
}
17+
}
18+
</script>
19+
20+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
define([
2+
'jquery',
3+
'mage/translate',
4+
'Magento_Ui/js/modal/modal'
5+
], function($, $tr, modal){
6+
'use strict';
7+
8+
$.widget('mage.cookieStatus', {
9+
/**
10+
* Init object
11+
* @private
12+
*/
13+
_init: function () {
14+
15+
if(!navigator.cookieEnabled) {
16+
console.log('popup');
17+
18+
const options = {
19+
type: 'popup',
20+
responsive: true,
21+
innerScroll: true,
22+
autoOpen: true,
23+
buttons: [{
24+
text: $.mage.__('Close'),
25+
class: 'cookie-status',
26+
click: function () {
27+
this.closeModal();
28+
}
29+
}]
30+
};
31+
32+
modal(options, $('#cookie-status'));
33+
}
34+
}
35+
});
36+
37+
return $.mage.cookieStatus;
38+
});

0 commit comments

Comments
 (0)