| 1 |
var buttonizer = { |
| 2 |
settings: { |
| 3 |
buttonizerOpened: false, |
| 4 |
buttonizerHasOpened: false, |
| 5 |
wHeight: 0, |
| 6 |
scrollBarTop: 0, |
| 7 |
showAfter: 0, |
| 8 |
exitIntent: 0, |
| 9 |
exitIntentText: 'Are you looking for this?', |
| 10 |
currentPageUrl: '', |
| 11 |
currentPageTitle: '', |
| 12 |
showedExitIntent: false, |
| 13 |
animated: false, |
| 14 |
}, |
| 15 |
init: function(options) { |
| 16 |
options = jQuery.extend({ |
| 17 |
scrollBarTop: 0, |
| 18 |
showAfter: 0, |
| 19 |
exitIntent: 0, |
| 20 |
exitIntentText: 'Are you looking for this?' |
| 21 |
}, options); |
| 22 |
|
| 23 |
this.settings.scrollBarTop = options.scrollBarTop; |
| 24 |
this.settings.showAfter = options.showAfter; |
| 25 |
this.settings.wHeight = Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight); |
| 26 |
this.settings.exitIntent = options.exitIntent; |
| 27 |
this.settings.exitIntentText = options.exitIntentText; |
| 28 |
|
| 29 |
this.ready(); |
| 30 |
}, |
| 31 |
ready: function() { |
| 32 |
if(document.getElementById("buttonizer-sys") != null) { |
| 33 |
document.addEventListener("click", function(e) { |
| 34 |
if(buttonizer.settings.buttonizerOpened && !document.getElementById("buttonizer-button").contains(e.target)) { |
| 35 |
document.getElementById("buttonizer-sys").className = 'buttonizer_inner'; |
| 36 |
buttonizer.settings.buttonizerOpened = false; |
| 37 |
|
| 38 |
if(document.querySelector("#buttonizer-sys .buttonizer_head .text") != null) { |
| 39 |
document.querySelector("#buttonizer-sys .buttonizer_head .text").remove(); |
| 40 |
} |
| 41 |
} |
| 42 |
}, false); |
| 43 |
|
| 44 |
document.getElementById("buttonizer-sys").addEventListener("click", function() { |
| 45 |
if(document.querySelector("#buttonizer-sys .buttonizer_head.onlyone") != null) { |
| 46 |
return; |
| 47 |
} |
| 48 |
|
| 49 |
if(buttonizer.settings.buttonizerOpened == true) { |
| 50 |
document.getElementById("buttonizer-sys").className = 'buttonizer_inner'; |
| 51 |
buttonizer.settings.buttonizerOpened = false; |
| 52 |
|
| 53 |
if(document.querySelector("#buttonizer-sys .buttonizer_head .text") != null && typeof document.querySelector("#buttonizer-sys .buttonizer_head .text").hasClass != 'undefined') { |
| 54 |
if(document.querySelector("#buttonizer-sys .buttonizer_head .text").hasClass('noremove')) { |
| 55 |
document.querySelector("#buttonizer-sys .buttonizer_head .text").remove(); |
| 56 |
} |
| 57 |
} |
| 58 |
}else{ |
| 59 |
document.getElementById("buttonizer-sys").className = 'buttonizer_inner opened'; |
| 60 |
buttonizer.settings.buttonizerOpened = true; |
| 61 |
} |
| 62 |
}); |
| 63 |
|
| 64 |
// Attenton animation |
| 65 |
if(document.getElementById("buttonizer-button").getAttribute('attention-animation') != 'none') { |
| 66 |
setInterval(function() { |
| 67 |
if(!buttonizer.settings.buttonizerOpened) { |
| 68 |
document.getElementById("buttonizer-button").setAttribute("attention-trigger", "true"); |
| 69 |
|
| 70 |
setTimeout(function() { |
| 71 |
document.getElementById("buttonizer-button").setAttribute("attention-trigger", "false"); |
| 72 |
}, 2000); |
| 73 |
} |
| 74 |
}, 10000); |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
/* Premium Code Stripped by Freemius */ |
| 80 |
|
| 81 |
} |
| 82 |
}; |
| 83 |
|
| 84 |
function onButtonizerClickEvent(text) { |
| 85 |
if (typeof ga == 'function') { |
| 86 |
ga('send', 'event', { |
| 87 |
eventCategory: 'Buttonizer', |
| 88 |
eventAction: document.location.href, |
| 89 |
eventLabel: text |
| 90 |
}); |
| 91 |
} |
| 92 |
} |
| 93 |
|
| 94 |
function onButtonizerButtonFacebook() { |
| 95 |
window.open('http://www.facebook.com/sharer.php?u='+ document.location.href +'&t='+ document.title +'', 'popupFacebook', 'width=610, height=480, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false; |
| 96 |
} |
| 97 |
|
| 98 |
function onButtonizerButtonTwitter() { |
| 99 |
window.open('https://twitter.com/intent/tweet?text='+ document.title + ' Hey! Check out this link:' + '&url='+ document.location.href +'', 'popupTwitter', 'width=610, height=480, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false; |
| 100 |
} |
| 101 |
|
| 102 |
function onButtonizerButtonLinkedin() { |
| 103 |
window.open('http://www.linkedin.com/shareArticle?mini=true&url='+ document.location.href +'&title='+ document.title +'&summary='+ document.title +'', 'popupLinkedIn', 'width=610, height=480, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false; |
| 104 |
} |
| 105 |
|
| 106 |
function onButtonizerButtonEmail() { |
| 107 |
window.location.href = "mailto:?subject=" + document.title + "&body= Hey! Check out this link: " + document.location.href; |
| 108 |
} |
| 109 |
|
| 110 |
// Next update, we promise! :) |
| 111 |
|
| 112 |
function onButtonizerButtonWhatsapp() { |
| 113 |
window.open("https://api.whatsapp.com/send?text=" + encodeURI(document.title + " Hey! Check out this link:" + document.location.href)); |
| 114 |
} |
| 115 |
// |
| 116 |
// function onButtonizerButtonPinterest() { |
| 117 |
// window.open('http://www.pinterest.com/pin/create/button/?url=/node'+ document.location.href +'&description='+ document.title, 'popupTwitter', 'width=610, height=480, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false; |
| 118 |
// } |
| 119 |
|
| 120 |
|
| 121 |
|