Created
September 19, 2012 13:58
-
-
Save xfenix/3749831 to your computer and use it in GitHub Desktop.
This script allow dynamically load content with images, that has no height attribute. Nyromodal version.
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
var secret = $('<div>').attr('id', 'secret-meter'), | |
loadNow = 0, | |
loadTotal = 0; | |
$('body').prepend(secret); | |
$('.dialog').click(function(){ | |
var url = $(this)[0].href, | |
loadWindow = function() { | |
$.nmData(secret.html(), { | |
closeButton: '<a href="#" class="nyroModalClose nyroModalCloseButton nmReposition" title="close"></a>', | |
sizes:{ | |
minH: secret.height() | |
} | |
}); | |
} | |
$.get(url, function(data) { | |
secret.html(data); | |
// почистим пустые параграфы | |
secret.find('p').each(function() { | |
var self = $(this); | |
if(self.html().replace(/\s| /g, '').length == 0) | |
self.remove(); | |
}); | |
secret.find('img').each(function() { | |
loadTotal++; | |
}); | |
if(loadTotal > 0) | |
secret.find('img').each(function() { | |
$(this).load(function(){ | |
loadNow++; | |
if(loadNow >= loadTotal) { | |
loadWindow(); | |
} | |
}); | |
}); | |
else | |
loadWindow(); | |
}); | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment