Last active
August 29, 2015 13:56
-
-
Save davidlevy/9090618 to your computer and use it in GitHub Desktop.
XITI Prototype integration
This file contains hidden or 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
vpTrackClick = function(tag, element) { | |
return xt_click(element,'C', xtn2, tag,'N'); | |
} | |
vpAttachClickTag = function(col, tag) { | |
col.each( function(element){ | |
$(element).observe('click', function(e) { | |
if (element.tagName=='A') { | |
e.preventDefault(); | |
return vpTrackClick(tag, element); | |
} else if (element.tagName=='INPUT' && element.type=="submit") { | |
e.preventDefault(); | |
vpTrackClick(tag, element); | |
// wait 1s for the tag to be loaded | |
setTimeout(function() { $(element).up('form').submit();}, 1000); | |
} | |
}); | |
}); | |
} | |
// example : | |
document.observe("dom:loaded", function(){ | |
// initialize click observers | |
vpAttachClickTag($$('#breadcrumb li.first a'), 'Accueil_fil_dariane'); | |
vpAttachClickTag($$('.vp_link_edit_profile'), 'Modifier_profil'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment