Laravel Siteye (Site Ücretsiz Hizmet Verecek) AdBlock detector kuruyorum Adi.js olanı fakat adblock onu da engelliyor
Trajikomik bir durumİşin komik tarafı adblock kapatınca uyarı görünüyor
Kodlar:
<div class="adcontainer"></div>
<script>
/**
* Adi.js
*/
;(function($) {
'use strict';
var Adi;
$.adi = function(args) {
/**
* Merge defaults with user options
*/
var options = $.extend({}, Adi.defaults, args);
return new Adi(options);
};
/**
* Constructor
*/
Adi = function(args) {
/**
* Merge this with user options
*/
$.extend(this, args);
if (this._check()) {
this._init();
this.active();
}
if (!this._check()) {
this.inactive();
}
};
/**
* Check for $.adblock
*/
Adi.prototype._check = function() {
return $.adblock === undefined
};
/**
* Start plugin
*/
Adi.prototype._init = function() {
this._append();
};
/**
* Set template
*/
Adi.prototype._setTemplate = function(title, content) {
return '<div class="jquery-adi">' +
'<div class="jquery-adi_content">' +
'<h2>' + title + '</h2>' +
'<p>' + content + '</p>' +
'</div>' +
'</div>';
};
/**
* Append html
*/
Adi.prototype._append = function(callback) {
this.$el = $(this._setTemplate(this.title, this.content)).appendTo($(document.body)).addClass(this.theme);
this._show();
};
/**
* Show modal
*/
Adi.prototype._show = function() {
var that = this;
this.$el.show();
this._center();
this._controls();
this.onOpen(this.$el);
};
/**
* Modal controls
*/
Adi.prototype._controls = function() {
var that = this;
function close() {
that.$el.hide();
that.onClose(that.$el);
}
this.$el.on('click', '.jquery-adi_close', close);
$(document).on('keyup', function(e) {
if (e.keyCode == 27)
close();
});
};
/**
* Center modal
*/
Adi.prototype._center = function() {
var $modal = this.$el.find('.jquery-adi_content');
$modal.css('margin-top', -Math.abs($modal.outerHeight() / 2));
};
/**
* Defaults
*/
Adi.defaults = {
title: 'Adblock detected!',
content: 'We noticed that you may have an Ad Blocker turned on. Please be aware that our site is best experienced with Ad Blockers turned off.',
theme: 'light',
onOpen: function() {},
onClose: function() {},
active: function() {},
inactive: function() {}
};
})(jQuery);
/*==========================
End plugin
===========================*/
$(document).ready(function() {
$.adi({
theme: 'dark',
onOpen: function(el) {
/* $.adi working with animate.css */
el.find('.jquery-adi_content').addClass('animated bounceInDown')
},
onClose: function(el) {
/**
* Redirect
* ========
* window.location.href('http://some-website')
*
* Dont let user to see content / reload page
* ==========================================
* window.location.reload(true);
*/
},
active: function() {
var tpl = '<h3></h3>' +
'';
$('.adcontainer').append(tpl);
console.log('Adblock detected :(')
},
inactive: function() {
var tpl = '<h3></h3>' +
'';
$('.adcontainer').append(tpl);
console.log('Adblock not detected :)');
}
});
});
</script><style>
/* Adi.js CSS ====== */
.jquery-adi {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
text-align: center;
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
background: rgba(0, 0, 0, .75);
z-index: 999999;
}
.jquery-adi_content {
position: absolute;
top: 50%;
left: 50%;
width: 320px;
padding: 30px 40px;
background: #ffffff;
border-radius: 10px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
margin-left: -160px;
box-sizing: border-box;
}
.jquery-adi_content h2,
.jquery-adi_content p,
.jquery-adi_content button {
padding: 0;
margin: 0;
}
.jquery-adi_content button {
position: absolute;
right: -15px;
top: -15px;
border: 0;
outline: 0;
width: 30px;
height: 30px;
border-radius: 50%;
background-color: #d5d5d5;
background-image: url('http://mariusbalaj.com/dev/Adi.js/plugin/images/icn_close.png');
background-repeat: no-repeat;
background-position: 0 0;
box-shadow: -2px 2px 8px rgba(148, 146, 145, 0.3);
}
.jquery-adi_content h2 {
color: #e76e65;
font-size: 22px;
font-weight: bold;
}
.jquery-adi_content h2:before {
content: "";
width: 80px;
height: 80px;
background-color: #e76e65;
background-image: url('http://mariusbalaj.com/dev/Adi.js/plugin/images/icn_danger.png');
background-position: 0 0;
background-repeat: no-repeat;
display: block;
margin: 0 auto 30px;
border-radius: 50%;
}
.jquery-adi_content p {
font-size: 14px;
color: #989898;
line-height: 1.4;
margin: 10px 0;
}
/* Dark Theme ====== */
.jquery-adi.dark .jquery-adi_content {
background: #1F1F1F;
}
.jquery-adi.dark .jquery-adi_content h2 {
color: #FF4335;
}
.jquery-adi.dark .jquery-adi_content h2:before {
background-color: #FF4335;
background-position: bottom center;
}
.jquery-adi.dark .jquery-adi_content p {
color: #ffffff;
}
.jquery-adi.dark .jquery-adi_content button {
background-color: #ffffff;
background-position: bottom left;
}
/* End Adi.js CSS ====== */
body {
text-align:center;
margin: 0;
padding: 0;
font-size: 16px;
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
}
.adcontainer {
width:500px;
margin: 50px auto;
}
.adcontainer h3 {
margin: 0 0 15px;
}
</style>