1/* -------------------------------------------------------------------------------- / 2 3 Plugin Name: Go â Responsive Portfolio for WP 4 Author: Granth 5 Version: 1.4.0 6 7 +----------------------------------------------------+ 8 TABLE OF CONTENTS 9 +----------------------------------------------------+ 10 11 [1] SETUP 12 [2] AJAX PAGINATION 13 [2.1] LOAD MORE 14 [3] SLIDER 15 [4] POPUP 16 [5] ISOTOPE 17 [6] EFFECTS 18 [7] DEEP LINKING 19 [8] OTHERS 20 21/ -------------------------------------------------------------------------------- */ 22 23(function ($, undefined) { 24 "use strict"; 25 26 $(function () { 27 28 /* -------------------------------------------------------------------------------- / 29 [1] SETUP 30 / -------------------------------------------------------------------------------- */ 31 32 /* Detect IE & Chrome */ 33 var isIE = document.documentMode != undefined && document.documentMode >5 ? document.documentMode : false, 34 isChrome = !!window.chrome && !!window.chrome.webstore; 35 36 /* Detect touch devices */ 37 function isTouchDevice() { return 'ontouchstart' in window || navigator.msMaxTouchPoints; }; 38 var isTouchDevice = isTouchDevice(); 39 40 /* Detect orintationchange */ 41 function supportsOrientationchange() { return 'onorientationchange' in window }; 42 var supportsOrientationchange = supportsOrientationchange(); 43 44 /* Detect CSS transition support */ 45 function supportsTransitions() { 46 var s = document.createElement('p').style; 47 return 'transition' in s || 'WebkitTransition' in s || 'MozTransition' in s || 'msTransition' in s || 'OTransition' in s; 48 } 49 var supportsTransitions = supportsTransitions(); 50 51 /* Detect retina screens */ 52 function isRetina() { 53 var retinaMediaQuery = '(-webkit-min-device-pixel-ratio: 2),\ 54 (min--moz-device-pixel-ratio: 2),\ 55 (-o-min-device-pixel-ratio: 2/1),\ 56 (min-device-pixel-ratio: 2),\ 57 (min-resolution: 192dpi),\ 58 (min-resolution: 2dppx)'; 59 if (window.matchMedia && window.matchMedia(retinaMediaQuery).matches) { 60 return true; 61 } else { 62 return false; 63 }; 64 }; 65 66 var isRetina = isRetina(), 67 retinaImageList = []; 68 69 function loadRetinaImages() { 70 var $retinaReadyImages = $portfolio.find('.gw-gopf-retina'), 71 retinaReadyImageList = []; 72 73 $retinaReadyImages.each(function(index, element) { 74 retinaReadyImageList.push(this.src); 75 }); 76 77 retinaReadyImageList = $.grep(retinaReadyImageList, function(v, k){ 78 return $.inArray(v ,retinaReadyImageList) === k; 79 }); 80 81 for (var x=0;x<retinaReadyImageList.length;x++) { 82 var RetinaImageFileName=retinaReadyImageList[x].substr(0,retinaReadyImageList[x].lastIndexOf('.')), 83 RetinaImageFileExt=retinaReadyImageList[x].substr(retinaReadyImageList[x].lastIndexOf('.')); 84 85 if ($.inArray(RetinaImageFileName+'@2x'+RetinaImageFileExt ,retinaImageList)>-1) { 86 retinaImageList.push(RetinaImageFileName+'@2x'+RetinaImageFileExt); 87 $retinaReadyImages.each(function(index, element) { 88 $(this).removeClass('gw-gopf-retina'); 89 var RetinaImageW = this.naturalWidth; 90 var RetinaImageH = this.naturalHeight; 91 if (this.src==RetinaImageFileName+RetinaImageFileExt) { 92 this.src=RetinaImageFileName+'@2x'+RetinaImageFileExt; 93 this.style.width=RetinaImageW+'px'; 94 this.style.height=RetinaImageH+'px'; 95 }; 96 }); 97 } else { 98 var http = new XMLHttpRequest(); 99 http.open('HEAD', RetinaImageFileName+'@2x'+RetinaImageFileExt, false); 100 http.onreadystatechange = function() { 101 if (http.readyState==4 && http.status==200) { 102 retinaImageList.push(RetinaImageFileName+'@2x'+RetinaImageFileExt); 103 $retinaReadyImages.each(function(index, element) { 104 $(this).removeClass('gw-gopf-retina'); 105 var RetinaImageW = this.naturalWidth; 106 var RetinaImageH = this.naturalHeight; 107 if (this.src==RetinaImageFileName+RetinaImageFileExt) { 108 this.src=RetinaImageFileName+'@2x'+RetinaImageFileExt; 109 this.style.width=RetinaImageW+'px'; 110 this.style.height=RetinaImageH+'px'; 111 }; 112 }); 113 }; 114 }; 115 http.send(); 116 }; 117 }; 118 }; 119 120 var $portfolio=$('.gw-gopf'), 121 $portfolioFilter=$portfolio.filter('.gw-gopf-grid-type').find('.gw-gopf-filter'), 122 $portfolioPosts=$portfolio.filter('.gw-gopf-grid-type').find('.gw-gopf-posts'), 123 $sliders = $portfolio.filter('.gw-gopf-slider-type').find('.gw-gopf-posts'); 124 125 /* Add CSS correction for chrome */ 126 if (isChrome) $portfolio.addClass('gw-gopf-chrome'); 127 128 /* Add 'gw-gopf-touch' class for touch devices */ 129 if (isTouchDevice) { $portfolio.addClass('gw-gopf-touch'); }; 130 131 if (isRetina) { loadRetinaImages() }; 132 133 /* Fix iframe hover */ 134 if (isIE) { 135 $portfolio.find('.gw-gopf-post iframe').delegate(this, 'mouseenter mouseleave', function (event) { 136 var $this = $(this); 137 if (event.type == 'mouseenter') { 138 $this.closest('.gw-gopf-post').trigger('mouseenter').addClass('gw-gopf-current'); 139 $this.closest('.gw-gopf-col-wrap').css('zIndex',3); 140 } else { 141 /* This is not required, just in case 142 $this.closest('.gw-gopf-post').trigger('mouseleave').removeClass('gw-gopf-current'); 143 $this.closest('.gw-gopf-col-wrap').css('zIndex',2);*/ 144 }; 145 }); 146 }; 147 148 /* Add show wrappers in sliders */ 149 $portfolio.filter('.gw-gopf-slider-type').find('.gw-gopf-col-wrap').css({'display' : 'block', 'visibility' : 'visible' }); 150 151 /* -------------------------------------------------------------------------------- / 152 [2] AJAX PAGINATION 153 / -------------------------------------------------------------------------------- */ 154 155 /* -------------------------------------------------------------------------------- / 156 [2.1] LOAD MORE 157 / -------------------------------------------------------------------------------- */ 158 159 $portfolio.on('click', '.gw-gopf-pagination-load-more:not(.gw-gopf-disabled)', function() { 160 var $this=$(this), 161 $wrapper = $this.closest('.gw-gopf-pagination-wrapper'), 162 $currentPortfolio = $this.closest('.gw-gopf'); 163 $wrapper.data('current-page', $wrapper.data('current-page')+1); 164 165 $.ajax({ 166 type: 'post', 167 url: gw_go_portfolio_settings.ajaxurl, 168 data: jQuery.param({ 169 action : 'go_portfolio_ajax_load_portfolio', 170 portfolio_id : $currentPortfolio.parent().attr('id').split('gw_go_portfolio_')[1], 171 current_page : $wrapper.data('current-page'), 172 current_id : $wrapper.data('current-id') 173 }), 174 beforeSend: function () { 175 $this.html($this.data('modified')); 176 $this.addClass('gw-gopf-disabled'); 177 } 178 }).always(function() { 179 $this.html($this.data('original')); 180 $this.removeClass('gw-gopf-disabled'); 181 if (parseInt($wrapper.data('current-page')) == parseInt($wrapper.data('pages'))) { 182 $wrapper.fadeTo(550, 0, function() { 183 $wrapper.slideUp(); 184 }); 185 }; 186 }).fail(function(jqXHR, textStatus) { 187 alert('Ajax error!'); 188 }).done(function(data) { 189 var $ajaxResponse=$('<div />
189', { 'class':'ajax-response', 'html' : data }), 190 $ajaxResult=$ajaxResponse.find('.gw-gopf-posts'), 191 $newPosts=$ajaxResponse.find('.gw-gopf-col-wrap'), 192 newPostsLength=$newPosts.length; 193 194 $currentPortfolio.removeClass('gw-gopf-isotope-ready').addClass('gw-gopf-isotope-new-added').find('.gw-gopf-posts').GWisotope( 'insert', $newPosts, function() { 195 $currentPortfolio.addClass('gw-gopf-isotope-ready'); 196 $currentPortfolio.removeClass('gw-gopf-isotope-new-added'); 197 $currentPortfolio.find('.gw-gopf-cats .gw-gopf-hidden').each(function(index, element) { 198 var $this = $(this); 199 if ($newPosts.filter('[data-filter~="'+$this.data('filter')+'"]').length) { $this.removeClass('gw-gopf-hidden'); }; 200 }); 201 if (isRetina) { loadRetinaImages() }; 202 DoMagnificPopup(); 203 updatePopupGallery($currentPortfolio.data('id')); 204 }); 205 206 var $currentFilter = $currentPortfolio.find('.gw-gopf-filter .gw-gopf-current'); 207 $currentPortfolio.find('.gw-gopf-posts').callIsotope('*'); 208 if ($currentFilter.data('filter')!=undefined) { 209 $currentPortfolio.find('.gw-gopf-posts').GWisotope('reLayout', function(){ 210 $currentPortfolio.find('.gw-gopf-posts').callIsotope('[data-filter~="'+$currentFilter.data('filter')+'"]'); 211 setTimeout(function(){ 212 $currentPortfolio.addClass('gw-gopf-isotope-ready'); 213 },5); 214 }); 215 }; 216 }); 217 return false; 218 }); 219 220 /* -------------------------------------------------------------------------------- / 221 [3] SLIDER - CarouFredSel Slider 222 / -------------------------------------------------------------------------------- */ 223 224 if (jQuery().carouFredSel && $sliders.length) { 225 226 var $scrollOverlay = $('<div class="gw-gopf-posts-wrap-inner-overlay">').appendTo('.gw-gopf-posts-wrap-inner').css({ 227 'position' : 'absolute', 228 'top' : 0, 229 'z-index' : '2', 230 'width' : '100%', 231 'height' : '100%', 232 'display' : 'none' 233 }); 234 235 $sliders.each(function(index, element) { 236 var $this=$(this); 237 $this.addClass('gw-gopf-slider').data('sliderDefaults', { 238 responsive : true, 239 height : 'variable', 240 width : '100%', 241 next : { 242 button : $this.closest('.gw-gopf-posts-wrap').find('.gw-gopf-slider-controls-wrap').find('.gw-gopf-control-next'), 243 onAfter : function(data) { 244 $this.find('.gw-gopf-col-wrap').css('pointer-events','auto'); 245 if ($this.css('letterSpacing')=='30px') { 246 var id=0; 247 } else if ($this.css('letterSpacing')=='20px') { 248 var id=1; 249 } else { 250 var id=$this.data('col')-1; 251 }; 252 253 $this.closest('.gw-gopf-posts-wrap').css('overflow', 'visible'); 254 var items = $this.triggerHandler('currentVisible'); 255 $this.find('.gw-gopf-col-wrap').css({ 256 'opacity' : 0, 257 'zIndex' : 0, 258 'position': 'absolute', 259 'visibility' : 'hidden' 260 }).eq(id).css({ 261 'position' : 'relative', 262 'left' : '0', 263 'z-index' : 'auto' 264 }); 265 items.each(function(index, element) { 266 $(element).css({ 'visibility' : 'visible', 'opacity' : 1, 'position': 'relative', 'z-index' : 'auto' }); 267 }); 268 $this.closest('.gw-gopf-posts-wrap-inner').find('.gw-gopf-posts-wrap-inner-overlay').hide(); 269 } 270 }, 271 prev : { 272 button : $this.closest('.gw-gopf-posts-wrap').find('.gw-gopf-slider-controls-wrap').find('.gw-gopf-control-prev'), 273 onAfter : function(data) { 274 $this.find('.gw-gopf-col-wrap').css('pointer-events','auto'); 275 if ($this.css('letterSpacing')=='30px') { 276 var id=1; 277 } else if ($this.css('letterSpacing')=='20px') { 278 var id=2; 279 } else { 280 var id=$this.data('col'); 281 }; 282 283 $this.closest('.gw-gopf-posts-wrap').css('overflow', 'visible'); 284 var items = $this.triggerHandler('currentVisible'); 285 $this.find('.gw-gopf-col-wrap').css({ 286 'opacity' : 0, 287 'z-index' : 0, 288 'position': 'absolute', 289 'visibility' : 'hidden' 290 }).eq(id).css({ 291 'position' : 'relative', 292 'left': '0', 293 'z-index' : 'auto' 294 }); 295 items.each(function(index, element) { 296 $(element).css({ 'visibility' : 'visible', 'opacity' : 1, 'position': 'relative', 'z-index' : 'auto' }); 297 }); 298 $this.closest('.gw-gopf-posts-wrap-inner').find('.gw-gopf-posts-wrap-inner-overlay').hide(); 299 } 300 }, 301 scroll : { 302 queue : true, 303 items: 1, 304 onBefore : function(data) { 305 var items = $this.triggerHandler('currentVisible'); 306 $this.find('.gw-gopf-col-wrap').css('pointer-events','none'); 307 $portfolio.find('.gw-gopf-current.gw-gopf-post').removeClass('gw-gopf-current').trigger('tapOff'); 308 309 if ($this.css('letterSpacing')=='30px') { 310 var id=1; 311 } else if ($this.css('letterSpacing')=='20px') { 312 var id=2; 313 } else { 314 var id=$this.data('col'); 315 }; 316 317 $this.closest('.gw-gopf-posts-wrap').css('overflow', 'hidden'); 318 var items = $this.triggerHandler('currentVisible'); 319 $this.find('.gw-gopf-col-wrap').css({ 320 'visibility' : 'hidden', 321 'position': 'relative', 322 'opacity' : 0, 323 'zIndex' : 0 324 }).eq(id).css({ 325 'position' : 'absolute', 326 'left' : $this.closest('.caroufredsel_wrapper').width()+'px', 327 'z-index' : '200', 328 'visibility' : 'visible', 329 'opacity' : 1, 330 'zIndex' : 'auto' 331 }); 332 items.each(function(index, element) { 333 $(element).css({ 'visibility' : 'visible', 'opacity' : 1, 'position': 'relative', 'z-index' : 'auto' }); 334 }); 335 336 $this.closest('.gw-gopf-posts-wrap-inner').find('.gw-gopf-posts-wrap-inner-overlay').show(); 337 $this.trigger('resume'); 338 }, 339 onAfter : function(data) { 340 var direction = $this.triggerHandler('configuration', 'direction'); 341 $this.find('.gw-gopf-col-wrap').css('pointer-events','auto'); 342 /* Scrolling left */ 343 if (direction=='left') { 344 if ($this.css('letterSpacing')=='30px') { 345 var id=0; 346 } else if ($this.css('letterSpacing')=='20px') { 347 var id=1; 348 } else { 349 var id=$this.data('col')-1; 350 }; 351 352 $this.closest('.gw-gopf-posts-wrap').css('overflow', 'visible'); 353 var items = $this.triggerHandler('currentVisible'); 354 $this.find('.gw-gopf-col-wrap').css({ 355 'opacity' : 0, 356 'zIndex' : 0 357 }).eq(id).css({ 358 'position' : 'relative', 359 'left' : '0', 360 'z-index' : 'auto' 361 }); 362 items.each(function(index, element) { 363 $(element).css({ 'visibility' : 'visible', 'opacity' : 1, 'position': 'relative', 'z-index' : 'auto' }); 364 }); 365 $this.closest('.gw-gopf-posts-wrap-inner').find('.gw-gopf-posts-wrap-inner-overlay').hide(); 366 } 367 368 /* Scrolling right */ 369 if (direction=='right') { 370 if ($this.css('letterSpacing')=='30px') { 371 var id=1; 372 } else if ($this.css('letterSpacing')=='20px') { 373 var id=2; 374 } else { 375 var id=$this.data('col'); 376 } 377 378 $this.closest('.gw-gopf-posts-wrap').css('overflow', 'visible'); 379 var items = $this.triggerHandler('currentVisible'); 380 $this.find('.gw-gopf-col-wrap').css({ 381 'opacity' : 0, 382 'z-index' : 0 383 }).eq(id).css({ 384 'position' : 'relative', 385 'left': '0', 386 'z-index' : 'auto' 387 }); 388 items.each(function(index, element) { 389 $(element).css({ 'visibility' : 'visible', 'opacity' : 1, 'position': 'relative', 'z-index' : 'auto' }); 390 }); 391 $this.closest('.gw-gopf-posts-wrap-inner').find('.gw-gopf-posts-wrap-inner-overlay').hide(); 392 } 393 } 394 }, 395 swipe : { 396 onMouse : true 397 }, 398 items : { 399 height : 'variable', 400 visible : { 401 min : 1, 402 max : $this.data('col') 403 } 404 }, 405 onCreate : function (data) { 406 $this.closest('.gw-gopf-posts-wrap').css('overflow', 'visible'); 407 var items = $this.triggerHandler('currentVisible'); 408 $this.find('.gw-gopf-col-wrap').css({ 409 'visibility' : 'hidden', 410 'position': 'absolute', 411 'opacity' : 0 412 }); 413 items.each(function(index, element) { 414 $(element).css({ 'visibility' : 'visible', 'opacity' : 1, 'position': 'relative' }); 415 }); 416 417 $(window).on('resize', function(){ 418 var items = $this.triggerHandler('currentVisible'); 419 $this.find('.gw-gopf-col-wrap').css({ 420 'visibility' : 'hidden', 421 'position': 'absolute', 422 'opacity' : 0 423 }); 424 items.each(function(index, element) { 425 $(element).css({ 'visibility' : 'visible', 'opacity' : 1, 'position': 'relative' }); 426 }); 427 var paused = $this.triggerHandler('isPaused'); 428 if ($this.css('letterSpacing')=='30px') { 429 $this.trigger('configuration', ['items.visible', 1]); 430 } else if ($this.css('letterSpacing')=='20px') { 431 $this.trigger('configuration', ['items.visible', 2]); 432 } else { 433 $this.trigger('configuration', ['items.visible', $this.data('col')]); 434 }; 435 if (paused) { $this.trigger('pause', true); } 436 }); 437 } 438 }); 439 440 /* Call slider */ 441 $this.carouFredSel(jQuery.extend($this.data('slider'), $this.data('sliderDefaults'))); 442 }); 443 444 }; 445 446 /* -------------------------------------------------------------------------------- / 447 [4] POPUP - Magnific Popup 448 / -------------------------------------------------------------------------------- */ 449 450 var portfolioGallery = [], portfolioGalleryO = [], mfpOpened=false; 451 function DoMagnificPopup() { 452 if (jQuery().magnificPopup) { 453 $portfolio.each(function(index, element) { 454 var $this = $(this); 455 portfolioGallery[$this.data('id')] = $this.find('.gw-gopf-magnific-popup, .gw-gopf-magnific-popup-html').magnificPopup({ 456 type : 'image', 457 closeOnContentClick : true, 458 removalDelay : 300, 459 mainClass : 'my-mfp-slide-bottom', 460 closeMarkup : '<a title="%title%" class="gw-gopf-mfp-close"></a>', 461 titleSrc: 'title', 462 gallery : { 463 enabled : $this.data('lbgallery'), 464 arrowMarkup: '<a title="%title%" class="gw-gopf-mfp-arrow mfp-arrow mfp-arrow-%dir%"></a>' 465 }, 466 image : { 467 markup: '<div class="mfp-figure">'+ 468 '<div class="mfp-close"></div>'+ 469 '<div class="mfp-img"></div>'+ 470 '<div class="mfp-bottom-bar">'+ 471 '<div class="gw-gopf-mfp-title mfp-title"></div>'+ 472 '<div class="gw-gopf-mfp-counter mfp-counter"></div>'+ 473 '</div>'+ 474 '</div>' 475 }, 476 iframe : { 477 patterns : { 478 vimeo : { 479 index: 'vimeo.com/', 480 id: '/', 481 src: '//player.vimeo.com/video/%id%&autoplay=1' 482 }, 483 dailymotion : { 484 index : 'dailymotion.com/', 485 id : '/', 486 src :'//dailymotion.com/embed/video/%id%?autoPlay=1' 487 }, 488 metacafe : { 489 index : 'metacafe.com/', 490 id : '/', 491 src : 'http://www.metacafe.com/embed/%id%?ap=1' 492 }, 493 soundcloud : { 494 index : 'soundcloud.com', 495 id : null, 496 src : '%id%' 497 },
498 mixcloud : { 499 index : 'mixcloud.com', 500 id: null, 501 src: '%id%' 502 }, 503 beatport : { 504 index : 'beatport.com', 505 id : null, 506 src : '%id%' 507 } 508 }, 509 markup : '<div class="mfp-iframe-scaler">'+ 510 '<div class="mfp-close"></div>'+ 511 '<iframe class="mfp-iframe" frameborder="0" allowfullscreen></iframe>'+ 512 '<div class="mfp-bottom-bar" style="margin-top:4px;"><div class="gw-gopf-mfp-title mfp-title"></div><div class="gw-gopf-mfp-counter mfp-counter"></div></div>'+ 513 '</div>' 514 }, 515 callbacks : { 516 elementParse : function(item) { 517 if ($(item.el).hasClass('gw-gopf-magnific-popup-html')) { 518 item.type = 'iframe' 519 }; 520 }, 521 change : function() { 522 var $currentItem = $(this.currItem.el); 523 if ($currentItem.hasClass('gw-gopf-magnific-popup-html')) { 524 setTimeout(function(){ 525 $('.mfp-title').html($currentItem.attr('title')) 526 },5); 527 } 528 529 /* Deep linking */ 530 if ($this.data('deepLinking')) { 531 mfpOpened = $(this.currItem.el); 532 if(history.pushState) { 533 location.hash = '#mpf-popup@'+$currentItem.attr('href')+'|'+$currentItem.data('id').split('_')[0]+'|'+$currentItem.data('id').split('_')[1]; 534 if (history.state==$currentItem.data('id')) { 535 history.pushState($currentItem.data('id'), null, window.location.href.replace(window.location.origin,'').split('#')[0]+'#mpf-popup@'+$currentItem.attr('href')+'|'+$currentItem.data('id').split('_')[0]+'|'+$currentItem.data('id').split('_')[1]); 536 }; 537 } else { 538 location.hash = '#mpf-popup@'+$currentItem.attr('href')+'|'+$currentItem.data('id').split('_')[0]+'|'+$currentItem.data('id').split('_')[1]; 539 }; 540 }; 541 542 var forcedHeight = $(this.currItem.el).data('height'); 543 544 if (forcedHeight != undefined) { 545 setTimeout(function(){ 546 $('.mfp-iframe-scaler').css({ 547 'paddingTop' : 0, 548 'display' : 'table-cell', 549 'verticalAlign' : 'middle', 550 'height' : forcedHeight 551 }); 552 },5); 553 } else { 554 setTimeout(function(){ 555 $('.mfp-iframe-scaler').css({ 556 'padding-top': '56.25%', 557 'display' : 'block', 558 'verticalAlign' : 'baseline', 559 'height' : 0 560 }); 561 },5); 562 }; 563 }, 564 beforeClose : function() { 565 var st = parseInt($(window).scrollTop()) 566 window.location.hash = ''; 567 $('html,body').scrollTop(st) 568 if ($(this.currItem.el).hasClass('gw-gopf-magnific-popup-html')) { 569 $('.mfp-wrap').css('display','none'); 570 }; 571 mfpOpened=false; 572 }, 573 afterClose : function() { 574 if (this.items[this.index].type == 'iframe') { 575 /* Firefox bug fix - force to redraw thumbnail */ 576 var timer=setInterval(function() { 577 if ($('.mfp-bg').length==0) { 578 clearInterval(timer); 579 $portfolio.find('.gw-gopf-post').css('opacity','0.99'); 580 setTimeout(function(){ $portfolio.find('.gw-gopf-post').css('opacity','1'); },20) 581 } 582 },50); 583 }; 584 } 585 } 586 }); 587 }); 588 }; 589 }; 590 591 DoMagnificPopup(); 592 593 function updatePopupGallery( portfolioId ) { 594 var $galleryItems = $portfolio.filter('[data-id="'+portfolioId+'"]').find('.gw-gopf-magnific-popup, .gw-gopf-magnific-popup-html'); 595 portfolioGallery[portfolioId].splice(0, $galleryItems.length); 596 $galleryItems.each(function(index, element) { 597 if (!$(this).closest('.gw-gopf-isotope-hidden').length) { 598 portfolioGallery[portfolioId].push(this); 599 }; 600 }); 601 }; 602
603 $portfolio.find('.gw-gopf-magnific-popup, .gw-gopf-magnific-popup-html').on('mfpOpen', function(e) { 604 if (jQuery().carouFredSel && $sliders.length) { 605 $portfolio.find('.gw-gopf-posts-wrap-inner-overlay').show(); 606 setTimeout(function() { 607 $sliders.each(function(index, element) { 608 var $this = $(this); 609 $this.trigger('pause', true); 610 }); 611 }, 10); 612 } 613 }); 614 615 $portfolio.find('.gw-gopf-magnific-popup, .gw-gopf-magnific-popup-html').on('mfpAfterClose', function(e) { 616 if (jQuery().carouFredSel && $sliders.length) { 617 $portfolio.find('.gw-gopf-posts-wrap-inner-overlay').hide(); 618 setTimeout(function() { 619 $sliders.each(function(index, element) { 620 var $this = $(this); 621 $this.trigger('resume'); 622 }); 623 }, 10); 624 } 625 }); 626 627 /* -------------------------------------------------------------------------------- / 628 [5] ISOTOPE 629 / -------------------------------------------------------------------------------- */ 630 631 /* Isotope */ 632 if (jQuery().GWisotope) { 633 634 /* Call Isotope plugin */ 635 $.fn.callIsotope = function ( filter ) { 636 var $this = $(this); 637 638 $this.GWisotope({
639 filter : filter, 640 transformsEnabled: $this.closest('.gw-gopf').data('transenabled') ? true : false, 641 animationEngine: isIE && isIE == 8 ? 'css' : 'best-available', 642 containerClass : 'gw-gopf-isotope', 643 hiddenClass : 'gw-gopf-isotope-hidden', 644 itemClass : 'gw-gopf-isotope-item', 645 layoutMode : 'masonry', 646 onLayout: function( $elems, instance ) { 647 if (instance.element.closest('.gw-gopf').data('id')!=undefined) { 648 updatePopupGallery(instance.element.closest('.gw-gopf').data('id')); 649 }; 650 } 651 }); 652 }; 653 654 /* Extend the plugin to hack change column number if required */ 655 $.extend( $.GWIsotope.prototype, { 656 _masonryReset : function() { 657 // layout-specific props 658 this.masonry = {}; 659 660 // FIXME shouldn't have to call this again 661 this._getSegments(); 662 663 /* Hack - set col number manually */ 664 if (this.element.hasClass('gw-gopf-posts')) { 665 if (this.element.css('letterSpacing')=='30px') { 666 this.masonry.cols = 1; 667 } else if (this.element.css('letterSpacing')=='20px') { 668 this.masonry.cols = 2; 669 } else { 670 this.masonry.cols = this.element.data('col'); 671 }; 672 var i = this.masonry.cols; 673 }; 674 /* end of Hack */ 675 676 this.masonry.colYs = []; 677 while (i--) { 678 this.masonry.colYs.push( 0 ); 679 } 680 } 681 }); 682 683 /* Filter button events */ 684 $portfolioFilter.delegate('div a', 'click', function(e) { 685 var $this=$(this), $parent=$this.closest('span'), filter; 686 e.preventDefault(); 687 688 $parent.addClass('gw-gopf-current').siblings().removeClass('gw-gopf-current'); 689 if ($parent.data('filter')==undefined) { 690 $this.closest('.gw-gopf').find('.gw-gopf-posts').callIsotope('*'); 691 } else { 692 $this.closest('.gw-gopf').find('.gw-gopf-posts').callIsotope('[data-filter~="'+$parent.data('filter')+'"]'); 693 }; 694 }); 695 696 697 /* Call Isotope plugin */ 698 $portfolio.filter('.gw-gopf-grid-type').each(function(index, element) { 699 var $this = $(this); 700 $this.find('.gw-gopf-posts').callIsotope('*'); 701 if (!$this.hasClass('gw-gopf-isotope-ready')) { $this.closest('.gw-gopf').addClass('gw-gopf-isotope-ready'); }; 702 }); 703 704 }; 705 706 /* -------------------------------------------------------------------------------- / 707 [6] EFFECTS 708 / -------------------------------------------------------------------------------- */ 709 710 /* Handle taps on touch devices */ 711 712 if (isTouchDevice) { 713 $portfolio.delegate('.gw-gopf-post', 'touchstart', function (event) { 714 var $this = $(this); 715 $portfolio.find('.gw-gopf-current.gw-gopf-post').not($this).removeClass('gw-gopf-current').trigger('tapOff'); 716 if ( !$this.hasClass('gw-gopf-current')) { 717 $this.addClass('gw-gopf-current'); 718 $this.trigger('tapOn'); 719 }; 720 }); 721 722 /* Remove effect when you tap anywhere out */ 723 $(document).delegate(this, 'touchstart', function (event) { 724 if (!$(event.target).closest('.gw-gopf-current.gw-gopf-post').length) { 725 $portfolio.find('.gw-gopf-current.gw-gopf-post').removeClass('gw-gopf-current').trigger('tapOff'); 726 }; 727 if (!$(event.target).closest('.gw-gopf-posts-wrap').length) { 728 $portfolio.find('.gw-gopf-current.gw-gopf-post').removeClass('gw-gopf-current').trigger('tapOff'); 729 }; 730 731 }); 732 733 /* Some trick to re-enable filtering (exluded element fix) */ 734 $portfolio.delegate('.gw-gopf-cats > span a', 'touchstart', function (event) { 735 var $this = $(this); 736 $this.off('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd'); 737 $this.one('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function() { 738 /* $(this).trigger('click');* - just in case */ 739 }); 740 $portfolio.find('.gw-gopf-current.gw-gopf-post').removeClass('gw-gopf-current').trigger('tapOff'); 741 }); 742 743 /* Remove effect - exluded elements correction */ 744 $('body').delegate('button, input, select, textarea, a, .noSwipe', 'touchstart', function (event) { 745 if (!$(event.target).closest('.gw-gopf-current.gw-gopf-post').length) { 746 $portfolio.find('.gw-gopf-current.gw-gopf-post').removeClass('gw-gopf-current').trigger('tapOff'); 747 }; 748 }); 749 750 }; 751 752 var events = !isTouchDevice ? 'mouseenter mouseleave' : 'tapOn tapOff'; 753 754 $portfolio.delegate('.gw-gopf-post', events, function (event) { 755 var $this = $(this), 756 postHeight = $this.outerHeight(), 757 $content = $this.find('.gw-gopf-post-content'), 758 contentHeight = $content.outerHeight(), 759 $overlayInner = $this.find('.gw-gopf-post-overlay-inner'), 760 overlayInnerHeight = $overlayInner.height(); 761 762 if (event.type == 'mouseenter' || event.type == 'tapOn') { 763 $this.find('.gw-gopf-post-overlay').css('height', $this.find('.gw-gopf-post-header').outerHeight()); 764 $this.find('.gw-gopf-post-content-wrap').show(); 765 } 766 767 /* Flex Slide Up */ 768 if ($this.closest('.gw-gopf').hasClass('gw-gopf-style-flex-slide-up')) { 769 if (event.type == 'mouseenter' || event.type == 'tapOn') { 770 if ( postHeight-contentHeight-overlayInnerHeight <= 0 ) { 771 $overlayInner.css('display', 'none'); 772 } else { 773 $overlayInner.css('display', 'inline-block'); 774 }; 775 776 /* Media wrap */ 777 $this.find('.gw-gopf-post-content-wrap').css({ 778 'top' : postHeight 779 }).off('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd'); 780 781 setTimeout(function(){ 782 $this.find('.gw-gopf-post-content-wrap').css({ 783 'top' : postHeight-contentHeight < 0 ? 0 : postHeight-contentHeight 784 }); 785 }, 1); 786 787 /* Overlay */ 788 $this.find('.gw-gopf-post-overlay').css({ 789 'height' : postHeight 790 }).off('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd'); 791 792 setTimeout(function(){ 793 $this.find('.gw-gopf-post-overlay').css({ 794 'height' : postHeight-contentHeight < 0 ? 0 : postHeight-contentHeight 795 }).off('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd'); 796 }, 1); 797 }; 798 799 if (event.type == 'mouseleave' || event.type == 'tapOff') { 800 $this.find('.gw-gopf-post-content-wrap').css({ 801 'top' : supportsTransitions ? postHeight : '100%' 802 }).one('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function() { 803 $(this).css({ 'top' : '100%' }); 804 }); 805 806 $this.find('.gw-gopf-post-overlay').css({ 807 'height' : supportsTransitions ? postHeight : '100%' 808 }).one('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function() { 809 $(this).css({ 'height' : '100%' }); 810 }); 811 }; 812 }; 813 814 /* Flex Slide & Push Up */ 815 if ($this.closest('.gw-gopf').hasClass('gw-gopf-style-flex-slide-push-up')) { 816 if (event.type == 'mouseenter' || event.type == 'tapOn') { 817 if ( postHeight-contentHeight-overlayInnerHeight <= 0 ) { 818 $overlayInner.css('display', 'none'); 819 } else { 820 $overlayInner.css('display', 'inline-block'); 821 }; 822 823 /* Media wrap */ 824 $this.find('.gw-gopf-post-content-wrap').css({ 825 'top' : postHeight 826 }).off('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd'); 827 828 setTimeout(function(){ 829 $this.find('.gw-gopf-post-content-wrap').css({ 830 'top' : postHeight-contentHeight < 0 ? 0 : postHeight-contentHeight 831 }); 832 }, 1); 833 834 /* Overlay */ 835 $this.find('.gw-gopf-post-overlay').css({ 836 'top' : postHeight-contentHeight < 0 ? 100 : contentHeight, 837 'height' : postHeight 838 }).off('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd'); 839 840 setTimeout(function(){ 841 $this.find('.gw-gopf-post-overlay').css({ 842 'height' : postHeight-contentHeight < 0 ? 0 : postHeight-contentHeight 843 }).off('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd'); 844 }, 1); 845 846 /* Header */ 847 $this.find('.gw-gopf-post-header').css({ 848 'marginTop' : (postHeight-contentHeight < 0 ? postHeight : contentHeight)*-1, 849 'marginBottom' : postHeight-contentHeight < 0 ? postHeight : contentHeight 850 }); 851 }; 852 853 if (event.type == 'mouseleave' || event.type == 'tapOff') { 854 $this.find('.gw-gopf-post-content-wrap').css({ 855 'top' : supportsTransitions ? postHeight : '100%' 856 }).one('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function() { 857 $(this).css({ 'top' : '100%' }); 858 }); 859 860 $this.find('.gw-gopf-post-overlay').css({ 861 'top' : 0, 862 'height' : supportsTransitions ? postHeight : '100%' 863 }).one('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function() { 864 $(this).css({ 'height' : '100%' }); 865 }); 866 867 $this.find('.gw-gopf-post-header').css({ 868 'marginTop' : 0, 869 'marginBottom' : 0 870 }); 871 }; 872 }; 873 874 /* Flex Slide & Push Up Full */ 875 if ($this.closest('.gw-gopf').hasClass('gw-gopf-style-flex-slide-push-up-full')) { 876 if (event.type == 'mouseenter' || event.type == 'tapOn') { 877 $this.find('.gw-gopf-post-header').css({ 878 'marginTop' : postHeight*-1, 879 'marginBottom' : postHeight 880 }); 881 }; 882 883 if (event.type == 'mouseleave' || event.type == 'tapOff') { 884 $this.find('.gw-gopf-post-header').css({ 885 'marginTop' : 0, 886 'marginBottom' : 0 887 }); 888 }; 889 }; 890 891 /* Flex Slide Down */ 892 if ($this.closest('.gw-gopf').hasClass('gw-gopf-style-flex-slide-down')) { 893 if (event.type == 'mouseenter' || event.type == 'tapOn') { 894 if ( postHeight-contentHeight-overlayInnerHeight <= 0 ) { 895 $overlayInner.css('display', 'none'); 896 } else { 897 $overlayInner.css('display', 'inline-block'); 898 }; 899 900 /* Media wrap */ 901 $this.find('.gw-gopf-post-content-wrap').css({ 902 'bottom' : postHeight 903 }).off('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd'); 904 905 setTimeout(function(){ 906 $this.find('.gw-gopf-post-content-wrap').css({ 907 'bottom' : postHeight-contentHeight < 0 ? 0 : postHeight-contentHeight 908 }); 909 }, 1); 910 911 /* Overlay */ 912 $this.find('.gw-gopf-post-overlay').css({ 913 'height' : postHeight 914 }).off('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd'); 915 916 setTimeout(function(){ 917 $this.find('.gw-gopf-post-overlay').css({ 918 'height' : postHeight-contentHeight < 0 ? 0 : postHeight-contentHeight 919 }).off('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd'); 920 }, 1); 921 }; 922 923 if (event.type == 'mouseleave' || event.type == 'tapOff') { 924 $this.find('.gw-gopf-post-content-wrap').css({ 925 'bottom' : supportsTransitions ? postHeight : '100%' 926 }).one('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function() { 927 $(this).css({ 'bottom' : '100%' }); 928 }); 929 930 $this.find('.gw-gopf-post-overlay').css({ 931 'height' : supportsTransitions ? postHeight : '100%' 932 }).one('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function() { 933 $(this).css({ 'height' : '100%' }); 934 }); 935 }; 936 }; 937 938 /* Flex Slide & Push Down */ 939 if ($this.closest('.gw-gopf').hasClass('gw-gopf-style-flex-slide-push-down')) { 940 if (event.type == 'mouseenter' || event.type == 'tapOn') { 941 if ( postHeight-contentHeight-overlayInnerHeight <= 0 ) { 942 $overlayInner.css('display', 'none'); 943 } else { 944 $overlayInner.css('display', 'inline-block'); 945 }; 946 947 /* Media wrap */ 948 $this.find('.gw-gopf-post-content-wrap').css({ 949 'bottom' : postHeight 950 }).off('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd'); 951 952 setTimeout(function(){ 953 $this.find('.gw-gopf-post-content-wrap').css({ 954 'bottom' : postHeight-contentHeight < 0 ? 0 : postHeight-contentHeight 955 }); 956 }, 1); 957 958 /* Overlay */ 959 $this.find('.gw-gopf-post-overlay').css({ 960 'bottom' : postHeight-contentHeight < 0 ? 100 : contentHeight, 961 'height' : postHeight 962 }).off('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd'); 963 964 setTimeout(function(){ 965 $this.find('.gw-gopf-post-overlay').css({ 966 'height' : postHeight-contentHeight < 0 ? 0 : postHeight-contentHeight 967 }).off('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd'); 968 }, 1); 969 970 /* Header */ 971 $this.find('.gw-gopf-post-header').css({ 972 'marginBottom' : (postHeight-contentHeight < 0 ? postHeight : contentHeight)*-1, 973 'marginTop' : postHeight-contentHeight < 0 ? postHeight : contentHeight 974 }); 975 }; 976 977 if (event.type == 'mouseleave' || event.type == 'tapOff') { 978 $this.find('.gw-gopf-post-content-wrap').css({ 979 'bottom' : supportsTransitions ? postHeight : '100%' 980 }).one('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function() { 981 $(this).css({ 'bottom' : '100%' }); 982 }); 983 984 $this.find('.gw-gopf-post-overlay').css({ 985 'bottom' : 0, 986 'height' : supportsTransitions ? postHeight : '100%' 987 }).one('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function() { 988 $(this).css({ 'height' : '100%' }); 989 }); 990 991 $this.find('.gw-gopf-post-header').css({ 992 'marginBottom' : 0, 993 'marginTop' : 0 994 }); 995 }; 996 }; 997 998 /* Flex Slide & Push Down Full */ 999 if ($this.closest('.gw-gopf').hasClass('gw-gopf-style-flex-slide-push-down-full')) { 1000 if (event.type == 'mouseenter' || event.type == 'tapOn') { 1001 $this.find('.gw-gopf-post-header').css({ 1002 'marginTop' : postHeight, 1003 'marginBottom' : postHeight*-1 1004 }); 1005 }; 1006 1007 if (event.type == 'mouseleave' || event.type == 'tapOff') { 1008 $this.find('.gw-gopf-post-header').css({ 1009 'marginTop' : 0, 1010 'marginBottom' : 0 1011 }); 1012 }; 1013 }; 1014 1015 /* Door style */ 1016 if ($this.closest('.gw-gopf').hasClass('gw-gopf-style-door-slide-down')) { 1017 if (event.type == 'mouseenter' || event.type == 'tapOn') { 1018 $this.css({ 1019 'marginBottom' : contentHeight * -1, 1020 'paddingBottom' : contentHeight 1021 }); 1022 }; 1023 1024 if (event.type == 'mouseleave' || event.type == 'tapOff') { 1025 $this.css({ 1026 'marginBottom' : 0, 1027 'paddingBottom' : 0 1028 }); 1029 }; 1030 }; 1031 1032 /* Delux Push Up */ 1033 if ($this.closest('.gw-gopf').hasClass('gw-gopf-style-delux-push-up')) { 1034 if (event.type == 'mouseenter' || event.type == 'tapOn') { 1035 $this.find('.gw-gopf-post-content-wrap').css('top', $this.find('.gw-gopf-post-header').outerHeight()); 1036 $this.css({ 1037 'marginTop' : contentHeight * -1, 1038 'paddingBottom' : contentHeight 1039 }); 1040 1041 }; 1042 1043 if (event.type == 'mouseleave' || event.type == 'tapOff') { 1044 $this.css({ 1045 'marginTop' : 0, 1046 'paddingBottom' : 0 1047 }); 1048 }; 1049 }; 1050 1051 /* Delux Push Down */ 1052 if ($this.closest('.gw-gopf').hasClass('gw-gopf-style-delux-push-down')) { 1053 if (event.type == 'mouseenter' || event.type == 'tapOn') { 1054 $this.find('.gw-gopf-post-content-wrap').css('bottom', $this.find('.gw-gopf-post-header').outerHeight()); 1055 $this.find('.gw-gopf-post-overlay').css('height', $this.find('.gw-gopf-post-header').outerHeight()); 1056 $this.css({ 1057 'marginBottom' : contentHeight * -1, 1058 'paddingTop' : contentHeight 1059 }); 1060 }; 1061 1062 if (event.type == 'mouseleave' || event.type == 'tapOff') { 1063 $this.css({ 1064 'marginBottom' : 0, 1065 'paddingTop' : 0 1066 }); 1067 }; 1068 }; 1069 1070 }); 1071 1072 /* -------------------------------------------------------------------------------- / 1073 [7] DEEP LINKING 1074 / -------------------------------------------------------------------------------- */ 1075 1076 function doHashChange() { 1077 var hashinfo = getHashInfo(), 1078 galleryItemIndex; 1079 1080 if (!hashinfo || hashinfo==undefined) { 1081 if (mfpOpened!=false) { 1082 $.magnificPopup.close(); 1083 } 1084 return false;
1085 } else { 1086 if (!$portfolio.filter('[data-id="'+hashinfo[2]+'"]').data('deepLinking')) { return false; }; 1087 }; 1088 1089 if (portfolioGallery[hashinfo[2]]!=undefined) { 1090 portfolioGallery[hashinfo[2]].each(function(index, element) { 1091 if ($(this).data('id')==hashinfo[1]+'_'+hashinfo[2]) { 1092 galleryItemIndex=index; 1093 }; 1094 }); 1095 1096 if (galleryItemIndex>-1) { 1097 if (mfpOpened!=false) { 1098 if (mfpOpened.data('id')!=$(portfolioGallery[hashinfo[2]]).eq(galleryItemIndex).data('id')) { 1099 portfolioGallery[hashinfo[2]].magnificPopup('open', galleryItemIndex); 1100 }; 1101 } else { 1102 portfolioGallery[hashinfo[2]].magnificPopup('open', galleryItemIndex); 1103 }; 1104 }; 1105 }; 1106 }; 1107 1108 doHashChange(); 1109 1110 function getHash() { 1111 var currentHash = location.hash && location.hash !='' ? location.hash.split('#')[1] : null; 1112 return currentHash; 1113 }; 1114 1115 function getHashInfo() { 1116 var hashData = getHash(); 1117 if (!hashData) return false; 1118 if (hashData && hashData.split('@').length == 2 && hashData.split('@')[0] == 'mpf-popup' && hashData.split('@')[1].split('|').length == 3) { 1119 var hashParts = hashData.split('@')[1].split('|'); 1120 return hashParts; 1121 }; 1122 }; 1123 1124 if (window.addEventListener) { 1125 window.addEventListener("hashchange", doHashChange, false); 1126 } else if (window.attachEvent) { 1127 window.attachEvent("onhashchange", doHashChange); 1128 }; 1129 1130 /* -------------------------------------------------------------------------------- / 1131 [8] OTHERS 1132 / -------------------------------------------------------------------------------- */ 1133 1134 var resizeFired = false, 1135 reLayoutFired = false; 1136 1137 function onResizeEvents() { 1138 $portfolio.filter('.gw-gopf-isotope-ready').find('.gw-gopf-posts').GWisotope('reLayout'); 1139 setTimeout(function(){ 1140 reLayoutFired = false; 1141 }, 900); 1142 } 1143 1144 /* Windows resize */ 1145 $(window).resize(function() { 1146 if (!resizeFired) { 1147 resizeFired = true; 1148 if (!reLayoutFired) { 1149 reLayoutFired = true; 1150 onResizeEvents(); 1151 }; 1152 }; 1153 setTimeout(function(){ resizeFired = false; }, 100); 1154 }); 1155 1156 /* Device orientation change */ 1157 if (supportsOrientationchange) { 1158 window.onorientationchange = function() { 1159 $portfolio.find('.gw-gopf-current.gw-gopf-post').removeClass('gw-gopf-current').trigger('tapOff'); 1160 if (!resizeFired) { 1161 resizeFired = true; 1162 if (!reLayoutFired) { 1163 reLayoutFired = true; 1164 onResizeEvents(); 1165 }; 1166 }; 1167 }; 1168 }; 1169 1170 }); 1171}(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.