! function($, undefined) { $(function() { // fancy loading effects var $delay = 150; var $speed = 0; $('.instagram-container .image-container').each(function(i, e) { setTimeout(function() { $(e).css({opacity: 1}); }, ($delay * i)); }); // click on image actions $('.instagram-container').on('click', '.image-container', function() { // Open it in a new tab window.open( $(this).attr("id"), '_blank').focus(); }); // stop close modal on inner element clicks $('.modal-content').on('click', '.image-container', function(e){ e.stopPropagation(); e.stopImmediatePropagation(); }); // close modal $('.modal-container .modal-close, .modal-container, .modal-content').click(function(e) { $('.modal-container').fadeOut('fast'); $('html').css({ 'overflow-y': 'auto'}); }); // load more $('.load-more').click(function() { $.ajax( { cache: false, type: 'get', url: 'instagram.php?next_url='+escape($(this).data('url')), success: function(response) { var $res = $(response); $res.filter('.instagram-container').find('.image-container').addClass('hidden').appendTo('.instagram-container'); $('.instagram-container .image-container.hidden').each(function(i, e) { setTimeout(function() { $(e).css({opacity: 1}); }, ($delay * i)); }); $res.filter('.large-instagram-container').find('.image-container').appendTo('.large-instagram-container'); if ( $res.find('.load-more').length ) { $('.load-more').data('url', $res.find('.load-more').data('url')); } else { $('.load-more').remove(); } } }); }); }); }(jQuery);