1function ftg_getURLParameter(name) { 2 return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null 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 ($, window, document, undefined) { 14 15 $.fn.visible = function (partial) { 16 17 if (!$(this).offset()) 18 return true; 19 20 var $t = $(this), 21 $w = $(window), 22 viewTop = $w.scrollTop(), 23 viewBottom = viewTop + $w.height(), 24 _top = $t.offset().top, 25 _bottom = _top + $t.height(), 26 compareTop = partial === true ? _bottom : _top, 27 compareBottom = partial === true ? _top : _bottom; 28 29 return ((compareBottom <= viewBottom) && (compareTop >= viewTop)); 30 31 }; 32 33 var pluginName = "finalTilesGallery", 34 defaults = { 35 layout: 'final', // final | columns | smart 36 columns: [ 37 [4000, 5], 38 [1024, 4], 39 [800, 3], 40 [480, 2], 41 [320, 1] 42 ], 43 rowHeight: 200, 44 margin: 10, 45 minTileWidth: 200, 46 ignoreImageAttributes: true, 47 imageSizeFactor: [ 48 [4000, .9], 49 [1024, .8], 50 [800, .7], 51 [600, .6], 52 [480, .5], 53 [320, .3] 54 ], 55 gridSize: 10, 56 disableGridSizeBelow: 800, 57 allowEnlargement: true, 58 autoLoadURL: null, 59 selectedFilter: '', 60 loadMethod: 'sequential', 61 62 onComplete: function () {}, 63 onUpdate: function () {}, 64 onLoading: function () {}, 65 debug: false 66 }; 67 68 // The actual plugin constructor 69 function Plugin(element, options) { 70 71 /*! properties */ 72 this.element = element; 73 this.$element = $(element); 74 this.settings = $.extend({}, defaults, options); 75 this._columnSize = 0; 76 this.columns; 77 this._defaults = defaults; 78 this._name = pluginName; 79 this.tiles = []; 80 this._loadedImages = 0; 81 this._rows = [[]]; 82 this._currentRow = 0; 83 this._currentRowTile = 0; 84 this.edges = []; 85 this.imagesData = {}; 86 this.currentWidth = 0; 87 this.currentImageSizeFactor = 1; 88 this.currentColumnsCount = 0; 89 this.currentGridSize = 0; 90 this.ajaxComplete = false; 91 this.isLoading = false; 92 this.currentPage = 1; 93 this.init(); 94 } 95 96 // Avoid Plugin.prototype conflicts 97 $.extend(Plugin.prototype, { 98 print : function (text) { 99 if(this.settings.debug) 100 console.log(text); 101 }, 102 setCurrentImageSizeFactor : function () { 103 this.currentImageSizeFactor = 1; 104 var ww = $(window).width(); 105 for (var i = 0; i < this.settings.imageSizeFactor.length; i++) { 106 if (this.settings.imageSizeFactor[i][0] >= ww) 107 this.currentImageSizeFactor = this.settings.imageSizeFactor[i][1]; 108 } 109 if(!this.currentImageSizeFactor) 110 this.currentImageSizeFactor = 1; 111 this.print("current image size factor: " + this.currentImageSizeFactor + " (" + ww + ")"); 112 }, 113 setCurrentColumnSize: function () { 114 var ww = $(window).width(); 115 for (var i = 0; i < this.settings.columns.length; i++) { 116 if (this.settings.columns[i][0] >= ww) { 117 this.currentColumnsCount = this.settings.columns[i][1]; 118 this.print("columns count: " + this.currentColumnsCount); 119 this.columns = []; 120 for(var j=0; j<this.currentColumnsCount; j++) { 121 this.columns.push([]); 122 } 123 } 124 } 125 126 this._columnSize = (this.currentWidth - (this.settings.margin * (this.currentColumnsCount - 1))) / this.currentColumnsCount; 127 128 this.print(this.currentWidth, this._columnSize); 129 }, 130 setCurrentGridSize: function () { 131 132 if(this.currentWidth < this.settings.disableGridSizeBelow) 133 { 134 this.currentGridSize = 0; 135 } 136 else 137 { 138 if(this.settings.layout == "final") 139 this.currentGridSize = this.settings.gridSize * this.currentImageSizeFactor 140 else 141 this.currentGridSize = this.settings.gridSize; 142 } 143 this.print("currentGridSize : " + this.currentGridSize); 144 }, 145 init: function () { 146 var instance = this; 147 var current_filter = this.settings.selectedFilter; 148 var filter_url = ftg_getURLParameter('ftg-set'); 149 if(filter_url)
150 current_filter = filter_url; 151 152 instance.currentWidth = instance.$element.width(); 153 154 if(instance.$element.filter(":visible").length == 0) { 155 instance.print('cannot initialize the gallery, container is hidden. Retrying in 500ms.'); 156 setTimeout(function () { 157 instance.init(); 158 }, 500); 159 return; 160 } 161 162 this.$element.find(".ftg-items").css({ 163 position: 'relative' 164 }); 165 166 var current_filter = this.settings.selectedFilter; 167 var filter_url = ftg_getURLParameter('ftg-set'); 168 if(filter_url) 169 current_filter = filter_url; 170 171 var instance = this; 172 173 if(current_filter != null && current_filter != "n-a") 174 { 175 instance.print(".. found filter (" + current_filter + ")"); 176 instance.$element.find(".ftg-filters a").removeClass('selected'); 177 instance.$element.find(".ftg-filters a").each(function(){ 178 179 if($(this).data('filter') == current_filter) 180 { 181 instance.print(".. selecting filter"); 182 $(this).addClass('selected'); 183 } 184 }) 185 } 186 187 var hash = window.location.hash; 188 189 this.$element.find(".ftg-items").css({ 190 position: 'relative', 191 minWidth: instance.settings.minTileWidth 192 }); 193 194 if((hash && hash != "#ftg-set-ftgall" && hash.substr(0, 8) == '#ftg-set') || 195 instance.settings.selectedFilter) 196 { 197 var ft = '#ftg-set-' + instance.settings.selectedFilter; 198 if(hash) 199 ft = hash; 200 201 var hash_class = ft.replace('#','.'); 202 var filters = []; 203 204 instance.$element.find(".ftg-filters a").each(function(){ 205 filters.push($(this).attr('href')); 206 }); 207 208 if($.inArray(ft, filters) >= 0) 209 { 210 hash_class = hash_class.substring(1); 211 212 instance.$element.find(".ftg-filters a").each(function(){ 213 214 if($(this).attr('href') != ft){ 215 216 instance.$element.find('.item').each(function(){ 217 var img = $(this).parent().parent(); 218 219 if(img.hasClass(hash_class) == false) 220 { 221 img.addClass('ftg-filter-hidden-tile'); 222 } 223 }) 224 225 226 $(this).removeClass('selected'); 227 }; 228 }); 229 230 $('a[href="' + ft + '"]').addClass('selected'); 231 } 232 } 233 234 this.tiles = this.$element.find('.tile').not('.ftg-hidden-tile').not('.ftg-filter-hidden-tile'); 235 236 /*this.tiles.css({ 237 transition: 'all .3s' 238 });*/ 239 this.currentWidth = this.$element.width(); 240 this.print("this.currentWidth: " + this.currentWidth); 241 242 if(this.settings.layout != 'columns' && this.settings.layout != 'rows' && 243 this.settings.layout != 'final') { 244 console.log("WARNING: unknown layout, falling back to 'final'.") 245 } 246 247 if(this.settings.layout == 'columns') { 248 this.setCurrentColumnSize(); 249 } 250 251 var _resizeTo = 0; 252 this.setCurrentImageSizeFactor(); 253 this.setCurrentGridSize(); 254 $(window).resize(function () { 255 _resizeTo = setTimeout(function () { 256 if (instance.currentWidth != instance.$element.width()) { 257 clearTimeout(_resizeTo); 258 instance.print("this.currentWidth", this.currentWidth);
259 instance.currentWidth = instance.$element.width(); 260 instance.setCurrentColumnSize(); 261 instance.setCurrentImageSizeFactor(); 262 instance.setCurrentGridSize(); 263 instance.refresh(); 264 } 265 }, 500); 266 }); 267 268 instance.isLoading = true; 269 if(instance.settings.autoLoadURL) { 270 $(window).scroll(function () { 271 if(!instance.ajaxComplete && !instance.isLoading) { 272 if (instance.tiles.last().visible()) { 273 instance.isLoading = true; 274 if(instance.settings.onLoading) 275 instance.settings.onLoading(); 276 277 $.post( 278 instance.settings.autoLoadURL, 279 { 280 page: ++instance.currentPage, 281 action: 'load_chunk', 282 pageSize: instance.settings.pageSize, 283 finaltilesgallery: instance.settings.nonce, 284 gallery: instance.settings.galleryId 285 }, function (html) { 286 if ($.trim(html).length == 0) { 287 instance.ajaxComplete = true; 288 } else { 289 instance.$element.find(".ftg-items").append(html); 290 instance.tiles = instance.$element.find('.tile') 291 instance.loadImage(); 292 } 293 }); 294 } 295 } 296 }); 297 } 298 299 300 this.edges.push({ left: 0, top: 0, width: this.currentWidth, index: 0 }); 301 302 this.isImageLoading = false; 303 if(this.settings.loadMethod == 'lazy') { 304 $(window).scroll(function(event) { 305 instance.loadImage(); 306 }); 307 } 308 this.loadImage(); 309 }, 310 addElements: function (html) { 311 this.$element.find(".ftg-items").append(html); 312 this.tiles = this.$element.find('.tile') 313 this.loadImage(); 314 }, 315 removeAt: function(index) { 316 this.tiles[index].remove(); 317 this.refresh(); 318 }, 319 clear: function() { 320 this.$element.find(".ftg-items").height(0).empty(); 321 this.refresh(); 322 }, 323 324 printEdges: function () { 325 this.$element.find(".edge").remove(); 326 for (i = 0; i < this.edges.length; i++) { 327 var $e = $("<div class='edge' />"); 328 $e.append("top: " + this.edges[i].top + "<br>"); 329 $e.append("left: " + this.edges[i].left + "<br>"); 330 $e.append("width: " + this.edges[i].width + "<br>"); 331 $e.css({ 332 left: this.edges[i].left, 333 top: this.edges[i].top, 334 marginTop: -25, 335 marginLeft: 20 336 }); 337 this.$element.append($e); 338 } 339 }, 340 printEdge: function (edge) { 341 var $e = $("<div class='edge enlarged-"+edge.enlarged+"' />"); 342 $e.append("<b>"+ edge.index + " " + edge.case + "</b><br>"); 343 $e.append("t: " + Math.round(edge.top) + " l: " + edge.left + "<br>"); 344 $e.append("width: " + edge.width + "<br>"); 345 $e.append("idx: " + edge.tileIndex + "<br>"); 346 347 $e.css({ 348 left: edge.left, 349 top: edge.top, 350 marginTop: -25, 351 marginLeft: 20 352 }); 353 this.$element.append($e); 354 }, 355 refresh: function () { 356 this.setCurrentColumnSize(); 357 this.$element.find(".edge").remove(); 358 this.edges = [
359 { left: 0, top: 0, width: this.currentWidth } 360 ]; 361 this.tiles.removeClass("ftg-loaded ftg-enlarged"); 362 this.tiles = this.$element.find('.tile').not('.ftg-hidden-tile').not('.ftg-filter-hidden-tile'); 363 this._loadedImages = 0; 364 this.loadImage(); 365 }, 366 367 getAvailableRowSpace: function () { 368 return this.currentWidth - this.getBusyRowSpace(); 369 }, 370 371 getBusyRowSpace: function () { 372 var space = 0; 373 for(var i=0; i<this._rows[this._currentRow].length; i++) { 374 space += this._rows[this._currentRow][i].data('width') + 375 this.settings.margin; 376 } 377 return space; 378 }, 379 380 addImageToRow: function($img) { 381 this._rows[this._currentRow].push($img); 382 }, 383 384 fitImagesInRow: function () { 385 var left = this.getAvailableRowSpace() - this.settings.margin; 386 var ratio = (this.currentWidth - (this._rows[this._currentRow].length - 1) * this.settings.margin) / this.getBusyRowSpace(); 387 388 for(var i=0; i<this._rows[this._currentRow].length; i++) { 389 $item = this._rows[this._currentRow][i]; 390 var w = $item.data('width'); 391 var h = $item.data('height'); 392 393 $item.data('width', w * ratio); 394 this.add(this._currentRowTile++); 395 } 396 }, 397 398 nextTile : function (add) { 399 var instance = this; 400 instance.isImageLoading = false; 401 if(add) 402 instance.add(instance._loadedImages); 403 404 if (++instance._loadedImages < instance.tiles.length) { 405 instance.loadImage(); 406 } else { 407 var height = instance.lowerEdgeTop(); 408 instance.print("lower edge top: " + height); 409 //instance.$element.find(".ftg-items").height(height); 410 instance.isLoading = false; 411 instance.settings.onComplete(); 412 } 413 }, 414 415 /*! loadImage */ 416 loadImage: function () { 417 var instance = this; 418 419 if(instance.isImageLoading || this.tiles.not(".ftg-loaded").length == 0) { 420 this.print("No more images to load"); 421 return; 422 } 423 424 instance.isImageLoading = true; 425 426 var $tile = this.tiles.eq(this._loadedImages); 427 428 if(instance._loadedImages > 0) { 429 var $last = instance.tiles.filter(".ftg-loaded").last(); 430 431 if(instance.settings.loadMethod == 'lazy' && !$last.visible(true)) { 432 instance.isImageLoading = false; 433 return; 434 } 435 } 436 437 if($tile.find("iframe").length) 438 $tile.find("iframe").addClass("item"); 439 440 var $item = $tile.find('.item'); 441 442 switch ($item.get(0).tagName.toLowerCase()) { 443 case "img": 444 var img = new Image(); 445 img.onload = function () { 446 var iFactor = instance.currentImageSizeFactor; 447 if ($tile.data("ftg-ignore-size-factor")) 448 iFactor = 1; 449 450 var size = {}; 451 var addImage = true; 452 if(instance.settings.layout == "final") { 453 var w = $item.attr("width") ? parseInt($item.attr("width")) : img.width; 454 var h = $item.attr("height") ? parseInt($item.attr("height")) : img.height; 455 456 size.width = w * iFactor; 457 size.height = h * iFactor; 458 } 459 if(instance.settings.layout == "columns") { 460 size.width = instance._columnSize; 461 size.height = (size.width * img.height) / img.width; 462 } 463 //WIP rows layout not yet available 464 if(instance.settings.layout == "rows") { 465 size.width = (instance.settings.rowHeight * img.width) / img.height; 466 size.height = instance.settings.rowHeight; 467 addImage = false; 468 469 if(instance.getAvailableRowSpace() > size.width) { 470 instance.addImageToRow($item); 471 } else { 472 //not enough available space, make a new row 473 //and print the current one 474 instance.fitImagesInRow(); 475 instance._currentRow++; 476 instance._rows.push([]); 477 instance.addImageToRow($item); 478 } 479 } 480
481 $item.attr("src", this.src); 482 483 instance.imagesData["tile" + instance._loadedImages] = { 484 width: size.width, 485 height: size.height, 486 owidth: img.width, 487 oheight: img.height, 488 src: img.src 489 }; 490 491 instance.nextTile(addImage); 492 } 493 img.onerror = function() { 494 console.error("Final Tiles Gallery: Error loading image: " + img.src); 495 instance.nextTile(false); 496 } 497 img.src = $item.data("ftg-source"); 498 $tile.data("ftg-type", "image"); 499 break; 500 case "iframe": 501 var w = $item.attr("width") ? 502 parseInt($item.attr("width")) : 503 $item.data("width"); 504 var h = $item.attr("height") ? 505 parseInt($item.attr("height")) : 506 $item.data("height"); 507 var size = { 508 width: w, 509 height: h, 510 owidth: w, 511 oheight: h 512 }; 513 if(instance.settings.layout == "columns") { 514 size.width = instance._columnSize; 515 size.height = (size.width * size.oheight) / size.owidth; 516 } 517 instance.imagesData["tile" + instance._loadedImages] = size; 518 $tile.data("ftg-type", "iframe"); 519 instance.nextTile(true); 520 break; 521 default: 522 instance.imagesData["tile" + instance._loadedImages] = { 523 width: parseInt($item.data("width")), 524 height: parseInt($item.data("height")), 525 owidth: parseInt($item.data("width")), 526 oheight: parseInt($item.data("height")) 527 }; 528 instance.nextTile(true); 529 break; 530 } 531 }, 532 higherEdge: function () { 533 var left = 0; 534 var _top = 100000; 535 var _left = 0; 536 var found = 0; 537 538 for (var i = 0; i < this.edges.length; i++) { 539 if (this.edges[i].top < _top) { 540 found = i; 541 _top = this.edges[i].top; 542 } 543 } 544 545 return this.edges[found]; 546 }, 547 lowerEdgeTop: function () { 548 var min = 0; 549 for (var i = 0; i < this.edges.length; i++) { 550 if (this.edges[i].top > min) { 551 min = this.edges[i].top; 552 } 553 } 554 555 return min; 556 }, 557 alignEdge: function (edge, index) { 558 //look left 559 for (var i = 0; i < this.edges.length; i++) { 560 if (this.edges[i].left + this.edges[i].width + this.settings.margin == edge.left) { 561 this.print("found edge on left", i); 562 //adjust edge 563 if (edge.top == this.edges[i].top) { 564 this.print("edges can be aligned [1]"); 565 return { side: 'left', edge: this.edges[i] }; 566 } 567 } 568 } 569 //TODO look right 570 for (var i = 0; i < this.edges.length; i++) { 571 if (this.edges[i].left - this.settings.margin == edge.left + edge.width) { 572 this.print("found edge on right", i); 573 //adjust edge 574 if (edge.top == this.edges[i].top) { 575 this.print("edges can be aligned [2]"); 576 return { side: 'right', edge: this.edges[i] }; 577 } 578 } 579 } 580 581 return null; 582 }, 583 removeEdge: function (edge) { 584 var tmp = []; 585 for (var i = 0; i < this.edges.length; i++) { 586 if (this.edges[i] != edge) 587 tmp.push(this.edges[i]); 588 } 589 this.edges = tmp; 590 }, 591 get_highest_col: function () { 592 var h = 0; 593 for(var i=0; i<this.columns.length; i++) { 594 for(var j=0; j<this.columns[i].length; j++) { 595 if(this.columns[i][j] > h) 596 h = this.columns[i][j];
597 } 598 } 599 return h; 600 }, 601 get_shortest_col: function () { 602 for(var i=0; i<this.columns.length; i++) { 603 var col = this.columns[i]; 604 if(col.length == 0) { 605 return { 606 col: i, 607 top: 0 608 } 609 } 610 } 611 612 var ret = { 613 col: 0, 614 top: 100000000 615 }; 616 for(var i=this.columns.length - 1; i >= 0; i--) { 617 var col = this.columns[i]; 618 var last = col[col.length - 1]; 619 if(last <= ret.top) { 620 //console.log("shortest is ", i, last); 621 ret.top = last; 622 ret.col = i; 623 } 624 } 625 626 if(ret.top == 0) 627 console.warn("col ret 0"); 628 629 return ret; 630 }, 631 add: function (tileIndex) { 632 if(this.settings.layout == "columns") { 633 this.add_to_column(tileIndex); 634 } else { 635 this.add_to_final(tileIndex); 636 } 637 }, 638 add_to_column: function (tileIndex) { 639 var $t = this.tiles.eq(tileIndex); 640 641 var $item = $t.find('.item'); 642 var key = "tile" + tileIndex; 643 var w = this.imagesData[key].width; 644 var h = this.imagesData[key].height; 645 646 var slot = this.get_shortest_col(); 647 648 var ratio = h / w; 649 650 var t_w = this._columnSize; 651 var t_h = t_w * ratio; 652 var t_h_b = t_w * ratio; 653 654 if(this.currentGridSize) { 655 var n = Math.floor(t_h / this.currentGridSize); 656 if(n > 0) { 657 t_h = this.currentGridSize * n; 658 } 659 } 660 661 /*if(this.currentGridSize) { 662 console.log("this.currentGridSize", this.currentGridSize); 663 var diff = h % this.currentGridSize; 664 console.log("diff", diff); 665 slot.top -= diff; 666 h -= diff; 667 }*/ 668 669 $t.css({ 670 position: 'absolute', 671 width: t_w, 672 height: t_h, 673 top: slot.top + this.settings.margin, 674 left: (slot.col * this._columnSize) + (this.settings.margin * slot.col) 675 }); 676 677 var hdiff = t_h_b - t_h; 678 679 if ($t.data("ftg-type") != "iframe") 680 $item.css({ height: "auto" }); 681 682 if(hdiff > 0) { 683 $item.css({ 684 top: 0 - (hdiff / 2) 685 }); 686 } 687 var transition = $t.css('transition'); 688 689 setTimeout( function () { 690 $t.css( { 691 display : 'block', 692 transform: 'scale(1)' 693 } ); 694 }, 1 ); 695 696 $t.addClass("ftg-loaded"); 697 698 this.columns[slot.col].push(slot.top + t_h + this.settings.margin); 699 700 this.$element.find(".ftg-items").css({ 701 height: this.get_highest_col() + "px" 702 }); 703 }, 704 add_to_final: function (tileIndex) { 705 var outside = false; 706 if ($('.final-tiles-gallery').hasClass('caption-outside')) { 707 outside = true; 708 } 709 var $t = this.tiles.eq(tileIndex); 710 711 var $item = $t.find('.item'); 712 var key = "tile" + tileIndex; 713 714 var w = this.imagesData[key].width; 715 var h = this.imagesData[key].height; 716 717 var hEdge = this.higherEdge(); 718 this.print(hEdge); 719 hEdge.tileIndex = tileIndex; 720 721 this.print(tileIndex + " [" + $t.data("ftg-type") + "] (" + w + "x" + h + ")"); 722 this.print("hEdge.width: " + hEdge.width); 723 724 if (hEdge.top > 0) { 725 hEdge.top += this.settings.margin; 726 } 727 if (outside === true) { 728 h += 30; 729 } 730 731 $t.css({ 732 left: hEdge.left, 733 top: hEdge.top, 734 position: 'absolute' 735 }); 736 737 hEdge.enlarged = false; 738 739 //is the tile wider than the current edge? 740 if (hEdge.width - w < w + this.settings.margin) { 741 hEdge.case = 'Te'; 742 this.print('Te'); 743 //edge smaller than the image 744 var w2 = hEdge.width; 745 var h2 = (h / w) * w2; 746 747 if (w2 + hEdge.left - this.settings.margin == this.currentWidth) { 748 this.print("END"); 749 w2 -= this.settings.margin; 750 h2 = (h / w) * w2; 751 } 752 753 w = w2; 754 h = h2; 755 } else if (hEdge.width >= w) { 756 this.print('tE'); 757 //break the edge 758 //is the new edge wider than minTileWidth? 759 if (this.settings.layout == 'columns' || hEdge.width - w >= this.settings.minTileWidth) { 760 hEdge.case = 'tE'; 761 this.print('tE1', hEdge.width, hEdge.left, this.currentWidth);
762 763 var newEdge = { 764 left: hEdge.left + w + this.settings.margin, 765 top: hEdge.top - (hEdge.top > 0 ? this.settings.margin : 0), 766 width: hEdge.width - w - this.settings.margin, 767 marginLeft: true, 768 case: 'NEW', 769 index: hEdge.index + 1 770 } 771 772 //console.log("newEdge", newEdge); 773 this.edges.push(newEdge); 774 //this.printEdge(newEdge); 775 } else { 776 hEdge.case = 'tE2'; 777 this.print('tE2'); 778 //not enough space for the next tile 779 //enlargement 780 this.print("enlargement", hEdge.width, hEdge.left, this.currentWidth); 781 var m = hEdge.left + hEdge.width == this.currentWidth ? 0 : this.settings.margin; 782 //var w2 = hEdge.width - m; 783 var w2 = hEdge.width; 784 var h2 = this.settings.allowEnlargement && this.settings.layout != 'rows' ? (h / w) * w2 : h; 785 786 if (this.settings.allowEnlargement) { 787 $t.addClass("ftg-enlarged"); 788 hEdge.enlarged = true; 789 } else { 790 if(this.settings.layout != 'rows') 791 $t.find(".item").css({ 792 width: w, 793 height: h 794 }); 795 } 796 797 w = w2; 798 h = h2; 799 } 800 } 801 802 hEdge.top += h; 803 if(this.currentGridSize) { 804 var diff = hEdge.top % this.currentGridSize; 805 hEdge.top -= diff; 806 h -= diff; 807 } 808 809 hEdge.left = hEdge.left; 810 hEdge.width = w; 811 //hEdge.index = tileIndex + 1; 812 813 var printEdge = true; 814 815 var aligned = this.alignEdge(hEdge, tileIndex); 816 if (aligned) { 817 if(aligned.side == 'left') { 818 this.removeEdge(hEdge); 819 aligned.edge.width += w + this.settings.margin; 820 h = h - (hEdge.top - aligned.edge.top); 821 hEdge.top -= h; 822 printEdge = false; 823 } else { 824 this.removeEdge(aligned.edge); 825 hEdge.width += this.settings.margin + aligned.edge.width; 826 printEdge = false; 827 } 828 829 $t.height(h); 830 } 831 832 if (this.$element.find(".ftg-items").height() != hEdge.top) 833 this.$element.find(".ftg-items").height(hEdge.top); 834 835 if(this.settings.debug && printEdge) { 836 this.printEdge(hEdge); 837 } 838 839 if ($t.data("ftg-type") == "iframe") { 840 $t.find("iframe").height(h); 841 } 842 843 this.print(w + "x" + h); 844 this.print("----"); 845 846 if (outside === true) { 847 h += 30; 848 } 849 850 $t.css({ 851 width: w, 852 height: h 853 }); 854 var transition = $t.css('transition'); 855 var ratio = w / this.imagesData[key].width; 856 var hdiff = (this.imagesData[key].height * ratio) - h; 857 858 if ($t.data("ftg-type") != "iframe") 859 $item.css({ height: "auto" }); 860 861 if(hdiff > 0) { 862 $item.css({ 863 top: 0 - (hdiff / 2) 864 }); 865 } 866 867 // Set a minor timeout so that the function won't be triggered right away 868 setTimeout( function () { 869 $t.css( { 870 display : 'block', 871 transform: 'scale(1)' 872 } ); 873 }, 1 ); 874 875 $t.addClass("ftg-loaded"); 876 } 877 });
878 879 $.fn[pluginName] = function (options) { 880 this.each(function () { 881 if (!$.data(this, pluginName)) { 882 $.data(this, pluginName, new Plugin(this, options)); 883 } 884 }); 885 886 // chain jQuery functions 887 return this; 888 }; 889 890 $(window).on('load', function(){ 891 $('.loading-bar i').css({ 892 width: '100%' 893 }); 894 }); 895 896 $(function () { 897 898 $(".ftg-social a").on( 'click', function(e) { 899 900 e.preventDefault(); 901 var social = $(this).data("social"); 902 var $tile = $(this).parents(".tile").first(); 903 var image = $tile.data("big"); 904 if(! image) 905 image = $tile.find(".item").attr("src"); 906 907 var text = $.trim($tile.find(".subtitle").text()); 908 if(! text.length) 909 text = document.title; 910 911 var desc = $.trim($tile.find(".title").text()); 912 if(! desc.length) 913 desc = document.title; 914 915 if(social == "facebook") { 916 var url = "https://www.facebook.com/dialog/feed?app_id=1447224948871585&"+ 917 "link="+encodeURIComponent(location.href)+"&" + 918 "display=popup&"+ 919 "name="+encodeURIComponent(desc)+"&"+ 920 "caption=&"+ 921 "description="+encodeURIComponent(text)+"&"+ 922 "picture="+encodeURIComponent(qualifyURL(image))+"&"+ 923 "ref=share&"+ 924 "actions={%22name%22:%22View%20the%20gallery%22,%20%22link%22:%22"+encodeURIComponent(location.href)+"%22}&"+ 925 "redirect_uri=http://www.final-tiles-gallery.com/facebook_redirect.html"; 926 927 var w = window.open(url, "ftgw", "location=1,status=1,scrollbars=1,width=600,height=400"); 928 w.moveTo((screen.width / 2) - (300), (screen.height / 2) - (200)); 929 } 930 931 if(social == "twitter") { 932 var w = window.open("https://twitter.com/intent/tweet?url=" + encodeURI(location.href.split('#')[0]) + "&text=" + encodeURI(desc + " " + text), "ftgw", "location=1,status=1,scrollbars=1,width=600,height=400"); 933 w.moveTo((screen.width / 2) - (300), (screen.height / 2) - (200)); 934 } 935 936 if(social == "pinterest") { 937 var url = "http://pinterest.com/pin/create/button/?url=" + encodeURIComponent(location.href) + "&description=" + encodeURI(desc + " " + text); 938 939 url += ("&media=" + encodeURIComponent(qualifyURL(image))); 940 941 var w = window.open(url, "ftgw", "location=1,status=1,scrollbars=1,width=600,height=400"); 942 w.moveTo((screen.width / 2) - (300), (screen.height / 2) - (200)); 943 } 944 945 }); 946 }); 947})(jQuery, window, document);
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.