1(function($) { 2 window.thegemBlogImagesLoaded = function($box, image_selector, callback) { 3 function check_image_loaded(img) { 4 return img.getAttribute('loading') === 'lazy' || img.getAttribute('src') === '' || (img.complete && img.naturalWidth !== undefined && img.naturalWidth !== 0); 5 } 6 7 var $images = $(image_selector, $box).filter(function() { 8 return !check_image_loaded(this); 9 }), 10 images_count = $images.length; 11 12 if (images_count == 0) { 13 return callback(); 14 } 15 16 if (window.gemBrowser.name == 'ie' && !isNaN(parseInt(window.gemBrowser.version)) && parseInt(window.gemBrowser.version) <= 10) { 17 function image_load_event() { 18 images_count--; 19 if (images_count == 0) { 20 callback(); 21 } 22 } 23 24 $images.each(function() { 25 if (check_image_loaded(this)) { 26 return; 27 } 28 29 var proxyImage = new Image(); 30 proxyImage.addEventListener( 'load', image_load_event ); 31 proxyImage.addEventListener( 'error', image_load_event ); 32 proxyImage.src = this.src; 33 }); 34 return; 35 } 36 37 $images.on('load error', function() { 38 images_count--; 39 if (images_count == 0) { 40 callback(); 41 } 42 }); 43 } 44 45 window.thegemInitBlogScrollNextPage = function($blog, $pagination) { 46 if (!$pagination.length) { 47 return false; 48 } 49 50 var watcher = scrollMonitor.create($pagination[0]); 51 watcher.enterViewport(function() { 52 window.thegemBlogLoadMoreRequest($blog, $pagination, true); 53 }); 54 } 55 56 function finishAjaxRequestActions($blog, $inserted_data, is_scroll, $pagination, next_page, $loading_marker) { 57 if (window.wp !== undefined && window.wp.mediaelement !== undefined) { 58 window.wp.mediaelement.initialize(); 59 } 60 $blog.itemsAnimations('instance').show($inserted_data); 61 62 if ($blog.hasClass('blog-style-justified-2x') || $blog.hasClass('blog-style-justified-3x') || $blog.hasClass('blog-style-justified-4x') || $blog.hasClass('blog-style-justified-100')) { 63 window.thegemBlogImagesLoaded($blog, 'article img', function() { 64 window.thegemBlogOneSizeArticles($blog); 65 }); 66 } 67 68 if (!$blog.hasClass('pagination-normal')) { 69 if (is_scroll) { 70 $pagination.removeClass('active').html(''); 71 } else { 72 $loading_marker.remove(); 73 if (next_page == 0) { 74 $pagination.hide(); 75 } 76 } 77 } 78 $blog 79 .data('request-process', false) 80 .data('next-page', next_page); 81 } 82 83 window.thegemBlogLoadMoreRequest = function($blog, $pagination, is_scroll) { 84 var data = thegem_blog_ajax; 85 86 var is_processing_request = $blog.data('request-process') || false; 87 if (is_processing_request) { 88 return false; 89 } 90 91 var paged = $blog.data('next-page'); 92 if (paged == null || paged == undefined) { 93 paged = 1; 94 } 95 if (paged == 0) { 96 return false; 97 } 98 99 if (typeof data['data'] == 'string') { 100 data['data'] = JSON.parse(data['data']); 101 } 102 data['data']['paged'] = paged; 103 data['action'] = $blog.data('load-more-action') ? $blog.data('load-more-action') : 'blog_load_more'; 104 if ( data['action'] === 'thegem_bloggrid_load_more' || data['action'] === 'thegem_bloglist_load_more' || data['action'] === 'thegem_blogtimeline_load_more') { 105 data['data'] = JSON.stringify(data['data']); 106 } 107 $blog.data('request-process', true); 108 if ($blog.hasClass('pagination-normal')) { 109 $blog.prepend('<div class="preloader-spin-new"></div>'); 110 } else if (is_scroll) { 111 $pagination.addClass('active').html('<div class="loading"><div class="preloader-spin"></div></div>'); 112 } else { 113 var $loading_marker = $('<div class="loading"><div class="preloader-spin"></div></div>'); 114 $('.gem-button-container', $pagination).before($loading_marker); 115 } 116 117 $.ajax({ 118 type: 'post', 119 dataType: 'json', 120 url: thegem_blog_ajax.url, 121 data: data, 122 success: function(response) { 123 if (response.status == 'success') { 124 var $newItems = $(response.html), 125 $inserted_data = $($newItems.html()), 126 current_page = $newItems.data('page'), 127 next_page = $newItems.data('next-page'); 128 129 if ($blog.hasClass('pagination-normal')) { 130 $blog.html($inserted_data); 131 finishAjaxRequestActions($blog, $inserted_data, is_scroll, $pagination, next_page, $loading_marker); 132 } else if ($blog.hasClass('blog-style-masonry') || $blog.hasClass('blog-style-timeline_new')) { 133 window.thegemBlogImagesLoaded($newItems, 'article img', function() { 134 $blog.thegem_isotope('insert', $newItems); 135 finishAjaxRequestActions($blog, $inserted_data, is_scroll, $pagination, next_page, $loading_marker); 136 });
137 } else { 138 $blog.append($inserted_data); 139 finishAjaxRequestActions($blog, $inserted_data, is_scroll, $pagination, next_page, $loading_marker); 140 } 141 $blog.initBlogFancybox(); 142 window.thegemUpdateLikesIcons($blog); 143 } else { 144 alert(response.message); 145 } 146 } 147 }); 148 } 149 150 window.thegemBlogOneSizeArticles = function($blog){ 151 var elements = {}; 152 $("article", $blog).css('height', ''); 153 $("article", $blog).each(function(i, e){ 154 var transform = $(this).css('transform'); 155 var translateY = 0; 156 157 if (transform != undefined && transform != 'none') { 158 translateY = parseFloat(transform.substr(1, transform.length - 2).split(',')[5]); 159 if (isNaN(translateY)) { 160 translateY = 0; 161 } 162 } 163 164 var elPosition = parseInt($(this).position().top - translateY); 165 var elHeight = $(this).height(); 166 167 if(elements[elPosition] == undefined){ 168 elements[elPosition] = {'array':[$(this)], 'maxHeight':elHeight}; 169 } else { 170 elements[elPosition]['array'].push($(this)); 171 if(elements[elPosition]['maxHeight'] < elHeight){ 172 elements[elPosition]['maxHeight'] = elHeight; 173 } 174 } 175 }); 176 $.each(elements, function(i, e){ 177 var item = this; 178 $.each(item.array, function(){ 179 $(this).height(item.maxHeight); 180 }); 181 }); 182 } 183 184 window.thegemUpdateLikesIcons = function($blog) { 185 $blog.find('.post-meta-likes').each(function () { 186 if ($(this).find('i').length) { 187 if (!$(this).find('a').children('i').length) { 188 var icon = $(this).children('i'); 189 $(this).find('a').prepend(icon); 190 } 191 } else if ($(this).find('svg').length) { 192 if (!$(this).find('a').children('svg').length) { 193 var icon_svg = $(this).children('svg'); 194 $(this).find('a').prepend(icon_svg); 195 } 196 } 197 }); 198 } 199 200})(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.