1/************************************************************************** 2 * jquery.themepunch.megafolio.js - jQuery Plugin for megafolio pro gallery 3 * @version: 1.0 (10.01.2013) 4 * @requires jQuery v1.4 or later 5 * @author Krisztian Horvath 6**************************************************************************/ 7 8 9 10(function($,undefined){ 11 12 13 //////////////////////////////////////// 14 // THE REVOLUTION PLUGIN STARTS HERE // 15 /////////////////////////////////////// 16 17 $.fn.extend({ 18 19 /////////////////////////// 20 // MAIN PLUGIN FUNCTION // 21 /////////////////////////// 22 megafoliopro: function(options) { 23 24 var defaults = { 25 filterChangeAnimation:"rotatescale", // fade, rotate, scale, rotatescale, pagetop, pagebottom,pagemiddle 26 filterChangeSpeed:400, // Speed of Transition 27 filterChangeRotate:99, // If you ue scalerotate or rotate you can set the rotation (99 = random !!) 28 filterChangeScale:0.6, // Scale Animation Endparameter 29 delay:20, 30 defaultWidth:980, 31 paddingHorizontal:10, 32 paddingVertical:10, 33 layoutarray:[11], 34 lowSize:50 35 }; 36 37 options = $.extend({}, defaults, options); 38 39 40 return this.each(function() { 41 42 // Delegate .transition() calls to .animate() 43 // if the browser can't do CSS transitions. 44 if (!$.support.transition) 45 $.fn.transition = $.fn.animate; 46 47 var opt=options; 48 opt.detaiview="off"; 49 opt.firststart=1; 50 if (opt.filter==undefined) opt.filter="*"; 51 52 if (opt.delay==undefined) opt.delay=0; 53 54 //opt.savetrans = opt.filterChangeAnimation; 55 //opt.filterChangeAnimation="fade"; 56 57 // CHECK IF FIREFOX 13 IS ON WAY.. IT HAS A STRANGE BUG, CSS ANIMATE SHOULD NOT BE USED 58 var firefox = ($.browser.mozilla) && (parseInt($.browser.version,0)==13 || parseInt($.browser.version,0)==14 || parseInt($.browser.version,0)==15 || parseInt($.browser.version,0)==16 ); 59 var ie = $.browser.msie && parseInt($.browser.version,0)<9; 60 var ie9 = $.browser.msie && parseInt($.browser.version,0)==9; 61 opt.ie=ie; 62 opt.ie9=ie9; 63 64 if (ie) $('body').addClass("ie8"); 65 if (ie9) $('body').addClass("ie9"); 66 67 var container=$(this); 68 container.data('defaultwidth',opt.defaultWidth); 69 container.data('paddingh',opt.paddingHorizontal); 70 container.data('paddingv',opt.paddingVertical); 71 container.data('order',opt.layoutarray); 72 container.data('ie',ie); 73 container.data('ie9',ie9); 74 container.data('ff',firefox); 75 container.data('opt',opt); 76 77 78 79 /*prepairEntries(container,opt); 80 reOrder(container,0); 81 rePosition(container); 82 preparingLazyLoad(container); 83 addFilter(container,"*"); 84 reOrder(container,0); 85 setTimeout(function() { 86 rePosition(container); 87 },400) 88*/ 89 90 prepairEntries(container,opt); 91 reOrder(container,0); 92 addFilter(container,"*"); 93 preparingLazyLoad(container); 94 reOrder(container,0); 95 setTimeout(function() { 96 rePosition(container); 97 },400) 98 99 100 101 $(window).resize(function() { 102 clearTimeout(container.data('resized')); 103 104 container.data('resized',setTimeout(function() { 105 reOrderOrdered(container,0,container.find('>.mega-entry.tp-ordered').length); 106 107 },150)); 108 }); 109 110 /**************************************************** 111 - APPLE IPAD AND IPHONE WORKAROUNDS HERE - 112 ******************************************************/ 113 114 if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) { 115 $(".mega-entry").click(function(){ 116 //we just need to attach a click event listener to provoke iPhone/iPod/iPad's hover event 117 //strange 118 }); 119 } 120 }) 121 }, 122 123 /////////////////////// 124 // METHODE RESUME // 125 ////////////////////// 126 megamethode: function(option) { 127 return this.each(function() { 128 // CATCH THE CONTAINER 129 var container=$(this); 130 }) 131 }, 132 133 megagetcurrentorder: function() { 134 135 // CATCH THE CONTAINER 136 var container=$(this); 137 return container.data('lastorder'); 138 139 }, 140 141 megaappendentry: function(entry) { 142 143 // CATCH THE CONTAINER 144 var container=$(this); 145 var newentry=$(entry); 146 newentry.addClass("mega-entry-added"); 147 container.append(newentry); 148 var opt=container.data('opt'); 149 150 prepairNewEntries(container,opt); 151 152 reOrder(container,0); 153 154 rePosition(container,1); 155 156 setTimeout(function() { 157 addFilter(container,opt.filter); 158 reOrder(container,0); 159 rePosition(container,1); 160 },200); 161 162 163 }, 164 165 megaremix: function(order) { 166 return this.each(function() { 167 // CATCH THE CONTAINER 168 var container=$(this); 169 if (order!=undefined) 170 container.data('order',order); 171 notOrdered(container); 172 reOrder(container,0); 173 rePosition(container); 174 175 }) 176 }, 177 178 megafilter: function(filter) { 179 return this.each(function() { 180 // CATCH THE CONTAINER 181 var container=$(this); 182 addFilter(container,filter); 183 184 reOrder(container,0); 185 rePosition(container); 186 }) 187 }, 188 189 megaanimchange: function(anim,speed,rotate,scale) { 190 return this.each(function() { 191 // CATCH THE CONTAINER 192 var container=$(this); 193 var opt=container.data('opt'); 194 var filter=opt.filter; 195 opt.filterChangeAnimation=anim; 196 opt.filterChangeSpeed=speed; 197 opt.filterChangeRotate=rotate; 198 opt.filterChangeScale=scale; 199 addFilter(container,""); 200 addFilter(container,filter); 201 setTimeout(function() { 202 203 reOrder(container,0); 204 rePosition(container); 205 },2*opt.filterChangeSpeed); 206 container.data('opt',opt); 207 }) 208 } 209 }) 210 211 212 213 //////////////////////////////////////////////////////// 214 // WRAP THE DIVS DEPENDING ON THE AMOUNT OF ENTRIES // 215 //////////////////////////////////////////////////////// 216 function prepairEntries(container,opt) { 217 218 container.find('>.mega-entry').each(function() { 219 var ent=$(this); 220 ent.removeClass('tp-layout-first-item').removeClass('tp-layout-last-item').removeClass('very-last-item'); 221 ent.addClass("tp-notordered").addClass("mega-entry-added"); 222 ent.wrapInner('<div class="mega-entry-innerwrap"></div>'); 223 //ent.find('.mega-socialbar').appendTo(ent) 224 var iw = ent.find('.mega-entry-innerwrap') 225 /*if (opt.ie) { 226 iw.append('<img class="ieimg" src='+ent.data("src")+'>'); 227 } else {*/ 228 iw.css({'background':'url('+ent.data("src")+')','backgroundPosition':'50% 49%', 'backgroundSize':'
228cover', 'background-repeat':'no-repeat'}); 229// } 230 231 // LET ACT ON THE CLICK ON ITEM SOMEWAY 232 ent.find('.mega-show-more').each(function() { 233 var msm = $(this); 234 235 // SAVE THE ID OF THE mega-entry WHICH IS CORRESPONDING ON THE BUTTON 236 msm.data('entid',ent.attr('id')); 237 238 // HANDLING OF THE CLICK 239 msm.click(function() { 240 var msm=$(this); 241 var ent=container.find('#'+msm.data('entid')); 242 ent.addClass("mega-in-detailview"); 243 opt.detailview="on"; 244 }); 245 246 }); 247 }); 248 249 250 251 } 252 253 254 //////////////////////////////////////////////////////// 255 // WRAP THE DIVS DEPENDING ON THE AMOUNT OF ENTRIES // 256 //////////////////////////////////////////////////////// 257 function prepairNewEntries(container,opt) { 258 259 container.find('>.mega-entry-added').each(function(i) { 260 var ent=$(this); 261 if (!ent.hasClass('tp-layout')) { 262 263 ent.removeClass('tp-layout-first-item').removeClass('tp-layout-last-item').removeClass('very-last-item'); 264 ent.addClass("tp-notordered") 265 ent.wrapInner('<div class="mega-entry-innerwrap"></div>'); 266 //ent.find('.mega-socialbar').appendTo(ent) 267 var iw = ent.find('.mega-entry-innerwrap') 268 /*if (opt.ie) { 269 iw.append('<img class="ieimg" src='+ent.data("src")+'>'); 270 } else {*/ 271 iw.css({'background':'url('+ent.data("src")+')','backgroundPosition':'50% 49%', 'backgroundSize':'cover', 'background-repeat':'no-repeat'}); 272 //} 273 274 // LET ACT ON THE CLICK ON ITEM SOMEWAY 275 ent.find('.mega-show-more').each(function() { 276 var msm = $(this); 277 278 // SAVE THE ID OF THE mega-entry WHICH IS CORRESPONDING ON THE BUTTON 279 msm.data('entid',ent.attr('id')); 280 281 // HANDLING OF THE CLICK 282 msm.click(function() { 283 var msm=$(this); 284 var ent=container.find('#'+msm.data('entid')); 285 ent.addClass("mega-in-detailview"); 286 opt.detailview="on"; 287 288 }); 289 290 }); 291 } 292 }); 293 294 295 296 } 297 298 /////////////////////////////////////// 299 // ADD NOT ORDERED TO THE ENTRIES // 300 /////////////////////////////////////// 301 function notOrdered(container) { 302 container.find('>.mega-entry.tp-layout').each(function() { 303 var ent=$(this); 304 ent.removeClass('tp-layout').addClass('tp-notordered'); 305 }); 306 } 307 308 309 310 /////////////////////////////////////// 311 // ADD FILTER FOR THE ENTRIES // 312 /////////////////////////////////////// 313 function addFilter(container,filter) { 314 315 316 var ie=container.data('ie'); 317 var ie9=container.data('ie9'); 318 var opt = container.data('opt'); 319 if (opt.filterChangeSpeed == undefined) opt.filterChangeSpeed = Math.round(Math.random()*500+100); 320 opt.filter=filter; 321 var outi=1; 322 var ini=1; 323 324 container.find('>.mega-entry').each(function(i) { 325 var ent=$(this); 326 327 var rot = opt.filterChangeRotate; 328 if (rot==undefined) rot=30; 329 330 if (rot==99) rot = Math.round(Math.random()*50-25); 331 332 ent.removeClass('tp-layout-first-item').removeClass('tp-layout-last-item').removeClass('very-last-item'); 333 334 335 if (ent.hasClass(filter) || filter=="*") { 336 337 338 ent.removeClass('tp-layout').addClass('tp-notordered'); 339 } else { 340 341 ent.removeClass('tp-ordered').removeClass('tp-layout'); 342 setTimeout(function() { 343 if (ie || ie9) { 344 ent.animate({'scale':0, 'opacity':0},{queue:false,duration:opt.filterChangeSpeed}); 345 } else { 346 347 if (opt.filterChangeAnimation=="fade") { 348 ent.transition({'scale':1, 'opacity':0,'rotate':0},opt.filterChangeSpeed); 349 ent.find('.mega-entry-innerwrap').transition({'scale':1, 'opacity':1,perspective: '10000px',rotateX: '0deg'},opt.filterChangeSpeed); 350 } 351 else 352 if (opt.filterChangeAnimation=="scale") { 353 ent.transition({'scale':opt.filterChangeScale, 'opacity':0,'rotate':0},opt.filterChangeSpeed); 354 ent.find('.mega-entry-innerwrap').transition({'scale':1, 'opacity':1,perspective: '10000px',rotateX: '0deg'},opt.filterChangeSpeed); 355 } 356 else 357 if (opt.filterChangeAnimation=="rotate") { 358 ent.transition({'scale':1, 'opacity':0,'rotate':rot},opt.filterChangeSpeed); 359 ent.find('.mega-entry-innerwrap').transition({'scale':1, 'opacity':1,perspective: '10000px',rotateX: '0deg'},opt.filterChangeSpeed); 360 } 361 else 362 if (opt.filterChangeAnimation=="rotatescale") { 363 ent.transition({'scale':opt.filterChangeScale, 'opacity':0,'rotate':rot},opt.filterChangeSpeed); 364 ent.find('.mega-entry-innerwrap').transition({'scale':1, 'opacity':1,perspective: '10000px',rotateX: '0deg'},opt.filterChangeSpeed); 365 } else 366 if (opt.filterChangeAnimation=="pagetop" || opt.filterChangeAnimation=="pagebottom" || opt.filterChangeAnimation=="pagemiddle") { 367 368 ent.find('.mega-entry-innerwrap').removeClass("pagemiddle").removeClass("pagetop").removeClass("pagebottom").addClass(opt.filterChangeAnimation); 369 ent.transition({'opacity':0},opt.filterChangeSpeed); 370 ent.find('.mega-entry-innerwrap').transition({'scale':1, 'opacity':0,perspective: '10000px',rotateX: '90deg'},opt.filterChangeSpeed); 371 } 372 373 } 374 setTimeout(function() { ent.css({visibility:'hidden'})},opt.filterChangeSpeed); 375 376 },ini*opt.delay/2); 377 ini++; 378 379 } 380 381 382 383 }); 384 385 386 387 } 388 389 390 /////////////////////////////////////////// 391 // PREPARE FOR THE FIRST START THE ITEMS // 392 ////////////////////////////////////////// 393 function preparingLazyLoad(container) { 394 395 var ie=container.data('ie'); 396 var ie9=container.data('ie9'); 397 var opt = container.data('opt'); 398 if (opt.filterChangeSpeed == undefined) opt.filterChangeSpeed = Math.round(Math.random()*500+100); 399 if (opt.filterChangeScale == undefined) opt.filterChangeScale = 0.8; 400 401 402 var outi=0; 403 var ini=0; 404 405 container.find('>.mega-entry').each(function(i) { 406 var ent=$(this); 407 408 var rot = opt.filterChangeRotate; 409 if (rot==undefined) rot=30; 410 if (rot==99) rot = Math.round(Math.random()*360); 411 412 if (ie || ie9) { 413 ent.css({'opacity':0}); 414 } else { 415 if (opt.filterChangeAnimation=="fade") 416 ent.transition({'scale':1, 'opacity':0,'rotate':0,duration:1,queue:false}); 417 else 418 if (opt.filterChangeAnimation=="scale") { 419 ent.transition({'scale':opt.filterChangeScale, 'opacity':0,'rotate':0,duration:1,queue:false}); 420 } 421 else 422 if (opt.filterChangeAnimation=="rotate") 423 ent.transition({'scale':1, 'opacity':0,'rotate':rot,duration:1,queue:false}); 424 else 425 if (opt.filterChangeAnimation=="rotatescale") { 426 427 ent.transition({'scale':opt.filterChangeScale, 'opacity':0,'rotate':rot,duration:1,queue:false}); 428 } 429 else 430 if (opt.filterChangeAnimation=="pagetop" || opt.filterChangeAnimation=="pagebottom" || opt.filterChangeAnimation=="pagemiddle") { 431 ent.find('.mega-entry-innerwrap').addClass(opt.filterChangeAnimation); 432 ent.transition({'opacity':0,duration:1,queue:false}); 433 ent.find('.mega-entry-innerwrap').transition({'scale':1, 'opacity':1,perspective: '10000px',rotateX: '90deg',duration:1,queue:false}); 434 } 435 436 } 437 }); 438 //opt.filterChangeAnimation = opt.savetrans; 439 440 441 442 } 443 444 445 //////////////////////////////////////////////////////// 446 // REORDER THE CONTAINER DEPENDING ON THE SETTINGS // 447 //////////////////////////////////////////////////////// 448 function reOrder(container,deep) { 449 450 451 // TO SAVE THE LAST ORDER FOR THE GALLERY, TO BE ABLE TO REPRODUCE IT 452 if (deep==0) { 453 var lastorder=new Array(); 454 } else 455 var lastorder=container.data('lastorder'); 456 457 458 var cw = container.width(); 459 460 // THIS IS THE CURRENT REQUESTED ORDER 461 var order=container.data('order'); 462 463 // IF ORDER ARRIVED TO THE END, SHOULD START FROM THE BEGINNING 464 if (deep>order.length-1) deep=0; 465 466 467 // SAVE THE ENTRIES IN AN ARRAY 468 var entries=container.find('>.mega-entry.tp-notordered'); 469 470 // LET SEE HOW MANY LAYOUT ART WE HAVE 2-9 ARE THE PREMIUM GRIDS 471 var max_layout_art=12; 472 if (entries.length<9) max_layout_art=entries.length; 473 474 //SAVE THE NEXT LAYOUT HERE 475 var next_layout = order[deep]; 476 477 if (order[deep]==0 || next_layout<2 || next_layout>
47717) 478 if ($.browser.msie && parseInt($.browser.version,0)<9) { 479 next_layout=9; 480 } else { 481 next_layout=Math.round(Math.random()*max_layout_art+1); 482 } 483 484 485 if (next_layout<2) next_layout=2; 486 if (next_layout>17) next_layout=17; 487 488 // PUSH THE NEXT LAYOUT INTO THE SAVED ORDER (IN CASE IT NEEDED SOMEWHERE) 489 lastorder.push(next_layout); 490 491 var element_amount=next_layout; 492 if (next_layout==10 || next_layout==14) element_amount=3; 493 if (next_layout==11 || next_layout==15) element_amount=4; 494 if (next_layout==12 || next_layout==16) element_amount=5; 495 if (next_layout==13 || next_layout==17) element_amount=6; 496 497 498 if (next_layout==11 || next_layout==12 || next_layout==13 || next_layout==15 || next_layout==16 || next_layout==17) 499 if (cw<840 && cw>721) element_amount=4 500 else 501 if (cw<720) element_amount=3; 502 503 504 505 // SET THE NEXT ITEM AS THE NEXT LAYOUT INDICATES 506 entries.slice(0,element_amount).each(function(i) { 507 508 var ent=$(this); 509 510 511 ent.removeClass('tp-layout-first-item').removeClass('tp-layout-last-item').removeClass('very-last-item'); 512 513 // tp-layout SHOWS THAT THE ITEM HAS ALREADY A LAYOUT 514 ent.addClass('tp-ordered tp-layout'); 515 // SAVE THE LAYOUT TYPE IN EACH mega-entry 516 ent.data('layout',next_layout) 517 //SAVE THE CHILD INDEX IN THE mega-entry 518 ent.data('child',i) 519 // MARK FIRST AND LAST ITEMS HERE 520 if (i==0) ent.addClass("tp-layout-first-item"); 521 522 if (i==element_amount-1) { 523 524 ent.addClass("tp-layout-last-item"); 525 } 526 527 //ITEM IS ORDERED, SO NOT ORDERED CLASS CAN BE REMOVED 528 ent.removeClass('tp-notordered'); 529 530 }); 531 532 // WE GO ONE FURTHER; DEEPER IN THE REKURSIVE FUNCTION 533 deep=deep+1; 534 //SAVE THE LAST ORDER !! 535 container.data('lastorder',lastorder); 536 537 //IF WE HAVE MORE ITEM TO ORDER, WE CAN CALL THE REKURSIVE FUNCTION AGAIN 538 if (container.find('>.mega-entry.tp-notordered').length>0) 539 reOrder(container,deep); 540 else 541 {
542 findLastOrdered(container).addClass('very-last-item'); 543 return container; 544 } 545 } 546 547 548 //////////////////////////////////////////////////////// 549 // REORDER THE CONTAINER DEPENDING ON THE SETTINGS // 550 //////////////////////////////////////////////////////// 551 function reOrderOrdered(container,deep,itemtogo) { 552 553 554 555 // TO SAVE THE LAST ORDER FOR THE GALLERY, TO BE ABLE TO REPRODUCE IT 556 if (deep==0) { 557 var lastorder=new Array(); 558 } else 559 var lastorder=container.data('lastorder'); 560 561 562 var cw = container.width(); 563 564 // THIS IS THE CURRENT REQUESTED ORDER 565 var order=container.data('order'); 566 567 // IF ORDER ARRIVED TO THE END, SHOULD START FROM THE BEGINNING 568 if (deep>order.length-1) deep=0; 569 570 571 // SAVE THE ENTRIES IN AN ARRAY 572 var entries=container.find('>.mega-entry.tp-ordered'); 573 574 // LET SEE HOW MANY LAYOUT ART WE HAVE 2-9 ARE THE PREMIUM GRIDS 575 var max_layout_art=12; 576 if (entries.length<9) max_layout_art=entries.length; 577 578 //SAVE THE NEXT LAYOUT HERE 579 var next_layout = order[deep]; 580 581 582 if (order[deep]==0 || next_layout<2 || next_layout>17) 583 if ($.browser.msie && parseInt($.browser.version,0)<9) { 584 next_layout=9; 585 } else { 586 next_layout=Math.round(Math.random()*max_layout_art+1); 587 } 588 589 if (next_layout<2) next_layout=2; 590 if (next_layout>17) next_layout=17; 591 592 // PUSH THE NEXT LAYOUT INTO THE SAVED ORDER (IN CASE IT NEEDED SOMEWHERE) 593 lastorder.push(next_layout); 594 595 var element_amount=next_layout; 596 if (next_layout==10 || next_layout==14) element_amount=3; 597 if (next_layout==11 || next_layout==15) element_amount=4; 598 if (next_layout==12 || next_layout==16) element_amount=5; 599 if (next_layout==13 || next_layout==17) element_amount=6; 600 601 602 if (next_layout==11 || next_layout==12 || next_layout==13 || next_layout==15 || next_layout==16 || next_layout==17) 603 if (cw<840 && cw>721) element_amount=4 604 else 605 if (cw<720) element_amount=3; 606 607 608 var firstent = entries.length-itemtogo; 609 610 // SET THE NEXT ITEM AS THE NEXT LAYOUT INDICATES 611 entries.slice(firstent,firstent+element_amount).each(function(i) { 612 613 var ent=$(this); 614 615 ent.removeClass('tp-layout-first-item').removeClass('tp-layout-last-item').removeClass('very-last-item'); 616 617 // tp-layout SHOWS THAT THE ITEM HAS ALREADY A LAYOUT 618 ent.addClass('tp-ordered tp-layout'); 619 // SAVE THE LAYOUT TYPE IN EACH mega-entry 620 ent.data('layout',next_layout) 621 //SAVE THE CHILD INDEX IN THE mega-entry 622 ent.data('child',i) 623 // MARK FIRST AND LAST ITEMS HERE 624 if (i==0) ent.addClass("tp-layout-first-item"); 625 626 if (i==element_amount-1) { 627 628 ent.addClass("tp-layout-last-item"); 629 } 630 631 //ITEM IS ORDERED, SO NOT ORDERED CLASS CAN BE REMOVED 632 ent.removeClass('tp-notordered'); 633 634 }); 635 636 // WE GO ONE FURTHER; DEEPER IN THE REKURSIVE FUNCTION 637 deep=deep+1; 638 //SAVE THE LAST ORDER !! 639 container.data('lastorder',lastorder); 640 itemtogo=itemtogo-element_amount; 641 642 //IF WE HAVE MORE ITEM TO ORDER, WE CAN CALL THE REKURSIVE FUNCTION AGAIN 643 if (itemtogo>0) 644 reOrderOrdered(container,deep,itemtogo); 645 else 646 {
647 findLastOrdered(container).addClass('very-last-item'); 648 rePosition(container); 649 return container; 650 } 651 } 652 653 654 655 ///////////////////////////// 656 // FIND LAST ORDERED ITEM // 657 /////////////////////////// 658 function findLastOrdered(container) { 659 var lastitem; 660 661 container.find('>.mega-entry.tp-layout.tp-ordered').each(function() { 662 lastitem=$(this); 663 }); 664 665 666 return lastitem; 667 } 668 669 670 ///////////////////////////// 671 // ROUND ME TO RIGHT VALUE // 672 //////////////////////////// 673 function roundme(val) { 674 return val; 675 } 676 677 ////////////////////////// 678 // PUT IT IN POSITION // 679 ////////////////////////// 680 function rePosition(container,maxdelay) { 681 682 var topp=0; 683 var startwidth = container.data('defaultwidth'); 684 var opt=container.data('opt'); 685 var optdelay=opt.delay; 686 687 var firststart=0; 688 if (opt.firststart==1) { 689 firststart=1; 690 opt.firststart=0; 691 } 692 693 694 695 var cw = container.width(); 696 var prop = cw / startwidth; 697 var basicheight = 185; 698 var paddingh = container.data('paddingh'); 699 var paddingv = container.data('paddingv'); 700 701 702 var outi=1; 703 var ini=1; 704 705 var ie=container.data('ie'); 706 var ie9=container.data('ie9'); 707 708 // CALCULATE THE BASI PROPORTIONS 709 var w5 = 5*prop; 710 711 // THE MAX HEIGHT OF THE ITEM 712 var maxhh=0; 713 714 // THE NEW BASIC VALUES 715 //w5 = Math.floor(w5)+dec; 716 717 // Calculate the Basic Grid Sizes 718 var w790 = roundme(w5 * 160); 719 var w780 = roundme(w5 * 158); 720 var w760 = roundme(w5 * 152); 721 var w740 = roundme(w5 * 148); 722 var w660 = roundme(w5 * 132); 723 var w615 = roundme(w5 * 123); 724 var w610 = roundme(w5 * 122); 725 var w595 = roundme(w5 * 119); 726 var w565 = roundme(w5 * 113); 727 var w560 = roundme(w5 * 112); 728 var w490 = roundme(w5 * 98); 729 var w420 = roundme(w5 * 84); 730 var w415 = roundme(w5 * 83); 731 var w395 = roundme(w5 * 79); 732 var w390 = roundme(w5 * 78); 733 var w385 = roundme(w5 * 77); 734 var w370 = roundme(w5 * 74); 735 var w365 = roundme(w5 * 73); 736 var w345 = roundme(w5 * 69); 737 var w340 = roundme(w5 * 68); 738 var w335 = roundme(w5 * 67); 739 var w326 = roundme(w5 * 65.3); 740 var w245 = roundme(w5 * 49); 741 var w240 = roundme(w5 * 48); 742 var w225 = roundme(w5 * 45); 743 var w220 = roundme(w5 * 44); 744 var w196 = roundme(w5 * 39.2); 745 var w195 = roundme(w5 * 39); 746 var w190 = roundme(w5 * 38); 747 var w185 = roundme(w5 * 37); 748 var w180 = roundme(w5 * 36); 749 var w163 = roundme(w5 * 32.66); 750 751 // The Basic Heights 752 var h1110 = roundme(w5 * 222); 753 var h740 = w740; 754 var h555 = roundme(w5*111); 755 var h370 = w370; 756 var h365 = w365; 757 var h245 = w245; 758 var h240 = w240; 759 var h185 = w185; 760 var h180 = w180; 761 762 var heights = new Array(0,0,0,0,0,0,0,0,0); 763 var lastheights = new Array(0,0,0,0,0,0,0,0,0); 764 765 var currentcolumn=0; 766 var layout=0; 767 768 var allelements=container.find('>.mega-entry.tp-layout').length; 769 770 // LET CREATE THE GIRDS 771 container.find('>.mega-entry.tp-layout').each(function(i) { 772 var ent=$(this); 773 var iw = ent.find('.mega-entry-innerwrap'); 774 layout=ent.data('layout'); 775 776 if (layout==11 || layout==12 || layout==13 ) 777 if (cw<840 && cw>721) layout=11 778 else 779 if (cw<720) layout=10; 780 781 if (layout==15 || layout==16 || layout==17) 782 if (cw<840 && cw>721) layout=15 783 else 784 if (cw<720) layout=14; 785 786 // SET THE SPEED 787 var dur=500; 788 789 // SET THE BASIC POSITIONS AND SIZES 790 var w,h,xp; 791 var ph=paddingh; 792 var pv=paddingv; 793 var yp=topp; 794 var lasth=h185; 795 796 if (cw>480) { 797 // THE GRID TYPE 3 POSITIONS SHOULD BE CALCULATED HERE 798 if (layout==2) { 799 if (cw>767) { 800 if (ent.data('child')==0) { w=w565; h=h370; xp=0; lasth=h370} 801 if (ent.data('child')==1) { w=w415; h=h370; xp=w565; ph=0; topp=topp+h370; lasth=h370} 802 803 } else { 804 if (cw>480 && cw<768) { 805 if (ent.data('child')==0) { w=w420; h=h370; xp=0; lasth=h370} 806 if (ent.data('child')==1) { w=w560; h=h370; xp=w420; ph=0; topp=topp+h370; lasth=h370} 807 } 808 } 809 } 810 811 812 // THE GRID TYPE 3 POSITIONS SHOULD BE CALCULATED HERE 813 if (layout==3) { 814 if (cw>767) { 815 if (ent.data('child')==0) { w=w390; h=h370; xp=0; lasth=h370} 816 if (ent.data('child')==1) { w=w225; h=h370; xp=w390; lasth=h370} 817 if (ent.data('child')==2) { w=w365; h=h370; xp=w615; topp=topp+h370; lasth=h370;ph=0;} 818 819 } else { 820 if (cw>480 && cw<768) { 821 if (ent.data('child')==0) { w=w370; h=h370; xp=0; lasth=h370} 822 if (ent.data('child')==1) { w=w390; h=h370; xp=w370; lasth=h370} 823 if (ent.data('child')==2) { w=w220; h=h370; xp=w760; lasth=h370; topp=topp+h370; ph=0;} 824 825 826 } 827 } 828 } 829 830 // THE GRID TYPE 4 POSITIONS SHOULD BE CALCULATED HERE 831 if (layout==4) { 832 if (cw>767) { 833 if (ent.data('child')==0) { w=w420; h=h370; xp=0; lasth=370;} 834 if (ent.data('child')==1) { w=w195; h=h185; xp=w420; } 835 if (ent.data('child')==2) { w=w365; h=h370; xp=w615; ph=0; topp=topp+h185; lasth=h370} 836 if (ent.data('child')==3) { w=w195; h=h185; xp=w420; topp=topp+h185;} 837 838 } else { 839 if (cw>480 && cw<768) { 840 841 if (ent.data('child')==0) { w=w195; h=h185; xp=w420; } 842 if (ent.data('child')==1) { w=w420; h=h370; xp=0; topp=topp+h185; } 843 if (ent.data('child')==2) { w=w195; h=h185; xp=w420; topp=topp-h185;} 844 if (ent.data('child')==3) { w=w365; h=h370; xp=w615; ph=0; topp=topp+h370; lasth=h370} 845 846 } 847 } 848 } 849 850 // THE GRID TYPE 5 POSITIONS SHOULD BE CALCULATED HERE 851 if (layout==5) { 852 if (cw>767) { 853 if (ent.data('child')==0) { w=w420; h=h185; xp=0; } 854 if (ent.data('child')==1) { w=w195; h=h185; xp=w420; } 855 if (ent.data('child')==2) { w=w365; h=h370; xp=w615; ph=0; topp=topp+h185; lasth=h370} 856 if (ent.data('child')==3) { w=w220; h=h185; xp=0; } 857 if (ent.data('child')==4) { w=w395; h=h185; xp=w220; topp=topp+h185;} 858 859 } else { 860 if (cw>480 && cw<768) { 861 if (ent.data('child')==0) { w=w420; h=h185; xp=0; } 862 if (ent.data('child')==1) { w=w195; h=h185; xp=w420; } 863 if (ent.data('child')==2) { w=w365; h=h185; xp=w615; ph=0; topp=topp+h185;} 864 if (ent.data('child')==3) { w=w490; h=h185; xp=0; } 865 if (ent.data('child')==4) { w=w490; h=h185; xp=w490; ph=0; topp=topp+h185;} 866 867 } 868 } 869 } 870 871 872 // THE GRID TYPE 5 POSITIONS SHOULD BE CALCULATED HERE 873 if (layout==6) { 874 875 876 if (cw>767) { 877 if (ent.data('child')==0) { w=w370; h=h370; xp=0; lasth=h370;} 878 if (ent.data('child')==1) { w=w225; h=h185; xp=w370; } 879 if (ent.data('child')==2) { w=w385; h=h185; xp=w595; ph=0; topp=topp+h185;} 880 if (ent.data('child')==3) { w=w225; h=h185; xp=w370; } 881 if (ent.data('child')==4) { w=w195; h=h185; xp=w595; } 882 if (ent.data('child')==5) { w=w190; h=h185; xp=w780; ph=0; topp=topp+h185;} 883 884 } else { 885 if (cw>480 && cw<768) { 886 if (ent.data('child')==0) { w=w225; h=h370; xp=0; lasth=h370;} 887 if (ent.data('child')==1) { w=w340; h=h370; xp=w225; lasth=h370;} 888 if (ent.data('child')==2) { w=w195; h=h185; xp=w565; } 889 if (ent.data('child')==3) { w=w220; h=h185; xp=w760; ph=0; topp=topp+h185;} 890 if (ent.data('child')==4) { w=w195; h=h185; xp=w565; } 891 if (ent.data('child')==5) { w=w220; h=h185; xp=w760; ph=0; topp=topp+h185;} 892 893 } 894 } 895 } 896 897 // THE GRID TYPE 7 POSITIONS SHOULD BE CALCULATED HERE 898 if (layout==7) { 899 900 901 902 903 if (cw>767) { 904 if (ent.data('child')==0) { w=w565; h=h370; xp=0; lasth=h370;} 905 if (ent.data('child')==1) { w=w415; h=h185; xp=w565; ph=0; topp=topp+h185;} 906 if (ent.data('child')==2) { w=w195; h=h185; xp=w565; } 907 if (ent.data('child')==3) { w=w220; h=h370; xp=w760; ph=0; topp=topp+h185;
907lasth=h370} 908 if (ent.data('child')==4) { w=w225; h=h185; xp=0; } 909 if (ent.data('child')==5) { w=w340; h=h185; xp=w225; } 910 if (ent.data('child')==6) { w=w195; h=h185; xp=w565; topp=topp+h185;} 911 912 } else { 913 if (cw>480 && cw<768) { 914 if (ent.data('child')==0) { w=w565; h=h370; xp=0; lasth=h370;} 915 if (ent.data('child')==1) { w=w415; h=h185; xp=w565; ph=0; topp=topp+h185;} 916 if (ent.data('child')==2) { w=w195; h=h185; xp=w565; } 917 if (ent.data('child')==3) { w=w220; h=h185; xp=w760; ph=0; topp=topp+h185;} 918 if (ent.data('child')==4) { w=w225; h=h185; xp=0; } 919 if (ent.data('child')==5) { w=w340; h=h185; xp=w225; } 920 if (ent.data('child')==6) { w=w415; h=h185; xp=w565; ph=0; topp=topp+h185;} 921 922 } 923 } 924 } 925 926 // THE GRID TYPE 8 POSITIONS SHOULD BE CALCULATED HERE 927 if (layout==8) { 928 929 930 931 if (cw>767) { 932 933 if (ent.data('child')==0) { w=w415; h=h185; xp=0; } 934 if (ent.data('child')==1) { w=w345; h=h370; xp=w415; lasth=h370;} 935 if (ent.data('child')==2) { w=w220; h=h185; xp=w760; ph=0; topp=topp+h185;} 936 if (ent.data('child')==3) { w=w195; h=h185; xp=0; } 937 if (ent.data('child')==4) { w=w220; h=h185; xp=w195; } 938 if (ent.data('child')==5) { w=w220; h=h370; xp=w760; ph=0; topp=topp+h185; lasth=h185;} 939 if (ent.data('child')==6) { w=w415; h=h185; xp=0; } 940 if (ent.data('child')==7) { w=w345; h=h185; xp=w415; topp=topp+h185; } 941 942 943 } else { 944 if (cw>480 && cw<768) { 945 if (ent.data('child')==0) { w=w415; h=h185; xp=0; } 946 if (ent.data('child')==1) { w=w195; h=h185; xp=w415; } 947 if (ent.data('child')==2) { w=w370; h=h185; xp=w610; ph=0; topp=topp+h185; lasth=h370;} 948 if (ent.data('child')==3) { w=w195; h=h185; xp=0; } 949 if (ent.data('child')==4) { w=w415; h=h185; xp=w195; } 950 if (ent.data('child')==5) { w=w370; h=h370; xp=w610; ph=0; topp=topp+h185; lasth=h370;} 951 if (ent.data('child')==6) { w=w415; h=h185; xp=0; } 952 if (ent.data('child')==7) { w=w195; h=h185; xp=w415; topp=topp+h185; } 953 954 955 } 956 } 957 } 958 959 960 // THE GRID TYPE 9 POSITIONS SHOULD BE CALCULATED HERE 961 if (layout==9) { 962 963 964 965 if (cw>767) { 966 if (ent.data('child')==0) { w=w565; h=h370; xp=0; lasth=h370;} 967 if (ent.data('child')==1) { w=w415; h=h185; xp=w565; ph=0; topp=topp+h185; } 968 if (ent.data('child')==2) { w=w195; h=h185; xp=w565; } 969 if (ent.data('child')==3) { w=w220; h=h370; xp=w760; ph=0; topp=topp+h185; lasth=h370;} 970 if (ent.data('child')==4) { w=w225; h=h370; xp=0; lasth=h370;} 971 if (ent.data('child')==5) { w=w340; h=h370; xp=w225; lasth=h370;} 972 if (ent.data('child')==6) { w=w195; h=h185; xp=w565; topp=topp+h185; } 973 if (ent.data('child')==7) { w=w195; h=h185; xp=w565; } 974 if (ent.data('child')==8) { w=w220; h=h185; xp=w760; ph=0; topp=topp+h185; } 975 976 977 } else { 978 if (cw>480 && cw<768) { 979 if (ent.data('child')==0) { w=w370; h=h370; xp=0; lasth=h370;} 980 if (ent.data('child')==1) { w=w240; h=h370; xp=w370; lasth=h370;} 981 if (ent.data('child')==2) { w=w370; h=h370; xp=w610; ph=0; topp=topp+h370; lasth=h370;} 982 if (ent.data('child')==3) { w=w240; h=h370; xp=0; lasth=h370;} 983 if (ent.data('child')==4) { w=w370; h=h370; xp=w240; lasth=h370;} 984 if (ent.data('child')==5) { w=w370; h=h370; xp=w610; ph=0; topp=topp+h370; lasth=h370;} 985 if (ent.data('child')==6) { w=w370; h=h370; xp=0; lasth=h370;} 986 if (ent.data('child')==7) { w=w370; h=h370; xp=w370; lasth=h370;} 987 if (ent.data('child')==8) { w=w240; h=h370; xp=w740; ph=0; topp=topp+h370; lasth=h370;} 988 989 990 } 991 } 992 } 993 994 // BASIC GRIDS 995 if (layout>9 && layout<14) { 996 if (layout==10) { 997 w=Math.round(w326); 998 999 w=w + (ph/3); 1000 } else 1001 if (layout==11) { 1002 w=Math.round(w245); 1003 1004 w=w + (ph/4); 1005 } else 1006 if (layout==12) { 1007 w=Math.round(w196); 1008 w=w + (ph/5); 1009 } else 1010 if (layout==13) { 1011 w=Math.round(w163); 1012 w=w + (ph/6); 1013 } 1014 1015 var h=w; 1016 var chil=ent.data('child'); 1017 xp=w*chil; 1018 lasth=h; 1019 1020 if ( (chil==2 && layout==10) || 1021 (chil==3 && layout==11) || 1022 (chil==4 && layout==12) || 1023 (chil==5 && layout==13) || 1024 (ent.hasClass('tp-layout-last-item')) 1025 ) { // ph=0; 1026 topp=topp+h; } 1027 } 1028 1029 1030 // DIFFERENT HEIGHT ITEMS 1031 if (layout>13 && layout<18) { 1032 if (layout==14) { 1033 w=Math.round(w326); 1034 1035 w=w + (ph/3); 1036 } else 1037 if (layout==15) { 1038 w=Math.round(w245); 1039 1040 w=w + (ph/4); 1041 } else 1042 if (layout==16) { 1043 w=Math.round(w196); 1044 w=w + (ph/5); 1045 } else 1046 if (layout==17) { 1047 w=Math.round(w163); 1048 w=w + (ph/6); 1049 } 1050 1051 var chil = ent.data('child'); 1052 var prop =w/ent.data('width'); 1053 1054 h=ent.data('height') * prop; 1055 xp=w*ent.data('child'); 1056 yp=heights[chil]; 1057 lasth=h*prop; 1058 lastheights[chil]=lasth; 1059 topp=yp+h; 1060/* if ( (chil==2 && layout==14) || 1061 (chil==3 && layout==15) || 1062 (chil==4 && layout==16) || 1063 (chil==5 && layout==17) 1064 ) ph=0; 1065*/ 1066 heights[chil] = topp; 1067 } 1068 1069 1070 } else { // IF THE CONTAINER IS TOO SMALL THAN LET 1071 1072 h=Math.round(ent.data('height')*(cw/ent.data('width'))); 1073 w=cw; 1074 ph=0; 1075 xp=0; 1076 yp=topp; 1077 topp=topp+h; 1078 } 1079 1080 1081 1082 var scal=1; 1083 var opaa=1; 1084 var rx = 0; 1085 var rot = 0; 1086 1087 var orot = opt.filterChangeRotate; 1088 if (orot==undefined) rot=30; 1089 1090 if (orot==99) orot = Math.round(Math.random()*360); 1091 1092 1093 1094 // FILTER DEPENDEND SETTINGS 1095 1096 if (ent.hasClass(opt.filter) || opt.filter=="*") { 1097 1098 ent.css({visibility:'visible'}); 1099 if (ie || ie9) { 1100 scal=1; 1101 opaa=1; 1102 1103 1104 } else { 1105 if (opt.filterChangeAnimation=="pagetop" || opt.filterChangeAnimation=="pagebottom" || opt.filterChangeAnimation=="pagemiddle") { 1106 rot=0; 1107 rx=0; 1108 scal=1; 1109 opaa=1; 1110 eiscal=1; 1111 eiopaa=1; 1112 eirx=0; 1113 1114 //ent.transition({rotate:0,'opacity':1},opt.filterChangeSpeed); 1115 } else { 1116 scal=1; 1117 rot=0; 1118 opaa=1; 1119 eiscal=1; 1120 eiopaa=1; 1121 eirx=0; 1122 1123 } 1124 } 1125 1126 } 1127 1128 1129 if (opt.detailview=="on" && opaa==1) opaa=0.4; 1130 if (ent.hasClass('mega-in-detailview')) opaa=1; 1131 1132 ent.removeClass("mega-square").removeClass("mega-portrait").removeClass("mega-landscape"); 1133 var wround=Math.floor(w/100); 1134 var hround=Math.floor(h/100); 1135 if (wround>hround) ent.addClass("mega-landscape"); 1136 if (hround>wround) ent.addClass("mega-portrait"); 1137 if (wround==hround) ent.addClass("mega-square"); 1138 1139 1140 var timer_delay=i*opt.delay; 1141 /*if (maxdelay!=undefined) { 1142 if (allelements-i<6) 1143 timer_delay=(allelements-i)*opt.delay; 1144 }*/ 1145 1146 // PUT THE mega-entry IN THE RIGHT POSITION 1147 if (ie || ie9) { 1148 ent.find('.mega-socialbar').animate({'width':w+'px'}); 1149 ent.animate({ 'scale':scal, 'opacity':opaa, width:w+"px", height:h+"px", left:xp+"px", top:yp+"px", 'paddingBottom':pv+"px", 'paddingRight':ph+"px"},{queue:false,duration:400}); 1150 iw.animate({'background-position':'50% 49%', 'background-size':'cover'},{queue:false,duration:400}); 1151 if (ie) { 1152 var img=iw.find('.ieimg'); 1153 var imgratio=Math.round(ent.data('width')) / Math.round(ent.data('height')); 1154 var conratio=Math.round(w)/Math.round(h); 1155 1156 var nw=w; 1157 var nh=nw/ent.data('width')*ent.data('height'); 1158 1159 1160 if (nh<h) { 1161 1162 nh=h; 1163 nw=nh/ent.data('height')*ent.data('width'); 1164 } 1165 1166 img.css({'width':nw+'px','height':nh+'px'}); 1167 1168 1169 1170 } 1171 1172 } else { 1173 1174 1175 var prop = (cw / startwidth)*100 -16; 1176 1177 1178 if (ent.data('lowsize')!=undefined ) 1179 if (prop<=ent.data('lowsize')) 1180 ent.addClass("mega-lowsize") 1181 else 1182 ent.removeClass("mega-lowsize"); 1183 1184 if (firststart) { 1185 timer_delay=timer_delay+100; 1186 ent.transition({ 'opacity':0, "top":yp+"px","left":xp+"px", width:w, height:h, 'paddingBottom':pv+"px", 'paddingRight':ph+"px",duration:1,queue:false}); 1187 } 1188 setTimeout(function() { 1189 ent.transition({ 'scale':scal, 'opacity':opaa,'rotate':rot, 'z-index':1,width:w, height:h, "top":yp+"px","left":xp+"px", 'paddingBottom':pv+"px", 'paddingRight':ph+"px",duration:opt.filterChangeSpeed,queue:false}); 1190 setTimeout(function() { 1191 ent.find('.mega-entry-innerwrap').transition({'scale':eiscal, 'opacity':eiopaa,perspective: '10000px',rotateX: eirx,duration:opt.filterChangeSpeed,queue:false}); 1192 ent.removeClass('mega-entry-added'); 1193 },50); 1194 iw.transition({'background-position':'50% 49%', 'background-size':'cover',duration:opt.filterChangeSpeed,queue:false}); 1195 },timer_delay); 1196 1197 } 1198 1199 1200 if (ent.hasClass('very-last-item') && !ent.hasClass('tp-layout-last-item')) { 1201 1202 topp=topp+lasth; 1203 1204 } else { 1205 //$('.debug').html($('.debug').html()+"<br>"+topp); 1206 } 1207 1208 if (maxhh<yp+h) maxhh=yp+h; 1209 1210 }) 1211 1212 // IF THE LAST LAYOUT HAD A DIFFERENT HEIGHT ATTRIBUTE, WE NEED TO CALCULATE THE HEIGHETS ROW 1213 if (layout>13 && layout<18) { 1214 1215 topp=heights[0]; 1216 for (allh=0;allh<heights.length;allh++) { 1217 1218 if (topp<heights[allh]) topp=heights[allh]; 1219 } 1220 } 1221 1222 1223 container.css({height:maxhh+"px"}) 1224 1225 1226 } 1227 1228 1229})(jQuery); 1230 1231 1232 1233
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.