Commit 1e1e777e by Bridger Maxwell

Fixed bugs caused by modal cloning. Now, only video modals are cloned.

parent 8b94318b
...@@ -24,10 +24,16 @@ ...@@ -24,10 +24,16 @@
var modal_id = $(this).attr("href"); var modal_id = $(this).attr("href");
modal_clone = $(modal_id).clone(true, true); if ($(modal_id).hasClass("video-modal")) {
//Video modals need to be cloned before being presented as a modal
//This is because actions on the video get recorded in the history.
//Deleting the video (clone) prevents the odd back button behavior.
var modal_clone = $(modal_id).clone(true, true);
modal_clone.attr('id', 'modal_clone'); modal_clone.attr('id', 'modal_clone');
$(modal_id).after(modal_clone); $(modal_id).after(modal_clone);
modal_id = '#modal_clone'; modal_id = '#modal_clone';
}
$("#lean_overlay").click(function() { $("#lean_overlay").click(function() {
close_modal(modal_id); close_modal(modal_id);
...@@ -74,9 +80,11 @@ ...@@ -74,9 +80,11 @@
$("#lean_overlay").fadeOut(200); $("#lean_overlay").fadeOut(200);
$('iframe', modal_id).attr('src', ''); $('iframe', modal_id).attr('src', '');
$(modal_id).css({ 'display' : 'none' }); $(modal_id).css({ 'display' : 'none' });
if (modal_id == '#modal_clone') {
$(modal_id).remove(); $(modal_id).remove();
} }
} }
}
}); });
$("a[rel*=leanModal]").each(function(){ $("a[rel*=leanModal]").each(function(){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment