( function( $ ) { "use strict"; $( function() { $('body').on('click', '.post-next-lightbox, .post-prev-lightbox', function(){ var post_id = $(this).data('post-id'); if($('.item-isotope article#post-'+ post_id +' .entry-title a').length){ $('.item-isotope article#post-'+ post_id +' .entry-title a').first().click(); }else{ $('.item-isotope article#post-'+ post_id +' figure').first().click(); } return false; }); $('body').on('click', '.lightbox-post-shadow, .close-lightbox-post', function(){ $('.lightbox-post-w').remove(); $('.lightbox-post-shadow').remove(); $('.close-lightbox-post').remove(); $('.post-prev-lightbox, .post-next-lightbox').remove(); }); $('.lightbox-tiles').on('click', '.post-content-body .post-content, .entry-title a, .figure-link, .read-more-link a', function(){ if(!$('.lightbox-post-shadow').length){ $('body').append('
'); } $('.post-next-lightbox, .post-prev-lightbox, .lightbox-post-w').removeClass('make-visible'); $('.lightbox-tiles .item-isotope').removeClass('loading-now'); var $current_tile = $(this).closest('.item-isotope'); var $next_tile = $current_tile.nextAll('.item-isotope:not(.magic-item-w):first'); var $prev_tile = $current_tile.prevAll('.item-isotope:not(.magic-item-w):first'); var post_id = $current_tile.find('article').first().attr('id'); post_id = post_id.replace('post-', ''); $current_tile.addClass('loading-now'); $.ajax({ type: 'POST', url: ajaxurl, data: { "action": "pluto_post_lightbox_process_request", "post_id" : post_id }, dataType: "json", success: function(data){ $('.lightbox-tiles .item-isotope').removeClass('loading-now'); $('.main-search-form form').removeClass('search-loading'); $('.lightbox-post-w').remove(); $('.post-next-lightbox, .post-prev-lightbox').remove(); if(data.status == 200){ $('body').append(data.message); $('.lightbox-post-i .flexslider').flexslider({ animation : "slide" }); $('.close-lightbox-post').fadeIn(300); // INIT NEW FACEBOOK LIKE BUTTONS if($('.lightbox-post-i .meta-like .fb-like').length){ try{ FB.XFBML.parse(); }catch(ex){} } // INIT NEW PINTEREST PIN BUTTONS if($('.lightbox-post-i .meta-like a[data-pin-do="buttonPin"]').length){ try{ window.parsePinBtns(); }catch(ex){} } if($prev_tile.length){ var prev_tile_post_id = $prev_tile.find('article').first().attr('id').replace('post-', ''); var prev_tile_title = $prev_tile.find('.entry-title a').text(); if(!prev_tile_title){ prev_tile_title = $prev_tile.find('.archive-item-media-thumbnail').data('lightbox-caption'); } if($prev_tile.find('figure.abs-image img').length){ var prev_tile_featured_image_url = $prev_tile.find('figure.abs-image img').attr('src'); }else if($prev_tile.find('figure.abs-slider li:first img').length){ var prev_tile_featured_image_url = $prev_tile.find('figure.abs-slider li:first img').attr('src'); }else if($prev_tile.find('.post-video-box').length){ var prev_tile_featured_image_url = $prev_tile.find('.post-video-box').data('featured-image-url'); } $('body').append('