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 $inserted_data.buildSimpleGalleries(); 58 $inserted_data.updateSimpleGalleries(); 59 if (window.wp !== undefined && window.wp.mediaelement !== undefined) { 60 window.wp.mediaelement.initialize(); 61 } 62 $blog.itemsAnimations('instance').show($inserted_data); 63 64 if ($blog.hasClass('blog-style-justified-2x') || $blog.hasClass('blog-style-justified-3x') || $blog.hasClass('blog-style-justified-4x')) { 65 window.thegemBlogImagesLoaded($blog, 'article img', function() { 66 window.thegemBlogOneSizeArticles($blog); 67 }); 68 } 69 70 if (!$blog.hasClass('pagination-normal')) { 71 if (is_scroll) { 72 $pagination.removeClass('active').html(''); 73 } else { 74 $loading_marker.remove(); 75 if (next_page == 0) { 76 $pagination.hide(); 77 } 78 } 79 } 80 $blog 81 .data('request-process', false) 82 .data('next-page', next_page); 83 } 84 85 window.thegemBlogLoadMoreRequest = function($blog, $pagination, is_scroll) { 86 var widget_settings_id = $blog.data('style-uid') ? $blog.data('style-uid') : ''; 87 var data = $.extend(true, {}, window['thegem_blog_ajax_' + widget_settings_id]); 88 if ($.isEmptyObject(data)) { 89 data = $.extend(true, {}, window['thegem_blog_ajax']); 90 } 91 92 var is_processing_request = $blog.data('request-process') || false; 93 if (is_processing_request) { 94 return false; 95 } 96 97 var paged = $blog.data('next-page'); 98 if (paged == null || paged == undefined) { 99 paged = 1; 100 } 101 if (paged == 0) { 102 return false; 103 } 104 105 data['data']['paged'] = paged; 106 data['action'] = 'blog_load_more'; 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: data.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', $inserted_data); 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 } else { 143 alert(response.message); 144 } 145 } 146 }); 147 } 148 149 window.thegemBlogOneSizeArticles = function($blog){ 150 var elements = {}; 151 $("article", $blog).css('height', ''); 152 $("article", $blog).each(function(i, e){ 153 var transform = $(this).css('transform'); 154 var translateY = 0; 155 156 if (transform != undefined && transform != 'none') { 157 translateY = parseFloat(transform.substr(1, transform.length - 2).split(',')[5]); 158 if (isNaN(translateY)) { 159 translateY = 0; 160 } 161 } 162 163 var elPosition = parseInt($(this).position().top - translateY); 164 var elHeight = $(this).height(); 165 166 if(elements[elPosition] == undefined){ 167 elements[elPosition] = {'array':[$(this)], 'maxHeight':elHeight}; 168 } else { 169 elements[elPosition]['array'].push($(this)); 170 if(elements[elPosition]['maxHeight'] < elHeight){ 171 elements[elPosition]['maxHeight'] = elHeight; 172 } 173 } 174 }); 175 $.each(elements, function(i, e){ 176 var item = this; 177 $.each(item.array, function(){ 178 $(this).height(item.maxHeight); 179 }); 180 }); 181 } 182 183})(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.