PageSourceSearch

https://prettylittleshoppers.com/wp-content/plugins/grid-kit-premium/js/crp-layer.js?ver=7.0.6

js prettylittleshoppers.com collected 2026-10-04 13:24:46 UTC 29,997 bytes, 772 lines download raw bytes

1
2//NOTE: Update CRPViewType definitions in gkit-configs.php too
3CRPTiledLayerType = {};
4CRPTiledLayerType.Unknown = 0;
5CRPTiledLayerType.Puzzle = 1;
6CRPTiledLayerType.Masonry = 2;
7CRPTiledLayerType.Square = 3;
8CRPTiledLayerType.Reserved1 = 4;
9CRPTiledLayerType.Reserved2 = 5;
10CRPTiledLayerType.TestLayout = 6;
11CRPTiledLayerType.SliderGeneral = 7;
12CRPTiledLayerType.SliderCarousel = 8;
13CRPTiledLayerType.TiledStyle1 = 11;
14CRPTiledLayerType.TiledStyle2 = 12;
15CRPTiledLayerType.TiledStyle3 = 13;
16CRPTiledLayerType.TiledStyle4 = 14;
17CRPTiledLayerType.TiledStyle5 = 15;
18CRPTiledLayerType.TiledStyle6 = 16;
19CRPTiledLayerType.TiledStyle7 = 17;
20CRPTiledLayerType.TiledStyle8 = 18;
21CRPTiledLayerType.TiledStyle9 = 19;
22CRPTiledLayerType.TiledStyle10 = 20;
23
24CRPTiledLayerType.isTiled = function(type) {
25  if (type == CRPTiledLayerType.Puzzle ||
26      type == CRPTiledLayerType.TiledStyle1 ||
27      type == CRPTiledLayerType.TiledStyle2 ||
28      type == CRPTiledLayerType.TiledStyle3 ||
29      type == CRPTiledLayerType.TiledStyle4 ||
30      type == CRPTiledLayerType.TiledStyle5 ||
31      type == CRPTiledLayerType.TiledStyle6 ||
32      type == CRPTiledLayerType.TiledStyle7 ||
33      type == CRPTiledLayerType.TiledStyle8 ||
34      type == CRPTiledLayerType.TiledStyle9 ||
35      type == CRPTiledLayerType.TiledStyle10 ){
36    return true;
37  }
38}
39
40CRPTiledLayerType.style = function(type) {
41
42  if (type == CRPTiledLayerType.Puzzle ) {
43    return CRPLayerStyle.style(CRPLayerStyle.kStylePuzzle);
44  } else if( type == CRPTiledLayerType.TiledStyle1 ) {
45    return CRPLayerStyle.style(CRPLayerStyle.kStyle1);
46  } else if( type == CRPTiledLayerType.TiledStyle2 ) {
47    return CRPLayerStyle.style(CRPLayerStyle.kStyle2);
48  } else if( type == CRPTiledLayerType.TiledStyle3 ) {
49    return CRPLayerStyle.style(CRPLayerStyle.kStyle3);
50  } else if( type == CRPTiledLayerType.TiledStyle4 ) {
51    return CRPLayerStyle.style(CRPLayerStyle.kStyle4);
52  } else if( type == CRPTiledLayerType.TiledStyle5 ) {
53    return CRPLayerStyle.style(CRPLayerStyle.kStyle5);
54  } else if( type == CRPTiledLayerType.TiledStyle6 ) {
55    return CRPLayerStyle.style(CRPLayerStyle.kStyle6);
56  } else if( type == CRPTiledLayerType.TiledStyle7 ) {
57    return CRPLayerStyle.style(CRPLayerStyle.kStyle7);
58  } else if( type == CRPTiledLayerType.TiledStyle8 ) {
59    return CRPLayerStyle.style(CRPLayerStyle.kStyle8);
60  } else if( type == CRPTiledLayerType.TiledStyle9 ) {
61    return CRPLayerStyle.style(CRPLayerStyle.kStyle9);
62  } else if( type == CRPTiledLayerType.TiledStyle10 ) {
63    return CRPLayerStyle.style(CRPLayerStyle.kStyle10);
64  }
65
66  return CRPLayerStyle.style(CRPLayerStyle.kStyle1);
67}
68
69CRPLayerStyle = {};
70CRPLayerStyle.kStylePuzzle = "stylePuzzle";
71CRPLayerStyle.kStyle1 = "style1";
72CRPLayerStyle.kStyle2 = "style2";
73CRPLayerStyle.kStyle3 = "style3";
74CRPLayerStyle.kStyle4 = "style4";
75CRPLayerStyle.kStyle5 = "style5";
76CRPLayerStyle.kStyle6 = "style6";
77CRPLayerStyle.kStyle7 = "style7";
78CRPLayerStyle.kStyle8 = "style8";
79CRPLayerStyle.kStyle9 = "style9";
80CRPLayerStyle.kStyle10 = "style10";
81
82CRPLayerStyle.style = function(key) {
83  return CRPLayerStyleConf[key];
84}
85CRPLayerStyleConf = {};
86
87
88CRPColumnCalcAlgo = {};
89CRPColumnCalcAlgo.Fixed = 'Fixed';
90CRPColumnCalcAlgo.Dynamic = 'Dynamic';
91
92CRPIdx = 1;
93
94(function ($) {
95    $.crpTiledLayer = function (element, options) {
96        if(options.approxTileWidth < options.minTileWidth){
97            options.approxTileWidth = options.minTileWidth;
98        }
99
100        var Slot = function (width, height) {
101            this.position = { x: 0, y: 0 };
102            this.blocks = { h: width, v: height };
103            this.size = { width: this.blocks.h, height: this.blocks.v };
104            this.px = { width: width, height: height };
105            this.edge_right = false;
106
107        }
108
109        Slot.prototype.resize = function (blocks, onlyWidth) {
110            //nw : nh = w : h => nh = nw * h / w
111            var new_width = blocks;
112            var new_height = (new_width * this.px.height) / this.px.width;
113            var bv = this.blocks.v;
114            this.blocks.h = blocks;
115            if(!onlyWidth && plugin.settings.layoutType != CRPTiledLayerType.Square)
116                this.blocks.v = new_height;
117        }
118
119        var Grid = function (margin, min_tile_width, width) {
120            this.slots = [];
121            this.cells = [];
122            this.margin = margin;
123            this.min_tile_width = min_tile_width;
124            this.width = width;
125            this.hor_size = width;
126            this.init();
127        }
128
129        Grid.prototype.init = function () {
130            this.slots.length = 0;
131            this.cells.length = 0;
132            for (var i = 0; i < this.hor_size * 1000; i++) {
133                this.cells[i] = 0;
134            }
135        }
136
137        Grid.prototype.add_slot = function (slot) {
138            for (var j = 0; j < slot.blocks.v; j++) {
139                for (var i = 0; i < slot.blocks.h; i++) {
140                    var row = slot.position.y + j;
141                    var column = slot.position.x + i;
142                    //if (this.cells.length < row * this.hor_size + column)
143
144                    this.cells[row * this.hor_size + column] = 1;
145                    this.cells.push(0);
146                }
147            }
148
149            this.slots.push(slot);
150        }
151
152        Grid.prototype.count_free_cells_on_right = function (index) {
153            var line = Math.floor(index / this.hor_size);
154            var line_end = (line + 1) * this.hor_size;
155
156            var length = 0;
157
158            for (; index < line_end; index++, length++) {
159                if (this.cells[index] == 1) {
160                    break;
161                }
162            }
163
164            return length;
165        }
166
167        Grid.prototype.insert = function (width, height, allowEnlargement, tile) {
168            /* Hack for square and masonry styles */
169            var sW = width;
170            var sH = height;
171
172            if(plugin.settings.layoutType == CRPTiledLayerType.Masonry || plugin.settings.layoutType == CRPTiledLayerType.Square){
173                var _wrapperWidth = $element.width() + plugin.settings.margin;
174                var _slotWidth;
175
176                if (plugin.settings.columnCalcAlgo == CRPColumnCalcAlgo.Fixed) {
177                    var customW = 0;
178                    var windowW = jQuery(window).width();
179
180                    if (windowW > plugin.settings.screenSizes.kDesktopMaxWidth) { // large desktop
181                        customW = _wrapperWidth / plugin.settings.screenSizes.lgDesktopCols;
182                    } else if (windowW >= plugin.settings.screenSizes.kDesktopMinWidth) { //desktop
183                        customW = _wrapperWidth / plugin.settings.screenSizes.desktopCols;
184                    } else if (windowW > plugin.settings.screenSizes.kMobileMaxWidth) { //tablet
185                        customW = _wrapperWidth / plugin.settings.screenSizes.tabletCols;
186                    } else{ //mobile
187                        customW = _wrapperWidth / plugin.settings.screenSizes.mobileCols;
188                    }
189                    _slotWidth = customW;
190                } else {
191                    _slotWidth = plugin.settings.approxTileWidth + plugin.settings.margin;
192                }
193
194                if(_slotWidth > _wrapperWidth - plugin.settings.margin){
195                    _slotWidth = _wrapperWidth - plugin.settings.margin;
196                }
197                var _itemsPerRow = parseInt( _wrapperWidth / _slotWidth );
198                var _delta = _wrapperWidth - _itemsPerRow * _slotWidth;
199                var _deltaPerCell = _delta / _itemsPerRow;
200                _slotWidth += _deltaPerCell;
201                _slotWidth = Math.ceil(_slotWidth);
202
203                sW = _slotWidth;
204
205                var _ratio;
206                if(plugin.settings.layoutType == CRPTiledLayerType.Masonry){
207                    _ratio = height / width;
208                } else {
209                  if (typeof plugin.settings.kTileRatio != 'undefined') {
210
211                      var parts = plugin.settings.kTileRatio.split('x');
212                       _ratio = parts[0] / parts[1];
213                  } else {
214
215                      if (plugin.settings.columnCalcAlgo == CRPColumnCalcAlgo.Fixed) {
216                          _ratio = plugin.settings.approxTileHeight / sW;
217                      } else {
218                          _ratio = plugin.settings.approxTileHeight / plugin.settings.approxTileWidth;
219                      }
220                  }
221                }
222
223                sH = Math.ceil(sW * _ratio);
224            } else {
225                if (GKIT_PKG_TYPE == GKIT_PKG_TYPE_PREMIUM) {
226                  var ratios = gkitLayoutStyleRatios(styleConf, plugin, $element.width() + plugin.settings.margin, jQuery(window).width());
227                  var ratio = ratios[ratioIndex++];
228                  if (ratioIndex > ratios.length -1) {
229                      ratioIndex = 0;
230                  }
231
232                  var step = gkitLayoutTileStep(styleConf, plugin, $element.width() + plugin.settings.margin, jQuery(window).width());
233                  sW = ratio.w * step;
234                  sH = ratio.h * step;
235                } else {
236                  gkitConsoleLog("Unsupported layout type!");
237                }
238
239           }
240
241            // This snippet of code is for not fixed addblock1 and 2
242            if (plugin.settings.freeAddBlocks == true) {
243                var tmp = '<div id="crp-tmp1-' + CRPIdx + '" style="visibility:hidden;width: ' + (sW - plugin.settings.margin) + 'px;">' + jQuery(".crp-additional-block1", tile).html() + '</div>';
244                jQuery('body').append(tmp);
245                plugin.settings.addBlock1Height = jQuery('#crp-tmp1-' + CRPIdx).height();
246                jQuery('#crp-tmp1-' + CRPIdx).remove();
247
248                var tmp = '<div id="crp-tmp2-' + CRPIdx + '" style="visibility:hidden;width: ' + (sW - plugin.settings.margin) + 'px;">' + jQuery(".crp-additional-block2", tile).html() + '</div>';
249                jQuery('body').append(tmp);
250                plugin.settings.addBlock2Height = jQuery('#crp-tmp2-' + CRPIdx).height();
251                jQuery('#crp-tmp2-' + CRPIdx).remove();
252
253                CRPIdx++;
254            }
255
256            var newsH = sH;
257            if (plugin.settings.addBlock1Height != false) {
258                newsH += plugin.settings.addBlock1Height;
259            }
260            if (plugin.settings.addBlock2Height != false) {
261                newsH += plugin.settings.addBlock2Height;
262            }
263            var slot = new Slot(sW, newsH);
264            var av_blocks = 0;
265            var free_cell = 0;
266            var line = 0;
267            if (this.slots.length == 0) {
268                av_blocks = this.hor_size;
269                slot.position.x = 0;
270                slot.position.y = 0;
271            } else {
272
273                //find first available cell
274                var exit = false;
275                for (; free_cell < this.cells.length; free_cell++) {
276                    if (this.cells[free_cell] == 0) {
277
278                        line = Math.floor(free_cell / this.hor_size);
279                        var line_end = (line + 1) * this.hor_size;
280
281                        //available blocks
282                        av_blocks = 0;
283                        for (var k = 0; k <= line_end - free_cell; k++) {
284                            av_blocks = k;
285                            if (this.cells[free_cell + k] == 1) {
286                                //there's another slot on the right
287                                break;
288                            }
289                        }
290                        break;
291                    }
292                }
293            }
294            //the slot need to be shrinked
295            if (av_blocks < slot.blocks.h) {
296                slot.resize(av_blocks);
297            } else {
298                var free_on_right = this.count_free_cells_on_right(free_cell + slot.blocks.h);
299                if (free_on_right - plugin.settings.margin < this.min_tile_width &&
300                    free_on_right > 0) {
301                    slot.resize(av_blocks, !allowEnlargement);
302                    slot.enlarged = true;
303                }
304                if (free_on_right == 0)
305                    slot.edge_right = true;
306            }
307
308            slot.position.x = free_cell % this.hor_size;
309            slot.position.y = Math.floor(free_cell / this.hor_size);
310
311            this.add_slot(slot);
312
313            return slot;
314        }
315
316        var defaults = {
317            layoutType: CRPTiledLayerType.Square,
318            approxTileWidth: 200,
319            approxTileHeight: 200,
320            minTileWidth: 200,
321            addBlock1Height: false,
322            addBlock2Height: false,
323            margin: 10,
324            allowEnlargement: false,
325            lazy: false,
326            dontCropImage: false,
327            columnCalcAlgo: CRPColumnCalcAlgo.Dynamic,
328            onComplete: function () { },
329            onUpdate: function () { },
330        }
331
332        var plugin = this;
333        var grid = null;
334        var maxHeight = 0;
335
336        plugin.settings = {}
337
338        var $element = $(element),
339            element = element;
340
341        var currentWidth = $element.width();
342
343        var wrapper = $element.closest('.crp-wrapper.crp-wrapper-catalog');
344
345        if (wrapper.length > 0) {
346            if (wrapper.closest('.crp-content').find('.crp-catalog-widget').hasClass('crp-widget-LeftSidebar') || wrapper.closest('.crp-content').find('.crp-catalog-widget').hasClass('crp-widget-RightSidebar')) {
347                if ($(window).width() < 1024) {
348                    wrapper.get(0).style.setProperty('width', '100%', 'important');
349                    wrapper.css('top', wrapper.closest('.crp-content').find('.crp-catalog-widget').outerHeight(true));
350                }
351            }
352        }
353
354        var completed = false;
355        var isBusy = false;
356
357        var ratioIndex = 0;
358        var styleConf = {};
359
360        var gridLeftMargin = 0;
361
362        var tilesForFilter = function(ft) {
363            var $tiles = $("void");
364
365            //if (ft && ft.length > 0) {
366            //  var selector = "ftg-" + ft;
367            //  selector = selector.replace(/[!"#\$%&'\(\)\*\+,\.\/:;<=>\?@\[\]\^`\{\|}~]/g, function(m){return '\\'+m});
368            //  $tiles = $element.find("."+selector);
369            //} else {
370            $tiles =  $element.find(".crp-tile");
371            //}
372
373            return $tiles;
374        }
375
376        var selectedFilter = function() {
377            return null;
378            //var ftg = $element.find(".ftg-filters a.selected");
379            //
380            //var ftgHref = $(ftg).attr("href");
381            //if(!ftgHref){
382            //  return null;
383            //}
384            //
385            //var ft = $(ftg).attr("href").substr(1);
386            //return ft;
387        }
388
389        var setupFilters = function () {
390            //if ($element.find(".ftg-filters").length == 0)
391            //    return;
392            //
393            //$element.find(".ftg-filters a").on("click", function (e) {
394            //    e.preventDefault();
395            //
396            //    $element.find(".ftg-filters a.selected").removeClass("selected");
397            //    $(this).addClass("selected");
398            //
399            //    doFiltration(true);
400            //});
401        }
402
403        var registerWindowResizeMainHandler = function () {
404          var _winSize = 0;
405          $(window).resize(function () {
406              if (_winSize != jQuery(window).width()) {
407                _winSize = jQuery(window).width();
408                refreshGrid();
409              }
410          });
411        }
412
413        var refreshGrid = function(callback = null) {
414          if(isBusy) {
415            return;
416          }
417          isBusy = true;
418
419          //Important: Do not remove this overflow update (making it visible, then hidden)!
420          //Otherwise it would cause unexpected rendering due to the last element margins
421          $element.css({'overflow': "visible"});
422
423          var wrapper = $element.closest('.crp-wrapper.crp-wrapper-catalog');
424          if (wrapper.length > 0) {
425              if (wrapper.closest('.crp-content').find('.crp-catalog-widget').hasClass('crp-widget-LeftSidebar') || wrapper.closest('.crp-content').find('.crp-catalog-widget').hasClass('crp-widget-RightSidebar')) {
426                  if ($(window).width() < 1024) {
427                      wrapper.get(0).style.setProperty('width', '100%', 'important');
428                  } else {
429                      wrapper.get(0).style.setProperty('width', '69%', 'important');
430                  }
431              } else if (wrapper.closest('.crp-content').find('.crp-catalog-widget').hasClass('crp-widget-TopBar')) {
432                  // if ($(window).width() < 1024) {
433                      wrapper.get(0).style.setProperty('top', jQuery(".crp-catalog-widget", $element.closest('.crp-content')).outerHeight(true)+'px', 'important');
434                  // } else {
435                      // wrapper.get(0).style.setProperty('top', 0, 'important');
436                  // }
437              }
438          }
439
440          currentWidth = $element.width();
441          setTimeout(function () {
442              grid = null;
443              maxHeight = 0;
444              ratioIndex = 0;
445
446              var $filteredTiles = tilesForFilter(selectedFilter());
447              entile($filteredTiles);
448
449              //Important: Do not remove this overflow update (making it visible, then hidden)!
450              //Otherwise it would cause unexpected rendering due to the last element margins
451              $element.css({'overflow': "hidden"});
452
453              //Disabled, because it causes issues with Ajax reloading
454              //$element.css({'margin-left':  (gridLeftMargin) + "px"});
455
456              isBusy = false;
457              if (callback != null) {
458
459                callback();
460              }
461          }, 500);
462        }
463
464        var finalizeInit = function(animate) {
465            styleConf = CRPTiledLayerType.style(plugin.settings.layoutType);
466
467            var ft = selectedFilter();
468            var $tiles = tilesForFilter(null);
469            var $filteredTiles = tilesForFilter(ft);
470
471            var transition = animate == true ? "transform .2s, opacity .2s" : "none";
472            maxHeight = 0;
473            grid = null;
474
475            $element.find(".ftg-items").css({
476              transition: transition,
477              opacity: 0,
478            });
479
480            //IMPORTANT BUG FIX: Whatever fix in the future, make sure to keep this flow:
481            //Timeout -> entile -> refresh -> registerWinResize -> refresh -> show
482            setTimeout(function () {
483                $tiles.css({visibility: 'invisible'});
484                entile($filteredTiles);
485                $filteredTiles.css({visibility: 'visible'});
486
487                refreshGrid(function (){
488                  registerWindowResizeMainHandler();
489                  refreshGrid(function (){
490                    $element.find(".ftg-items").css({ opacity: 1 });
491                  });
492                });
493            }, 250);
494        }
495
496        plugin.init = function () {
497            plugin.settings = $.extend({}, defaults, options);
498
499            $element.find(".ftg-items").css({
500                position: "relative",
501                minWidth: plugin.settings.minTileWidth,
502            });
503
504            var $tiles = $element.find(".crp-tile");
505            styleTiles($tiles);
506            assignImagesSize($tiles);
507            setupFilters();
508            //var category = window.location.hash;
509            //if (category != '' && category != '#') {
510            //    var current = jQuery(".ftg-filters a[href='" + category + "']");
511            //    if (current.length != 0) {
512            //        jQuery("a", current.closest(".ftg-filters")).removeClass('selected');
513            //        current.addClass('selected');
514            //    }
515            //}
516
517            finalizeInit(plugin.settings.appearWithFadeAnimation);
518
519            if(plugin.settings.lazy){
520                $element.find(".ftg-items").crpPreload({
521                    showInContainer: true,      //If set to true will load the preloader inside the selector element instead of across the whole page.
522                    disableOverlay: true,       //If set to true will not create the blocking overlay.
523                    useOpacity: false,          //If set to true will use opacity property to hide elements instead of display property.
524                    progressiveReveal: true,    //If set to true will show images as soon as they are preloaded.
525                    forceSequentialLoad: true,  //Will force images to load in the order they appear in the DOM, this	can potentially increase the load time because images won't start	loading in parallel.
526                    loaderText: "Loading... ",  //Set the text of the loading message.
527                });
528            }
529
530
531        }
532
533        /* MIT License (MIT) - Copyright (c) 2015 HTML5andBeyond.com */
534
535        var iCSS = function(target, property, value) {
536
537            var getStyle = target.attr('style');
538            if (getStyle == undefined) {
539                target.attr('style', property + ': ' +  value + ' !important;')
540            } else if (getStyle.slice(-1) != ';') {
541                target.attr('style', getStyle + '; ' + property + ': ' +  value + ' !important;');
542            } else {
543                target.attr('style', getStyle + property + ': ' +  value + ' !important;');
544            }
545        }
546
547        var styleTiles = function ($tiles) {
548            $tiles.css({
549                position: "absolute",
550                visibility: 'hidden',
551            });
552
553            $tiles.find('.crp-tile-inner').css({
554                position: "absolute",
555                display: "block",
556                overflow: "hidden",
557            });
558
559            $tiles.find('.crp-tile-img').css({
560                position: "absolute",
561                display: "inline-block",
562                fontSize: 10, //against weird rules in some reset.css
563            });
564        }
565
566        var assignImagesSize = function ($tiles) {
567            $tiles.each(function () {
568                var $item = $(this).find(".crp-tile-img");
569
570                var size = {
571                    width: $item.data("width"),
572                    height: $item.data("height")
573                };
574
575                $item.data("size", size);
576            });
577        }
578
579        var entile = function ($tiles) {
580            if (!grid) {
581                //Overwriteing minTileWidth option with approximate tile with option.
582                var gWidth = $element.width() + plugin.settings.margin;
583
584                if(plugin.settings.columnCalcAlgo == CRPColumnCalcAlgo.Fixed) {
585
586                    var colCount = styleConf.columns.desktop;
587                    var windowW = jQuery(window).width();
588
589                    if (windowW > plugin.settings.screenSizes.kDesktopMaxWidth) { // large desktop
590                        colCount = styleConf.columns.desktop;
591                    } else if (windowW >= plugin.settings.screenSizes.kDesktopMinWidth) { //desktop
592                        colCount = styleConf.columns.desktop;
593                    } else if (windowW > plugin.settings.screenSizes.kMobileMaxWidth) { //tablet
594                        colCount = styleConf.columns.tablet;
595                    } else { //mobile
596                        colCount = styleConf.columns.mobile;
597                    }
598
599                    gWidth = gkitFloorToDivideBy(gWidth, colCount);
600                } else {
601                    var colCount = parseInt(gWidth / (plugin.settings.approxTileWidth + plugin.settings.margin));
602                    gWidth = gkitFloorToDivideBy(gWidth, colCount);
603                }
604
605                gridLeftMargin = ($element.width() + plugin.settings.margin - gWidth) / 2;
606
607                //This is important to not split the functionlaity for square and masonry styles
608                if (plugin.settings.layoutType == CRPTiledLayerType.Masonry || plugin.settings.layoutType == CRPTiledLayerType.Square) {
609                  options.minTileWidth = options.approxTileWidth;
610                } else {
611                  options.minTileWidth = 1;
612                }
613
614                grid = new Grid(plugin.settings.margin, plugin.settings.minTileWidth, gW
614idth);
615            }
616            $tiles.each(function () {
617                if ($(this).hasClass("ftg-hidden"))
618                    return;
619
620                var size = $(this).find(".crp-tile-img").data("size");
621                if (typeof size == 'undefined') {
622                  return;
623                }
624
625                var slot = grid.insert(
626                    size.width + plugin.settings.margin,
627                    size.height + plugin.settings.margin,
628                    plugin.settings.allowEnlargement,
629                    $(this));
630
631                $(this).data("enlarged", slot.enlarged);
632
633
634                var top = slot.position.y;
635                var height = slot.blocks.v;
636
637                var tileWidth = slot.blocks.h - plugin.settings.margin;
638                var tileHeight = slot.blocks.v - plugin.settings.margin;
639
640                if (top + tileHeight > maxHeight)
641                    maxHeight = top + height + plugin.settings.margin;
642
643                if (plugin.settings.addBlock1Height != false) {
644                    tileHeight -= plugin.settings.addBlock1Height;
645                }
646
647                if (plugin.settings.addBlock2Height != false) {
648                    tileHeight -= plugin.settings.addBlock2Height;
649                }
650
651                $(this).css({
652                    top: top,
653                    left: slot.position.x,
654                    width: slot.blocks.h,
655                    height: height,
656                });
657
658                $(this).find('.crp-tile-inner').css({
659                        width: tileWidth,
660                        height: tileHeight
661                    })
662                    .data("width", tileWidth)
663                    .data("height", tileHeight);
664
665                if (plugin.settings.addBlock1Height != false) {
666                    $(this).find('.crp-tile-inner').css({
667                        top: plugin.settings.addBlock1Height
668                    });
669                    $(this).find('.crp-additional-block1').css({
670                        width: tileWidth,
671                        height: plugin.settings.addBlock1Height
672                    });
673                }
674                if (plugin.settings.addBlock2Height != false) {
675                    $(this).find('.crp-additional-block2').css({
676                        bottom: plugin.settings.margin,
677                        width: tileWidth,
678                        height: plugin.settings.addBlock2Height
679                    });
680                }
681
682                $element.find(".ftg-items").height(maxHeight);
683            });
684
685            $tiles.find(".crp-tile-img").each(function (i, item) {
686                var $item = $(item);
687                var size = $item.data("size");
688
689                var ratioImg = size.width / size.height;
690                var ratioTile = $item.parent().data("width") / $item.parent().data("height");
691
692                var bugFixDiff = 0;
693                if (ratioImg >= ratioTile) {
694                    $item.attr("case", "2");
695
696                    if (plugin.settings.dontCropImage) {
697                        iCSS($item, "width", "100%");
698                        $item.css({
699                            "top": ($item.parent().data("height") - $item.parent().data("width") / ratioImg) / 2,
700                            "left": 0
701                        });
702                    } else {
703                        var $h = $item.parent().data("height") + bugFixDiff;
704                        var $w = ratioImg * $h;
705
706                        iCSS($item, "width", $w + "px");
707                        iCSS($item, "height", $h + "px");
708
709                        // $item.css({
710                        //     width: $w,
711                        //     height: $h
712                        // });
713
714                        var diff = $w - $item.parent().data("width");
715                        $item.css({
716                            "left": diff / -2,
717                            "top": bugFixDiff / -2,
718                        });
719                    }
720
721                } else {
722                    $item.attr("case", "4");
723
724                    if (plugin.settings.dontCropImage) {
725                        iCSS($item, "height", "100%");
726                        $item.css({
727                            "top": 0,
728                            "left": ($item.parent().data("width") - $item.parent().data("height") * ratioImg) / 2
729                        });
730                    } else {
731
732                        var $w = $item.parent().data("width") + bugFixDiff;
733                        var $h = $w / ratioImg;
734
735                        iCSS($item, "width", $w + "px");
736                        iCSS($item, "height", $h + "px");
737
738                        // $item.css({
739                        //     width: $w,
740                        //     height: $h
741                        // });
742
743                        var diff = $h - $item.parent().data("height");
744                        $item.css({
745                            "top": diff / -2,
746                            "left": bugFixDiff / -2,
747                        });
748                    }
749                }
750            });
751
752            if (!completed) {
753                completed = true;
754                plugin.settings.onComplete.call(plugin);
755            } else {
756                plugin.settings.onUpdate.call(plugin);
757            }
758        }
759
760        plugin.init();
761    }
762
763    $.fn.crpTiledLayer = function (options) {
764        return this.each(function () {
765            if (typeof $(this).data('crpTiledLayer') == "undefined") {
766                //This option is being removed from plugin settings
767                var plugin = new $.crpTiledLayer(this, options);
768                $(this).data('crpTiledLayer', plugin);
769            }
770        });
771    }
772})(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.