Created
April 5, 2013 16:27
-
-
Save ryanschuhler/5320646 to your computer and use it in GitHub Desktop.
A simple javascript to make a menu (or anything) appear on click and disappear when anything else is clicked.
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
var A = AUI(); | |
var docClick = function () { | |
if (A.one('.pop-click')) { | |
A.one('.pop-click').removeClass('pop-click'); | |
document.removeEventListener('click', docClick, true); | |
} | |
} | |
A.all('.pop-clickable').each( | |
function(e) { | |
e.on( | |
'click', | |
function (f) { | |
if (e.hasClass('pop-click')) { | |
e.removeClass('pop-click'); | |
} else { | |
e.addClass('pop-click'); | |
document.addEventListener('click', docClick, true); | |
} | |
} | |
); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment