Skip to content

Instantly share code, notes, and snippets.

View ericakfranz's full-sized avatar

Erica Franz ericakfranz

View GitHub Profile
@ericakfranz
ericakfranz / om-use-javascript.js
Last active May 11, 2016 18:03
Vanilla Javascript method for using OptinMonster Events
document.addEventListener( "DOMContentLoaded", function(event) {
document.onload('EventName', function( event,data,object ) {} );
});
@ericakfranz
ericakfranz / om-available.js
Created December 7, 2015 21:49
What's available via OptinMonster.
$(document).on('OptinMonsterLoaded', function( event, data, object ){
console.log(event);
console.log(data);
console.log(object);
});
@ericakfranz
ericakfranz / OptinMonsterInit.js
Created December 7, 2015 21:58
Remove OM optin, requires own custom conditional statement (remove optin if x = y).
jQuery(document).ready( function($){
$(document).on('OptinMonsterInit', function( event, data, object ){
// If video is playing (add your own logic here), remove the optin.
if ( data.optin ) {
$('#om-' + data.optin).remove();
}
});
});
@ericakfranz
ericakfranz / OptinMonsterManualOptinSuccess.js
Created December 7, 2015 22:00
Write to the console a message whenever a manually-triggered OM optin is loaded into the DOM.
jQuery(document).ready( function($){
$(document).on('OptinMonsterManualOptinSuccess', function( event, data, object ){
console.log("Congratulations! The " + data.optin + '-' + data.type + " manual-trigger optin has been successfully loaded.");
});
});
@ericakfranz
ericakfranz / OptinMonsterManualOptinError.js
Created December 7, 2015 22:01
Write to the console when a manually-triggered OM optin fails to load into the DOM as expected.
jQuery(document).ready( function($){
$(document).on('OptinMonsterManualOptinError', function( event, data, object ){
console.log("Oops! There was a problem loading the " + data.optin + '-' + data.type + " manual-trigger optin on this page.");
});
});
@ericakfranz
ericakfranz / OptinMonsterLoaded.js
Created December 7, 2015 22:02
Write to the console when an OM optin has successfully loaded into the DOM.
jQuery(document).ready( function($){
$(document).on('OptinMonsterLoaded', function( event, data, object ){
console.log("Congratulations! The " + data.optin + '-' + data.type + " optin has been successfully loaded.");
});
});
@ericakfranz
ericakfranz / OptinMonsterBeforeShow.css
Last active December 7, 2015 22:09
Load a div containing a YouTube video set to autoplay behind our manually-triggered optin just before the optin shows. We’ll load the overlay only on desktop browsers and trigger the overlay to close with the ESC key.
/* --- CSS to position the video overlay --- */
#overlay {
position: fixed;
left: 0;
top: -90px;
bottom: 0;
right: 0;
width: 100%;
height: 500%;
background: #000;
@ericakfranz
ericakfranz / OptinMonsterOnShow.js
Created December 7, 2015 22:11
Stop a video from playing when the optin closes, then add the video url back when the optin opens - useful for Manual Trigger optins.
jQuery(document).ready( function($){
//Snag the URL of the iframe so we can use it later
var url = $('.optin_custom_html_applied iframe').attr('src');
$(document).on('OptinMonsterOnShow', function( event, data, object){
//Below we remove the URL to stop the video from playing, here we add it back in
$('.optin_custom_html_applied iframe').attr('src', url);
});
$(document).on('OptinMonsterOnClose', function( event, data, object){
@ericakfranz
ericakfranz / OptinMonsterPositionOptin.js
Created December 7, 2015 22:12
Make OM optin draggable using the Dragon jQuery script -- https://github.com/jeremyckahn/dragon
jQuery(document).ready( function($){
$(document).on('OptinMonsterPositionOptin', function( event, data, object ){
$('#om-canvas-whiteboard-optin').dragon();
});
});
@ericakfranz
ericakfranz / OptinMonsterBeforeClose.js
Created December 7, 2015 22:14
Redirect to a specific url before the optin closes.
jQuery(document).ready( function($){
$(document).on('OptinMonsterBeforeClose', function( event, data, object ){
var url = "http://optinmonster.com";
$(location).attr('href',url);
});
});