1/* eslint-disable no-undef */ 2(function($) { 3 4 FLBuilderPostGrid = function(settings) 5 { 6 this.settings = settings; 7 this.nodeClass = '.fl-node-' + settings.id; 8 this.matchHeight = settings.matchHeight; 9 10 if ( 'columns' == this.settings.layout ) { 11 this.wrapperClass = this.nodeClass + ' .fl-post-grid'; 12 this.postClass = this.nodeClass + ' .fl-post-column'; 13 } 14 else { 15 this.wrapperClass = this.nodeClass + ' .fl-post-' + this.settings.layout; 16 this.postClass = this.wrapperClass + '-post'; 17 } 18 19 if(this._hasPosts()) { 20 this._initLayout(); 21 this._initInfiniteScroll(); 22 } 23 }; 24 25 FLBuilderPostGrid.prototype = { 26 27 settings : {}, 28 nodeClass : '', 29 wrapperClass : '', 30 postClass : '', 31 gallery : null, 32 currPage : 1, 33 totalPages : 1, 34 35 _hasPosts: function() 36 { 37 return $(this.postClass).length > 0; 38 }, 39 40 _initLayout: function() 41 { 42 switch(this.settings.layout) { 43 44 case 'columns': 45 this._columnsLayout(); 46 break; 47 48 case 'grid': 49 this._gridLayout(); 50 break; 51 52 case 'gallery': 53 this._galleryLayout(); 54 break; 55 } 56 57 $(this.postClass).css('visibility', 'visible'); 58 59 FLBuilderLayout._scrollToElement( $( this.nodeClass + ' .fl-paged-scroll-to' ) ); 60 }, 61 62 _columnsLayout: function() 63 { 64 $(this.wrapperClass).imagesLoaded( $.proxy( function() { 65 this._gridLayoutMatchHeight(); 66 }, this ) ); 67 68 $( window ).on( 'resize', $.proxy( function(){ 69 $(this.wrapperClass).imagesLoaded( $.proxy( function() { 70 this._gridLayoutMatchHeight(); 71 }, this ) ); 72 }, this ) ); 73 }, 74 75 _gridLayout: function() 76 { 77 var wrap = $(this.wrapperClass); 78 79 wrap.masonry({ 80 columnWidth : this.nodeClass + ' .fl-post-grid-sizer', 81 gutter : parseInt(this.settings.postSpacing), 82 isFitWidth : true, 83 itemSelector : this.postClass, 84 transitionDuration : 0, 85 isRTL : this.settings.isRTL 86 }); 87 88 wrap.imagesLoaded( $.proxy( function() { 89 this._gridLayoutMatchHeight(); 90 wrap.masonry(); 91 }, this ) ); 92 93 $(window).scroll($.debounce( 25, function(){ 94 wrap.masonry() 95 })); 96 97 }, 98 99 _gridLayoutMatchHeight: function() 100 { 101 var highestBox = 0; 102 103 if ( ! this._isMatchHeight() ) { 104 $(this.nodeClass + ' .fl-post-grid-post').css('height', ''); 105 return; 106 } 107 108 $(this.nodeClass + ' .fl-post-grid-post').css('height', '').each(function(){ 109 110 if($(this).height() > highestBox) { 111 highestBox = $(this).height(); 112 } 113 }); 114 115 $(this.nodeClass + ' .fl-post-grid-post').height(highestBox); 116 }, 117 118 _isMatchHeight: function(){ 119 var width = $( window ).width(), 120 breakpoints = FLBuilderLayoutConfig.breakpoints, 121 matchLarge = '' != this.matchHeight.large ? this.matchHeight.large : this.matchHeight.default, 122 matchMedium = '' != this.matchHeight.medium ? this.matchHeight.medium : this.matchHeight.default, 123 matchSmall = '' != this.matchHeight.responsive ? this.matchHeight.responsive : this.matchHeight.default; 124 125 return (width > breakpoints.medium && 1 == this.matchHeight.default) // Must check medium here for backwards compat 126 || (width > breakpoints.medium && width <= breakpoints.large && 1 == matchLarge) 127 || (width > breakpoints.small && width <= breakpoints.medium && 1 == matchMedium) 128 || (width <= breakpoints.small && 1 == matchSmall); 129 }, 130 131 _galleryLayout: function() 132 { 133 this.gallery = new FLBuilderGalleryGrid({ 134 'wrapSelector' : this.wrapperClass, 135 'itemSelector' : '.fl-post-gallery-post', 136 'isRTL' : this.settings.isRTL 137 }); 138 }, 139 140 _initInfiniteScroll: function() 141 { 142 var isScroll = 'scroll' == this.settings.pagination || 'load_more' == this.settings.pagination, 143 pages = $( this.nodeClass + ' .fl-builder-pagination' ).find( 'li .page-numbers:not(.next)' ); 144 145 if( pages.length > 1) { 146 total = pages.last().text().replace( /\D/g, '' ) 147 this.totalPages = parseInt( total ); 148 } 149 150 if( isScroll && this.totalPages > 1 && 'undefined' === typeof FLBuilder ) { 151 this._infiniteScroll(); 152 153 if( 'load_more' == this.settings.pagination ) { 154 this._infiniteScrollLoadMore(); 155 } 156 } 157 }, 158 159 _infiniteScroll: function() 160 {
161 var path = $(this.nodeClass + ' .fl-builder-pagination a.next').attr('href'), 162 pagePattern = /(.*?(\/|&|\?)paged-[0-9]{1,}(\/|=))([0-9]{1,})+(.*)/, 163 wpPattern = /^(.*?\/?page\/?)(?:\d+)(.*?$)/, 164 pageMatched = null, 165 scrollData = { 166 navSelector : this.nodeClass + ' .fl-builder-pagination', 167 nextSelector : this.nodeClass + ' .fl-builder-pagination a.next', 168 itemSelector : this.postClass, 169 prefill : true, 170 bufferPx : 200, 171 loading : { 172 msgText : this.settings.loadingText, 173 finishedMsg : '', 174 img : FLBuilderLayoutConfig.paths.pluginUrl + 'img/ajax-loader-grey.gif', 175 speed : 1 176 } 177 }; 178 // Define path since Infinitescroll incremented our custom pagination '/paged-2/2/' to '/paged-3/2/'. 179 if ( pagePattern.test( path ) ) { 180 scrollData.path = function( currPage ){ 181 pageMatched = path.match( pagePattern ); 182 path = pageMatched[1] + currPage + pageMatched[5]; 183 return path; 184 } 185 } 186 else if ( wpPattern.test( path ) ) { 187 scrollData.path = path.match( wpPattern ).slice( 1 ); 188 } 189 190 $(this.postClass).first().parent().infinitescroll( scrollData, $.proxy(this._infiniteScrollComplete, this) ); 191 192 setTimeout(function(){ 193 $(window).trigger('resize'); 194 }, 100); 195 }, 196 197 _infiniteScrollComplete: function(elements) 198 { 199 var wrap = $(this.wrapperClass); 200 201 elements = $(elements); 202 203 if(this.settings.layout == 'columns') { 204 wrap.imagesLoaded( $.proxy( function() { 205 $( '#infscr-loading' ).remove(); 206 this._gridLayoutMatchHeight(); 207 elements.css('visibility', 'visible'); 208 }, this ) ); 209 } 210 else if(this.settings.layout == 'grid') { 211 wrap.imagesLoaded( $.proxy( function() { 212 this._gridLayoutMatchHeight(); 213 wrap.masonry('appended', elements); 214 wrap.masonry(); 215 elements.css('visibility', 'visible'); 216 }, this ) ); 217 } 218 else if(this.settings.layout == 'gallery') { 219 this.gallery.resize(); 220 elements.css('visibility', 'visible'); 221 } 222 223 if( 'load_more' == this.settings.pagination ) { 224 $( this.wrapperClass + ' .fl-post-grid-sizer.masonry-brick' ).appendTo( this.wrapperClass ); 225 $( '#infscr-loading' ).appendTo( this.wrapperClass ); 226 } 227 228 this.currPage++; 229 230 this._removeLoadMoreButton(); 231 232 // trigger an event 233 node = $(wrap).closest('.fl-module-post-grid').data('node') 234 $('.fl-node-' + node).trigger( 'gridScrollComplete', this ); 235 }, 236 237 _infiniteScrollLoadMore: function() 238 { 239 var wrap = $( this.postClass ).first().parent(); 240 241 $( window ).unbind( '.infscr' ); 242 243 $(this.nodeClass + ' .fl-builder-pagination-load-more .fl-button').on( 'click', function(){ 244 if( $( '#infscr-loading' ).length ) { 245 $( '#infscr-loading' ).remove(); 246 } 247 248 wrap.infinitescroll( 'retrieve' ); 249 return false; 250 }); 251 }, 252 253 _removeLoadMoreButton: function() 254 { 255 if ( 'load_more' == this.settings.pagination && this.totalPages == this.currPage ) { 256 $( this.nodeClass + ' .fl-builder-pagination-load-more' ).remove(); 257 } 258 } 259 }; 260 261})(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.