Easy-to-Use & Customizable
Age Verification Widget
<style>
/*<![CDATA[*/
#modal_screen {
position: fixed;
top:0;
left: 0;
height: 100%;
width: 100%;
z-index: 203002;
background-color: rgba(0,0,0,.9);
}
#modal_screen.nope {
background-color: #000;
}
#modal_content {
position: fixed;
z-index: 203002;
margin: 0 auto;
width:290px;
height: 290px;
color:#fff;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
-o-box-sizing: border-box;
box-sizing: border-box;
background-position: center 2em;
background-repeat: no-repeat;
background-size: 90px auto;
}
/*** hide the plugin for admin mode ***/
.matrix #modal_screen,.matrix #modal_content {
display:none!important;
}
#modal_content .content_wrapper {
padding:20px;
margin:3em auto 0;
text-align: center;
}
#modal_content h2 {
margin: 0 0 0 0;
color:#fff;
}
#modal_content p {
max-width: 75%;
margin: 1.2em auto 0;
color:#fff;
}
#modal_content nav {font-size: 16px; display:table; width: 100%;}
#modal_content nav ul {display:table-row; width: 100%; margin:0; padding:0;}
#modal_content nav li {display: table-cell; text-align: right; width: auto;}
#modal_content nav:after {
content: "";
display: block;
clear: both;
}
#modal_content nav small {
display: block;
text-align: center;
color: #888;
margin: 1em 0 0;
}
#modal_content nav a.av_btn {
display:block;
text-align:center;
width: 65px;
border-radius: 500px;
margin:1em auto 0;
text-decoration: none;
padding:1em;
color: #fff;
text-transform: none;
letter-spacing: 0;
}
#modal_content nav .av_go {
background-color: #7fbf4d;
}
#modal_content nav .av_no {
background-color: #d31823;
}
#modal_content nav .av_btn:hover {
background-color: #222;
}
#modal_content #modal_regret_wrapper nav a.av_btn {
margin-top:0;
width:100%;
font-size: 0.8em;
}
@media (min-width: 688px) {
#modal_content {
top: 10em;
top: 30vh;
left: 30vw;
width: 90%;
max-width: 500px;
height:500px;
padding:3em;
border-radius: 100%;
background-position: center 3em;
background-size: 160px auto;
font-size: 16px;
}
#modal_content .content_wrapper {
margin:3em auto 0;
text-align: center;
}
#modal_content h2 {
margin: 0 0 0 0;
font-size: 1.875em;
}
#modal_content p {
font-size: 1em;
line-height: 1.9em;
}
#modal_content nav {width: 100%;}
#modal_content nav a.av_btn {
padding:1em 2.5em;
margin:1.6em auto 0;
font-size: 1em;
}
}
/*]]>*/
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script type="text/javascript">
//<![CDATA[
jQuery.noConflict();
(function($) {
// Init
$(document).ready(function() {
// Simple Age Verification (https://github.com/Herudea/age-verification))
var modal_content,
modal_screen;
// Start Working ASAP.
$(document).ready(function() {
av_legality_check();
});
// Make sure the prompt stays in the middle.
$( window ).resize(function() {
av_positionPrompt();
});
av_legality_check = function() {
if ($.cookie('is_legal') == "yes") {
//legal!
// Do nothing?
} else {
av_showmodal();
}
};
av_showmodal = function() {
modal_screen = $('<div id="modal_screen"><\/div>');
modal_content = $('<div id="modal_content" style="display:none"><\/div>');
var modal_content_wrapper = $('<div id="modal_content_wrapper" class="content_wrapper"><\/div>');
var modal_regret_wrapper = $('<div id="modal_regret_wrapper" class="content_wrapper" style="display:none;"><\/div>');
// Question Content
var content_heading = $('<h2>Are you 18 or older?<\/h2>');
var content_buttons = $('<nav><ul><li><a href="#nothing" class="av_btn av_go" rel="yes">Yes<\/a><\/li><li><a href="#nothing" class="av_btn av_no" rel="no">No<\/a><\/li><\/nav');
var content_text = $('<p>You must verify that you are 18 years of age or older to enter this site.<\/p>');
// Regret Content
var regret_heading = $('<h2>We\'re Sorry!<\/h2>');
var regret_buttons = $('<nav><small>I hit the wrong button!<\/small> <ul><li><a href="#nothing" class="av_btn av_go" rel="yes">I\'m old enough!<\/a><\/li><\/ul><\/nav');
var regret_text = $('<p>You must be 18 years of age or older to enter this site.<\/p>');
modal_content_wrapper.append(content_heading, content_buttons, content_text);
modal_regret_wrapper.append(regret_heading, regret_text);
modal_content.append(modal_content_wrapper, modal_regret_wrapper);
// Append the prompt to the end of the document
$('body').append(modal_screen, modal_content);
// Center the box
av_positionPrompt();
modal_content.find('a.av_btn').on('click', av_setCookie);
};
av_setCookie = function(e) {
e.preventDefault();
var is_legal = $(e.currentTarget).attr('rel');
$.cookie('is_legal', is_legal, {
expires: 30,
path: '/'
});
if (is_legal == "yes") {
av_closeModal();
$(window).off('resize');
} else {
av_showRegret();
}
};
av_closeModal = function() {
modal_content.fadeOut();
modal_screen.fadeOut();
};
av_showRegret = function() {
modal_screen.addClass('nope');
modal_content.find('#modal_content_wrapper').hide();
modal_content.find('#modal_regret_wrapper').show();
};
av_positionPrompt = function() {
var top = ($(window).outerHeight() - $('#modal_content').outerHeight()) / 2;
var left = ($(window).outerWidth() - $('#modal_content').outerWidth()) / 2;
modal_content.css({
'top': top,
'left': left
});
if (modal_content.is(':hidden') && ($.cookie('is_legal') != "yes")) {
modal_content.fadeIn('slow')
}
};
});
})(jQuery);
//]]>
</script>
Click the Matrix Themes admin menu and select the 'Shortcodes' section.
Choose any custom widget using the copy button.
Paste the widget code to your website inside the 'Widget/HTML' module.
Customize it by adding your own text and images.
Make your own website
with built-in tools to grow your business online.