Skip to content

Commit

Permalink
0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-fediuk committed Jul 3, 2019
1 parent df10d4d commit aafd604
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 30 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kingpalm/adult"
,"version": "0.0.1"
,"version": "0.0.2"
,"description": "An adult confirmation module for kingpalm.com"
,"type": "magento2-module"
,"homepage": "https://github.com/kingpalm-com/adult"
Expand All @@ -11,7 +11,7 @@
,"homepage": "https://mage2.pro/users/dmitry_fedyuk"
,"role": "Developer"
}]
,"require": {"mage2pro/core": ">=4.8.8"}
,"require": {"mage2pro/core": ">=4.8.9"}
,"autoload": {"files": ["registration.php"], "psr-4": {"KingPalm\\Adult\\": ""}}
,"keywords": ["Magento 2"]
}
30 changes: 2 additions & 28 deletions view/frontend/templates/popup.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,9 @@
<li>Adult signature required upon delivery.</li>
<li>All products for tobacco and legal herbs use only.</li>
</ul>
<button class='action primary' onclick='ageCheck()'>
<button class='action primary'>
<span>Enter</span>
</button><span>or</span><a href='https://google.com'>Exit</a>
</div>
</div>
<script>
function ageCheck () {
var days = 14; //number of days until they must go through the age checker again.
var date = new Date;
date.setTime (date.getTime() + days * 24 * 60 * 60 * 1000);
var expires = "; expires=" + date.toGMTString ();
document.cookie = 'isAnAdult=true;' + expires + "; path=/";
location.reload();
}
function readCookie() {
var nameEQ = 'isAnAdult=';
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt (0) == ' ') {
c = c.substring (1, c.length);
}
if (c.indexOf (nameEQ) == 0) {
return c.substring (nameEQ.length, c.length);
}
}
return null;
}
if (readCookie()) {
document.write("<style>.kingpalm-adult-popup {display: none;}</style>");
}
</script>
<?= df_js_x('.kingpalm-adult-popup', 'KingPalm_Adult'); ?>
37 changes: 37 additions & 0 deletions view/frontend/web/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// 2019-07-03
define(['jquery'], function($) {return (
/**
* 2019-06-02
* @param {Object} c
* @param {HTMLDivElement} e
*/
function(c, e) {
var $e = $(e);
$('button', $e).click(function() {
var days = 14; //number of days until they must go through the age checker again.
var date = new Date;
date.setTime (date.getTime() + days * 24 * 60 * 60 * 1000);
var expires = "; expires=" + date.toGMTString ();
document.cookie = 'isAnAdult=true;' + expires + "; path=/";
location.reload();
});
(function() {
var readCookie = function() {
var nameEQ = 'isAnAdult=';
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt (0) == ' ') {
c = c.substring (1, c.length);
}
if (c.indexOf (nameEQ) == 0) {
return c.substring (nameEQ.length, c.length);
}
}
return null;
};
if (readCookie()) {
$e.hide();
}
})();
});});

0 comments on commit aafd604

Please sign in to comment.