Last active
April 21, 2017 09:32
-
-
Save chrismauck/163469b580e5b293239b93356fe5003c to your computer and use it in GitHub Desktop.
DoubleClick Exit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* addExit - Add DoubleClick exit | |
* | |
* @param {String | Array} el - id, or array of element ids to accept the event | |
* @param {String} evt - event to listen for | |
* @param {String} ext - name of the DoubleClick exit | |
* @param {String} alt - URL of DoubleClick exit override if exists | |
* Usage addExit.event('cta', 'click', 'Main Exit'); | |
*/ | |
var addExit = { | |
event: function( el, evt, ext, alt ) { | |
if(typeof el === 'string') { | |
var ele = document.getElementById(el); | |
ele.addEventListener(evt, function(){ addExit.exit( ext, alt ); }, false); | |
} else if (Array.isArray(el)) { | |
for (var j=0, len = el.length; j < len; j++) { | |
var ele = document.getElementById(el[j]); | |
ele.addEventListener(evt, function(){ addExit.exit( ext, alt ); }, false); | |
} | |
} | |
}, | |
exit: function( ext, alt ) { | |
return ( alt ) ? Enabler.exit(ext, alt) : Enabler.exit(ext); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment