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