1"use strict"; 2 3// ------------------------------------------------------------------------------------------- 4// Post Grid 5// ------------------------------------------------------------------------------------------- 6(function ($) { 7 "use strict"; 8 9 $.fn.epPostsGrid = function (options) { 10 //return if we didnt find anything 11 if (!this.length) return this; 12 var methods = { 13 show_bricks: function show_bricks(bricks, callback, newlyLoaded) { 14 bricks.each(function (brick) { 15 var currentLink = $(this); 16 17 if (newlyLoaded) { 18 currentLink.addClass('newly-loaded'); 19 } else { 20 currentLink.addClass('already-loaded'); 21 } 22 23 setTimeout(function () { 24 if (brick == bricks.length - 1 && typeof callback == 'function') { 25 callback.call(); 26 } 27 }, 100); 28 }); 29 }, 30 loadMore: function loadMore(e) { 31 e.preventDefault(); 32 var current = $(this), 33 currentLabel = current.find(".avia_iconbox_title"), 34 masonry = current.parent().prev('.ep-posts-load-more'), 35 aSingleColumn = masonry.children(".entry").first().outerHeight(), 36 scrollTopValue = masonry.offset().top + masonry.outerHeight() - aSingleColumn - 80, 37 // dynamically update this 38 data = current.data(); //calculate a new offset 39 40 if (!data.offset) data.offset = 0; 41 data.offset += data.items; 42 data.action = 'ep_post_grid_more'; 43 currentLabel.text(current.data('loadingLabel')); 44 $.ajax({ 45 url: avia_framework_globals.ajaxurl, 46 type: "POST", 47 data: data, 48 success: function success(response) { 49 $('html, body').animate({ 50 scrollTop: scrollTopValue 51 }, 50); 52 currentLabel.text(current.data('buttonLabel')); 53 54 if (response.indexOf("{post-grid-loaded}") !== -1) { 55 //fetch the response. if any php warnings were displayed before rendering of the items the are removed by the string split 56 var response = response.split('{post-grid-loaded}'), 57 new_items = $(response.pop()).filter('.entry'); //check if we got more items than we need. if not we have reached the end of items 58 59 if (new_items.length > data.items) { 60 new_items = new_items.not(':last'); 61 } else { 62 current.addClass('ep-no-more-items'); 63 } 64 65 masonry.append(new_items); 66 setTimeout(function () { 67 methods.show_bricks(new_items, false, true); 68 }, 50); 69 } 70 } 71 }); 72 } 73 }; 74 return this.each(function () { 75 var grid = $(this), 76 container = $(this).parent(), 77 bricks = grid.find('> *'), 78 load_more = container.find('.ajax-load-more').css({ 79 visibility: "visible", 80 opacity: 0 81 }); 82 methods.show_bricks(bricks, function () { 83 load_more.css({ 84 opacity: 1 85 }).on('click', methods.loadMore); 86 }, false); 87 }); 88 }; 89})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.