Last active
December 14, 2015 01:49
-
-
Save jackabox/4949fe20344bc06a21ca to your computer and use it in GitHub Desktop.
Creating a JS function to fire a reveal model on a link.
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
<div id="arbitrary-modal" class="reveal-modal medium"> | |
<div class="modal-content"></div> | |
<a class="close-reveal-modal">×</a> | |
</div> |
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
function open_reveal(html_element_or_url) { | |
if ($('.reveal-modal:visible').length > 0) { | |
close_reveal(function() { | |
open_reveal(html_element_or_url) | |
}); | |
return; | |
} | |
if (typeof(html_element_or_url) == 'string' && html_element_or_url.substr(0, 4) == 'http') { | |
$('#arbitrary-modal .modal-content').html("<h2>Loading, please wait...</h2>"); | |
$('#arbitrary-modal').bind('reveal:opened.reveal', function() { | |
$.get(html_element_or_url, function(data) { | |
$('#arbitrary-modal').html(data).trigger('loaded_festival_reveal'); | |
}); | |
}).reveal(); | |
return; | |
} else { | |
$('#arbitrary-modal .modal-content').html(html_element_or_url); | |
$('#arbitrary-modal').reveal(); | |
} | |
} | |
$(".fire-ajax").click(function (e){ | |
open_reveal($(this).attr('href')); return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment