PageSourceSearch

https://wildlifehospital.co.nz/wp-content/plugins/photoblocks-grid…/public/js/photoblocks.public.js?ver=1.3.1

js wildlifehospital.co.nz collected 2026-10-08 20:15:17 UTC 26,231 bytes, 903 lines download raw bytes

1/*global jQuery*/
2var PhotoBlocks = {};
3
4//credits James Padolsey http://james.padolsey.com/
5var qualifyURL = function (url) {
6  var img = document.createElement("img");
7  img.src = url; // set string url
8  url = img.src; // get qualified url
9  img.src = null; // no server request
10  return url;
11};
12
13(function($) {
14  $.fn.visible = function (partial) {
15
16      if (!$(this).offset())
17          return true;
18
19      var $t = $(this),
20          $w = $(window),
21          viewTop = $w.scrollTop(),
22          viewBottom = viewTop + $w.height(),
23          _top = $t.offset().top,
24          _bottom = _top + $t.height(),
25          compareTop = partial === true ? _bottom : _top,
26          compareBottom = partial === true ? _top : _bottom;
27
28      return ((compareBottom <= viewBottom) && (compareTop >= viewTop));
29
30  };
31
32  PhotoBlocks = function(conf) {
33    this.$grid = null;
34    this.$blocks = [];
35    this.geometry = {
36      width: 0,
37      squareSize: 0,
38      on: {
39        before: null,
40        after: null,
41        refresh: null
42      },
43      debug: false
44    };
45    this.loaded_images = 0;
46    this.err_images = 0;
47    this.images_count = 0;
48  
49    this.mode = "grid";
50    this.packery_init = false;
51
52    this.settings = {
53      selector: null,
54      columns: 4,
55      padding: 10,
56      disable_below: 320,
57      image_quality: 80,
58      imageExtraWidth: 0,
59      imageFactor: 1.5,
60      lazy: false,
61      mobile_layout: []
62    };
63    for (var a in conf) {
64      this.settings[a] = conf[a];
65    }
66
67    this.effects = {
68      fade: {
69        animeOpts: {
70          targets : ".pb-block",
71          duration: function(t,i) {
72            return 600 + i*75;
73          },
74          easing: 'easeOutExpo',
75          delay: function(t,i) {
76            return i*50;
77          },
78          opacity: {
79            value: [0,1],
80            easing: 'linear'
81          },
82        }	
83      }
84    };
85    /* <fs_premium_only> */
86    var premium_effects = {      
87      pop: {
88        animeOpts: {
89          targets : ".pb-block",
90          duration: function(t,i) {
91            return 600 + i*75;
92          },
93          easing: 'easeOutExpo',
94          delay: function(t,i) {
95            return i*50;
96          },
97          opacity: {
98            value: [0.7,1],
99            easing: 'linear'
100          },
101          scale: [0,1]
102        }	
103      },
104      slideFromBottom: {
105        animeOpts: {
106          targets : ".pb-block",
107          duration: 800,
108          easing: 'easeOutExpo',          
109          opacity: {
110            value: [0,1],
111            duration: 800,
112            easing: 'linear'
113          },
114          translateY: [400,0]
115        }
116      },
117      slideFromTop: {
118        animeOpts: {
119          targets : ".pb-block",
120          duration: 800,
121          easing: 'easeOutExpo',          
122          opacity: {
123            value: [0,1],
124            duration: 800,
125            easing: 'linear'
126          },
127          translateY: [-400,0]
128        }
129      },
130      slideFromLeft: {
131        animeOpts: {
132          targets : ".pb-block",
133          duration: 800,
134          easing: [0.1,1,0.3,1],
135          delay: function(t,i) {
136            return i * 20;
137          },
138          opacity: {
139            value: [0,1],
140            duration: 600,
141            easing: 'linear'
142          },
143          translateX: [-500,0],
144          rotateZ: [15,0]
145        }
146      },
147      elastic: {
148        animeOpts: {
149          targets : ".pb-block",
150          duration: 900,
151          elasticity: 500,
152          delay: function(t,i) {
153            return i*15;
154          },
155          opacity: {
156            value: [0.5,1],
157            duration: 250,
158            easing: 'linear'
159          },
160          translateX: function() {
161            return [anime.random(0,1) === 0 ? 100 : -100,0];
162          },
163          translateY: function() {
164            return [anime.random(0,1) === 0 ? 100 : -100,0];
165          }
166        }
167      },
168      elastic2: {        
169        animeOpts: {
170          targets : ".pb-image",
171          duration: 1500,
172          elasticity: 400,
173          delay: function(t,i) {
174            return i*75;
175          },
176          opacity: {
177            value: [0.6,1],
178            duration: 250,
179            easing: 'linear'
180          },
181          rotateX: [-90,0]
182        }
183      },      
184      wobble: {
185        animeOpts: {
186          targets: ".pb-block",
187          duration: 800,
188          elasticity: 600,
189          delay: function(t,i) {
190            return i*100;
191          },
192          opacity: {
193            value: [.5,1],
194            duration: 250,
195            easing: 'linear'
196          },
197          scaleX: {
198            value: [0.4,1]
199          },
200          scaleY: {
201            value: [0.6,1],
202            duration: 1000
203          }
204        }
205      },
206      deal: {
207        animeOpts: {
208          targets: ".pb-block",
209          duration: 600,
210          easing: 'easeOutExpo',
211          delay: function(t,i) {
212            return i*100;
213          },
214          opacity: {
215            value: [0,1],
216            duration: 100,
217            easing: 'linear'
218          },
219          translateX: function(t,i) {
220            var docScrolls = {left : document.body.scrollLeft + document.documentElement.scrollLeft},
221              x1 = window.innerWidth/2 + docScrolls.left,
222              tBounds = t.getBoundingClientRect(),
223              x2 = tBounds.left +docScrolls.left + tBounds.width/2;
224  
225            return [x1-x2,0];
226          },
227          translateY: function(t,i) {
228            var docScrolls = {top : document.body.scrollTop + document.documentElement.scrollTop},
229              y1 = window.innerHeight + docScrolls.top,
230              tBounds = t.getBoundingClientRect(),
231              y2 = tBounds.top + docScrolls.top + tBounds.height/2;
232  
233            return [y1-y2,0];
234          },
235          rotate: function(t,i) {
236            var x1 = window.innerWidth/2,
237              tBounds = t.getBoundingClientRect(),
238              x2 = tBounds.left + tBounds.width/2;
239  
240            return [x2 < x1 ? 90 : -90,0];
241          },
242          scale: [0,1]
243        }
244      },
245      stretch: {
246        animeOpts: {
247          targets: ".pb-image",
248          duration: 500,
249          easing: 'easeOutBack',
250          delay: function(t,i) {
251            return i * 100;
252          },
253          opacity: {
254            value: [0,1],
255            easing: 'linear'
256          },
257          translateY: [400,0],
258          scaleY: [
259            {value: [3,0.6], delay: function(t,i) {return i * 100 + 120;}, duration: 300, easing: 'easeOutExpo'},
260            {value: [0.6,1], duration: 1400, easing: 'easeOutElastic'}
261          ],
262          scaleX: [
263            {value: [0.9,1.05], delay: function(t,i) {return i * 100 + 120;}, duration: 300, easing: 'easeOutExpo'},
264            {value: [1.05,1], duration: 1400, easing: 'easeOutElastic'}
265          ]
266        }
267      }
268    };
269    this.effects = $.extend(this.effects, premium_effects);
270    /* </fs_premium_only> */
271
272    if (this.init()) {
273      this.load_images(this.$blocks);
274      this.setup_social();
275
276      /* <fs_premium_only> */
277      this.setup_filters();
278      /* </fs_premium_only> */
279    }
280  };
281
282  PhotoBlocks.prototype.setup_social = function () {
283    var self = this;
284
285    function block_text($block) {
286      var text = {
287        title: "",
288        description: ""
289      };
290      
291      if($block.find(".pb-title").length)
292        text.title = $block.find(".pb-title").text();
293
294        if($block.find(".pb-description").length)
295        text.description = $block.find(".pb-description").text();
296
297      return text;
298    }
299
300    self.social_actions = {
301      facebook: function ($block) {        
302        var text = block_text($block);
303        var url = "https://www.facebook.com/dialog/feed?app_id=1447224948871585&"+
304                            "link="+encodeURIComponent(location.href)+"&" +
305                            "display=popup&"+
306                            "name="+encodeURIComponent(text.title)+"&"+
307                            "caption=&"+
308                            "description="+encodeURIComponent(text.description)+"&"+
309                            "ref=share&"+
310                            "actions={%22name%22:%22View%20the%20gallery%22,%20%22link%22:%22"+encodeURIComponent(location.href)+"%22}&"+
311                            "redirect_uri=http://www.final-tiles-gallery.com/facebook_redirect.html";
312
313                var w = window.open(url, "photoblocks-share-facebook", "location=1,status=1,scrollbars=1,width=600,height=400");
314                w.moveTo((screen.width / 2) - (300), (screen.height / 2) - (200));
315      },
316      twitter: function ($block) {
317        var text = block_text($block);
318        var w = window.open("https://twitter.com/intent/tweet?url=" + encodeURI(location.href.split('#')[0]) + "&text=" + encodeURI(text.title + " " + text.description), "photoblocks-share-twitter", "location=1,status=1,scrollbars=1,width=600,height=400");
319        w.moveTo((screen.width / 2) - (300), (screen.height / 2) - (200));
320      },
321      houzz: function ($block) {
322        var image = $block.find(".pb-image").attr("src");
323        var text = block_text($block);
324        var w = window.open("http://www.houzz.com/imageClipperUpload?imageUrl="+encodeURIComponent(qualifyURL(image))+"&title="+ text.t
324itle + " " + text.description +"&link=" + encodeURI(location.href), "photoblocks-share-houzz", "location=1,status=1,scrollbars=1,width=800,height=500");
325        w.moveTo((screen.width / 2) - (300), (screen.height / 2) - (200));
326      },
327      pinterest: function ($block) {
328        var image = $block.find(".pb-image").attr("src");
329        var text = block_text($block);
330        var url = "http://pinterest.com/pin/create/button/?url=" + encodeURIComponent(location.href) + "&description=" + encodeURI(text.title + " " + text.description);
331
332        url += ("&media=" + encodeURIComponent(qualifyURL(image)));
333
334        var w = window.open(url, "photoblocks-share-pinterest", "location=1,status=1,scrollbars=1,width=600,height=400");
335        w.moveTo((screen.width / 2) - (300), (screen.height / 2) - (200));
336      },
337      google: function ($block) {
338        var url = "https://plus.google.com/share?url=" + encodeURI(location.href);
339
340        var w = window.open(url, "photoblocks-share-google", "location=1,status=1,scrollbars=1,width=600,height=400");
341        w.moveTo((screen.width / 2) - (300), (screen.height / 2) - (200));
342      }
343    };
344
345    this.$blocks.each(function (i, block) {
346      var $block = $(block);
347
348      $block.find(".pb-social button").each(function (i, button) {
349        var $button = $(button);
350        var social = $button.data("social");
351        $button.click(function (e) {
352          e.preventDefault();
353          e.stopPropagation();
354          self.social_actions[social]($block);
355        });
356      });
357    });    
358  };
359
360  PhotoBlocks.prototype.apply_effects = function ($block) {
361    var anim = this.$grid.data("anim");
362
363    var effect = this.effects[anim];
364    effect.animeOpts.targets = $block.get(0);
365
366    $block.css({
367      transition: "none"
368    });
369    anime(effect.animeOpts);
370    setTimeout(function () {
371      $block.css({
372        transition: "left .25s, top .45s, transform .25s"
373      });
374    }, 1000);    
375  };
376
377  PhotoBlocks.prototype.print_i = function(data) {
378    if (this.settings.debug) console.info("PB > ", data);
379  };
380
381  PhotoBlocks.prototype.print_e = function(data) {
382    if (this.settings.debug) console.error("PB > ", data);
383  };
384
385  PhotoBlocks.prototype.print_w = function(data) {
386    if (this.settings.debug) console.warn("PB > ", data);
387  };
388
389  /* <fs_premium_only> */
390  PhotoBlocks.prototype.setup_filters = function () {
391    if(this.$grid.find(".pb-filters").length) {
392      var self = this;
393      var $blocks = this.$blocks;
394      var $filters = this.$grid.find(".pb-filters a");
395
396      var selected = "";
397      
398      $filters.each(function () {
399        $(this).click(function () {
400
401          if($(this).hasClass("selected"))
402            return;
403
404          var ft = $(this).data("filter");
405
406          $filters.removeClass("selected");
407          $(this).addClass("selected");
408
409          var pkry = self.$grid.find(".pb-blocks").data('packery');
410          if(ft == "pbf-all") {
411            var hidden = $blocks.filter(".pb-filtered");
412            self.$grid.find(".pb-blocks").data('packery').unignore(hidden);
413            $blocks.removeClass("pb-filtered");
414            $blocks.find("a").each(function () {
415              if($(this).data("fancybox-rel"))
416                $(this).attr("data-fancybox", $(this).data("fancybox-rel"));
417            });                       
418            self.$grid.find(".pb-blocks").packery('layout');
419            $blocks.show();
420          } else {
421            var to_hide = [];
422            var to_show = [];
423            $blocks.each(function () {
424              var filters = $(this).data("filters").split(" ");
425              var $a = $(this).find("a");
426              
427              if($.inArray(ft, filters) < 0) {
428                //$(this).addClass("pb-filtered");
429                
430                $a.data("fancybox-rel", $a.data("fancybox"));
431                $a.removeAttr("data-fancybox");
432                $(this).hide();
433                to_hide.push(this);
434              } else {
435                $(this).removeClass("pb-filtered");                
436                if($a.data("fancybox-rel")) {
437                  $a.attr("data-fancybox", $a.data("fancybox-rel"));                  
438                  //self.apply_effects($(this));
439                }
440                to_show.push(this);
441                $(this).show();
442              }
443            });
444
445            if(self.packery_init) {
446              pkry.ignore(to_hide);
447              pkry.unignore(to_show);
448            }
449          }  
450          if(self.packery_init) {
451            pkry.layout();
452          }
453        });
454      });
455
456      this.startup_filters();
457    }
458  };
459  
460  PhotoBlocks.prototype.startup_filters = function () {
461    var fstart = location.hash;
462    if(fstart == "#pbf-all") {
463      this.$grid.find(".pb-filters a.pbf-all").addClass("selected");
464    } else {
465      var $filters = this.$grid.find(".pb-filters a");
466      $filters.each(function (i, o) {
467        if($(this).attr("href") == location.hash) {
468            $(o).click();
469        }        
470      });
471      this.init_packery();
472    }
473  };
474  /* </fs_premium_only> */
475
476  PhotoBlocks.prototype.cellSize = function() {    
477    var self = this;
478    var w = self.$grid.width();    
479    if(w < self.settings.disable_below) {
480      self.$grid.addClass("pb-disabled");
481      this.mode.type = "stack";
482    } else {
483      self.$grid.removeClass("pb-disabled");
484      this.mode.type = "grid";
485    }
486
487    if(this.mode == "stack")
488      return this.geometry.width;
489
490    var w =
491      this.geometry.width -
492      this.settings.padding * (this.settings.columns - 1);
493    var size = (w / this.settings.columns);
494    return size;
495  };
496
497  PhotoBlocks.prototype.init_packery = function() {
498    var self = this;
499
500    self.build();
501    if(self.$grid.find(".pb-blocks").data('packery'))
502      self.$grid.find(".pb-blocks").packery('destroy');
503
504    self.$grid.find(".pb-blocks").css({
505      width: "calc(100% + " + self.settings.padding + "px)"
506    });
507
508    var settings = {
509      itemSelector: '.pb-block',
510      gutter: self.settings.padding,      
511      resize: false
512    };
513
514    if(this.mode.type != "stack") {
515      settings.columnWidth = self.geometry.squareSize;
516      settings.rowHeight = self.geometry.squareSize;
517      self.$grid.find(".pb-blocks").packery(settings);
518    } 
519
520    this.packery_init = true;
521  }
522
523  PhotoBlocks.prototype.loaded_image = function () {
524    var self = this;
525    if(self.err_images == self.images_count) {
526      self.$grid.append("<strong>Cannot load all images, check cache settings</strong>");
527    }
528  };
529
530  PhotoBlocks.prototype.apply_alignments = function($image, img) {
531    var $block = $image.parent();
532
533    var bw = $block.width();
534    var bh = $block.height();
535    var iw = $image.width();
536    var ih = $image.height();
537
538    if(ih > bh) {
539      switch($block.data("valign")) {
540        case "top": 
541          $image.css({
542            top: 0,
543            bottom: "auto"
544          });
545          break;
546        case "bottom": 
547          $image.css({
548            top: "auto",
549            bottom: 0
550          });
551          break;
552        case "center": 
553          $image.css({
554            top: - ((ih - bh) / 2),
555            bottom: "auto"
556          });   
557          break;
558      }
559    }
560    if(iw > bw) {
561      switch($block.data("halign")) {
562        case "left": 
563          $image.css({
564            left: 0,
565            right: "auto"
566          });
567          break;
568        case "right": 
569          $image.css({
570            left: "auto",
571            right: 0
572          });
573          break;
574        case "center": 
575          $image.css({
576            left: - ((iw - bw) / 2),
577            right: "auto"
578          });   
579          break;
580      }
581    }
582  }
583
584  PhotoBlocks.prototype.load_images = function($blocks) {  
585    var self = this;
586    $blocks.not(".pb-ready").each(function() {
587      var $block = $(this);
588
589      if(self.settings.lazy && ! $block.visible(true))
590        return false;
591
592      var type = $(this).data("type");
593
594      if(type == "empty" || type == "text") {
595        $block.addClass("pb-ready");
596        self.apply_effects($block);
597      }
598      if(type == "image" || type == "post") {
599        self.setImageSrc($block)
600        var $image = $(this).find(".pb-image");
601        var src = $image.attr("src");        
602
603        var i = new Image();
604        i.onload = function () {
605          self.loaded_images++;
606          self.loaded_image();
607          $block.addClass("pb-ready");
608          $block.data("image-width", i.width);
609          $block.data("image-height", i.height);
610          //console.log(i.src, $block.data("image-width"), $block.data("image-height"));
611
612          if(! self.settings.resizer)
613            self.apply_alignments($image, i);
614          self.apply_effects($block);
615        };
616        i.onerror = function () {
617          self.err_images++;
618          $block.addClass("pb-ready-err");
619          console.warn("Loading error", $block);
620        };
621        i.src = src;
622      }      
623    });
624  };
625
626  PhotoBlocks.prototype.setImageSrc = function($block) {
627    var self = this;
628    
629    if($block.data("type") == "image" || $block.data("type") == "post") {
630      var valign = $block.data("valign");
631      var halign = $block.data("halign");
632      var rowspan = $block.data("rowspan");
633      var colspan = $block.data("colspan");
634          
635      var src = $block.find(".pb-image").data("pb-source");
636      
637      var width = self.getSnappedSize(
638        colspan * self.geometry.squareSize
639      );
640      var height = self.getSnappedSize(
641        rowspan * self.geometry.squareSize
642      );      
643
644      width *= self.settings.imageFactor;
645      height *= self.settings.imageFactor;
646
647      if(self.mode.type == "stack") {
648        width = self.geometry.width;
649        height = null; 
650      }
651
652      var resized_src = self.getImageUrl(
653        src,
654        width,
655        height,
656        valign,
657        halign,
658        self.settings.imageExtraWidth
659      );
660
661      $block.find(".pb-image").attr("src", resized_src).show();
662    }  
663  }
664
665  PhotoBlocks.prototype.currentMode = function() {
666    var self = this;
667    var w = $(window).width();
668
669    var mode = { type: "grid" };
670    if(w < self.settings.disable_below)
671      return { type: "stack" };
672    
673    /* <fs_premium_only> */  
674    self.settings.mobile_layout.sort(function (a, b) {
675      if(a.w < b.w)
676        return -1;
677
678      if(a.w > b.w)
679        return 1;
680
681      return 0;
682    });
683    $.each(self.settings.mobile_layout, function () {
684      if(this.w > w) {
685        self.print_i("Found mobile layout: " + this.w + " (" + this.cols + " cols)");
686        mode = { type: "mobile", layout: this };
687        return false;
688      }
689    });
690    /* </fs_premium_only> */
691    return mode;
692  }
693
694  PhotoBlocks.prototype.build = function() {
695    var self = this;
696    var w = self.$grid.width();
697    this.mode = self.currentMode();
698    if(this.mode.type == "stack") {
699      self.$grid.addClass("pb-disabled");
700    } else {
701      self.$grid.removeClass("pb-disabled");        
702    }
703
704    this.print_i("Gallery mode: " + this.mode.type);
705
706    this.$blocks.not(".pb-filtered").each(function() {
707      var $block = $(this);
708      var rowspan = $block.data("rowspan");
709      var colspan = $block.data("colspan");
710
711      var width = self.getSnappedSize(
712        colspan * self.geometry.squareSize
713      );
714      var height = self.getSnappedSize(
715        rowspan * self.geometry.squareSize
716      );
717
718      //self.print_i("Calculated: " + width + "x" + height);
719
720      if(self.mode.type == "stack") {        
721        width = "100%";
722        height = "auto";
723
724        console.log("!");
725
726        $block.css({
727          position: "relative",
728          marginBottom: self.settings.padding
729        }).find(".pb-image").css({
730          position: "static",
731          width: "100%",
732          height: "auto",
733          position: "static"
734        });
735      }
736      else if(self.mode.type == "grid") {
737        
738      } else if(self.mode.type == "mobile") {
739        width = (w - ( (self.mode.layout.cols - 1) * self.settings.padding)) / self.mode.layout.cols;
740        height = width; 
741        /*if(self.mode.layout.square) {
742          height = width;
743        } else {
744          height = w / width * height;
745        }*/
746        
747        self.geometry.squareSize = width
748      }
749
750      self.print_i("build: " +  (width + "x" + height));
751
752      $block.css({
753        width: width,
754        height: height
755      });
756      
757      if(! self.settings.lazy)
758        self.setImageSrc($block)
759    });
760    
761  };
762
763  PhotoBlocks.prototype.getImageUrl = function(
764    src,
765    width,
766    height,
767    valign,
768    halign,
769    exceeding_w
770  ) {
771
772    if(! this.settings.resizer)
773      return src;
774
775
776    var parts = [];
777
778    var v = "c";
779    if (valign == "top") v = "t";
780    if (valign == "bottom") v = "b";
781
782    var h = halign.substr(0, 1);
783
784    //var w_ = colspan * 200 + exceeding_w;
785    //var h_ = rowspan * 200;
786    var w_ = width + exceeding_w;
787    var h_ = height;
788
789    parts.push("q=" + this.settings.image_quality);
790    parts.push("src=" + src);
791
792    parts.push("w=" + w_);
793    if(h_)
794      parts.push("h=" + h_);
795    parts.push("a=" + v + h);
796    parts.push("zc=4");
797    return this.settings.resizer + "?" + parts.join("&");
798  };
799
800  PhotoBlocks.prototype.getSquareIndex = function(len) {
801    return Math.round(len / this.geometry.squareSize);
802  };
803
804  PhotoBlocks.prototype.getSnappedSize = function(len) {    
805    var x = this.getSquareIndex(len);
806    return this.geometry.squareSize * x + this.settings.padding * (x - 1);
807  };
808
809  PhotoBlocks.prototype.init = function() {
810
811    if(this.settings.on.before)
812      this.settings.on.before();
813
814    if (!this.settings.selector) {
815      this.print_e("Null selector !");
816      return false;
817    }
818
819    this.settings.imageFactor = parseFloat(this.settings.imageFactor);
820    if(this.settings.imageFactor == 0 || isNaN(this.settings.imageFactor))
821      this.settings.imageFactor = 1.5;
822
823    this.$grid = $(this.settings.selector);
824
825    if (this.$grid.length == 0) {
826      this.print_e("Gallery element not found!");
827      return;
828    }
829    
830    this.$blocks = this.$grid.find(".pb-block");
831
832    if (this.$blocks.length == 0) {
833      this.print_w("Useless empty gallery?");
834    }
835
836    this.images_count = this.$blocks.find(".pb-image").length;
837
838    this.$blocks.each(function () {
839      var $block = $(this);
840      $block.data("conf", {
841        geometry: {
842          colspan: $block.data("colspan"),
843          rowspan: $block.data("rowspan"),
844          col: $block.data("col"),
845          row: $block.data("row")
846        }
847      });
848      $block.data("previous_conf", $.extend({}, $block.data("conf")));
849
850    });    
851
852    //TODO if width is 0 delay and loop until width is gt 0
853    this.geometry.width = this.$grid.width();
854    this.geometry.squareSize = this.cellSize();
855
856    this.print_i("width: " + this.geometry.width);
857    this.print_i("squareSize: " + this.geometry.squareSize);
858
859    var self = this;
860
861    //self.build();
862    if(location.hash.substr(0, 5) != "#pbf-" || location.hash == "#pbf-all")
863      self.init_packery();
864
865    $(window).resize(function() {
866      self.resizeTO = setTimeout(function() {
867        self.print_i("resizing gallery");
868        var w = self.$grid.width();
869        
870        self.print_i("new gallery width: " + w);
871        if (w != self.geometry.width) {
872          clearInterval(self.resizeTO);
873          self.print_i("gallery width changed, resizing");
874          self.geometry.width = w;
875          self.geometry.squareSize = self.cellSize();
876          
877          self.init_packery();
878
879          if(self.settings.on.refresh)
880            self.settings.on.refresh();
881        }
882      }, 500);
883    });
884
885    if(! self.settings.lazy) {
886      self.load_images(self.$blocks);
887    }
888    /* <fs_premium_only> */
889    var _debounce = 0;
890    $(window).scroll(function () {
891      clearTimeout(_debounce);
892      _debounce = setTimeout(function () {
893        self.load_images(self.$blocks);
894      }, 100);
895    });
896    /* </fs_premium_only> */
897
898    if(this.settings.on.after)
899      this.settings.on.after();
900
901    return true;
902  };
903})(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.