1(function($) 2{ 3 "use strict"; 4 5 $(document).ready(function() 6 { 7 //global variables that are used on several ocassions 8 $.avia_utilities = $.avia_utilities || {}; 9 10 if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) && 'ontouchstart' in document.documentElement) 11 { 12 $.avia_utilities.isMobile = true; 13 } 14 else 15 { 16 $.avia_utilities.isMobile = false; 17 } 18 19 //activate fixed bg fallback for mobile 20 if($.fn.avia_mobile_fixed) 21 $('.avia-bg-style-fixed').avia_mobile_fixed(); 22 23 //activate parallax scrolling for backgrounds. 24 if($.fn.avia_parallax) 25 $('.av-parallax').avia_parallax(); 26 27 //calculate the browser height and append a css rule to the head 28 if($.fn.avia_browser_height) 29 $('.av-minimum-height, .avia-fullscreen-slider, .av-cell-min-height').avia_browser_height(); 30 31 //calculate the height of each video section 32 if($.fn.avia_video_section) 33 $('.av-section-with-video-bg').avia_video_section(); 34 35 //creates team social icon tooltip 36 new $.AviaTooltip({'class': "avia-tooltip", data: "avia-tooltip", delay:0, scope: "body"}); 37 38 //creates icon element tooltip 39 new $.AviaTooltip({'class': "avia-tooltip avia-icon-tooltip", data: "avia-icon-tooltip", delay:0, scope: "body"}); 40 41 $.avia_utilities.activate_shortcode_scripts(); 42 43 //layer slider height helper 44 $('.avia-layerslider').layer_slider_height_helper(); 45 46 //"ajax" portfolio 47 if($.fn.avia_portfolio_preview) 48 { 49 $('.grid-links-ajax').avia_portfolio_preview(); 50 } 51 52 // actiavte the masonry script: sorting/loading/etc 53 if($.fn.avia_masonry) 54 $('.av-masonry').avia_masonry(); 55 56 //activate the accordion 57 if($.fn.aviaccordion) 58 $('.aviaccordion').aviaccordion(); 59 60 61 //activate the accordion 62 if($.fn.avia_textrotator) 63 $('.av-rotator-container').avia_textrotator(); 64 65 //activates the tab section shortcode 66 if($.fn.avia_sc_tab_section) 67 { 68 $('.av-tab-section-container').avia_sc_tab_section(); 69 } 70 71 //activates the hor gallery shortcode 72 if($.fn.avia_hor_gallery) 73 { 74 $('.av-horizontal-gallery').avia_hor_gallery(); 75 } 76 77 78 if($.fn.avia_delayed_animation_in_container) 79 { 80 $('.av-animation-delay-container').avia_delayed_animation_in_container(); 81 } 82 83 84 }); 85 86 87 88 89 90// ------------------------------------------------------------------------------------------- 91// ACTIVATE ALL SHORTCODES 92// ------------------------------------------------------------------------------------------- 93 94 $.avia_utilities = $.avia_utilities || {}; 95 $.avia_utilities.activate_shortcode_scripts = function(container) 96 { 97 if(typeof container == 'undefined'){ container = 'body';} 98 99 //activates the form shortcode 100 if($.fn.avia_ajax_form) 101 { 102 $('.avia_ajax_form:not( .avia-disable-default-ajax )', container).avia_ajax_form(); 103 } 104 105 activate_waypoints(container); 106 107 //activate the video api 108 if($.fn.aviaVideoApi) 109 { 110 $('.avia-slideshow iframe[src*="youtube.com"], .av_youtube_frame, .avia-slideshow iframe[src*="vimeo.com"], .avia-slideshow video').aviaVideoApi({}, 'li'); 111 } 112 113 //activates the toggle shortcode 114 if($.fn.avia_sc_toggle) 115 { 116 $('.togglecontainer', container).avia_sc_toggle(); 117 } 118 119 //activates the tabs shortcode 120 if($.fn.avia_sc_tabs) 121 { 122 $('.top_tab', container).avia_sc_tabs(); 123 $('.sidebar_tab', container).avia_sc_tabs({sidebar:true}); 124 } 125 126 //activates behavior and animation for gallery 127 if($.fn.avia_sc_gallery) 128 { 129 $('.avia-gallery', container).avia_sc_gallery(); 130 } 131 132 //activates animated number shortcode 133 if($.fn.avia_sc_animated_number) 134 { 135 $('.avia-animated-number', container).avia_sc_animated_number(); 136 } 137 138 //animation for elements that are not connected like icon shortcode 139 if($.fn.avia_sc_animation_delayed) 140 { 141 $('.av_font_icon', container).avia_sc_animation_delayed({delay:100}); 142 $('.avia-image-container', container).avia_sc_animation_delayed({delay:100}); 143 $('.av-hotspot-image-container', container).avia_sc_animation_delayed({delay:100}); 144 $('.av-animated-generic', container).avia_sc_animation_delayed({delay:100}); 145 } 146 147 //activates animation for iconlist 148 if($.fn.avia_sc_iconlist) 149 { 150 $('.avia-icon-list.av-iconlist-big', container).avia_sc_iconlist(); 151 } 152 153 //activates animation for progress bar 154 if($.fn.avia_sc_progressbar) 155 { 156 $('.avia-progress-bar-container', container).avia_sc_progressbar(); 157 } 158 159 //activates animation for testimonial 160 if($.fn.avia_sc_testimonial) 161 { 162 $('.avia-testimonial-wrapper', container).avia_sc_testimonial(); 163 } 164 165 //activate the fullscreen slider 166 $('.avia-slideshow.av_fullscreen', container).aviaFullscreenSlider(); 167 168 //activate the aviaslider 169 $('.avia-slideshow:not(.av_fullscreen)', container).aviaSlider(); 170 171 //content slider 172 $('.avia-content-slider-active', container).aviaSlider({wrapElement: '.avia-content-slider-inner', slideElement:'.slide-entry-wrap', fullfade:true}); 173 174 //testimonial slider 175 $('.avia-slider-testimonials', container).aviaSlider({wrapElement: '.avia-testimonial-row', slideElement:'.avia-testimonial', fullfade:true}); 176 177 //load and activate maps 178 if($.fn.aviaMaps) 179 { 180 $('.avia-google-map-container', container).aviaMaps(); 181 } 182 183 //load magazine sorting 184 if($.fn.aviaMagazine) 185 { 186 $('.av-magazine-tabs-active', container).aviaMagazine(); 187 } 188 189 //load image hotspot 190 if($.fn.aviaHotspots) 191 { 192 $('.av-hotspot-image-container', container).aviaHotspots(); 193 } 194 195 //load countdown 196 if($.fn.aviaCountdown) 197 { 198 $('.av-countdown-timer', container).aviaCountdown(); 199 } 200 201 //load audio player 202 if($.fn.aviaPlayer) 203 { 204 $('.av-player', container).aviaPlayer(); 205 } 206 207 208 } 209 210 211 function activate_waypoints(container) 212 { 213 //activates simple css animations of the content once the user scrolls to an elements 214 if($.fn.avia_waypoints) 215 { 216 if(typeof container == 'undefined'){ container = 'body';}; 217 218 $('.avia_animate_when_visible', container).avia_waypoints(); 219 $('.avia_animate_when_almost_visible', container).avia_waypoints({ offset: '80%'}); 220 221 if(container == 'body') container = '.avia_desktop body'; 222 $('.av-animated-generic', container).avia_waypoints({ offset: '95%'}); 223 } 224 } 225 226 227 228 229 230 231// ------------------------------------------------------------------------------------------- 232// 233// AVIA Player 234// 235// ------------------------------------------------------------------------------------------- 236(function($) 237{ 238 "use strict"; 239 240 var autostarted = false, 241 container = null, 242 243 monitorStart = function( container ) 244 { 245 var play_pause = container.find('.av-player-player-container .mejs-playpause-button'); 246 247 if( play_pause.length == 0 ) 248 { 249 setTimeout( function(){ 250 monitorStart( container ); 251 }, 200 ); 252 } 253 254 if( ! play_pause.hasClass('mejs-pause') ) 255 { 256 play_pause.trigger( 'click' ); 257 } 258 259 }; 260 261 $.fn.aviaPlayer = function( options ) 262 { 263 if( ! this.length ) return; 264 265 return this.each(function() 266 { 267 var _self = {}; 268 269 _self.container = $( this ); 270 271 /** 272 * Limit autostart to the first player with this option set only 273 *
274 * DOM is not loaded completely and we have no event when player is loaded 275 */ 276 if( _self.container.hasClass( 'avia-playlist-autoplay' ) && ! autostarted ) 277 { 278 if( ( _self.container.css('display') == 'none') || ( _self.container.css("visibility") == "hidden" ) ) 279 { 280 return; 281 } 282 283 autostarted = true; 284 setTimeout( function(){ 285 monitorStart( _self.container ); 286 }, 200 ); 287 } 288 289 }); 290 }; 291}(jQuery)); 292 293 294// ------------------------------------------------------------------------------------------- 295// 296// AVIA Image Hotspots 297// 298// ------------------------------------------------------------------------------------------- 299(function($) 300{ 301 "use strict"; 302 303 $.fn.aviaHotspots = function( options ) 304 { 305 if(!this.length) return; 306 307 return this.each(function() 308 { 309 var _self = {}; 310 311 _self.container = $(this); 312 _self.hotspots = _self.container.find('.av-image-hotspot'); 313 314 _self.container.on('avia_start_animation', function() 315 { 316 setTimeout(function() 317 { 318 _self.hotspots.each(function(i) 319 { 320 var current = $(this); 321 setTimeout(function(){ current.addClass('av-display-hotspot'); },300 * i); 322 }); 323 },400); 324 }); 325 326 }); 327 }; 328 329}(jQuery)); 330 331 332 333 334// ------------------------------------------------------------------------------------------- 335// 336// AVIA Magazine function for magazine sorting 337// 338// ------------------------------------------------------------------------------------------- 339(function($) 340{ 341 "use strict"; 342 343 var animating = false, 344 methods = { 345 346 switchMag: function(clicked, _self) 347 { 348 var current = $(clicked) 349 350 if(current.is('.active_sort') || animating) return; 351 352 var filter = current.data('filter'), 353 oldContainer = _self.container.filter(':visible'), 354 newContainer = _self.container.filter('.' + filter); 355 356 //switch Class 357 animating = true; 358 _self.sort_buttons.removeClass('active_sort'); 359 current.addClass('active_sort'); 360 361 //apply fixed heiht for transition 362 _self.magazine.height(_self.magazine.outerHeight()); 363 364 //switch items 365 oldContainer.avia_animate({opacity:0}
365, 200, function() 366 { 367 oldContainer.css({display:'none'}); 368 newContainer.css({opacity:0, display:'block'}).avia_animate({opacity:1}, 150, function() 369 { 370 _self.magazine.avia_animate({height: (newContainer.outerHeight() + _self.sort_bar.outerHeight())}, 150, function() 371 { 372 _self.magazine.height('auto'); 373 animating = false; 374 }); 375 376 }); 377 }); 378 } 379 }; 380 381 382 $.fn.aviaMagazine = function( options ) 383 { 384 if(!this.length) return; 385 386 return this.each(function() 387 { 388 var _self = {}; 389 390 _self.magazine = $(this), 391 _self.sort_buttons = _self.magazine.find('.av-magazine-sort a'); 392 _self.container = _self.magazine.find('.av-magazine-group'); 393 _self.sort_bar = _self.magazine.find('.av-magazine-top-bar'); 394 395 _self.sort_buttons.on('click', function(e){ e.preventDefault(); methods.switchMag(this, _self); } ); 396 }); 397 } 398 399}(jQuery)); 400 401// ------------------------------------------------------------------------------------------- 402// 403// AVIA MAPS API - loads the google maps api asynchronously 404// 405// afterwards applies the map to the container 406// 407// ------------------------------------------------------------------------------------------- 408 409 410(function($) 411{ 412 "use strict"; 413 414 $.AviaMapsAPI = function(options, container) 415 { 416 if(typeof window.av_google_map == 'undefined') 417 { 418 $.avia_utilities.log('Map creation stopped, var av_google_map not found'); 419 return; 420 } 421 422 // gatehr container and map data 423 this.container = container; 424 this.$container = $( container ); 425 this.$body = $('body'); 426 this.$mapid = this.$container.data('mapid') - 1; 427 this.$data = window.av_google_map[this.$mapid]; 428 this.retina = window.devicePixelRatio > 1; 429 430 // set up the whole api object 431 this._init( options ); 432 }; 433 434 $.AviaMapsAPI.apiFiles = 435 { 436 loading: false, 437 finished: false, 438 src: '' 439 }; 440 441 $.AviaMapsAPI.prototype = 442 { 443 _init: function() 444 { 445 if( 'undefined' == typeof avia_framework_globals.gmap_maps_loaded || avia_framework_globals.gmap_maps_loaded == '' ) 446 { 447 // this is only a fallback setting 448 $.AviaMapsAPI.apiFiles.src = 'https://maps.googleapis.com/maps/api/js?v=3.30&callback=aviaOnGoogleMapsLoaded'; 449 if( typeof avia_framework_globals.gmap_api != 'undefined' && avia_framework_globals.gmap_api != "" ) 450 { 451 $.AviaMapsAPI.apiFiles.src += "&key=" + avia_framework_globals.gmap_api; 452 } 453 } 454 else 455 { 456 $.AviaMapsAPI.apiFiles.src = avia_framework_globals.gmap_maps_loaded; 457 } 458 459 this._bind_execution(); 460 this._getAPI(); 461 }, 462 463 _getAPI: function( ) 464 { 465 //make sure the api file is loaded only once 466 if((typeof window.google == 'undefined' || typeof window.google.maps == 'undefined') && $.AviaMapsAPI.apiFiles.loading == false) 467 { 468 $.AviaMapsAPI.apiFiles.loading = true; 469 var script = document.createElement('script'); 470 script.type = 'text/javascript'; 471 script.src = $.AviaMapsAPI.apiFiles.src; 472 473 document.body.appendChild(script); 474 } 475 else if((typeof window.google != 'undefined' && typeof window.google.maps != 'undefined') || $.AviaMapsAPI.apiFiles.loading == false) 476 //else if($.AviaMapsAPI.apiFiles.finished === true) 477 { 478 this._applyMap(); 479 } 480 }, 481 482 _bind_execution: function() 483 { 484 this.$body.on('av-google-maps-api-loaded', $.proxy( this._applyMap, this) ); 485 }, 486 487 _applyMap: function() 488 { 489 if(typeof this.map != 'undefined') return; 490 if(!this.$data.marker || !this.$data.marker[0] || !this.$data.marker[0].long || !this.$data.marker[0].long) 491 { 492 $.avia_utilities.log('Latitude or Longitude missing', 'map-error'); 493 return; 494 } 495 496 var _self = this, 497 mobile_drag = $.avia_utilities.isMobile ? this.$data.mobile_drag_control : true, 498 zoomValue = this.$data.zoom == "auto" ? 10 : this.$data.zoom; 499 500 var mapTypeControl = false; 501 var mapTypeId = google.maps.MapTypeId.ROADMAP; 502 var mapTypeControlOptions = google.maps.MapTypeControlStyle.DROPDOWN_MENU; 503 504 switch( this.$data.maptype_control ) 505 { 506 case 'dropdown': 507 mapTypeControl = true; 508 mapTypeControlOptions = google.maps.MapTypeControlStyle.DROPDOWN_MENU; 509 break; 510 case 'horizontal': 511 mapTypeControl = true; 512 mapTypeControlOptions = google.maps.MapTypeControlStyle.HORIZONTAL_BAR; 513 break; 514 case 'default': 515 mapTypeControl = true; 516 mapTypeControlOptions = google.maps.MapTypeControlStyle.DEFAULT; 517 break; 518 default: 519 mapTypeControl = false;
520 mapTypeControlOptions = google.maps.MapTypeControlStyle.DROPDOWN_MENU; 521 break; 522 } 523 524 switch( this.$data.maptype_id ) 525 { 526 case 'SATELLITE': 527 mapTypeId = google.maps.MapTypeId.SATELLITE; 528 break; 529 case 'HYBRID': 530 mapTypeId = google.maps.MapTypeId.HYBRID; 531 break; 532 case 'TERRAIN': 533 mapTypeId = google.maps.MapTypeId.TERRAIN; 534 break; 535 default: 536 mapTypeId = google.maps.MapTypeId.ROADMAP; 537 } 538 539 this.mapVars = { 540 mapMaker: false, //mapmaker tiles are user generated content maps. might hold more info but also be inaccurate 541 backgroundColor:'transparent', 542 streetViewControl: false, 543 zoomControl: this.$data.zoom_control, 544 //draggable: mobile_drag, 545 gestureHandling: 'cooperative', 546 scrollwheel: false, 547 zoom: zoomValue, 548 mapTypeControl: mapTypeControl, 549 mapTypeControlOptions: {style:mapTypeControlOptions}, 550 mapTypeId: mapTypeId, 551 center: new google.maps.LatLng(this.$data.marker[0].lat, this.$data.marker[0].long), 552 styles:[{featureType: "poi", elementType: "labels", stylers: [ { visibility: "off" }] }] 553 }; 554 555 this.map = new google.maps.Map(this.container, this.mapVars); 556 557 this._applyMapStyle(); 558 559 if(this.$data.zoom == "auto") 560 { 561 this._setAutoZoom(); 562 } 563 564 google.maps.event.addListenerOnce(this.map, 'tilesloaded', function() { 565 _self._addMarkers(); 566 }); 567 }, 568 569 _setAutoZoom: function() 570 { 571 var bounds = new google.maps.LatLngBounds(); 572 573 for (var key in this.$data.marker) 574 { 575 bounds.extend( new google.maps.LatLng (this.$data.marker[key].lat , this.$data.marker[key].long) ); 576 } 577 578 this.map.fitBounds(bounds); 579 }, 580 581 _applyMapStyle: function() 582 { 583 var stylers = [], style = [], mapType, style_color = ""; 584 585 if(this.$data.hue != "") stylers.push({hue: this.$data.hue}); 586 if(this.$data.saturation != "") stylers.push({saturation: this.$data.saturation}); 587 588 if(stylers.length) 589 { 590 style = [{ 591 featureType: "all", 592 elementType: "all", 593 stylers: stylers 594 }, { 595 featureType: "poi", 596 stylers: [ 597 { visibility: "off" } 598 ] 599 }]; 600 601 602 if(this.$data.saturation == "fill") 603 { 604 605 style_color = this.$data.hue ||Â "#242424"; 606 607 var c = style_color.substring(1); // strip # 608 var rgb = parseInt(c, 16); // convert rrggbb to decimal 609 var r = (rgb >> 16) & 0xff; // extract red 610 var g = (rgb >> 8) & 0xff; // extract green 611 var b = (rgb >> 0) & 0xff; // extract blue 612 613 var luma = 0.2126 * r + 0.7152 * g + 0.0722 * b; // per ITU-R BT.709 614 var lightness = 1; 615 var street_light = 2; 616 617 if (luma > 60) { 618 lightness = -1; 619 street_light = 3; 620 } 621 if (luma > 220) { 622 lightness = -2; 623 street_light = -2; 624 } 625 626 style = [ 627{"featureType":"all","elementType":"all","stylers":[{"color":style_color},{"lightness":0}]}, 628{"featureType":"all","elementType":"labels.text.fill","stylers":[{"color":style_color},{"lightness":(25 * street_light)}]}, 629{"featureType":"all","elementType":"labels.text.stroke","stylers":[{"visibility":"on"},{"color":style_color},{"lightness":3}]}, 630{"featureType":"all","elementType":"labels.icon","stylers":[{"visibility":"off"}]}, 631{"featureType":"administrative","elementType":"geometry.fill","stylers":[{"color":style_color},{"lightness":30}]}, 632{"featureType":"administrative","elementType":"geometry.stroke","stylers":[{"color":style_color},{"lightness":30},{"weight":1.2}]}, 633{"featureType":"landscape","elementType":"geometry","stylers":[{visibility: 'simplified'},{"color":style_color},{"lightness":3}]}, 634{"featureType":"poi","elementType":"geometry","stylers":[{ "visibility": "off" }]}, 635{"featureType":"road.highway","elementType":"geometry.fill","stylers":[{"color":style_color},{"lightness":-3}]}, 636{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":style_color},{"lightness":2},{"weight":0.2}]}, 637{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":style_color},{"lightness":-3}]}, 638{"featureType":"road.local","elementType":"geometry","stylers":[{"color":style_color},{"lightness":-3}]}, 639{"featureType":"transit","elementType":"geometry","stylers":[{"color":style_color},{"lightness":-3}]}, 640{"featureType":"water","elementType":"geometry","stylers":[{"color":style_color},{"lightness":-20}]} 641 ]; 642 } 643 644 mapType = new google.maps.StyledMapType(style, { name:"av_map_style" }); 645 this.map.mapTypes.set('av_styled_map', mapType); 646 this.map.setMapTypeId('av_styled_map'); 647 } 648 }, 649 650 _addMarkers: function() 651 { 652 for (var key in this.$data.marker) 653 { 654 var _self = this; 655 656 (function(key, _self) 657 { 658 setTimeout(function() 659 { 660 var marker = ""; 661 662 if(!_self.$data.marker[key] || !_self.$data.marker[key].long || !_self.$data.marker[key].long) 663 { 664 $.avia_utilities.log('Latitude or Longitude for single marker missing', 'map-error'); 665 return; 666 } 667 668 _self.$data.LatLng = new google.maps.LatLng(_self.$data.marker[key].lat, _self.$data.marker[key].long); 669 670 var markerArgs = { 671 flat: false, 672 position: _self.$data.LatLng, 673 animation: google.maps.Animation.BOUNCE, 674 map: _self.map, 675 title: _self.$data.marker[key].address, 676 optimized: false 677 }; 678 679 //set a custom marker image if available. also set the size and reduce the marker on retina size so its sharp 680 if(_self.$data.marker[key].icon && _self.$data.marker[key].imagesize) 681 { 682 var size = _self.$data.marker[key].imagesize, half = "", full = ""; 683 684 if(_self.retina && size > 40) size = 40; //retina downsize to at least half the px size 685 half = new google.maps.Point(size / 2, size ) ; //used to position the marker 686 full = new google.maps.Size(size , size ) ; //marker size 687 markerArgs.icon = new google.maps.MarkerImage(_self.$data.marker[key].icon, null, null, half, full); 688 } 689 690 marker = new google.maps.Marker(markerArgs); 691 692 setTimeout(function(){ marker.setAnimation(null); _self._infoWindow(_self.map, marker, _self.$data.marker[key]); },500); 693 694 },200 * (parseInt(key,10) + 1)); 695 696 }(key, _self)); 697 } 698 }, 699 700 _infoWindow: function(map, marker, data) 701 { 702 var info = $.trim(data.content); 703 704 if(info != "") 705 { 706 var infowindow = new google.maps.InfoWindow({ 707 content: info 708 }); 709 710 google.maps.event.addListener(marker, 'click', function() { 711 infowindow.open(map,marker); 712 }); 713 714 if(data.tooltip_display) infowindow.open(map,marker); 715 } 716 } 717 718 719 }; 720 721 //simple wrapper to call the api. makes sure that the api data is not applied twice 722 $.fn.aviaMaps = function( options ) 723 { 724 return this.each(function() 725 { 726 var self = $.data( this, 'aviaMapsApi' ); 727 728 if(!self) 729 { 730 self = $.data( this, 'aviaMapsApi', new $.AviaMapsAPI( options, this ) ); 731 } 732 }); 733 }; 734 735})( jQuery ); 736 737//this function is executed once the api file is loaded 738window.aviaOnGoogleMapsLoaded = function(){ $('body').trigger('av-google-maps-api-loaded'); $.AviaMapsAPI.apiFiles.finished = true; }; 739 740 741// ------------------------------------------------------------------------------------------- 742// 743// AVIA VIDEO API - make sure that youtube, vimeo and html 5 use the same interface 744// 745// requires froogaloop vimeo library and youtube iframe api (yt can be loaded async) 746// 747// ------------------------------------------------------------------------------------------- 748 749 750(function($) 751{ 752 "use strict"; 753 754 $.AviaVideoAPI = function(options, video, option_container) 755 { 756 this.videoElement = video; 757 758 // actual video element. either iframe or video 759 this.$video = $( video ); 760
761 // container where the AviaVideoAPI object will be stored as data, and that can receive events like play, pause etc 762 // also the container that allows to overwrite javacript options by adding html data- attributes 763 this.$option_container = option_container ? $( option_container ) : this.$video; 764 765 //mobile device? 766 this.isMobile = $.avia_utilities.isMobile; 767 768 //iamge fallback use 769 this.fallback = this.isMobile ? this.$option_container.is('.av-mobile-fallback-image') : false; 770 771 if(this.fallback) return; 772 773 // set up the whole api object 774 this._init( options ); 775 776 } 777 778 $.AviaVideoAPI.defaults = { 779 780 loop: false, 781 mute: false, 782 controls: false, 783 events: 'play pause mute unmute loop toggle reset unload' 784 785 }; 786 787 $.AviaVideoAPI.apiFiles = 788 { 789 youtube : {loaded: false, src: 'https://www.youtube.com/iframe_api' } 790 } 791 792 $.AviaVideoAPI.players = 793 { 794 795 } 796 797 $.AviaVideoAPI.prototype = 798 { 799 _init: function( options ) 800 { 801 // set slider options 802 this.options = this._setOptions(options); 803 804 // info which video service we are using: html5, vimeo or youtube 805 this.type = this._getPlayerType(); 806 807 this.player = false; 808 809 // store the player object to the this.player variable created by one of the APIs (mediaelement, youtube, vimeo) 810 this._setPlayer(); 811 812 // set to true once the events are bound so it doesnt happen a second time by accident or racing condition 813 this.eventsBound = false; 814 815 // info if the video is playing 816 this.playing = false; 817 818 //set css class that video is currently not playing 819 this.$option_container.addClass('av-video-paused'); 820 821 //play pause indicator 822 this.pp = $.avia_utilities.playpause(this.$option_container); 823 }, 824 825 826 //set the video options by first merging the default options and the passed options, then checking the video element if any data attributes overwrite the option set 827 _setOptions: function(options) 828 { 829 var newOptions = $.extend( true, {}, $.AviaVideoAPI.defaults, options ), 830 htmlData = this.$option_container.data(), 831 i = ""; 832 833 //overwritte passed option set with any data properties on the html element 834 for (i in htmlData) 835 { 836 if (htmlData.hasOwnProperty(i) && (typeof htmlData[i] === "string" || typeof htmlData[i] === "number" || typeof htmlData[i] === "boolean")) 837 { 838 newOptions[i] = htmlData[i]; 839 } 840 } 841 842 return newOptions; 843 }, 844 845 846 //get the player type 847 _getPlayerType: function() 848 { 849 var vid_src = this.$video.get(0).src || this.$video.data('src'); 850 851 852 if(this.$video.is('video')) return 'html5'; 853 if(this.$video.is('.av_youtube_frame')) return 'youtube'; 854 if(vid_src.indexOf('vimeo.com') != -1 ) return 'vimeo'; 855 if(vid_src.indexOf('youtube.com') != -1) return 'youtube'; 856 }, 857 858 //get the player object 859 _setPlayer: function() 860 { 861 var _self = this; 862 863 switch(this.type) 864 { 865 case "html5": 866 867 this.player = this.$video.data('mediaelementplayer'); 868 869 //appply fallback. sometimes needed for safari 870 if(!this.player) 871 { 872 this.$video.data('mediaelementplayer', $.AviaVideoAPI.players[ this.$video.attr('id').replace(/_html5/,'') ] ); 873 this.player = this.$video.data('mediaelementplayer'); 874 } 875 876 this._playerReady(); 877 878 break; 879 880 case "vimeo": 881 882 this.player = Froogaloop(this.$video.get(0)); 883 this._playerReady(); 884 885 break; 886 887 case "youtube": 888 889 this._getAPI(this.type); 890 $('body').on('av-youtube-iframe-api-loaded', function(){ _self._playerReady(); }); 891 892 break; 893 } 894 }, 895 896 _getAPI: function( api ) 897 { 898 //make sure the api file is loaded only once 899 if($.AviaVideoAPI.apiFiles[api].loaded === false) 900 { 901 $.AviaVideoAPI.apiFiles[api].loaded = true; 902 //load the file async 903 var tag = document.createElement('script'), 904 first = document.getElementsByTagName('script')[0]; 905 906 tag.src = $.AviaVideoAPI.apiFiles[api].src; 907 first.parentNode.insertBefore(tag, first); 908 } 909 }, 910 911 912 913 //wait for player to be ready, then bind events 914 _playerReady: function() 915 { 916 var _self = this; 917 918 this.$option_container.on('av-video-loaded', function(){ _self._bindEvents(); }); 919 920 switch(this.type) 921 { 922 case "html5": 923 924 this.$video.on('av-mediajs-loaded', function(){ _self.$option_container.trigger('av-video-loaded'); }); 925 this.$video.on('av-mediajs-ended' , function(){ _self.$option_container.trigger('av-video-ended'); }); 926 927 break; 928 case "vimeo": 929 930 //finish event must be applied after ready event for firefox 931 _self.player.addEvent('ready', function(){ _self.$option_container.trigger('av-video-loaded'); 932 _self.player.addEvent('finish', function(){ _self.$option_container.trigger('av-video-ended'); }); 933 }); 934 935 // vimeo sometimes does not fire. fallback jquery load event should fix this 936 // currently not used because it causes firefox problems 937 /* 938 this.$video.load(function() 939 { 940 if(_self.eventsBound == true || typeof _self.eventsBound == 'undefined') return; 941 _self.$option_container.trigger('av-video-loaded'); 942 $.avia_utilities.log('VIMEO Fallback Trigger'); 943 }); 944 */ 945 946 947 break; 948 949 case "youtube": 950 951 var params = _self.$video.data(); 952 953 if(_self._supports_video()) params.html5 = 1; 954 955 _self.player = new YT.Player(_self.$video.attr('id'), { 956 videoId: params.videoid, 957 height: _self.$video.attr('height'), 958 width: _self.$video.attr('width'), 959 playerVars: params, 960 events: { 961 'onReady': function(){ _self.$option_container.trigger('av-video-loaded'); }, 962 'onError': function(player){ $.avia_utilities.log('YOUTUBE ERROR:', 'error', player); }, 963 'onStateChange': function(event){
964 if (event.data === YT.PlayerState.ENDED) 965 { 966 var command = _self.options.loop != false ? 'loop' : 'av-video-ended'; 967 _self.$option_container.trigger(command); 968 } 969 } 970 } 971 }); 972 973 974 break; 975 } 976 977 //fallback always trigger after 2 seconds 978 setTimeout(function() 979 { 980 if(_self.eventsBound == true || typeof _self.eventsBound == 'undefined' || _self.type == 'youtube' ) { return; } 981 $.avia_utilities.log('Fallback Video Trigger "'+_self.type+'":', 'log', _self); 982 983 _self.$option_container.trigger('av-video-loaded'); 984 985 },2000); 986 987 }, 988 989 //bind events we should listen to, to the player 990 _bindEvents: function() 991 { 992 if(this.eventsBound == true || typeof this.eventsBound == 'undefined') 993 { 994 return; 995 } 996 997 var _self = this, volume = 'unmute'; 998 999 this.eventsBound = true; 1000 1001 this.$option_container.on(this.options.events, function(e) 1002 { 1003 _self.api(e.type); 1004 }); 1005 1006 if(!_self.isMobile) 1007 { 1008 //set up initial options 1009 if(this.options.mute != false) { volume = "mute"; } 1010 if(this.options.loop != false) { _self.api('loop'); } 1011 1012 _self.api(volume); 1013 } 1014 1015 //set timeout to prevent racing conditions with other scripts 1016 setTimeout(function() 1017 { 1018 _self.$option_container.trigger('av-video-events-bound').addClass('av-video-events-bound'); 1019 },50); 1020 }, 1021 1022 1023 _supports_video: function() { 1024 return !!document.createElement('video').canPlayType; 1025 }, 1026 1027 1028 /************************************************************************ 1029 PUBLIC Methods 1030 *************************************************************************/ 1031 1032 api: function( action ) 1033 { 1034 //commands on mobile can not be executed if the player was not started manually 1035 if(this.isMobile && !this.was_started()) return; 1036 1037 // prevent calling of unbound function 1038 if(this.options.events.indexOf(action) === -1) return; 1039 1040 // broadcast that the command was executed 1041 this.$option_container.trigger('av-video-'+action+'-executed'); 1042 1043 // calls the function based on action. eg: _html5_play() 1044 if(typeof this[ '_' + this.type + '_' + action] == 'function') 1045 { 1046 this[ '_' + this.type + '_' + action].call(this); 1047 } 1048 1049 //call generic function eg: _toggle() or _play() 1050 if(typeof this[ '_' + action] == 'function') 1051 { 1052 this[ '_' + action].call(this); 1053 } 1054 1055 }, 1056 1057 was_started: function() 1058 { 1059 if(!this.player) return false; 1060 1061 switch(this.type) 1062 { 1063 case "html5": 1064 if(this.player.getCurrentTime() > 0) return true; 1065 break; 1066 1067 case "vimeo": 1068 if(this.player.api('getCurrentTime') > 0) return true; 1069 break; 1070 1071 case "youtube": 1072 if(this.player.getPlayerState() !== -1) return true; 1073 break; 1074 } 1075 1076 return false; 1077 }, 1078 1079 /************************************************************************ 1080 Generic Methods, are always executed and usually set variables 1081 *************************************************************************/ 1082 _play: function() 1083 { 1084 this.playing = true; 1085 this.$option_container.addClass('av-video-playing').removeClass('av-video-paused'); 1086 }, 1087 1088 _pause: function() 1089 { 1090 this.playing = false; 1091 this.$option_container.removeClass('av-video-playing').addClass('av-video-paused'); 1092 }, 1093 1094 _loop: function() 1095 { 1096 this.options.loop = true; 1097 }, 1098 1099 _toggle: function( ) 1100 { 1101 var command = this.playing == true ? 'pause' : 'play'; 1102 1103 this.api(command); 1104 this.pp.set(command); 1105 }, 1106 1107 1108 /************************************************************************ 1109 VIMEO Methods 1110 *************************************************************************/ 1111 1112 _vimeo_play: function( ) 1113 { 1114 this.player.api('play'); 1115 }, 1116 1117 _vimeo_pause: function( ) 1118 { 1119 this.player.api('pause'); 1120 }, 1121 1122 _vimeo_mute: function( ) 1123 { 1124 this.player.api('setVolume', 0); 1125 }, 1126 1127 _vimeo_unmute: function( ) 1128 { 1129 this.player.api('setVolume', 0.7); 1130 }, 1131 1132 _vimeo_loop: function( ) 1133 { 1134 // currently throws error, must be set in iframe 1135 // this.player.api('setLoop', true); 1136 }, 1137 1138 _vimeo_reset: function( ) 1139 { 1140 this.player.api('seekTo',0); 1141 }, 1142 1143 _vimeo_unload: function() 1144 { 1145 this.player.api('unload'); 1146 }, 1147 1148 /************************************************************************ 1149 YOUTUBE Methods 1150 *************************************************************************/ 1151 1152 _youtube_play: function( ) 1153 { 1154 this.player.playVideo(); 1155 }, 1156 1157 _youtube_pause: function( ) 1158 { 1159 this.player.pauseVideo() 1160 }, 1161 1162 _youtube_mute: function( ) 1163 { 1164 this.player.mute(); 1165 }, 1166 1167 _youtube_unmute: function( ) 1168 { 1169 this.player.unMute(); 1170 }, 1171 1172 _youtube_loop: function( ) 1173 { 1174 // does not work properly with iframe api. needs to manual loop on "end" event 1175 // this.player.setLoop(true); 1176 if(this.playing == true) this.player.seekTo(0); 1177 }, 1178 1179 _youtube_reset: function( ) 1180 { 1181 this.player.stopVideo(); 1182 }, 1183 1184 _youtube_unload: function() 1185 { 1186 this.player.clearVideo(); 1187 }, 1188 1189 /************************************************************************ 1190 HTML5 Methods 1191 *************************************************************************/ 1192 1193 _html5_play: function( ) 1194 { 1195 //disable stoping of other videos in case the user wants to run section bgs 1196 if(this.player) 1197 { 1198 this.player.options.pauseOtherPlayers = false;
1199 this.player.play(); 1200 } 1201 1202 }, 1203 1204 _html5_pause: function( ) 1205 { 1206 if(this.player) this.player.pause(); 1207 }, 1208 1209 _html5_mute: function( ) 1210 { 1211 if(this.player) this.player.setMuted(true); 1212 }, 1213 1214 _html5_unmute: function( ) 1215 { 1216 if(this.player) this.player.setVolume(0.7); 1217 }, 1218 1219 _html5_loop: function( ) 1220 { 1221 if(this.player) this.player.options.loop = true; 1222 }, 1223 1224 _html5_reset: function( ) 1225 { 1226 if(this.player) this.player.setCurrentTime(0); 1227 }, 1228 1229 _html5_unload: function() 1230 { 1231 this._html5_pause(); 1232 this._html5_reset(); 1233 } 1234 } 1235 1236 //simple wrapper to call the api. makes sure that the api data is not applied twice 1237 $.fn.aviaVideoApi = function( options , apply_to_parent) 1238 { 1239 return this.each(function() 1240 { 1241 // by default save the object as data to the initial video. 1242 // in the case of slideshows its more benefitial to save it to a parent element (eg: the slide) 1243 var applyTo = this; 1244 1245 if(apply_to_parent) 1246 { 1247 applyTo = $(this).parents(apply_to_parent).get(0); 1248 } 1249 1250 var self = $.data( applyTo, 'aviaVideoApi' ); 1251 1252 if(!self) 1253 { 1254 self = $.data( applyTo, 'aviaVideoApi', new $.AviaVideoAPI( options, this, applyTo ) ); 1255 } 1256 }); 1257 } 1258 1259})( jQuery ); 1260 1261window.onYouTubeIframeAPIReady = function(){ $('body').trigger('av-youtube-iframe-api-loaded'); }; 1262 1263 1264 1265// ------------------------------------------------------------------------------------------- 1266// Masonry 1267// ------------------------------------------------------------------------------------------- 1268 1269$.fn.avia_masonry = function(options) 1270{ 1271 //return if we didnt find anything 1272 if(!this.length) return this; 1273 1274 var the_body = $('body'), 1275 the_win = $(window), 1276 isMobile = $.avia_utilities.isMobile, 1277 loading = false, 1278 methods = { 1279 1280 1281 masonry_filter: function() 1282 { 1283 var current = $(this), 1284 linktext = current.html(), 1285 selector = current.data('filter'), 1286 masonry = current.parents('.av-masonry:eq(0)'), 1287 container = masonry.find('.av-masonry-container:eq(0)'), 1288 links = masonry.find('.av-masonry-sort a'), 1289 activeCat = masonry.find('.av-current-sort-title'); 1290 1291 links.removeClass('active_sort'); 1292 current.addClass('active_sort'); 1293 container.attr('id', 'masonry_id_'+selector); 1294 1295 if(activeCat.length) activeCat.html(linktext); 1296 1297 methods.applyMasonry(container, selector, function() 1298 { 1299 container.css({overflow:'visible'}); 1300 }); 1301 1302 setTimeout(function() { the_win.trigger('debouncedresize'); }, 500); 1303 1304 return false; 1305 }, 1306 1307 applyMasonry: function(container, selector, callback) 1308 { 1309 var filters = selector ? {filter: '.'+selector} : {}; 1310 1311 filters['layoutMode'] = 'packery'; 1312 filters['packery'] = {gutter:0}; 1313 filters['percentPosition'] = true; 1314 filters['itemSelector'] = "a.isotope-item, div.isotope-item"; 1315 1316 container.isotope(filters, function() 1317 { 1318 the_win.trigger('av-height-change'); 1319 }); 1320 1321 if(typeof callback === 'function') 1322 { 1323 setTimeout(callback, 0); 1324 } 1325 }, 1326 1327 show_bricks: function(bricks, callback) 1328 { 1329 bricks.each(function(i) 1330 { 1331 var currentLink = $(this), 1332 browserPrefix = $.avia_utilities.supports('transition'), 1333 multiplier = isMobile ? 0 : 100; 1334 1335 setTimeout(function() 1336 { 1337 if(browserPrefix === false) 1338 { 1339 currentLink.css({visibility:"visible", opacity:0}).animate({opacity:1},1500); 1340 } 1341 else 1342 { 1343 currentLink.addClass('av-masonry-item-loaded'); 1344 } 1345 1346 if(i == bricks.length - 1 && typeof callback == 'function') 1347 { 1348 callback.call(); 1349 the_win.trigger('av-height-change'); 1350 } 1351 1352 }, (multiplier * i)); 1353 }); 1354 }, 1355 1356 loadMore: function(e) 1357 { 1358 e.preventDefault(); 1359 1360 if(loading) return false; 1361 1362 loading = true; 1363 1364 var current = $(this), 1365 data = current.data(), 1366 masonry = current.parents('.av-masonry:eq(0)'), 1367 container = masonry.find('.av-masonry-container'), 1368 items = masonry.find('.av-masonry-entry'), 1369 loader = $.avia_utilities.loading(), 1370 finished = function(){ loading = false; loader.hide(); the_body.trigger('av_resize_finished'); }; 1371 1372 //calculate a new offset 1373 if(!data.offset){ data.offset = 0; } 1374 data.offset += data.items; 1375 data.action = 'avia_ajax_masonry_more'; 1376 data.loaded = []; //prevents duplicate entries from beeing loaded when randomized is active 1377 1378 items.each(function(){ 1379 var item_id = $(this).data('av-masonry-item'); 1380 if(item_id) data.loaded.push( item_id ); 1381 }); 1382 1383 $.ajax({ 1384 url: avia_framework_globals.ajaxurl, 1385 type: "POST", 1386 data:data, 1387 beforeSend: function() 1388 { 1389 loader.show(); 1390 }, 1391 success: function(response) 1392 { 1393 if(response.indexOf("{av-masonry-loaded}") !== -1) 1394 { 1395 //fetch the response. if any php warnings were displayed before rendering of the items the are removed by the string split 1396 var response = response.split('{av-masonry-loaded}'), 1397 new_items = $(response.pop()).filter('.isotope-item'); 1398 1399 //check if we got more items than we need. if not we have reached the end of items 1400 if(new_items.length > data.items) 1401 { 1402 new_items = new_items.not(':last'); 1403 } 1404 else 1405 { 1406 current.addClass('av-masonry-no-more-items'); 1407 } 1408
1409 var load_container = $('<div class="loadcontainer"></div>').append(new_items); 1410 1411 1412 1413 $.avia_utilities.preload({container: load_container, single_callback: function() 1414 { 1415 var links = masonry.find('.av-masonry-sort a'), 1416 filter_container = masonry.find('.av-sort-by-term'), 1417 allowed_filters = filter_container.data("av-allowed-sort"); 1418 1419 filter_container.hide(); 1420 1421 loader.hide(); 1422 container.isotope( 'insert', new_items); 1423 $.avia_utilities.avia_ajax_call(masonry); 1424 setTimeout( function(){ methods.show_bricks( new_items , finished); },150); 1425 setTimeout(function(){ the_win.trigger('av-height-change'); }, 550); 1426 if(links) 1427 { 1428 $(links).each(function(filterlinkindex) 1429 { 1430 var filterlink = $(this), 1431 sort = filterlink.data('filter'); 1432 1433 if(new_items) 1434 { 1435 $(new_items).each(function(itemindex){ 1436 var item = $(this); 1437 1438 if(item.hasClass(sort) && allowed_filters.indexOf(sort) !== -1) 1439 { 1440 var term_count = filterlink.find('.avia-term-count').text(); 1441 filterlink.find('.avia-term-count').text(' ' + (parseInt(term_count) + 1) + ' '); 1442 1443 if(filterlink.hasClass('avia_hide_sort')) 1444 { 1445 filterlink.removeClass('avia_hide_sort').addClass('avia_show_sort'); 1446 masonry.find('.av-masonry-sort .'+sort+'_sep').removeClass('avia_hide_sort').addClass('avia_show_sort'); 1447 masonry.find('.av-masonry-sort .av-sort-by-term').removeClass('hidden'); 1448 } 1449 } 1450 }); 1451 } 1452 }); 1453 1454 } 1455 1456 filter_container.fadeIn(); 1457 } 1458 }); 1459 } 1460 else 1461 { 1462 finished(); 1463 } 1464 }, 1465 error: finished, 1466 complete: function() 1467 { 1468 setTimeout(function() { the_win.trigger('debouncedresize'); }, 500); 1469 } 1470 }); 1471 } 1472 1473 }; 1474 1475 return this.each(function() 1476 { 1477 var masonry = $(this), 1478 container = masonry.find('.av-masonry-container'), 1479 bricks = masonry.find('.isotope-item'), 1480 filter = masonry.find('.av-masonry-sort').css({visibility:"visible", opacity:0}).on('click', 'a', methods.masonry_filter), 1481 load_more = masonry.find('.av-masonry-load-more').css({visibility:"visible", opacity:0}); 1482 1483 $.avia_utilities.preload({container: container, single_callback: function() 1484 { 1485 var start_animation = function() 1486 { 1487 filter.animate({opacity:1}, 400); 1488 1489 //fix for non aligned elements because of scrollbar 1490 if(container.outerHeight() + container.offset().top + $('#footer').outerHeight() > $(window).height()) 1491 { 1492 $('html').css({'overflow-y':'scroll'}); 1493 } 1494 1495 methods.applyMasonry(container, false, function() 1496 { 1497 masonry.addClass('avia_sortable_active'); 1498 container.removeClass('av-js-disabled '); 1499 }); 1500 1501 methods.show_bricks(bricks, function() 1502 { 1503 load_more.css({opacity:1}).on('click', methods.loadMore); 1504 }); 1505 1506 //container.isotope( 'reLayout' ); 1507 1508 }; 1509 1510 if(isMobile) 1511 { 1512 start_animation(); 1513 } 1514 else 1515 { 1516 masonry.waypoint(start_animation , { offset: '80%'} ); 1517 } 1518 1519 // update columnWidth on window resize 1520 $(window).on( 'debouncedresize', function() 1521 { 1522 methods.applyMasonry(container, false, function() 1523 { 1524 masonry.addClass('avia_sortable_active'); 1525 }); 1526 }); 1527 } 1528 }); 1529 1530 1531 }); 1532}; 1533 1534 1535 1536 1537 1538 1539// ------------------------------------------------------------------------------------------- 1540// Fullscreen Slideshow 1541// 1542// extends avia slideshow script with a more sophisticated preloader and fixed size for slider 1543// ------------------------------------------------------------------------------------------- 1544 1545 1546 $.AviaFullscreenSlider = function(options, slider) 1547 { 1548 this.$slider = $( slider ); 1549 this.$inner = this.$slider.find('.avia-slideshow-inner'); 1550 this.$innerLi = this.$inner.find('>li'); 1551 this.$caption = this.$inner.find('.avia-slide-wrap .caption_container'); 1552 this.$win = $( window ); 1553 this.isMobile = $.avia_utilities.isMobile; 1554 this.property = {}; 1555 this.scrollPos = "0"; 1556 this.transform3d= document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false;
1557 this.ticking = false; 1558 1559 1560 if($.avia_utilities.supported.transition === undefined) 1561 { 1562 $.avia_utilities.supported.transition = $.avia_utilities.supports('transition'); 1563 } 1564 1565 this._init( options ); 1566 } 1567 1568 $.AviaFullscreenSlider.defaults = { 1569 1570 //height of the slider in percent 1571 height: 100, 1572 1573 //subtract elements from the height 1574 subtract: '#wpadminbar, #header, #main>.title_container' 1575 1576 1577 }; 1578 1579 $.AviaFullscreenSlider.prototype = 1580 { 1581 _init: function( options ) 1582 { 1583 var _self = this; 1584 //set the default options 1585 this.options = $.extend( true, {}, $.AviaFullscreenSlider.defaults, options ); 1586 1587 if(this.$slider.data('slide_height')) this.options.height = this.$slider.data('slide_height'); 1588 1589 //if background attachment is set to fixed or scroll disable the parallax effect 1590 this.options.parallax_enabled = this.$slider.data('image_attachment') == "" ? true : false; 1591 1592 //elements that get subtracted from the image height 1593 this.$subtract = $(this.options.subtract); 1594 1595 1596 // set the slideshow size 1597 this._setSize(); 1598 1599 // set resizing script on window resize 1600 this.$win.on( 'debouncedresize', $.proxy( this._setSize, this) ); 1601 1602 //parallax scroll if element if leaving viewport 1603 setTimeout(function() 1604 { 1605 if(!_self.isMobile && _self.options.parallax_enabled) //disable parallax scrolling on mobile 1606 { 1607 _self.$win.on( 'scroll', $.proxy( _self._on_scroll, _self) ); 1608 } 1609 1610 },100); 1611 /**/ 1612 1613 //activate the defaule slider 1614 this.$slider.aviaSlider({bg_slider:true}); 1615 1616 1617 }, 1618 1619 _on_scroll: function(e) 1620 { 1621 var _self = this; 1622 1623 if(!_self.ticking) { 1624 _self.ticking = true; 1625 window.requestAnimationFrame( $.proxy( _self._parallax_scroll, _self) ); 1626 } 1627 }, 1628 1629 1630 _fetch_properties: function(slide_height) 1631 { 1632 this.property.offset = this.$slider.offset().top; 1633 this.property.wh = this.$win.height(); 1634 this.property.height = slide_height || this.$slider.outerHeight(); 1635 1636 //re-position the slider 1637 this._parallax_scroll(); 1638 }, 1639 1640 _setSize: function( ) 1641 { 1642 if(!$.fn.avia_browser_height) 1643 { 1644 1645 var viewport = this.$win.height(), 1646 slide_height = Math.ceil( (viewport / 100) * this.options.height ); 1647 1648 if(this.$subtract.length && this.options.height == 100) 1649 { 1650 this.$subtract.each(function() 1651 { 1652 slide_height -= this.offsetHeight - 0.5; 1653 }); 1654 } 1655 else 1656 { 1657 slide_height -= 1; 1658 } 1659 this.$slider.height(slide_height).removeClass('av-default-height-applied'); 1660 this.$inner.css('padding',0); 1661 } 1662 1663 1664 this._fetch_properties(slide_height); 1665 }, 1666 1667 _parallax_scroll: function(e) 1668 { 1669 if(this.isMobile || ! this.options.parallax_enabled) return; //disable parallax scrolling on mobile 1670 1671 var winTop = this.$win.scrollTop(), 1672 winBottom = winTop + this.property.wh, 1673 scrollPos = "0", 1674 prop = {}, prop2 = {}; 1675 1676 if(this.property.offset < winTop && winTop <= this.property.offset + this.property.height) 1677 { 1678 scrollPos = Math.round( (winTop - this.property.offset) * 0.3 ); 1679 } 1680 1681 if(this.scrollPos != scrollPos) 1682 { 1683 //slide background parallax 1684 this.scrollPos = scrollPos; 1685 1686 //currently no 3d transform, because of browser quirks 1687 //this.transform3d = false; 1688 1689 if(this.transform3d) 1690 { 1691 prop[$.avia_utilities.supported.transition+"transform"] = "translate3d(0px,"+ scrollPos +"px,0px)"; 1692 } 1693 else 1694 { 1695 prop[$.avia_utilities.supported.transition+"transform"] = "translate(0px,"+ scrollPos +"px)"; 1696 } 1697 1698 1699 this.$inner.css(prop); 1700 1701 1702 1703 //slider caption parallax 1704 1705 // prop2[$.avia_utilities.supported.transition+"transform"] = "translate(0px,-"+ ( scrollPos * 1) +"px)"; 1706 /* 1707 prop2['opacity'] = Math.ceil((this.$slider.height() - (scrollPos * 2)) / 100)/ 10; 1708 prop2['opacity'] = prop2['opacity'] < 0 ? 0 : prop2['opacity']; 1709 this.$caption.css(prop2); 1710 */ 1711 } 1712 1713 this.ticking = false;
1714 } 1715 }; 1716 1717 1718 1719$.fn.aviaFullscreenSlider = function( options ) 1720{ 1721 return this.each(function() 1722 { 1723 var active = $.data( this, 'aviaFullscreenSlider' ); 1724 1725 if(!active) 1726 { 1727 //make sure that the function doesnt get aplied a second time 1728 $.data( this, 'aviaFullscreenSlider', 1 ); 1729 1730 //create the preparations for fullscreen slider 1731 new $.AviaFullscreenSlider( options, this ); 1732 } 1733 }); 1734} 1735 1736// ------------------------------------------------------------------------------------------- 1737// makes sure that the fixed container height is removed once the layerslider is loaded, so it adapts to the screen resolution 1738// ------------------------------------------------------------------------------------------- 1739 1740 $.AviaParallaxElement = function(options, element) 1741 { 1742 this.$el = $( element ).addClass('active-parallax'); 1743 this.$win = $( window ); 1744 this.$body = $( 'body' ); 1745 this.$parent = this.$el.parent(); 1746 this.property = {}; 1747 this.isMobile = $.avia_utilities.isMobile; 1748 this.ratio = this.$el.data('avia-parallax-ratio') || 0.5; 1749 this.transform = document.documentElement.className.indexOf('avia_transform') !== -1 ? true : false; 1750 this.transform3d= document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false; 1751 this.ticking = false; 1752 1753 if($.avia_utilities.supported.transition === undefined) 1754 { 1755 $.avia_utilities.supported.transition = $.avia_utilities.supports('transition'); 1756 } 1757 1758 this._init( options ); 1759 } 1760 1761 $.AviaParallaxElement.prototype = { 1762 1763 _init: function( options ) 1764 { 1765 var _self = this; 1766 if(_self.isMobile) 1767 { 1768 return; //disable parallax scrolling on mobile 1769 } 1770 1771 //fetch window constants 1772 setTimeout(function() 1773 { 1774 _self._fetch_properties(); 1775 },30); 1776 1777 this.$win.on("debouncedresize av-height-change", $.proxy( _self._fetch_properties, _self)); 1778 this.$body.on("av_resize_finished", $.proxy( _self._fetch_properties, _self)); 1779 1780 1781 1782 //activate the scrolling 1783 setTimeout(function() 1784 { 1785 _self.$win.on( 'scroll', $.proxy( _self._on_scroll, _self) ); 1786 1787 },100); 1788 }, 1789 1790 _fetch_properties: function() 1791 { 1792 this.property.offset = this.$parent.offset().top; 1793 this.property.wh = this.$win.height(); 1794 this.property.height = this.$parent.outerHeight(); 1795 1796 //set the height of the element based on the windows height, offset ratio and parent height 1797 this.$el.height(Math.ceil((this.property.wh * this.ratio) + this.property.height)); 1798 1799 //re-position the element 1800 this._parallax_scroll(); 1801 }, 1802 1803 _on_scroll: function(e) 1804 { 1805 var _self = this; 1806 1807 if(!_self.ticking) { 1808 _self.ticking = true; 1809 window.requestAnimationFrame( $.proxy( _self._parallax_scroll, _self) ); 1810 } 1811 }, 1812 1813 _parallax_scroll: function(e) 1814 { 1815 var winTop = this.$win.scrollTop(), 1816 winBottom = winTop + this.property.wh, 1817 scrollPos = "0", 1818 prop = {}; 1819 1820 //shift element when it moves into viewport 1821 if(this.property.offset < winBottom && winTop <= this.property.offset + this.property.height) 1822 { 1823 scrollPos = Math.ceil( (winBottom - this.property.offset) * this.ratio ); 1824 1825 //parallax movement via backround position change, although 1826 if(this.transform3d) 1827 { 1828 prop[$.avia_utilities.supported.transition+"transform"] = "translate3d(0px,"+ scrollPos +"px, 0px)"; 1829 } 1830 else if(this.transform) 1831 { 1832 prop[$.avia_utilities.supported.transition+"transform"] = "translate(0px,"+ scrollPos +"px)"; 1833 } 1834 else 1835 { 1836 prop["background-position"] = "0px "+ scrollPos +"px"; 1837 } 1838 1839 this.$el.css(prop); 1840 } 1841 1842 this.ticking = false; 1843 } 1844 }; 1845 1846 1847$.fn.avia_parallax = function(options) 1848{ 1849 return this.each(function() 1850 { 1851 var self = $.data( this, 'aviaParallax' ); 1852 1853 if(!self) 1854 { 1855 self = $.data( this, 'aviaParallax', new $.AviaParallaxElement( options, this ) ); 1856 } 1857 }); 1858} 1859 1860 1861// ------------------------------------------------------------------------------------------- 1862// Helper to allow fixed bgs on mobile
1863// ------------------------------------------------------------------------------------------- 1864 1865$.fn.avia_mobile_fixed = function(options) 1866{ 1867 var isMobile = $.avia_utilities.isMobile; 1868 if(!isMobile) return; 1869 1870 return this.each(function() 1871 { 1872 var current = $(this).addClass('av-parallax-section'), 1873 $background = current.attr('style'), 1874 $attachment_class = current.data('section-bg-repeat'), 1875 template = ""; 1876 1877 if($attachment_class == 'stretch' || $attachment_class == 'no-repeat' ) 1878 { 1879 $attachment_class = " avia-full-stretch"; 1880 } 1881 else 1882 { 1883 $attachment_class = ""; 1884 } 1885 1886 template = "<div class='av-parallax " + $attachment_class + "' data-avia-parallax-ratio='0.0' style = '" + $background + "' ></div>"; 1887 1888 current.prepend(template); 1889 current.attr('style',''); 1890 }); 1891} 1892 1893 1894 1895 1896 1897// ------------------------------------------------------------------------------------------- 1898// makes sure that the fixed container height is removed once the layerslider is loaded, so it adapts to the screen resolution 1899// ------------------------------------------------------------------------------------------- 1900 1901$.fn.layer_slider_height_helper = function(options) 1902{ 1903 return this.each(function() 1904 { 1905 var container = $(this), 1906 first_div = container.find('>div:first'), 1907 timeout = false, 1908 counter = 0, 1909 reset_size = function() 1910 { 1911 if(first_div.height() > 0 || counter > 5) 1912 { 1913 container.height('auto'); 1914 } 1915 else 1916 { 1917 timeout = setTimeout(reset_size, 500); 1918 counter++; 1919 } 1920 }; 1921 1922 if(!first_div.length) return; 1923 1924 timeout = setTimeout(reset_size, 0); 1925 }); 1926} 1927 1928// ------------------------------------------------------------------------------------------- 1929// testimonial shortcode javascript 1930// ------------------------------------------------------------------------------------------- 1931 1932$.fn.avia_sc_testimonial = function(options) 1933{ 1934 return this.each(function() 1935 { 1936 var container = $(this), elements = container.find('.avia-testimonial'); 1937 1938 1939 //trigger displaying of thumbnails 1940 container.on('avia_start_animation', function() 1941 { 1942 elements.each(function(i) 1943 { 1944 var element = $(this); 1945 setTimeout(function(){ element.addClass('avia_start_animation') }, (i * 150)); 1946 }); 1947 }); 1948 }); 1949} 1950 1951 1952// ------------------------------------------------------------------------------------------- 1953// Progress bar shortcode javascript 1954// ------------------------------------------------------------------------------------------- 1955 1956$.fn.avia_sc_progressbar = function(options) 1957{ 1958 return this.each(function() 1959 { 1960 var container = $(this), elements = container.find('.avia-progress-bar'); 1961 1962 1963 //trigger displaying of progress bar 1964 container.on('avia_start_animation', function() 1965 { 1966 elements.each(function(i) 1967 { 1968 var element = $(this) 1969 1970 setTimeout(function() 1971 { 1972 element.find('.progress').addClass('avia_start_animation') 1973 element.find('.progressbar-percent').avia_sc_animated_number( 1974 { 1975 instant_start:true, simple_up:true, start_timer: 10 1976 }); 1977 1978 }, (i * 250)); 1979 }); 1980 }); 1981 }); 1982} 1983 1984// ------------------------------------------------------------------------------------------- 1985// Iconlist shortcode javascript 1986// ------------------------------------------------------------------------------------------- 1987 1988$.fn.avia_sc_iconlist = function(options) 1989{ 1990 return this.each(function() 1991 { 1992 var iconlist = $(this), elements = iconlist.find('>li'); 1993 1994 1995 //trigger displaying of thumbnails 1996 iconlist.on('avia_start_animation', function() 1997 { 1998 elements.each(function(i) 1999 { 2000 var element = $(this); 2001 setTimeout(function(){ element.addClass('avia_start_animation') }, (i * 350)); 2002 }); 2003 }); 2004 }); 2005} 2006 2007 2008// ------------------------------------------------------------------------------------------- 2009// shortcode javascript for delayed animation even when non connected elements are used 2010// ------------------------------------------------------------------------------------------- 2011 2012$.fn.avia_sc_animation_delayed = function(options) 2013{ 2014 var global_timer = 0, 2015 delay = options.delay || 50,
2016 max_timer = 10, 2017 new_max = setTimeout(function(){ max_timer = 20; }, 500); 2018 2019 return this.each(function() 2020 { 2021 var elements = $(this); 2022 2023 //trigger displaying of thumbnails 2024 elements.on('avia_start_animation', function() 2025 { 2026 var element = $(this); 2027 2028 if(global_timer < max_timer) global_timer ++; 2029 2030 setTimeout(function() 2031 { 2032 element.addClass('avia_start_delayed_animation'); 2033 if(global_timer > 0) global_timer --; 2034 2035 }, (global_timer * delay)); 2036 2037 }); 2038 }); 2039} 2040 2041/*delayd animations when used within tab sections or similar elements. this way they get animated each new time a tab is shown*/ 2042$.fn.avia_delayed_animation_in_container = function(options) 2043{ 2044 return this.each(function() 2045 { 2046 var elements = $(this); 2047 2048 elements.on('avia_start_animation_if_current_slide_is_active', function() 2049 { 2050 var current = $(this), 2051 animate = current.find('.avia_start_animation_when_active'); 2052 2053 animate.addClass('avia_start_animation').trigger('avia_start_animation'); 2054 }); 2055 2056 elements.on('avia_remove_animation', function() 2057 { 2058 var current = $(this), 2059 animate = current.find('.avia_start_animation_when_active, .avia_start_animation'); 2060 animate.removeClass('avia_start_animation avia_start_delayed_animation'); 2061 }); 2062 }); 2063} 2064 2065 2066 2067 2068 2069// ------------------------------------------------------------------------------------------- 2070// Section Height Helper 2071// ------------------------------------------------------------------------------------------- 2072 2073$.fn.avia_browser_height = function() 2074{ 2075 if(!this.length) return; 2076 2077 var win = $(window), 2078 html_el = $('html'), 2079 subtract = $('#wpadminbar, #header.av_header_top:not(.html_header_transparency #header), #main>.title_container'), 2080 css_block = $("<style type='text/css' id='av-browser-height'></style>").appendTo('head:first'), 2081 sidebar_menu= $('.html_header_sidebar #top #header_main'), 2082 full_slider = $('.html_header_sidebar .avia-fullscreen-slider.avia-builder-el-0.avia-builder-el-no-sibling').addClass('av-solo-full'), 2083 calc_height = function() 2084 { 2085 var css = "", 2086 wh100 = win.height(), 2087 ww100 = win.width(), 2088 wh100_mod = wh100, 2089 whCover = (wh100 / 9) * 16, 2090 wwCover = (ww100 / 16) * 9, 2091 wh75 = Math.round( wh100 * 0.75 ), 2092 wh50 = Math.round( wh100 * 0.5 ), 2093 wh25 = Math.round( wh100 * 0.25 ), 2094 solo = 0; 2095 2096 if(sidebar_menu.length) solo = sidebar_menu.height(); 2097 2098 subtract.each(function(){ wh100_mod -= this.offsetHeight - 1; }); 2099 2100 var whCoverMod = (wh100_mod / 9) * 16; 2101 2102 //fade in of section content with minimum height once the height has been calculated 2103 css += ".avia-section.av-minimum-height .container{opacity: 1; }\n"; 2104 2105 //various section heights (100-25% as well as 100% - header/adminbar in case its the first builder element) 2106 css += ".av-minimum-height-100 .container, .avia-fullscreen-slider .avia-slideshow, #top.avia-blank .av-minimum-height-100 .container, .av-cell-min-height-100 > .flex_cell{height:"+wh100+"px;}\n"; 2107 css += ".av-minimum-height-75 .container, .av-cell-min-height-75 > .flex_cell {height:"+wh75+"px;}\n"; 2108 css += ".av-minimum-height-50 .container, .av-cell-min-height-50 > .flex_cell {height:"+wh50+"px;}\n"; 2109 css += ".av-minimum-height-25 .container, .av-cell-min-height-25 > .flex_cell {height:"+wh25+"px;}\n"; 2110 css += ".avia-builder-el-0.av-minimum-height-100 .container, .avia-builder-el-0.avia-fullscreen-slider .avia-slideshow, .avia-builder-el-0.av-cell-min-height-100 > .flex_cell{height:"+wh100_mod+"px;}\n"; 2111 2112 css += "#top .av-solo-full .avia-slideshow {min-height:"+solo+"px;}\n"; 2113 2114 //fullscreen video calculations 2115 if(ww100/wh100 < 16/9) 2116 { 2117 css += "#top .av-element-cover iframe, #top .av-element-cover embed, #top .av-element-cover object, #top .av-element-cover video{width:"+whCover+"px; left: -"+(whCover - ww100)/2+"px;}\n"; 2118 } 2119 else 2120 { 2121 css += "#top .av-element-cover iframe, #top .av-element-cover embed, #top .av-element-cover object, #top .av-element-cover video{height:"+wwCover+"px; top: -"+(wwCover - wh100)/2+"px;}\n"; 2122 } 2123 2124 if(ww100/wh100_mod < 16/9) 2125 { 2126 css += "#top .avia-builder-el-0 .av-element-cover iframe, #top .avia-builder-el-0 .av-element-cover embed, #top .avia-builder-el-0 .av-element-cover object, #top .avia-builder-el-0 .av-element-cover video{width:"+whCoverMod+"px; left: -"+(whCoverMod - ww100)/2+"px;}\n"; 2127 } 2128 else 2129 {
2130 css += "#top .avia-builder-el-0 .av-element-cover iframe, #top .avia-builder-el-0 .av-element-cover embed, #top .avia-builder-el-0 .av-element-cover object, #top .avia-builder-el-0 .av-element-cover video{height:"+wwCover+"px; top: -"+(wwCover - wh100_mod)/2+"px;}\n"; 2131 } 2132 2133 //ie8 needs different insert method 2134 try{ 2135 css_block.text(css); 2136 } 2137 catch(err){ 2138 css_block.remove(); 2139 css_block = $("<style type='text/css' id='av-browser-height'>"+css+"</style>").appendTo('head:first'); 2140 } 2141 2142 2143 setTimeout(function(){ win.trigger('av-height-change'); /*broadcast the height change*/ },100); 2144 }; 2145 2146 win.on( 'debouncedresize', calc_height); 2147 calc_height(); 2148} 2149 2150// ------------------------------------------------------------------------------------------- 2151// Video Section helper 2152// ------------------------------------------------------------------------------------------- 2153 2154$.fn.avia_video_section = function() 2155{ 2156 if(!this.length) return; 2157 2158 var elements = this.length, content = "", 2159 win = $(window), 2160 css_block = $("<style type='text/css' id='av-section-height'></style>").appendTo('head:first'), 2161 calc_height = function(section, counter) 2162 { 2163 if(counter === 0) { content = "";} 2164 2165 var css = "", 2166 the_id = '#' +section.attr('id'), 2167 wh100 = section.height(), 2168 ww100 = section.width(), 2169 aspect = section.data('sectionVideoRatio').split(':'), 2170 video_w = aspect[0], 2171 video_h = aspect[1], 2172 whCover = (wh100 / video_h ) * video_w, 2173 wwCover = (ww100 / video_w ) * video_h; 2174 2175 //fullscreen video calculations 2176 if(ww100/wh100 < video_w/video_h) 2177 { 2178 css += "#top "+the_id+" .av-section-video-bg iframe, #top "+the_id+" .av-section-video-bg embed, #top "+the_id+" .av-section-video-bg object, #top "+the_id+" .av-section-video-bg video{width:"+whCover+"px; left: -"+(whCover - ww100)/2+"px;}\n"; 2179 } 2180 else 2181 { 2182 css += "#top "+the_id+" .av-section-video-bg iframe, #top "+the_id+" .av-section-video-bg embed, #top "+the_id+" .av-section-video-bg object, #top "+the_id+" .av-section-video-bg video{height:"+wwCover+"px; top: -"+(wwCover - wh100)/2+"px;}\n"; 2183 } 2184 2185 content = content + css; 2186 2187 if(elements == counter + 1) 2188 { 2189 //ie8 needs different insert method 2190 try{ 2191 css_block.text(content); 2192 } 2193 catch(err){ 2194 css_block.remove(); 2195 css_block = $("<style type='text/css' id='av-section-height'>"+content+"</style>").appendTo('head:first'); 2196 } 2197 } 2198 }; 2199 2200 2201 return this.each(function(i) 2202 { 2203 var self = $(this); 2204 2205 win.on( 'debouncedresize', function(){ calc_height(self, i); }); 2206 calc_height(self, i); 2207 }); 2208 2209} 2210 2211 2212 2213 2214 2215 2216 2217 2218// ------------------------------------------------------------------------------------------- 2219// Gallery shortcode javascript 2220// ------------------------------------------------------------------------------------------- 2221 2222$.fn.avia_sc_gallery = function(options) 2223{ 2224 return this.each(function() 2225 { 2226 var gallery = $(this), images = gallery.find('img'), big_prev = gallery.find('.avia-gallery-big'); 2227 2228 2229 //trigger displaying of thumbnails 2230 gallery.on('avia_start_animation', function() 2231 { 2232 images.each(function(i) 2233 { 2234 var image = $(this); 2235 setTimeout(function(){ image.addClass('avia_start_animation') }, (i * 110)); 2236 }); 2237 }); 2238 2239 if(gallery.hasClass('deactivate_avia_lazyload')) gallery.trigger('avia_start_animation'); 2240 2241 //trigger thumbnail hover and big prev image change 2242 if(big_prev.length) 2243 { 2244 gallery.on('mouseenter','.avia-gallery-thumb a', function() 2245 { 2246 var _self = this; 2247 2248 big_prev.attr('data-onclick', _self.getAttribute("data-onclick")); 2249 big_prev.height(big_prev.height()); 2250 big_prev.attr('href', _self.href) 2251 2252 var newImg = _self.getAttribute("data-prev-img"), 2253 oldImg = big_prev.find('img'), 2254 oldImgSrc = oldImg.attr('src'); 2255 2256 if(newImg != oldImgSrc) 2257 { 2258 var next_img = new Image(); 2259 next_img.src = newImg; 2260 2261 var $next = $(next_img); 2262 2263 if(big_prev.hasClass('avia-gallery-big-no-crop-thumb')) 2264 { 2265 $next.css({'height':big_prev.height(),'width':'auto'}); 2266 } 2267 2268 big_prev.stop().animate({opacity:0}
2268, function() 2269 { 2270 $next.insertAfter(oldImg); 2271 oldImg.remove(); 2272 big_prev.animate({opacity:1}); 2273 2274 big_prev.attr('title',$(_self).attr('title')); 2275 2276 }); 2277 } 2278 }); 2279 2280 big_prev.on('click', function() 2281 { 2282 var imagelink = gallery.find('.avia-gallery-thumb a').eq(this.getAttribute("data-onclick") - 1); 2283 2284 if(imagelink && !imagelink.hasClass('aviaopeninbrowser')) 2285 { 2286 imagelink.trigger('click'); 2287 } 2288 else if(imagelink) 2289 { 2290 var imgurl = imagelink.attr("href"); 2291 2292 if(imagelink.hasClass('aviablank') && imgurl != '' ) 2293 { 2294 window.open(imgurl, '_blank'); 2295 } 2296 else if( imgurl != '' ) 2297 { 2298 window.open(imgurl, '_self'); 2299 } 2300 } 2301 return false; 2302 }); 2303 2304 2305 $(window).on("debouncedresize", function() 2306 { 2307 big_prev.height('auto'); 2308 }); 2309 2310 } 2311 }); 2312} 2313 2314// ------------------------------------------------------------------------------------------- 2315// Toggle shortcode javascript 2316// ------------------------------------------------------------------------------------------- 2317 2318$.fn.avia_sc_toggle = function(options) 2319{ 2320 var defaults = 2321 { 2322 single: '.single_toggle', 2323 heading: '.toggler', 2324 content: '.toggle_wrap', 2325 sortContainer:'.taglist' 2326 }; 2327 2328 var win = $(window), 2329 options = $.extend(defaults, options); 2330 2331 return this.each(function() 2332 { 2333 var container = $(this).addClass('enable_toggles'), 2334 toggles = $(options.single, container), 2335 heading = $(options.heading, container), 2336 allContent = $(options.content, container), 2337 sortLinks = $(options.sortContainer + " a", container); 2338 2339 heading.each(function(i) 2340 { 2341 var thisheading = $(this), content = thisheading.next(options.content, container); 2342 2343 function scroll_to_viewport() 2344 { 2345 //check if toggle title is in viewport. if not scroll up 2346 var el_offset = content.offset().top, 2347 scoll_target = el_offset - 50 - parseInt($('html').css('margin-top'),10); 2348 2349 if(win.scrollTop() > el_offset) 2350 { 2351 $('html:not(:animated),body:not(:animated)').animate({scrollTop: scoll_target},200); 2352 } 2353 } 2354 2355 if(content.css('visibility') != "hidden") 2356 { 2357 thisheading.addClass('activeTitle'); 2358 } 2359 2360 thisheading.on('click', function() 2361 { 2362 if(content.css('visibility') != "hidden") 2363 { 2364 content.slideUp(200, function() 2365 { 2366 content.removeClass('active_tc').attr({style:''}); 2367 win.trigger('av-height-change'); 2368 win.trigger('av-content-el-height-changed', this ); 2369 2370 location.replace(thisheading.data('fake-id') + "-closed"); 2371 }); 2372 thisheading.removeClass('activeTitle'); 2373 2374 } 2375 else 2376 { 2377 if(container.is('.toggle_close_all')) 2378 { 2379 allContent.not(content).slideUp(200, function() 2380 { 2381 $(this).removeClass('active_tc').attr({style:''}); 2382 scroll_to_viewport(); 2383 }); 2384 heading.removeClass('activeTitle'); 2385 } 2386 2387 content.addClass('active_tc'); 2388 2389 setTimeout(function(){ 2390 2391 content.slideDown(200, 2392 2393 function() 2394 { 2395 if(!container.is('.toggle_close_all')) 2396 { 2397 scroll_to_viewport(); 2398 } 2399 2400 win.trigger('av-height-change'); 2401 win.trigger('av-content-el-height-changed', this ); 2402 } 2403 2404 ); 2405 2406 }, 1); 2407 2408 thisheading.addClass('activeTitle'); 2409 location.replace(thisheading.data('fake-id')); 2410 } 2411 2412 2413 2414 }); 2415 }); 2416 2417 2418 sortLinks.click(function(e){ 2419 2420 e.preventDefault(); 2421 var show = toggles.filter('[data-tags~="'+$(this).data('tag')+'"]'), 2422 hide = toggles.not('[data-tags~="'+$(this).data('tag')+'"]'); 2423 2424 sortLinks.removeClass('activeFilter'); 2425 $(this).addClass('activeFilter'); 2426 heading.filter('.activeTitle').trigger('click'); 2427 show.slideDown(); 2428 hide.slideUp(); 2429 }); 2430 2431 2432 function trigger_default_open(hash) 2433 { 2434 if(!hash && window.location.hash) hash = window.location.hash; 2435 if(!hash) return; 2436 2437 var open = heading.filter('[data-fake-id="'+hash+'"]'); 2438 2439 if(open.length) 2440 { 2441 if(!open.is('.activeTitle')) open.trigger('click'); 2442 window.scrollTo(0, container.offset().top - 70); 2443 } 2444 } 2445 trigger_default_open(false); 2446 2447 $('a').on('click',function(){ 2448 var hash = $(this).attr('href'); 2449 if(typeof hash != "undefined" && hash) 2450 { 2451 hash = hash.replace(/^.*?#/,''); 2452 trigger_default_open('#'+hash); 2453 } 2454 }); 2455 2456 }); 2457}; 2458 2459 2460 2461 2462// ------------------------------------------------------------------------------------------- 2463// Tab Shortcode 2464// ------------------------------------------------------------------------------------------- 2465 2466$.fn.avia_sc_tabs= function(options) 2467{ 2468 var defaults = 2469 { 2470 heading: '.tab', 2471 content:'.tab_content', 2472 active:'active_tab', 2473 sidebar: false 2474 }; 2475 2476 var win = $(window), 2477 options = $.extend(defaults, options); 2478 2479 return this.each(function() 2480 { 2481 var container = $(this),
2482 tab_titles = $('<div class="tab_titles"></div>').prependTo(container), 2483 tabs = $(options.heading, container), 2484 content = $(options.content, container), 2485 newtabs = false, 2486 oldtabs = false; 2487 2488 newtabs = tabs.clone(); 2489 oldtabs = tabs.addClass('fullsize-tab'); 2490 tabs = newtabs; 2491 2492 tabs.prependTo(tab_titles).each(function(i) 2493 { 2494 var tab = $(this), the_oldtab = false; 2495 2496 if(newtabs) the_oldtab = oldtabs.filter(':eq('+i+')'); 2497 2498 tab.addClass('tab_counter_'+i).bind('click', function() 2499 { 2500 open_content(tab, i, the_oldtab); 2501 return false; 2502 }); 2503 2504 if(newtabs) 2505 { 2506 the_oldtab.bind('click', function() 2507 { 2508 open_content(the_oldtab, i, tab); 2509 return false; 2510 }); 2511 } 2512 }); 2513 2514 set_size(); 2515 trigger_default_open(false); 2516 win.on("debouncedresize", set_size); 2517 2518 $('a').on('click',function(){ 2519 var hash = $(this).attr('href'); 2520 if(typeof hash != "undefined" && hash) 2521 { 2522 hash = hash.replace(/^.*?#/,''); 2523 trigger_default_open('#'+hash); 2524 } 2525 }); 2526 2527 function set_size() 2528 { 2529 if(!options.sidebar) return; 2530 content.css({'min-height': tab_titles.outerHeight() + 1}); 2531 } 2532 2533 function open_content(tab, i, alternate_tab) 2534 { 2535 if(!tab.is('.'+options.active)) 2536 { 2537 $('.'+options.active, container).removeClass(options.active); 2538 $('.'+options.active+'_content', container).removeClass(options.active+'_content'); 2539 2540 tab.addClass(options.active); 2541 2542 var new_loc = tab.data('fake-id'); 2543 if(typeof new_loc == 'string') location.replace(new_loc); 2544 2545 if(alternate_tab) alternate_tab.addClass(options.active); 2546 var active_c = content.filter(':eq('+i+')').addClass(options.active+'_content'); 2547 2548 if(typeof click_container != 'undefined' && click_container.length) 2549 { 2550 sidebar_shadow.height(active_c.outerHeight()); 2551 } 2552 2553 //check if tab title is in viewport. if not scroll up 2554 var el_offset = active_c.offset().top, 2555 scoll_target = el_offset - 50 - parseInt($('html').css('margin-top'),10); 2556 2557 if(win.scrollTop() > el_offset) 2558 { 2559 $('html:not(:animated),body:not(:animated)').scrollTop(scoll_target); 2560 } 2561 } 2562 2563 win.trigger( 'av-content-el-height-changed', tab ); 2564 } 2565 2566 function trigger_default_open(hash) 2567 { 2568 if(!hash && window.location.hash) hash = window.location.hash; 2569 if(!hash) return; 2570 2571 var open = tabs.filter('[data-fake-id="'+hash+'"]'); 2572 2573 if(open.length) 2574 { 2575 if(!open.is('.active_tab')) open.trigger('click'); 2576 window.scrollTo(0, container.offset().top - 70); 2577 } 2578 } 2579 2580 }); 2581}; 2582 2583 2584 2585 2586// ------------------------------------------------------------------------------------------- 2587// Tab Section 2588// ------------------------------------------------------------------------------------------- 2589 2590$.fn.avia_sc_tab_section= function() 2591{ 2592 var win = $(window), 2593 browserPrefix = $.avia_utilities.supports('transition'), 2594 cssActive = this.browserPrefix !== false ? true : false, 2595 isMobile = $.avia_utilities.isMobile, 2596 transform3d = document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false, 2597 transition = {}; 2598 2599 return this.each(function() 2600 { 2601 var container = $(this), 2602 tabs = container.find('.av-section-tab-title'), 2603 tab_outer = container.find('.av-tab-section-outer-container'), 2604 tab_wrap = container.find('.av-tab-section-tab-title-container'), 2605 tab_nav = container.find('.av_tab_navigation'), 2606 content_wrap = container.find('.av-tab-section-inner-container'), 2607 single_tabs = container.find('.av-animation-delay-container'), //for elements inside the tab that receive waypoint animation 2608 inner_content = container.find('.av-layout-tab-inner'), 2609 sliding_active = container.is('.av-tab-slide-transition'), 2610 flexible = container.is('.av-tab-content-auto'), 2611 current_content = container.find('.__av_init_open'), 2612 min_width = 0, 2613 change_tab = function(e, prevent_hash) 2614 { 2615 e.preventDefault(); 2616 2617 var current_tab = $(e.currentTarget), 2618 current_arrow = current_tab.find('.av-tab-arrow-container span'), 2619 tab_nr = current_tab.data('av-tab-section-title'); 2620 2621 current_content = container.find('[data-av-tab-section-content="'+tab_nr+'"]'); 2622 2623 var new_bg = current_content.data('av-tab-bg-color'), 2624 new_font = current_content.data('av-tab-color'), 2625 prev_container = container.find('.av-active-tab-content').not('[data-av-tab-section-content="'+tab_nr+'"]'); 2626 2627 tabs.attr('style','').removeClass('av-active-tab-title'); 2628 current_tab.addClass('av-active-tab-title'); 2629 current_content.addClass("av-active-tab-content"); 2630 2631 if(new_bg !== "") current_arrow.css('background-color', new_bg); 2632 if(new_font !== "") current_tab.css('color', new_font); 2633 2634 var new_pos = ((parseInt(tab_nr,10) - 1) * -100 ); 2635 if ($('body').hasClass('rtl')) { 2636 new_pos = ((parseInt(tab_nr,10) - 1) * 100 ); 2637 } 2638 2639 if(cssActive) 2640 { 2641 //move the slides 2642 new_pos = new_pos / tabs.length; 2643 transition['transform'] = transform3d ? "translate3d(" + new_pos + "%, 0, 0)" : "translate(" + new_pos + "%,0)"; //3d or 2d transform? 2644 transition['left'] = "0%"; 2645 content_wrap.css(transition); 2646 } 2647 else 2648 { 2649 content_wrap.css('left', new_pos + "%"); 2650 } 2651 2652 set_tab_titlte_pos(); 2653 set_slide_height(); 2654 2655 if(!prevent_hash) location.hash = current_tab.attr('href'); 2656 2657 setTimeout(function() 2658 { 2659 current_content.trigger('avia_start_animation_if_current_slide_is_active'); 2660 single_tabs.not(current_content).trigger('avia_remove_animation'); 2661 2662 }, 600); 2663 2664 }, 2665 set_min_width = function() 2666 { 2667 min_width = 0; 2668 tabs.each(function() 2669 { 2670 min_width += $(this).outerWidth(); 2671 }); 2672 2673 tab_wrap.css('min-width',min_width); 2674 }, 2675 2676 set_slide_height = function() 2677 { 2678 if(current_content.length && flexible) 2679 { 2680 var old_height = inner_content.height(); 2681 inner_content.height('auto'); 2682 2683 var height = current_content.find('.av-layout-tab-inner').height(), 2684 add_height = tab_wrap.height(); 2685 2686 tab_outer.css('max-height', height + add_height + 100); 2687 inner_content.height(old_height); 2688 inner_content.height(height); 2689 2690 inner_content.css( 'overflow', 'hidden' ); 2691 2692 setTimeout(function() { win.trigger('av-height-change'); }, 600); 2693 } 2694 }, 2695 2696 set_tab_titlte_pos = function() 2697 { 2698 // scroll the tabs if there is not enough room to display them all - rtl allign right to left !! 2699 var current_tab = container.find('.av-active-tab-title'), 2700 viewport = container.width(), 2701 left_pos = ( current_tab.position().left * - 1) - (current_tab.outerWidth() / 2) + (viewport / 2); 2702 2703 if( ! $('body').hasClass("rtl") ) 2704 { 2705 if( viewport >= min_width ) 2706 { 2707 left_pos = 0; 2708 } 2709 2710 if(left_pos + min_width < viewport) left_pos = (min_width - viewport) * -1; 2711 if(left_pos > 0) left_pos = 0; 2712 2713 tab_wrap.css('left',left_pos ); 2714 } 2715 else 2716 { 2717 var right_pos = 0; 2718 2719 if( viewport < min_width ) 2720 { 2721 if( left_pos + min_width > viewport ) 2722 { 2723 if( left_pos > 0 ) left_pos = 0; 2724 2725 var right_pos = (left_pos + min_width - viewport) * -1; 2726 tab_wrap.css('left', 'auto' ); 2727 tab_wrap.css('right', right_pos ); 2728 } 2729 } 2730 tab_wrap.css('left', 'auto' ); 2731 tab_wrap.css('right', right_pos ); 2732 } 2733 }, 2734 switch_to_next_prev = function(e) 2735 { 2736 if(!isMobile) return; 2737 2738 var clicked = $(e.currentTarget), 2739 current_tab = container.find('.av-active-tab-title'); 2740 2741 if(clicked.is('.av_prev_tab_section')) 2742 { 2743 current_tab.prev('.av-section-tab-title').trigger('click'); 2744 } 2745 else 2746 { 2747 current_tab.next('.av-section-tab-title').trigger('click'); 2748 } 2749 }, 2750 2751 get_init_open = function() 2752 { 2753 if(!hash && window.location.hash) var hash = window.location.hash; 2754 2755 var open = tabs.filter('[href="'+hash+'"]'); 2756 2757 if(open.length) 2758 { 2759 if(!open.is('.active_tab')) open.trigger('click'); 2760 } 2761 else 2762 { 2763 //set correct color 2764 container.find('.av-active-tab-title').trigger('click', true); 2765 } 2766 }; 2767 2768 $.avia_utilities.preload({ 2769 2770 container: current_content ,
2771 single_callback: function(){ 2772 2773 tabs.on('click', change_tab); 2774 tab_nav.on('click', switch_to_next_prev); 2775 win.on('debouncedresize', set_tab_titlte_pos); 2776 2777 /** 2778 * We had to remove av-height-change because this event is recursivly triggered in set_slide_height and lead to performance problems 2779 * AND broken layout - content was not displayed completly 2780 * 2781 * Content elements that can can change their height and trigger av-height-change should trigger this additional event after to 2782 * allow layout elements like tab section to react on this and then call av-height-change by themself 2783 * 2784 * @since 4.2.3 2785 */ 2786 win.on('debouncedresize av-content-el-height-changed', set_slide_height); 2787 2788 set_min_width(); 2789 set_slide_height(); 2790 get_init_open(); 2791 } 2792 2793 }); 2794 2795 content_wrap.avia_swipe_trigger({prev:'.av_prev_tab_section', next:'.av_next_tab_section'}); 2796 2797 }); 2798}; 2799 2800 2801 2802 2803// ------------------------------------------------------------------------------------------- 2804// Horizontal Gallery 2805// ------------------------------------------------------------------------------------------- 2806 2807$.fn.avia_hor_gallery= function(options) 2808{ 2809 var defaults = 2810 { 2811 slide_container : '.av-horizontal-gallery-inner', //element with max width 2812 slide_element : '.av-horizontal-gallery-slider', //element that gets moved 2813 slide_content : '.av-horizontal-gallery-wrap', 2814 active : 'av-active-gal-item', // must be a class string without the . in front 2815 prev : '.av-horizontal-gallery-prev', 2816 next : '.av-horizontal-gallery-next' 2817 }; 2818 2819 var options = $.extend(defaults, options); 2820 2821 var win = $(window), 2822 browserPrefix = $.avia_utilities.supports('transition'), 2823 cssActive = this.browserPrefix !== false ? true : false, 2824 isMobile = $.avia_utilities.isMobile, 2825 transform3d = document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false, 2826 transition = {}; 2827 2828 return this.each(function() 2829 { 2830 var container = $(this), 2831 slide_container = container.find(options.slide_container), 2832 slide_element = container.find(options.slide_element), 2833 slide_content = container.find(options.slide_content), 2834 prev = container.find(options.prev), 2835 next = container.find(options.next), 2836 imgs = container.find('img'), 2837 2838 all_elements_width = 0, 2839 currentIndex = false, 2840 initial = container.data('av-initial'), 2841 2842 set_up = function( init ) 2843 { 2844 var sl_height = (slide_container.width() / 100 ) * slide_container.data('av-height'); 2845 2846 slide_container.css({'padding':0}).height(sl_height); 2847 2848 //fixes img distortion when resizing browser: 2849 imgs.css('display','inline-block'); 2850 setTimeout(function(){ imgs.css('display','block'); }, 10); 2851 2852 //calculate the slidelement width based on the elements inside 2853 all_elements_width = 0; 2854 2855 slide_content.each(function() 2856 { 2857 all_elements_width += $(this).outerWidth( true ); 2858 }); 2859 2860 slide_element.css( 'min-width' , all_elements_width ); 2861 2862 if(currentIndex !== false ) 2863 { 2864 change_active(currentIndex); 2865 } 2866 }, 2867 change_active = function(index) 2868 { 2869 //scroll the tabs if there is not enough room to display them all 2870 var current = slide_element.find(options.slide_content).eq(index), 2871 viewport = slide_container.width(), 2872 modifier = container.data('av-enlarge') > 1 && currentIndex == index ? container.data('av-enlarge') : 1, 2873 outerWidth = current.outerWidth( true ) * modifier, 2874 margin_right= parseInt( current.css('margin-right') , 10 ) / 2, 2875 left_pos = viewport < all_elements_width ? (current.position().left * - 1) - (outerWidth / 2) + (viewport / 2): 0; 2876 2877 //center properly 2878 left_pos = left_pos + margin_right; 2879 2880 //out of bounce right side 2881 if(left_pos + all_elements_width < viewport) left_pos = (all_elements_width - viewport - parseInt(current.css('margin-right'),10) ) * -1; 2882 2883 //out of bounce left side 2884 if(left_pos > 0) left_pos = 0; 2885 2886 //set pos 2887 slide_element.css('left',left_pos ); 2888 2889 slide_container.find("." +options.active).removeClass(options.active); 2890 current.addClass(options.active); 2891 currentIndex = index; 2892 2893 }; 2894 2895 2896 $.avia_utilities.preload({container: container , global_callback: function() 2897 { 2898 // activate behavior 2899 set_up( 'init' ); 2900 win.on('debouncedresize', set_up); 2901 if(initial) change_active(initial - 1); 2902 2903 setTimeout(function(){ 2904 container.addClass('av-horizontal-gallery-animated'); 2905 },10); 2906 2907 }}); 2908 2909 2910 2911 2912 2913 2914 2915 //swipe on mobile 2916 slide_element.avia_swipe_trigger({prev:options.prev, next:options.next}); 2917 2918 //element click 2919 slide_content.on('click', function(e) 2920 { 2921 var current = $(this); 2922 var index = slide_content.index(current); 2923 2924 if(currentIndex === index) 2925 { 2926 if(container.data('av-enlarge') > 1 && !$(e.target).is('a') ) 2927 { 2928 //slide_container.find("." +options.active).removeClass(options.active); 2929 //currentIndex = false; 2930 } 2931 return; 2932 } 2933 2934 change_active(index); 2935 }); 2936 2937 prev.on('click', function(e) 2938 { 2939 if(currentIndex === false) currentIndex = 1; 2940 var index = currentIndex - 1; 2941 if(index < 0) index = 0; 2942 2943 change_active(index); 2944 }); 2945 2946 next.on('click', function(e) 2947 { 2948 if(currentIndex === false) currentIndex = -1; 2949 var index = currentIndex + 1; 2950 if(index > slide_content.length - 1) index = slide_content.length - 1; 2951 2952 change_active(index); 2953 }); 2954 2955 //if its a desktop browser add arrow navigation, otherwise add touch nav 2956 if(!isMobile) 2957 {
2958 container.avia_keyboard_controls({ 37: options.prev, 39: options.next }); 2959 } 2960 else 2961 { 2962 container.avia_swipe_trigger({next: options.next, prev: options.prev}); 2963 } 2964 2965 2966 2967 }); 2968}; 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981// ------------------------------------------------------------------------------------------- 2982// Aviaccordion Slideshow 2983// 2984// accordion slider script 2985// ------------------------------------------------------------------------------------------- 2986 2987 $.AviaccordionSlider = function(options, slider) 2988 { 2989 this.$slider = $( slider ); 2990 this.$inner = this.$slider.find('.aviaccordion-inner'); 2991 this.$slides = this.$inner.find('.aviaccordion-slide'); 2992 this.$images = this.$inner.find('.aviaccordion-image'); 2993 this.$last = this.$slides.filter(':last'); 2994 this.$titles = this.$slider.find('.aviaccordion-preview'); 2995 this.$titlePos = this.$slider.find('.aviaccordion-preview-title-pos'); 2996 this.$titleWrap = this.$slider.find('.aviaccordion-preview-title-wrap'); 2997 this.$win = $( window ); 2998 2999 if($.avia_utilities.supported.transition === undefined) 3000 { 3001 $.avia_utilities.supported.transition = $.avia_utilities.supports('transition'); 3002 } 3003 3004 this.browserPrefix = $.avia_utilities.supported.transition; 3005 this.cssActive = this.browserPrefix !== false ? true : false; 3006 this.transform3d = document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false; 3007 this.isMobile = $.avia_utilities.isMobile; 3008 this.property = this.browserPrefix + 'transform', 3009 this.count = this.$slides.length; 3010 this.open = false; 3011 this.autoplay = false; 3012 this.increaseTitle = this.$slider.is(".aviaccordion-title-on-hover"); 3013 // this.cssActive = false; //testing no css3 browser 3014 3015 this._init( options ); 3016 } 3017 3018 $.AviaccordionSlider.prototype = 3019 { 3020 _init: function( options ) 3021 { 3022 var _self = this; 3023 _self.options = $.extend({}, options, this.$slider.data()); 3024 $.avia_utilities.preload({container: this.$slider , single_c
3024allback: function(){ _self._kickOff(); }}); 3025 }, 3026 3027 _kickOff: function() 3028 { 3029 var _self = this; 3030 3031 _self._calcMovement(); 3032 _self._bindEvents(); 3033 _self._showImages(); 3034 _self._autoplay(); 3035 }, 3036 3037 _autoplay: function() 3038 { 3039 var _self = this; 3040 3041 if(_self.options.autoplay) 3042 { 3043 _self.autoplay = setInterval(function() 3044 { 3045 _self.open = _self.open === false ? 0 : _self.open + 1; 3046 if(_self.open >= _self.count) _self.open = 0; 3047 _self._move({}, _self.open); 3048 3049 }, _self.options.interval * 1000) 3050 } 3051 }, 3052 3053 _showImages: function() 3054 { 3055 var _self = this, counter = 0, delay = 300, title_delay = this.count * delay; 3056 3057 if(this.cssActive) 3058 { 3059 setTimeout(function(){ _self.$slider.addClass('av-animation-active'); } , 10); 3060 } 3061 3062 this.$images.each(function(i) 3063 { 3064 var current = $(this), timer = delay * (i + 1); 3065 3066 setTimeout(function() 3067 { 3068 current.avia_animate({opacity:1}, 400, function() 3069 { 3070 current.css($.avia_utilities.supported.transition + "transform", "none"); 3071 }); 3072 },timer); 3073 }); 3074 3075 if(_self.increaseTitle) title_delay = 0; 3076 3077 this.$titlePos.each(function(i) 3078 { 3079 var current = $(this), new_timer = title_delay + 100 * (i + 1); 3080 3081 setTimeout(function() 3082 { 3083 current.avia_animate({opacity:1}, 200, function() 3084 { 3085 current.css($.avia_utilities.supported.transition + "transform", "none"); 3086 }); 3087 },new_timer); 3088 }); 3089 }, 3090 3091 _bindEvents: function() 3092 { 3093 var trigger = this.isMobile ? "click" : "mouseenter"; 3094 3095 this.$slider.on(trigger,'.aviaccordion-slide', $.proxy( this._move, this)); 3096 this.$slider.on('mouseleave','.aviaccordion-inner', $.proxy( this._move, this)); 3097 this.$win.on('debouncedresize', $.proxy( this._calcMovement, this)); 3098 this.$slider.on('av-prev av-next', $.proxy( this._moveTo, this)); 3099 3100 if(this.isMobile) 3101 { 3102 this.$slider.avia_swipe_trigger({next: this.$slider, prev: this.$slider, event:{prev: 'av-prev', next: 'av-next'}}); 3103 } 3104 3105 }, 3106 3107 _titleHeight: function() 3108 { 3109 var th = 0; 3110 3111 this.$titleWrap.css({'height':'auto'}).each(function() 3112 { 3113 var new_h = $(this).outerHeight(); 3114 if( new_h > th) th = new_h; 3115 3116 }).css({'height':th + 2}); 3117 3118 }, 3119 3120 _calcMovement: function(event, allow_repeat) 3121 { 3122 var _self = this, 3123 containerWidth = this.$slider.width(), 3124 defaultPos = this.$last.data('av-left'), 3125 imgWidth = this.$images.filter(':last').width() || containerWidth, 3126 imgWidthPercent = Math.floor((100 / containerWidth) * imgWidth), 3127 allImageWidth = imgWidthPercent * _self.count, 3128 modifier = 3, // 10 - _self.count, 3129 tempMinLeft = 100 - imgWidthPercent, 3130 minLeft = tempMinLeft > defaultPos / modifier ? tempMinLeft : 0, 3131 oneLeft = minLeft / (_self.count -1 ), 3132 titleWidth = imgWidth; 3133 3134 3135 3136 if(allImageWidth < 110 && allow_repeat !== false) 3137 { 3138 //set height if necessary 3139 var slideHeight = this.$slider.height(), 3140 maxHeight = (slideHeight / allImageWidth) * 110 ; 3141 3142 this.$slider.css({'max-height': maxHeight}); 3143 _self._calcMovement(event, false); 3144 return; 3145 } 3146 3147 //backup so the minimized slides dont get too small 3148 if(oneLeft < 2) minLeft = 0; 3149 3150 this.$slides.each(function(i) 3151 { 3152 var current = $(this), newLeft = 0, newRight = 0, defaultLeft = current.data('av-left'); 3153 3154 if( minLeft !== 0) 3155 { 3156 newLeft = oneLeft * i; 3157 newRight = imgWidthPercent + newLeft - oneLeft; 3158 } 3159 else 3160 { 3161 newLeft = defaultLeft / Math.abs(modifier); 3162 newRight = 100 - ((newLeft / i) * (_self.count - i)); 3163 } 3164 3165 if(i == 1 && _self.increaseTitle) { titleWidth = newRight + 1; } 3166 3167 if(_self.cssActive) 3168 { 3169 //if we are not animating based on the css left value but on css transform we need to subtract the left value 3170 newLeft = newLeft - defaultLeft; 3171 newRight = newRight - defaultLeft; 3172 defaultLeft = 0; 3173 } 3174 3175 current.data('av-calc-default', defaultLeft); 3176 current.data('av-calc-left', newLeft); 3177 current.data('av-calc-right', newRight); 3178 3179 }); 3180 3181 if(_self.increaseTitle) { _self.$titles.css({width: titleWidth + "%"});} 3182 }, 3183 3184 _moveTo: function(event) 3185 { 3186 var direction = event.type == "av-next" ? 1 : -1, 3187 nextSlide = this.open === false ? 0 : this.open + direction; 3188 3189 if(nextSlide >= 0 && nextSlide < this.$slides.length) this._move(event, nextSlide); 3190 }, 3191 3192 _move: function(event, direct_open) 3193 { 3194 var _self = this, 3195 slide = event.currentTarget, 3196 itemNo = typeof direct_open != "undefined" ? direct_open : this.$slides.index(slide); 3197 3198 this.open = itemNo; 3199 3200 if(_self.autoplay && typeof slide != "undefined") { clearInterval(_self.autoplay); _self.autoplay = false; } 3201 3202 this.$slides.removeClass('aviaccordion-active-slide').each(function(i) 3203 { 3204 var current = $(this), 3205 dataSet = current.data(), 3206 trans_val = i <= itemNo ? dataSet.avCalcLeft : dataSet.avCalcRight, 3207 transition = {}, 3208 reset = event.type == 'mouseleave' ? 1 : 0, 3209 active = itemNo === i ? _self.$titleWrap.eq(i) : false;
3210 3211 if(active) current.addClass('aviaccordion-active-slide'); 3212 3213 if(reset) 3214 { 3215 trans_val = dataSet.avCalcDefault; 3216 this.open = false; 3217 } 3218 3219 if(_self.cssActive) //do a css3 animation 3220 { 3221 //move the slides 3222 transition[_self.property] = _self.transform3d ? "translate3d(" + trans_val + "%, 0, 0)" : "translate(" + trans_val + "%,0)"; //3d or 2d transform? 3223 current.css(transition); 3224 } 3225 else 3226 { 3227 transition.left = trans_val + "%"; 3228 current.stop().animate(transition, 700, 'easeOutQuint'); 3229 } 3230 }); 3231 } 3232 }; 3233 3234 3235$.fn.aviaccordion = function( options ) 3236{ 3237 return this.each(function() 3238 { 3239 var active = $.data( this, 'AviaccordionSlider' ); 3240 3241 if(!active) 3242 { 3243 //make sure that the function doesnt get aplied a second time 3244 $.data( this, 'AviaccordionSlider', 1 ); 3245 3246 //create the preparations for fullscreen slider 3247 new $.AviaccordionSlider( options, this ); 3248 } 3249 }); 3250} 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262// ------------------------------------------------------------------------------------------- 3263// Aviaccordion Slideshow 3264// 3265// accordion slider script 3266// ------------------------------------------------------------------------------------------- 3267 3268 $.AviaTextRotator = function(options, slider) 3269 { 3270 this.$win = $( window ); 3271 this.$slider = $( slider ); 3272 this.$inner = this.$slider.find('.av-rotator-text'); 3273 this.$slides = this.$inner.find('.av-rotator-text-single'); 3274 this.$current = this.$slides.eq(0); 3275 this.open = 0; 3276 this.count = this.$slides.length; 3277 3278 if($.avia_utilities.supported.transition === undefined) 3279 { 3280 $.avia_utilities.supported.transition = $.avia_utilities.supports('transition'); 3281 } 3282 3283 this.browserPrefix = $.avia_utilities.supported.transition; 3284 this.cssActive = this.browserPrefix !== false ? true : false; 3285 this.property = this.browserPrefix + 'transform', 3286 3287 //this.cssActive = false; //testing no css3 browser 3288 3289 this._init( options ); 3290 } 3291 3292 $.AviaTextRotator.prototype = 3293 { 3294 _init: function( options ) 3295 { 3296 var _self = this; 3297 3298 if(this.count <= 1) return; 3299 3300 _self.options = $.extend({}, options, this.$slider.data()); 3301 _self.$inner.addClass('av-rotation-active'); 3302 //if(_self.options.fixwidth == 1) this.$inner.width(this.$current.width()); 3303 _self._autoplay(); 3304 }, 3305 3306 _autoplay: function() 3307 { 3308 var _self = this; 3309 3310 _self.autoplay = setInterval(function() 3311 { 3312 _self.open = _self.open === false ? 0 : _self.open + 1; 3313 if(_self.open >= _self.count) _self.open = 0; 3314 _self._move({}, _self.open); 3315 3316 }, _self.options.interval * 1000) 3317 }, 3318 3319 _move: function(event) 3320 { 3321 var _self = this, 3322 modifier = 30 * _self.options.animation, 3323 fade_out = {opacity:0}, 3324 fade_start = {display:'inline-block', opacity:0}, 3325 fade_in = {opacity:1}; 3326 3327 this.$next = _self.$slides.eq(this.open); 3328 3329 if(this.cssActive) 3330 { 3331 fade_out[_self.property] = "translate(0px," + modifier +"px)"; 3332 fade_start[_self.property] = "translate(0px," + (modifier * -1) +"px)"; 3333 fade_in[_self.property] = "translate(0px,0px)"; 3334 } 3335 else 3336 { 3337 fade_out['top'] = modifier; 3338 fade_start['top'] = (modifier * -1); 3339 fade_in['top'] = 0; 3340 } 3341 3342 3343 _self.$current.avia_animate(fade_out, function() 3344 { 3345 _self.$current.css({display:'none'}); 3346 _self.$next.css(fade_start).avia_animate(fade_in, function() 3347 { 3348 _self.$current = _self.$slides.eq(_self.open); 3349 }); 3350 }); 3351 } 3352 }; 3353 3354 3355$.fn.avia_textrotator = function( options ) 3356{ 3357 return this.each(function() 3358 { 3359 var active = $.data( this, 'AviaTextRotator' ); 3360 3361 if(!active) 3362 { 3363 //make sure that the function doesnt get aplied a second time 3364 $.data( this, 'AviaTextRotator', 1 ); 3365 3366 //create the preparations for fullscreen slider 3367 new $.AviaTextRotator( options, this ); 3368 } 3369 }); 3370} 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386// ------------------------------------------------------------------------------------------- 3387// HELPER FUNCTIONS 3388// ------------------------------------------------------------------------------------------- 3389 3390 3391//waipoint script when something comes into viewport 3392 $.fn.avia_waypoints = function(options_passed) 3393 { 3394 if(! $('html').is('.avia_transform')) return; 3395 3396 var defaults = { offset: 'bottom-in-view' , triggerOnce: true}, 3397 options = $.extend({}, defaults, options_passed), 3398 isMobile = $.avia_utilities.isMobile; 3399 3400 return this.each(function() 3401 { 3402 var element = $(this); 3403 3404 setTimeout(function() 3405 { 3406 if(isMobile) 3407 { 3408 element.addClass('avia_start_animation').trigger('avia_start_animation'); 3409 } 3410 else 3411 { 3412 element.waypoint(function(direction) 3413 { 3414 var current = $(this.element), 3415 parent = current.parents('.av-animation-delay-container:eq(0)'); 3416 3417 if(parent.length) 3418 { 3419 current.addClass('avia_start_animation_when_active').trigger('avia_start_animation_when_active'); 3420 } 3421 3422 if(!parent.length || (parent.length && parent.is('.__av_init_open'))) 3423 { 3424 current.addClass('avia_start_animation').trigger('avia_start_animation'); 3425 } 3426 3427 3428 3429 }, options ); 3430 } 3431 },100) 3432 3433 }); 3434 }; 3435 3436 3437 3438 3439 3440 3441 3442// window resize script 3443var $event = $.event, $special, resizeTimeout; 3444 3445$special = $event.special.debouncedresize = { 3446 setup: function() { 3447 $( this ).on( "resize", $special.handler ); 3448 }, 3449 teardown: function() { 3450 $( this ).off( "resize", $special.handler ); 3451 }, 3452 handler: function( event, execAsap ) { 3453 // Save the context 3454 var context = this, 3455 args = arguments, 3456 dispatch = function() { 3457 // set correct event type 3458 event.type = "debouncedresize"; 3459 $event.dispatch.apply( context, args ); 3460 }; 3461 3462 if ( resizeTimeout ) { 3463 clearTimeout( resizeTimeout ); 3464 } 3465 3466 execAsap ? 3467 dispatch() : 3468 resizeTimeout = setTimeout( dispatch, $special.threshold ); 3469 }, 3470 threshold: 150 3471}; 3472 3473 3474 3475 3476 3477$.easing['jswing'] = $.easing['swing']; 3478 3479$.extend( $.easing, 3480{ 3481 def: 'easeOutQuad', 3482 swing: function (x, t, b, c, d) { return $.easing[$.easing.def](x, t, b, c, d); }, 3483 easeInQuad: function (x, t, b, c, d) { return c*(t/=d)*t + b; }, 3484 easeOutQuad: function (x, t, b, c, d) { return -c *(t/=d)*(t-2) + b; }, 3485 easeInOutQuad: function (x, t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t + b; return -c/2 * ((--t)*(t-2) - 1) + b; },
vendor: 4,549 bytes, lines 3486-3591
3486 easeInCubic: function (x, t, b, c, d) { return c*(t/=d)*t*t + b; }, 3487 easeOutCubic: function (x, t, b, c, d) { return c*((t=t/d-1)*t*t + 1) + b; }, 3488 easeInOutCubic: function (x, t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t*t + b; return c/2*((t-=2)*t*t + 2) + b; }, 3489 easeInQuart: function (x, t, b, c, d) { return c*(t/=d)*t*t*t + b; }, 3490 easeOutQuart: function (x, t, b, c, d) { return -c * ((t=t/d-1)*t*t*t - 1) + b; }, 3491 easeInOutQuart: function (x, t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t*t*t + b; return -c/2 * ((t-=2)*t*t*t - 2) + b; }, 3492 easeInQuint: function (x, t, b, c, d) { return c*(t/=d)*t*t*t*t + b; }, 3493 easeOutQuint: function (x, t, b, c, d) { return c*((t=t/d-1)*t*t*t*t + 1) + b; }, 3494 easeInOutQuint: function (x, t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; return c/2*((t-=2)*t*t*t*t + 2) + b; }, 3495 easeInSine: function (x, t, b, c, d) { return -c * Math.cos(t/d * (Math.PI/2)) + c + b; }, 3496 easeOutSine: function (x, t, b, c, d) { return c * Math.sin(t/d * (Math.PI/2)) + b; }, 3497 easeInOutSine: function (x, t, b, c, d) { return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b; }, 3498 easeInExpo: function (x, t, b, c, d) { return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b; }, 3499 easeOutExpo: function (x, t, b, c, d) { return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b; }, 3500 easeInOutExpo: function (x, t, b, c, d) { 3501 if (t==0) return b; 3502 if (t==d) return b+c; 3503 if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b; 3504 return c/2 * (-Math.pow(2, -10 * --t) + 2) + b; 3505 }, 3506 easeInCirc: function (x, t, b, c, d) { return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b; }, 3507 easeOutCirc: function (x, t, b, c, d) {return c * Math.sqrt(1 - (t=t/d-1)*t) + b; }, 3508 easeInOutCirc: function (x, t, b, c, d) { if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b; return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b; }, 3509 easeInElastic: function (x, t, b, c, d) { 3510 var s=1.70158;var p=0;var a=c; 3511 if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; 3512 if (a < Math.abs(c)) { a=c; var s=p/4; } 3513 else var s = p/(2*Math.PI) * Math.asin (c/a); 3514 return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; 3515 }, 3516 easeOutElastic: function (x, t, b, c, d) { 3517 var s=1.70158;var p=0;var a=c; 3518 if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; 3519 if (a < Math.abs(c)) { a=c; var s=p/4; } 3520 else var s = p/(2*Math.PI) * Math.asin (c/a); 3521 return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b; 3522 }, 3523 easeInOutElastic: function (x, t, b, c, d) { 3524 var s=1.70158;var p=0;var a=c; 3525 if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5); 3526 if (a < Math.abs(c)) { a=c; var s=p/4; } 3527 else var s = p/(2*Math.PI) * Math.asin (c/a); 3528 if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; 3529 return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b; 3530 }, 3531 easeInBack: function (x, t, b, c, d, s) { 3532 if (s == undefined) s = 1.70158; 3533 return c*(t/=d)*t*((s+1)*t - s) + b; 3534 }, 3535 easeOutBack: function (x, t, b, c, d, s) { 3536 if (s == undefined) s = 1.70158; 3537 return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; 3538 }, 3539 easeInOutBack: function (x, t, b, c, d, s) { 3540 if (s == undefined) s = 1.70158; 3541 if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; 3542 return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; 3543 }, 3544 easeInBounce: function (x, t, b, c, d) { 3545 return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b; 3546 }, 3547 easeOutBounce: function (x, t, b, c, d) { 3548 if ((t/=d) < (1/2.75)) { 3549 return c*(7.5625*t*t) + b; 3550 } else if (t < (2/2.75)) { 3551 return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; 3552 } else if (t < (2.5/2.75)) { 3553 return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; 3554 } else { 3555 return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b; 3556 } 3557 }, 3558 easeInOutBounce: function (x, t, b, c, d) { 3559 if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b; 3560 return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b; 3561 } 3562}); 3563 3564})( jQuery ); 3565 3566 3567 3568/*utility functions*/ 3569 3570 3571(function($) 3572{ 3573 "use strict"; 3574 3575 $.avia_utilities = $.avia_utilities || {}; 3576 3577 /************************************************************************ 3578 gloabl loading function 3579 *************************************************************************/ 3580 $.avia_utilities.loading = function(attach_to, delay){ 3581 3582 var loader = { 3583 3584 active: false, 3585 3586 show: function() 3587 { 3588 if(loader.active === false) 3589 { 3590 loader.active = true; 3591 loader.loading_item.css({display:'block', opacity:0}
3591); 3592 } 3593 3594 loader.loading_item.stop().animate({opacity:1}); 3595 }, 3596 3597 hide: function() 3598 { 3599 if(typeof delay === 'undefined'){ delay = 600; } 3600 3601 loader.loading_item.stop().delay( delay ).animate({opacity:0}, function() 3602 { 3603 loader.loading_item.css({display:'none'}); 3604 loader.active = false; 3605 }); 3606 }, 3607 3608 attach: function() 3609 { 3610 if(typeof attach_to === 'undefined'){ attach_to = 'body';} 3611 3612 loader.loading_item = $('<div class="avia_loading_icon"><div class="av-siteloader"></div></div>').css({display:"none"}).appendTo(attach_to); 3613 } 3614 } 3615 3616 loader.attach(); 3617 return loader; 3618 }; 3619 3620 /************************************************************************ 3621 gloabl play/pause visualizer function 3622 *************************************************************************/ 3623 $.avia_utilities.playpause = function(attach_to, delay){ 3624 3625 var pp = { 3626 3627 active: false, 3628 to1: "", 3629 to2: "", 3630 set: function(status) 3631 { 3632 pp.loading_item.removeClass('av-play av-pause'); 3633 pp.to1 = setTimeout(function(){ pp.loading_item.addClass('av-' + status); },10); 3634 pp.to2 = setTimeout(function(){ pp.loading_item.removeClass('av-' + status); },1500); 3635 }, 3636 3637 attach: function() 3638 { 3639 if(typeof attach_to === 'undefined'){ attach_to = 'body';} 3640 3641 pp.loading_item = $('<div class="avia_playpause_icon"></div>').css({display:"none"}).appendTo(attach_to); 3642 } 3643 } 3644 3645 pp.attach(); 3646 return pp; 3647 }; 3648 3649 3650 3651 /************************************************************************ 3652 preload images, as soon as all are loaded trigger a special load ready event 3653 *************************************************************************/ 3654 $.avia_utilities.preload = function(options_passed) 3655 { 3656 new $.AviaPreloader(options_passed); 3657 } 3658 3659 $.AviaPreloader = function(options) 3660 { 3661 this.win = $(window); 3662 this.defaults = 3663 { 3664 container: 'body', 3665 maxLoops: 10, 3666 trigger_single: true, 3667 single_callback: function(){}, 3668 global_callback: function(){} 3669 3670 }; 3671 this.options = $.extend({}, this.defaults, options); 3672 this.preload_images = 0; 3673 3674 this.load_images(); 3675 } 3676 3677 $.AviaPreloader.prototype = 3678 { 3679 load_images: function() 3680 { 3681 var _self = this; 3682 3683 if(typeof _self.options.container === 'string'){ _self.options.container = $(_self.options.container); } 3684 3685 _self.options.container.each(function() 3686 { 3687 var container = $(this); 3688 3689 container.images = container.find('img'); 3690 container.allImages = container.images; 3691 3692 _self.preload_images += container.images.length; 3693 setTimeout(function(){ _self.checkImage(container); }, 10); 3694 }); 3695 }, 3696 3697 checkImage: function(container) 3698 { 3699 var _self = this; 3700 3701 container.images.each(function() 3702 { 3703 if(this.complete === true) 3704 { 3705 container.images = container.images.not(this); 3706 _self.preload_images -= 1; 3707 } 3708 }); 3709 3710 if(container.images.length && _self.options.maxLoops >= 0) 3711 { 3712 _self.options.maxLoops-=1; 3713 setTimeout(function(){ _self.checkImage(container); }, 500); 3714 } 3715 else 3716 { 3717 _self.preload_images = _self.preload_images - container.images.length; 3718 _self.trigger_loaded(container); 3719 } 3720 }, 3721 3722 trigger_loaded: function(container) 3723 { 3724 var _self = this; 3725 3726 if(_self.options.trigger_single !== false) 3727 { 3728 _self.win.trigger('avia_images_loaded_single', [container]); 3729 _self.options.single_callback.call(container); 3730 } 3731 3732 if(_self.preload_images === 0) 3733 { 3734 _self.win.trigger('avia_images_loaded'); 3735 _self.options.global_callback.call(); 3736 } 3737 3738 } 3739 } 3740 3741 3742 /************************************************************************ 3743 CSS Easing transformation table 3744 *************************************************************************/ 3745 /* 3746 Easing transform table from jquery.animate-enhanced plugin 3747 http://github.com/benbarnett/jQuery-Animate-Enhanced 3748 */ 3749 $.avia_utilities.css_easings = { 3750 linear: 'linear', 3751 swing: 'ease-in-out', 3752 bounce: 'cubic-bezier(0.0, 0.35, .5, 1.3)', 3753 easeInQuad: 'cubic-bezier(0.550, 0.085, 0.680, 0.530)' , 3754 easeInCubic: 'cubic-bezier(0.550, 0.055, 0.675, 0.190)' , 3755 easeInQuart: 'cubic-bezier(0.895, 0.030, 0.685, 0.220)' , 3756 easeInQuint: 'cubic-bezier(0.755, 0.050, 0.855, 0.060)' , 3757 easeInSine: 'cubic-bezier(0.470, 0.000, 0.745, 0.715)' , 3758 easeInExpo: 'cubic-bezier(0.950, 0.050, 0.795, 0.035)' , 3759 easeInCirc: 'cubic-bezier(0.600, 0.040, 0.980, 0.335)' , 3760 easeInBack: 'cubic-bezier(0.600, -0.280, 0.735, 0.04)' , 3761 easeOutQuad: 'cubic-bezier(0.250, 0.460, 0.450, 0.940)' , 3762 easeOutCubic: 'cubic-bezier(0.215, 0.610, 0.355, 1.000)' , 3763 easeOutQuart: 'cubic-bezier(0.165, 0.840, 0.440, 1.000)' , 3764 easeOutQuint: 'cubic-bezier(0.230, 1.000, 0.320, 1.000)' , 3765 easeOutSine: 'cubic-bezier(0.390, 0.575, 0.565, 1.000)' , 3766 easeOutExpo: 'cubic-bezier(0.190, 1.000, 0.220, 1.000)' , 3767 easeOutCirc: 'cubic-bezier(0.075, 0.820, 0.165, 1.000)' , 3768 easeOutBack: 'cubic-bezier(0.175, 0.885, 0.320, 1.275)' , 3769 easeInOutQuad: 'cubic-bezier(0.455, 0.030, 0.515, 0.955)' , 3770 easeInOutCubic: 'cubic-bezier(0.645, 0.045, 0.355, 1.000)' , 3771 easeInOutQuart: 'cubic-bezier(0.770, 0.000, 0.175, 1.000)' , 3772 easeInOutQuint: 'cubic-bezier(0.860, 0.000, 0.070, 1.000)' , 3773 easeInOutSine: 'cubic-bezier(0.445, 0.050, 0.550, 0.950)' , 3774 easeInOutExpo: 'cubic-bezier(1.000, 0.000, 0.000, 1.000)' , 3775 easeInOutCirc: 'cubic-bezier(0.785, 0.135, 0.150, 0.860)' , 3776 easeInOutBack: 'cubic-bezier(0.680, -0.550, 0.265, 1.55)' , 3777 easeInOutBounce:'cubic-bezier(0.580, -0.365, 0.490, 1.365)', 3778 easeOutBounce: 'cubic-bezier(0.760, 0.085, 0.490, 1.365)' 3779 }; 3780 3781 /************************************************************************ 3782 check if a css feature is supported and save it to the supported array 3783 *************************************************************************/ 3784 $.avia_utilities.supported = {}; 3785 $.avia_utilities.supports = (function() 3786 { 3787 var div = document.createElement('div'), 3788 vendors = ['Khtml', 'Ms','Moz','Webkit']; // vendors = ['Khtml', 'Ms','Moz','Webkit','O']; 3789 3790 return function(prop, vendor_overwrite) 3791 { 3792 if ( div.style[prop] !== undefined ) { return ""; }
3793 if (vendor_overwrite !== undefined) { vendors = vendor_overwrite; } 3794 3795 prop = prop.replace(/^[a-z]/, function(val) 3796 { 3797 return val.toUpperCase(); 3798 }); 3799 3800 var len = vendors.length; 3801 while(len--) 3802 { 3803 if ( div.style[vendors[len] + prop] !== undefined ) 3804 { 3805 return "-" + vendors[len].toLowerCase() + "-"; 3806 } 3807 } 3808 3809 return false; 3810 }; 3811 3812 }()); 3813 3814 /************************************************************************ 3815 animation function 3816 *************************************************************************/ 3817 $.fn.avia_animate = function(prop, speed, easing, callback) 3818 { 3819 if(typeof speed === 'function') {callback = speed; speed = false; } 3820 if(typeof easing === 'function'){callback = easing; easing = false;} 3821 if(typeof speed === 'string'){easing = speed; speed = false;} 3822 3823 if(callback === undefined || callback === false){ callback = function(){}; } 3824 if(easing === undefined || easing === false) { easing = 'easeInQuad'; } 3825 if(speed === undefined || speed === false) { speed = 400; } 3826 3827 if($.avia_utilities.supported.transition === undefined) 3828 { 3829 $.avia_utilities.supported.transition = $.avia_utilities.supports('transition'); 3830 } 3831 3832 3833 3834 if($.avia_utilities.supported.transition !== false ) 3835 { 3836 var prefix = $.avia_utilities.supported.transition + 'transition', 3837 cssRule = {}, 3838 cssProp = {}, 3839 thisStyle = document.body.style, 3840 end = (thisStyle.WebkitTransition !== undefined) ? 'webkitTransitionEnd' : (thisStyle.OTransition !== undefined) ? 'oTransitionEnd' : 'transitionend'; 3841 3842 //translate easing into css easing 3843 easing = $.avia_utilities.css_easings[easing]; 3844 3845 //create css transformation rule 3846 cssRule[prefix] = 'all '+(speed/1000)+'s '+easing; 3847 //add namespace to the transition end trigger 3848 end = end + ".avia_animate"; 3849 3850 //since jquery 1.10 the items passed need to be {} and not [] so make sure they are converted properly 3851 for (var rule in prop) 3852 { 3853 if (prop.hasOwnProperty(rule)) { cssProp[rule] = prop[rule]; } 3854 } 3855 prop = cssProp; 3856 3857 3858 3859 this.each(function() 3860 { 3861 var element = $(this), css_difference = false, rule, current_css; 3862 3863 for (rule in prop) 3864 { 3865 if (prop.hasOwnProperty(rule)) 3866 { 3867 current_css = element.css(rule); 3868 3869 if(prop[rule] != current_css && prop[rule] != current_css.replace(/px|%/g,"")) 3870 { 3871 css_difference = true; 3872 break; 3873 } 3874 } 3875 } 3876 3877 if(css_difference) 3878 { 3879 //if no transform property is set set a 3d translate to enable hardware acceleration 3880 if(!($.avia_utilities.supported.transition+"transform" in prop)) 3881 { 3882 prop[$.avia_utilities.supported.transition+"transform"] = "translateZ(0)"; 3883 } 3884 3885 var endTriggered = false; 3886 3887 element.on(end, function(event) 3888 { 3889 if(event.target != event.currentTarget) return false; 3890 3891 if(endTriggered == true) return false; 3892 endTriggered = true; 3893 3894 cssRule[prefix] = "none"; 3895 3896 element.off(end); 3897 element.css(cssRule); 3898 setTimeout(function(){ callback.call(element); }); 3899 }); 3900 3901 3902 //desktop safari fallback if we are in another tab to trigger the end event 3903 setTimeout(function(){ 3904 if(!endTriggered && !avia_is_mobile && $('html').is('.avia-safari') ) { 3905 element.trigger(end); 3906 $.avia_utilities.log('Safari Fallback '+end+' trigger'); 3907 } 3908 }, speed + 100); 3909 3910 setTimeout(function(){ element.css(cssRule);},10); 3911 setTimeout(function(){ element.css(prop); },20); 3912 } 3913 else 3914 { 3915 setTimeout(function(){ callback.call(element); }); 3916 } 3917 3918 }); 3919 } 3920 else // if css animation is not available use default JS animation 3921 { 3922 this.animate(prop, speed, easing, callback); 3923 } 3924 3925 return this; 3926 }; 3927 3928})( jQuery ); 3929 3930 3931/* ====================================================================================================================================================== 3932Avia Slideshow 3933====================================================================================================================================================== */ 3934 3935(function($) 3936{ 3937 "use strict"; 3938 3939 $.AviaSlider = function(options, slider) 3940 { 3941 var self = this; 3942
3943 this.$win = $( window ); 3944 3945 this.$slider = $( slider ); 3946 3947 this.isMobile = $.avia_utilities.isMobile; 3948 3949 this._prepareSlides(options); 3950 3951 //default preload images then init slideshow 3952 $.avia_utilities.preload({container: this.$slider , single_callback: function(){ self._init( options ); }}); 3953 } 3954 3955 $.AviaSlider.defaults = { 3956 3957 //interval between autorotation switches 3958 interval:5, 3959 3960 //autorotation active or not 3961 autoplay:false, 3962 3963 //set if the loop will stop at the last/first slide or if the slides will loop infinite 3964 //set to false for infinite loop, "last" to stop at the last slide or "first" to stop at the first slide 3965 stopinfiniteloop: false, 3966 3967 //fade or slide animation 3968 animation:'slide', 3969 3970 //transition speed when switching slide 3971 transitionSpeed:900, 3972 3973 //easing method for the transition 3974 easing:'easeInOutQuart', 3975 3976 //slide wrapper 3977 wrapElement: '>ul', 3978 3979 //slide element 3980 slideElement: '>li', 3981 3982 //pause if mouse cursor is above item 3983 hoverpause: false, 3984 3985 //attach images as background 3986 bg_slider: false, 3987 3988 //delay of miliseconds to wait before showing the next slide 3989 show_slide_delay: 0, 3990 3991 //if slider animation is set to "fade" the fullfade property sets the crossfade behaviour 3992 fullfade: false 3993 3994 }; 3995 3996 $.AviaSlider.prototype = 3997 { 3998 _init: function( options ) 3999 { 4000 // set slider options 4001 this.options = this._setOptions(options); 4002 4003 //slidewrap 4004 this.$sliderUl = this.$slider.find(this.options.wrapElement); 4005 4006 // slide elements 4007 this.$slides = this.$sliderUl.find(this.options.slideElement); 4008 4009 // goto dots 4010 this.gotoButtons = this.$slider.find('.avia-slideshow-dots a'); 4011 4012 //perma caption 4013 this.permaCaption = this.$slider.find('>.av-slideshow-caption'); 4014 4015 // slide count 4016 this.itemsCount = this.$slides.length; 4017 4018 // current image index 4019 this.current = 0; 4020 4021 //loop count 4022 this.loopCount = 0; 4023 4024 // control if the slicebox is animating 4025 this.isAnimating = false; 4026 4027 // css browser prefix like -webkit-, -moz- 4028 this.browserPrefix = $.avia_utilities.supports('transition'); 4029 4030 // css3 animation? 4031 this.cssActive = this.browserPrefix !== false ? true : false; 4032 4033 // css3D animation? 4034 this.css3DActive = document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false; 4035 4036 //store the aviaVideoApi object for the current slide if available 4037 this.video = false; 4038 4039 //if we have a bg slider no images were preloaded yet. in that case start preloading and attaching images 4040 if(this.options.bg_slider == true) 4041 { 4042 //create array that holds all image urls to preload 4043 this.imageUrls = []; 4044 4045 //create a preloader icon to indicate loading 4046 this.loader = $.avia_utilities.loading(this.$slider); 4047 4048 //preload the images ony by one 4049 this._bgPreloadImages(); 4050 4051 } 4052 else //if it was a default slider all images are already loaded and we can start showing the slider 4053 { 4054 //kickoff the slider: bind functions, show first slide, if active start the autorotation timer 4055 this._kickOff(); 4056 } 4057 }, 4058 4059 //set the slider options by first merging the efault options and the passed options, then checking the slider element if any data attributes overwrite the option set 4060 _setOptions: function(options) 4061 { 4062 var newOptions = $.extend( true, {}, $.AviaSlider.defaults, options ), 4063 htmlData = this.$slider.data(), 4064 i = ""; 4065 4066 //overwritte passed option set with any data properties on the html element 4067 for (i in htmlData) 4068 { 4069 if (htmlData.hasOwnProperty(i)) 4070 { 4071 if(typeof htmlData[i] === "string" || typeof htmlData[i] === "number" || typeof htmlData[i] === "boolean") 4072 { 4073 newOptions[i] = htmlData[i]; 4074 } 4075 } 4076 } 4077 4078 return newOptions; 4079 }, 4080 4081 _prepareSlides: function(options) 4082 { 4083 //if its a mobile device find all video slides that need to be altered 4084 if(this.isMobile) 4085 { 4086 var alter = this.$slider.find('.av-mobile-fallback-image'); 4087 alter.each(function() 4088 { 4089 var current = $(this).removeClass('av-video-slide').data({'avia_video_events': true, 'video-ratio':0}), 4090 fallback = current.data('mobile-img'), 4091 fallback_link = current.data('fallback-link'), 4092 appendTo = current.find('.avia-slide-wrap'); 4093 4094 current.find('.av-click-overlay, .mejs-mediaelement, .mejs-container').remove(); 4095 4096 if(!fallback) 4097 { 4098 $('<p class="av-fallback-message"><span>Please set a mobile device fallback image for this video in your wordpress backend</span></p>').appendTo(appendTo); 4099 } 4100 4101 if(options && options.bg_slider) 4102 { 4103 current.data('img-url', fallback); 4104
4105 //if we got a fallback link we need to either replace the default link on mobile devices, or if there is no default link change the wrapping <div> to an <a> 4106 if(fallback_link != "") 4107 { 4108 if(appendTo.is('a')) 4109 { 4110 appendTo.attr('href', fallback_link); 4111 } 4112 else 4113 { 4114 appendTo.find('a').remove(); 4115 appendTo.replaceWith(function(){ 4116 var cur_slide = $(this); 4117 return $("<a>").attr({'data-rel': cur_slide.data('rel'), 'class': cur_slide.attr('class'), 'href': fallback_link} ).append( $(this).contents() ); 4118 }); 4119 4120 appendTo = current.find('.avia-slide-wrap'); 4121 } 4122 4123 current.parents('#main').avia_activate_lightbox(); 4124 } 4125 } 4126 else 4127 { 4128 var image = $('<img src="'+fallback+'" alt="" title="" />'); 4129 current.find('.avia-slide-wrap').append(image); 4130 } 4131 4132 }); 4133 } 4134 4135 }, 4136 4137 //start preloading the background images 4138 _bgPreloadImages : function(callback) 4139 { 4140 this._getImageURLS(); 4141 4142 this._preloadSingle(0, function() 4143 { 4144 this._kickOff(); 4145 this._preloadNext(1); 4146 }); 4147 }, 4148 4149 //if we are using a background image slider, fetch the images from a data attribute and preload them one by one 4150 _getImageURLS: function() 4151 { 4152 var _self = this; 4153 4154 //collect url strings of the images to preload 4155 this.$slides.each(function(i) 4156 { 4157 _self.imageUrls[i] = []; 4158 _self.imageUrls[i]['url'] = $(this).data("img-url"); 4159 4160 //if no image is passed we can set the slide to loaded 4161 if(typeof _self.imageUrls[i]['url'] == 'string') 4162 { 4163 _self.imageUrls[i]['status'] = false; 4164 } 4165 else 4166 { 4167 _self.imageUrls[i]['status'] = true; 4168 } 4169 }); 4170 }, 4171 4172 4173 _preloadSingle: function(key, callback) 4174 { 4175 var _self = this, 4176 objImage = new Image(); 4177 4178 if(typeof _self.imageUrls[key]['url'] == 'string') 4179 { 4180 $(objImage).bind('load error', function() 4181 { 4182 _self.imageUrls[key]['status'] = true; 4183 _self.$slides.eq(key).css('background-image','url(' + _self.imageUrls[key]['url'] + ')'); 4184 if(typeof callback == 'function') callback.apply( _self, [objImage, key] ); 4185 }); 4186 4187 if(_self.imageUrls[key]['url'] != "") 4188 { 4189 objImage.src = _self.imageUrls[key]['url']; 4190 } 4191 else 4192 { 4193 $(objImage).trigger('error'); 4194 } 4195 } 4196 else 4197 { 4198 if(typeof callback == 'function') callback.apply( _self, [objImage, key] ); 4199 } 4200 }, 4201 4202 _preloadNext: function(key) 4203 { 4204 if(typeof this.imageUrls[key] != "undefined") 4205 { 4206 this._preloadSingle(key, function() 4207 { 4208 this._preloadNext(key + 1); 4209 }); 4210 } 4211 }, 4212 4213 4214 //bind click events of slide controlls to the public functions 4215 _bindEvents: function() 4216 { 4217 var self = this, 4218 win = $( window ); 4219 4220 this.$slider.on('click','.next-slide', $.proxy( this.next, this) ); 4221 this.$slider.on('click','.prev-slide', $.proxy( this.previous, this) ); 4222 this.$slider.on('click','.goto-slide', $.proxy( this.go2, this) ); 4223 4224 if(this.options.hoverpause) 4225 { 4226 this.$slider.on('mouseenter', $.proxy( this.pause, this) ); 4227 this.$slider.on('mouseleave', $.proxy( this.resume, this) ); 4228 } 4229 4230 if(this.options.stopinfiniteloop && this.options.autoplay) 4231 { 4232 if(this.options.stopinfiniteloop == 'last') 4233 { 4234 this.$slider.on('avia_slider_last_slide', $.proxy(this._stopSlideshow, this) ); 4235 } 4236 else if(this.options.stopinfiniteloop == 'first') 4237 { 4238 this.$slider.on('avia_slider_first_slide', $.proxy(this._stopSlideshow, this) ); 4239 } 4240 } 4241 4242 win.on( 'debouncedresize.aviaSlider', $.proxy( this._setSize, this) ); 4243 4244 //if its a desktop browser add arrow navigation, otherwise add touch nav 4245 if(!this.isMobile) 4246 { 4247 this.$slider.avia_keyboard_controls(); 4248 } 4249 else 4250 { 4251 this.$slider.avia_swipe_trigger(); 4252 } 4253 4254 self._attach_video_events(); 4255 }, 4256 4257 //kickoff the slider by binding all functions to slides and buttons, show the first slide and start autoplay 4258 _kickOff: function() 4259 { 4260 var self = this, 4261 first_slide = self.$slides.eq(0), 4262 video = first_slide.data('video-ratio'); 4263 4264 // bind events to to the controll buttons 4265 self._bindEvents(); 4266 4267 this.$slider.removeClass('av-default-height-applied'); 4268 4269 //show the first slide. if its a video set the correct size, otherwise make sure to remove the % padding 4270 if(video) 4271 { 4272 self._setSize(true); 4273 } 4274 else 4275 { 4276 if(this.options.keep_pading != true) 4277 { 4278 self.$sliderUl.css('padding',0); 4279 self.$win.trigger('av-height-change'); 4280 } 4281 } 4282 4283 self._setCenter(); 4284 first_slide.css({visibility:'visible', opacity:0}
4284).avia_animate({opacity:1}, function() 4285 { 4286 var current = $(this).addClass('active-slide'); 4287 4288 if(self.permaCaption.length) 4289 { 4290 self.permaCaption.addClass('active-slide'); 4291 } 4292 }); 4293 4294 4295 4296 // start autoplay if active 4297 if( self.options.autoplay ) 4298 { 4299 self._startSlideshow(); 4300 } 4301 4302 }, 4303 4304 //calculate which slide should be displayed next and call the executing transition function 4305 _navigate : function( dir, pos ) { 4306 4307 if( this.isAnimating || this.itemsCount < 2Â || !this.$slider.is(":visible") ) 4308 { 4309 return false; 4310 } 4311 4312 this.isAnimating = true; 4313 4314 // current item's index 4315 this.prev = this.current; 4316 4317 // if position is passed 4318 if( pos !== undefined ) 4319 { 4320 this.current = pos; 4321 dir = this.current > this.prev ? 'next' : 'prev'; 4322 } 4323 // if not check the boundaries 4324 else if( dir === 'next' ) 4325 { 4326 this.current = this.current < this.itemsCount - 1 ? this.current + 1 : 0; 4327 4328 if( this.current === 0 && this.options.autoplay_stopper == 1 && this.options.autoplay ) 4329 { 4330 this.isAnimating = false; 4331 this.current = this.prev; 4332 this._stopSlideshow(); 4333 return false; 4334 } 4335 } 4336 else if( dir === 'prev' ) 4337 { 4338 this.current = this.current > 0 ? this.current - 1 : this.itemsCount - 1; 4339 } 4340 4341 //set goto button 4342 this.gotoButtons.removeClass('active').eq(this.current).addClass('active'); 4343 4344 //set slideshow size 4345 this._setSize(); 4346 4347 //if we are using a background slider make sure that the image is loaded. if not preload it, then show the slide 4348 if(this.options.bg_slider == true) 4349 { 4350 if(this.imageUrls[this.current]['status'] == true ) 4351 { 4352 this['_' + this.options.animation].call(this, dir); 4353 } 4354 else 4355 { 4356 this.loader.show(); 4357 this._preloadSingle(this.current, function() 4358 { 4359 this['_' + this.options.animation].call(this, dir); 4360 this.loader.hide(); 4361 }); 4362 } 4363 } 4364 else //no background loader -> images are already loaded 4365 { 4366 //call the executing function. for example _slide, or _fade. since the function call is absed on a var we can easily extend the slider with new animations 4367 this['_' + this.options.animation].call(this, dir); 4368 } 4369 4370 if(this.current == 0) 4371 { 4372 this.loopCount++; 4373 this.$slider.trigger('avia_slider_first_slide'); 4374 } 4375 else if(this.current == this.itemsCount - 1) 4376 { 4377 this.$slider.trigger('avia_slider_last_slide'); 4378 } 4379 else 4380 { 4381 this.$slider.trigger('avia_slider_navigate_slide'); 4382 } 4383 }, 4384 4385 //if the next slide has a different height than the current change the slideshow height 4386 _setSize: function(instant) 4387 { 4388 //if images are attached as bg images the slider has a fixed height 4389 if(this.options.bg_slider == true) return; 4390 4391 var self = this, 4392 slide = this.$slides.eq(this.current), 4393 img = slide.find('img'), 4394 current = Math.floor(this.$sliderUl.height()), 4395 ratio = slide.data('video-ratio'), 4396 setTo = ratio ? this.$sliderUl.width() / ratio : Math.floor(slide.height()), 4397 video_height = slide.data('video-height'), //forced video height %. needs to be set only once 4398 video_toppos = slide.data('video-toppos'); //forced video top position 4399 4400 this.$sliderUl.height(current).css('padding',0); //make sure to set the slideheight to an actual value 4401 4402 if(setTo != current) 4403 { 4404 if(instant == true) 4405 { 4406 this.$sliderUl.css({height:setTo}); 4407 this.$win.trigger('av-height-change'); 4408 } 4409 else 4410 { 4411 this.$sliderUl.avia_animate({height:setTo}, function() 4412 { 4413 self.$win.trigger('av-height-change'); 4414 }); 4415 } 4416 } 4417 4418 this._setCenter(); 4419 4420 if(video_height && video_height!= "set") 4421 { 4422 slide.find('iframe, embed, video, object, .av_youtube_frame').css({height: video_height + '%', top: video_toppos + '%'}); 4423 slide.data('video-height','set'); 4424 } 4425 }, 4426 4427 _setCenter: function() 4428 { 4429 //if the image has a min width and is larger than the slider center it 4430 //positon img based on caption. right caption->left pos, left caption -> right pos 4431 var slide = this.$slides.eq(this.current), 4432 img = slide.find('img'), 4433 min_width = parseInt(img.css('min-width'),10), 4434 slide_width = slide.width(), 4435 caption = slide.find('.av-slideshow-caption'), 4436 css_left = ((slide_width - min_width) / 2); 4437 4438 if(caption.length) 4439 { 4440 if(caption.is('.caption_left')) 4441 { 4442 css_left = ((slide_width - min_width) / 1.5); 4443 } 4444 else if(caption.is('.caption_right')) 4445 { 4446 css_left = ((slide_width - min_width) / 2.5); 4447 } 4448 } 4449 4450 if(slide_width >= min_width) 4451 { 4452 css_left = 0; 4453 } 4454 4455 img.css({left:css_left}); 4456 }, 4457 4458 _slide: function(dir) 4459 { 4460 var dynamic = false, //todo: pass by option if a slider is dynamic 4461 modifier = dynamic == true ? 2 : 1, 4462 sliderWidth = this.$slider.width(), 4463 direction = dir === 'next' ? -1 : 1, 4464 property = this.browserPrefix + 'transform', 4465 reset = {}, transition = {}, transition2 = {}, 4466 trans_val = ( sliderWidth * direction * -1), 4467 trans_val2 = ( sliderWidth * direction) / modifier; 4468 4469 //do a css3 animation 4470 if(this.cssActive) 4471 { 4472 property = this.browserPrefix + 'transform'; 4473 4474 //do a translate 3d transformation if available, since it uses hardware acceleration 4475 if(this.css3DActive) 4476 { 4477 reset[property] = "translate3d(" + trans_val + "px, 0, 0)"; 4478 transition[property] = "translate3d(" + trans_val2 + "px, 0, 0)";
4479 transition2[property] = "translate3d(0,0,0)"; 4480 } 4481 else //do a 2d transform. still faster than a position "left" change 4482 { 4483 reset[property] = "translate(" + trans_val + "px,0)"; 4484 transition[property] = "translate(" + trans_val2 + "px,0)"; 4485 transition2[property] = "translate(0,0)"; } 4486 } 4487 else 4488 { 4489 reset.left = trans_val; 4490 transition.left = trans_val2; 4491 transition2.left = 0; 4492 } 4493 4494 if(dynamic) 4495 { 4496 transition['z-index'] = "1"; 4497 transition2['z-index'] = "2"; 4498 } 4499 4500 this._slide_animate(reset, transition, transition2); 4501 }, 4502 4503 _slide_up: function(dir) 4504 { 4505 var dynamic = true, //todo: pass by option if a slider is dynamic 4506 modifier = dynamic == true ? 2 : 1, 4507 sliderHeight = this.$slider.height(), 4508 direction = dir === 'next' ? -1 : 1, 4509 property = this.browserPrefix + 'transform', 4510 reset = {}, transition = {}, transition2 = {}, 4511 trans_val = ( sliderHeight * direction * -1), 4512 trans_val2 = ( sliderHeight * direction) / modifier; 4513 4514 //do a css3 animation 4515 if(this.cssActive) 4516 { 4517 property = this.browserPrefix + 'transform'; 4518 4519 //do a translate 3d transformation if available, since it uses hardware acceleration 4520 if(this.css3DActive) 4521 { 4522 reset[property] = "translate3d( 0," + trans_val + "px, 0)"; 4523 transition[property] = "translate3d( 0," + trans_val2 + "px, 0)"; 4524 transition2[property] = "translate3d(0,0,0)"; 4525 } 4526 else //do a 2d transform. still faster than a position "left" change 4527 { 4528 reset[property] = "translate( 0," + trans_val + "px)"; 4529 transition[property] = "translate( 0," + trans_val2 + "px)"; 4530 transition2[property] = "translate(0,0)"; } 4531 } 4532 else 4533 { 4534 reset.top = trans_val; 4535 transition.top = trans_val2; 4536 transition2.top = 0; 4537 } 4538 4539 if(dynamic) 4540 { 4541 transition['z-index'] = "1"; 4542 transition2['z-index'] = "2"; 4543 } 4544 this._slide_animate(reset, transition, transition2); 4545 }, 4546 4547 4548 //slide animation: do a slide transition by css3 transform if possible. if not simply do a position left transition 4549 _slide_animate: function( reset , transition , transition2 ) 4550 { 4551 4552 var self = this, 4553 displaySlide = this.$slides.eq(this.current), 4554 hideSlide = this.$slides.eq(this.prev); 4555 4556 hideSlide.trigger('pause'); 4557 if( !displaySlide.data('disableAutoplay') ) displaySlide.trigger('play'); 4558 4559 displaySlide.css({visibility:'visible', zIndex:4, opacity:1, left
4559:0, top:0}); 4560 displaySlide.css(reset); 4561 4562 hideSlide.avia_animate(transition, this.options.transitionSpeed, this.options.easing); 4563 4564 var after_slide = function() 4565 { 4566 self.isAnimating = false; 4567 displaySlide.addClass('active-slide'); 4568 hideSlide.css({visibility:'hidden'}).removeClass('active-slide'); 4569 self.$slider.trigger('avia-transition-done'); 4570 } 4571 4572 if(self.options.show_slide_delay > 0) 4573 { 4574 setTimeout(function() { displaySlide.avia_animate(transition2, self.options.transitionSpeed, self.options.easing, after_slide); },self.options.show_slide_delay); 4575 } 4576 else 4577 { 4578 displaySlide.avia_animate(transition2, self.options.transitionSpeed, self.options.easing, after_slide); 4579 } 4580 4581 }, 4582 4583 //simple fade transition of the slideshow 4584 _fade: function() 4585 { 4586 var self = this, 4587 displaySlide = this.$slides.eq(this.current), 4588 hideSlide = this.$slides.eq(this.prev), 4589 properties = {visibility:'visible', zIndex:3, opacity:0}, 4590 fadeCallback = function() 4591 { 4592 self.isAnimating = false; 4593 displaySlide.addClass('active-slide'); 4594 hideSlide.css({visibility:'hidden', zIndex:2}).removeClass('active-slide'); 4595 self.$slider.trigger('avia-transition-done'); 4596 4597 }; 4598 4599 hideSlide.trigger('pause'); 4600 if( !displaySlide.data('disableAutoplay') ) displaySlide.trigger('play'); 4601 4602 if(self.options.fullfade == true) 4603 { 4604 hideSlide.avia_animate({opacity:0}
4604, 200, 'linear', function() 4605 { 4606 displaySlide.css(properties).avia_animate({opacity:1}, self.options.transitionSpeed, 'linear',fadeCallback); 4607 }); 4608 } 4609 else 4610 { 4611 displaySlide.css(properties).avia_animate({opacity:1}, self.options.transitionSpeed/2, 'linear', function() 4612 { 4613 hideSlide.avia_animate({opacity:0}, 200, 'linear', fadeCallback); 4614 }); 4615 } 4616 4617 }, 4618 4619 4620 /************************************************************************ 4621 Video functions 4622 *************************************************************************/ 4623 4624 //bind events to the video that tell the slider to autorotate once a video has been played 4625 _attach_video_events: function() 4626 { 4627 var self = this, $html = $('html'); 4628 4629 self.$slides.each(function(i) 4630 { 4631 var currentSlide = $(this), 4632 caption = currentSlide.find('.caption_fullwidth, .av-click-overlay'), 4633 mejs = currentSlide.find('.mejs-mediaelement'); 4634 4635 if(currentSlide.data('avia_video_events') != true) 4636 { 4637 currentSlide.data('avia_video_events', true); 4638 4639 currentSlide.on('av-video-events-bound', { slide: currentSlide, wrap: mejs , iteration: i , self: self }, onReady); 4640 4641 currentSlide.on('av-video-ended', { slide: currentSlide , self: self}, onFinish); 4642 4643 currentSlide.on('av-video-play-executed', function(){ setTimeout(function(){ self.pause() }, 100); }); 4644 4645 caption.on('click', { slide: currentSlide }, toggle); 4646 4647 // also if the player was loaded before the _bindEvents function was bound trigger it manually 4648 if(currentSlide.is('.av-video-events-bound')) currentSlide.trigger('av-video-events-bound'); 4649 } 4650 }); 4651 4652 4653 //helper functions 4654 function onReady( event ) 4655 { 4656 //autostart for first slide 4657 if(event.data.iteration === 0) 4658 { 4659 event.data.wrap.css('opacity',0); 4660 if(!event.data.self.isMobile && !event.data.slide.data('disableAutoplay')) 4661 { 4662 event.data.slide.trigger('play'); 4663 }Â 4664 setTimeout(function(){ event.data.wrap.avia_animate({opacity:1}, 400); }, 50); 4665 } 4666 else if ($html.is('.avia-msie') && !event.data.slide.is('.av-video-service-html5')) 4667 { 4668 /* 4669 * Internet Explorer fires the ready event for external videos once they become visible 4670 * as oposed to other browsers which always fire immediately. 4671 */ 4672 if( !event.data.slide.data('disableAutoplay') ) event.data.slide.trigger('play'); 4673 } 4674 4675 } 4676 4677 4678 4679 4680 function onFinish( event ) 4681 { 4682 //if the video is not looped resume the slideshow 4683 if(!event.data.slide.is('.av-single-slide') && !event.data.slide.is('.av-loop-video')) 4684 { 4685 event.data.slide.trigger('reset'); 4686 self._navigate( 'next' ); 4687 self.resume(); 4688 } 4689
4690 //safari 8 workaround for self hosted videos which wont loop by default 4691 if(event.data.slide.is('.av-loop-video') && event.data.slide.is('.av-video-service-html5')) 4692 { 4693 if($html.is('.avia-safari-8')) 4694 { 4695 setTimeout(function(){ event.data.slide.trigger('play'); },1); 4696 } 4697 } 4698 } 4699 4700 function toggle( event ) 4701 { 4702 if(event.target.tagName != "A") 4703 { 4704 event.data.slide.trigger('toggle'); 4705 } 4706 } 4707 4708 }, 4709 4710 4711 4712 /************************************************************************ 4713 Slideshow control functions 4714 *************************************************************************/ 4715 4716 _timer: function(callback, delay, first) 4717 { 4718 var self = this, start, remaining = delay; 4719 4720 self.timerId = 0; 4721 4722 this.pause = function() { 4723 window.clearTimeout(self.timerId); 4724 remaining -= new Date() - start; 4725 }; 4726 4727 this.resume = function() { 4728 start = new Date(); 4729 self.timerId = window.setTimeout(callback, remaining); 4730 }; 4731 4732 this.destroy = function() 4733 { 4734 window.clearTimeout(self.timerId); 4735 }; 4736 4737 this.resume(true); 4738 }, 4739 4740 //start autorotation 4741 _startSlideshow: function() 4742 { 4743 var self = this; 4744 4745 this.isPlaying = true; 4746 4747 this.slideshow = new this._timer( function() 4748 { 4749 /* 4750 var videoApi = self.$slides.eq(self.current).data('aviaVideoApi') 4751 if(!videoApi){} 4752 */ 4753 4754 self._navigate( 'next' ); 4755 4756 if ( self.options.autoplay ) 4757 { 4758 self._startSlideshow(); 4759 } 4760 4761 }, (this.options.interval * 1000)); 4762 }, 4763 4764 //stop autorotation 4765 _stopSlideshow: function() 4766 { 4767 if ( this.options.autoplay ) { 4768 4769 this.slideshow.destroy(); 4770 this.isPlaying = false; 4771 this.options.autoplay = false; 4772 } 4773 }, 4774 4775 // public method: shows next image 4776 next : function(e) 4777 { 4778 e.preventDefault(); 4779 this._stopSlideshow(); 4780 this._navigate( 'next' ); 4781 }, 4782 4783 // public method: shows previous image 4784 previous : function(e) 4785 { 4786 e.preventDefault(); 4787 this._stopSlideshow(); 4788 this._navigate( 'prev' ); 4789 }, 4790 4791 // public method: goes to a specific image 4792 go2 : function( pos ) 4793 { 4794 //if we didnt pass a number directly lets asume someone clicked on a link that triggered the goto transition 4795 if(isNaN(pos)) 4796 { 4797 //in that case prevent the default link behavior and set the slide number to the links hash 4798 pos.preventDefault(); 4799 pos = pos.currentTarget.hash.replace('#',''); 4800 } 4801 4802 pos -= 1; 4803 4804 if( pos === this.current || pos >= this.itemsCount || pos < 0 ) 4805 { 4806 return false; 4807 } 4808 4809 this._stopSlideshow(); 4810 this._navigate( false, pos ); 4811 4812 }, 4813 4814 // public method: starts the slideshow 4815 // any call to next(), previous() or goto() will stop the slideshow autoplay 4816 play : function() 4817 { 4818 if( !this.isPlaying ) 4819 { 4820 this.isPlaying = true; 4821 4822 this._navigate( 'next' ); 4823 this.options.autoplay = true; 4824 this._startSlideshow(); 4825 } 4826 4827 }, 4828 4829 // public methos: pauses the slideshow 4830 pause : function() 4831 { 4832 if( this.isPlaying ) 4833 { 4834 this.slideshow.pause(); 4835 } 4836 }, 4837 4838 // publiccmethos: resumes the slideshow 4839 resume : function() 4840 { 4841 if( this.isPlaying ) 4842 { 4843 this.slideshow.resume(); 4844 } 4845 }, 4846 4847 // public methos: destroys the instance 4848 destroy : function( callback ) 4849 { 4850 this.slideshow.destroy( callback ); 4851 } 4852 4853 } 4854 4855 //simple wrapper to call the slideshow. makes sure that the slide data is not applied twice 4856 $.fn.aviaSlider = function( options ) 4857 { 4858 return this.each(function() 4859 { 4860 var self = $.data( this, 'aviaSlider' ); 4861 4862 if(!self) 4863 { 4864 self = $.data( this, 'aviaSlider', new $.AviaSlider( options, this ) ); 4865 } 4866 }); 4867 } 4868 4869 4870 4871})( jQuery ); 4872 4873 4874 4875 4876// ------------------------------------------------------------------------------------------- 4877// keyboard controls 4878// ------------------------------------------------------------------------------------------- 4879 4880(function($) 4881{ 4882 "use strict"; 4883 4884 /************************************************************************ 4885 keyboard arrow nav 4886 *************************************************************************/ 4887 $.fn.avia_keyboard_controls = function(options_passed) 4888 { 4889 var defaults = 4890 { 4891 37: '.prev-slide', // prev 4892 39: '.next-slide' // next 4893 }, 4894 4895 methods = { 4896 4897 mousebind: function(slider) 4898 { 4899 slider.hover( 4900 function(){ slider.mouseover = true; }, 4901 function(){ slider.mouseover = false; } 4902 ); 4903 }, 4904 4905 keybind: function(slider) 4906 { 4907 $(document).keydown(function(e) 4908 { 4909 if(slider.mouseover && typeof slider.options[e.keyCode] !== 'undefined') 4910 { 4911 var item; 4912 4913 if(typeof slider.options[e.keyCode] === 'string') 4914 { 4915 item = slider.find(slider.options[e.keyCode]); 4916 } 4917 else 4918 { 4919 item = slider.options[e.keyCode]; 4920 } 4921 4922 if(item.length) 4923 { 4924 item.trigger('click', ['keypress']); 4925 return false;
4926 } 4927 } 4928 }); 4929 } 4930 }; 4931 4932 4933 return this.each(function() 4934 { 4935 var slider = $(this); 4936 slider.options = $.extend({}, defaults, options_passed); 4937 slider.mouseover = false; 4938 4939 methods.mousebind(slider); 4940 methods.keybind(slider); 4941 4942 }); 4943 }; 4944 4945 4946 /************************************************************************ 4947 swipe nav 4948 *************************************************************************/ 4949 $.fn.avia_swipe_trigger = function(passed_options) 4950 { 4951 var win = $(window), 4952 isMobile = $.avia_utilities.isMobile, 4953 defaults = 4954 { 4955 prev: '.prev-slide', 4956 next: '.next-slide', 4957 event: { 4958 prev: 'click', 4959 next: 'click' 4960 } 4961 }, 4962 4963 methods = { 4964 4965 activate_touch_control: function(slider) 4966 { 4967 var i, differenceX, differenceY; 4968 4969 slider.touchPos = {}; 4970 slider.hasMoved = false; 4971 4972 slider.on('touchstart', function(event) 4973 { 4974 slider.touchPos.X = event.originalEvent.touches[0].clientX; 4975 slider.touchPos.Y = event.originalEvent.touches[0].clientY; 4976 }); 4977 4978 slider.on('touchend', function(event) 4979 { 4980 slider.touchPos = {}; 4981 if(slider.hasMoved) { event.preventDefault(); } 4982 slider.hasMoved = false; 4983 }); 4984 4985 slider.on('touchmove', function(event) 4986 { 4987 if(!slider.touchPos.X) 4988 { 4989 slider.touchPos.X = event.originalEvent.touches[0].clientX; 4990 slider.touchPos.Y = event.originalEvent.touches[0].clientY; 4991 } 4992 else 4993 { 4994 differenceX = event.originalEvent.touches[0].clientX - slider.touchPos.X; 4995 differenceY = event.originalEvent.touches[0].clientY - slider.touchPos.Y; 4996 4997 //check if user is scrolling the window or moving the slider 4998 if(Math.abs(differenceX) > Math.abs(differenceY)) 4999 { 5000 event.preventDefault(); 5001 5002 if(slider.touchPos !== event.originalEvent.touches[0].clientX) 5003 { 5004 if(Math.abs(differenceX) > 50) 5005 { 5006 i = differenceX > 0 ? 'prev' : 'next'; 5007 5008 if(typeof slider.options[i] === 'string') 5009 { 5010 slider.find(slider.options[i]).trigger(slider.options.event[i], ['swipe']); 5011 } 5012 else 5013 { 5014 slider.options[i].trigger(slider.options.event[i], ['swipe']); 5015 } 5016 5017 slider.hasMoved = true; 5018 slider.touchPos = {}; 5019 return false; 5020 } 5021 } 5022 } 5023 } 5024 }); 5025 } 5026 }; 5027 5028 return this.each(function() 5029 { 5030 if(isMobile) 5031 { 5032 var slider = $(this); 5033 5034 slider.options = $.extend({}, defaults, passed_options); 5035 5036 methods.activate_touch_control(slider); 5037 } 5038 }); 5039 }; 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053}(jQuery)); 5054 5055 5056 5057
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.