772 lines
No EOL
23 KiB
JavaScript
772 lines
No EOL
23 KiB
JavaScript
|
|
|
|
|
|
var collapse_on_responsive = function() {
|
|
if (jQuery(document).width() < 992) {
|
|
jQuery('.widget').find('.collapse-widget:not(.open)').addClass('collapsed');
|
|
jQuery('.widget').find('.collapse:not(.open)').removeClass('in');
|
|
}else{
|
|
jQuery('.widget').find('.collapse-widget:not(.open)').removeClass('collapsed');
|
|
jQuery('.widget').find('.collapse:not(.open)').addClass('in');
|
|
}
|
|
};
|
|
|
|
collapse_on_responsive();
|
|
|
|
$(window).on('resize',function(e){
|
|
collapse_on_responsive();
|
|
});
|
|
|
|
$(document).ready(function() {
|
|
|
|
function scrollToTabContent(tabSelector){
|
|
$("html, body").animate({
|
|
scrollTop: $(tabSelector).offset().top - 220
|
|
}, 1000);
|
|
}
|
|
|
|
function activateTravelDatesTab(){
|
|
$('[href=\'#travel-dates-content-tab\']').first().on('shown.bs.tab', function () {
|
|
scrollToTabContent('#travel-dates-content-tab');
|
|
});
|
|
$('[href=\'#travel-dates-content-tab\']').first().tab('show');
|
|
}
|
|
$('.nav-tabs > li > a').click(function(){
|
|
if($(this).data('toggle') === 'tab'){
|
|
return
|
|
}
|
|
scrollToTabContent($(this).attr('href'));
|
|
});
|
|
|
|
$('#st-slider-booking-events-scroll').click(function (event) {
|
|
event.preventDefault();
|
|
activateTravelDatesTab();
|
|
});
|
|
|
|
if (location.hash === '#travel-dates-content-tab'){
|
|
activateTravelDatesTab();
|
|
}
|
|
});
|
|
|
|
window.currentScroll = 0;
|
|
jQuery('body').removeClass('no-js');
|
|
|
|
|
|
// Initialize library to lazy load images
|
|
|
|
var observer = lozad('.lozad', {
|
|
threshold: 0.1,
|
|
});
|
|
observer.observe();
|
|
|
|
|
|
|
|
|
|
var youtube_loader = function(self) {
|
|
options = {
|
|
width: 853,
|
|
height: 480,
|
|
autoplay: 1,
|
|
rel: 0,
|
|
class: "youtube-video",
|
|
frameborder: "0",
|
|
allowfullscreen: true
|
|
};
|
|
options.src = $(self).data('src') + "?rel=" + options.rel + "&autoplay=" + options.autoplay;
|
|
ret = $(document.createElement("iframe"));
|
|
var ele = $(self).parent().parent();
|
|
ele.html("");
|
|
ele.removeClass('video-wrap');
|
|
ele.addClass('youtube');
|
|
ele.append(ret);
|
|
ret.attr(options);
|
|
|
|
};
|
|
jQuery('a[data-type="youtube"]').on('click', function () {
|
|
youtube_loader(this);
|
|
|
|
});
|
|
|
|
var youtube_sterntours_video_closer = function(self) {
|
|
$('#show_sterntours_video_full').hide('slow', function () {
|
|
$(this).html("");
|
|
});
|
|
$('#show_sterntours_video_sidebar').show();
|
|
};
|
|
|
|
var youtube_sterntours_video_loader = function(self) {
|
|
$('#show_sterntours_video_sidebar').hide();
|
|
options = {
|
|
width: 853,
|
|
height: 480,
|
|
autoplay: 1,
|
|
rel: 0,
|
|
class: "youtube-video",
|
|
frameborder: "0",
|
|
allowfullscreen: true
|
|
};
|
|
options.src = $(self).data('src') + "?rel=" + options.rel + "&autoplay=" + options.autoplay;
|
|
div = $(document.createElement("div"));
|
|
div.addClass('youtube');
|
|
ret = $(document.createElement("iframe"));
|
|
h1 = $(document.createElement("h1")).html("Wir: STERN TOURS <a href=\"#\" title=\"Close\" class=\"pull-right btn btn-default btn-close-video\" id=\"sterntorus_video_close\"><i class=\"fa fa-times\"></i> <span class=\"\"></span></a>");
|
|
var ele = $('#show_sterntours_video_full');
|
|
ele.html("");
|
|
ele.append(h1);
|
|
div.append(ret);
|
|
ele.append(div);
|
|
ret.attr(options);
|
|
ele.show('slow');
|
|
|
|
jQuery('a#sterntorus_video_close').on('click', function () {
|
|
youtube_sterntours_video_closer(this);
|
|
|
|
});
|
|
};
|
|
|
|
jQuery('a[data-type="youtube_sterntours_video"]').on('click', function () {
|
|
youtube_sterntours_video_loader(this);
|
|
});
|
|
|
|
|
|
|
|
jQuery("button.btn-mobile").bind("click", function(e) {
|
|
e.preventDefault();
|
|
jQuery(this).toggleClass('btn-mobile-active');
|
|
jQuery('html').removeClass('noscroll');
|
|
jQuery('#menu-overlay').remove();
|
|
|
|
if(jQuery(this).hasClass('btn-mobile-active')) {
|
|
jQuery('body').append('<div id="menu-overlay"></div>');
|
|
if(!jQuery("#topMain").hasClass('nav-onepage') || window.width > 960) { /* onepage fix */
|
|
jQuery('html').addClass('noscroll');
|
|
window.currentScroll = jQuery(window).scrollTop();
|
|
}
|
|
} else {
|
|
if(!jQuery("#topMain").hasClass('nav-onepage') || window.width > 960) { /* onepage fix */
|
|
jQuery('html,body').animate({scrollTop: currentScroll}, 300, 'easeInOutExpo');
|
|
}
|
|
|
|
}
|
|
});
|
|
var addActiveClass = false;
|
|
jQuery("#topMain a.dropdown-toggle").bind("click", function(e) {
|
|
|
|
if(jQuery("button.btn-mobile").hasClass('btn-mobile-active') || jQuery("html").hasClass('touch')){
|
|
e.preventDefault();
|
|
}
|
|
|
|
addActiveClass = jQuery(this).parent().hasClass("resp-active");
|
|
jQuery("#topMain").find(".resp-active").removeClass("resp-active");
|
|
|
|
if(!addActiveClass) {
|
|
jQuery(this).parents("li").addClass("resp-active");
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
jQuery(document).ready(function($) {
|
|
"use strict";
|
|
window.addEventListener("load", function(){
|
|
window.cookieconsent.initialise({
|
|
"palette": {
|
|
"popup": {
|
|
"background": "#648859"
|
|
},
|
|
"button": {
|
|
"background": "#f1d600"
|
|
}
|
|
},
|
|
"position": "bottom",
|
|
"content": {
|
|
"message": "Diese Webseite verwendet Cookies, über die personenbezogene Daten erhoben werden können. Nähere Informationen zu den verwendeten Cookies finden Sie hier:",
|
|
"dismiss": "Einverstanden!",
|
|
"link": "Datenschutzerklärung",
|
|
"href": "https://www.sterntours.de/datenschutz"
|
|
}
|
|
})});
|
|
|
|
|
|
|
|
|
|
/* ==============================================
|
|
KEYWORDS -->
|
|
=============================================== */
|
|
|
|
var modal$ = $('#st-default-modal');
|
|
|
|
$('a.show-layer').click(function() {
|
|
|
|
$.get($(this).attr('href')).then(function(r) {
|
|
modal$.find('.modal-body').html(r);
|
|
modal$.find('a[data-type="youtube"]').on('click', function () {
|
|
youtube_loader(this);
|
|
});
|
|
modal$.find('img.lozad').each(function () {
|
|
$(this).attr('src', $(this).data('src'));
|
|
});
|
|
modal$.modal('show');
|
|
});
|
|
return false;
|
|
});
|
|
|
|
/* ==============================================
|
|
SIDEBAR BOX SLIDER -->
|
|
=============================================== */
|
|
|
|
function createSlider(ctx$, interval)
|
|
{
|
|
if (!interval)
|
|
{
|
|
interval = 0;
|
|
}
|
|
|
|
function setSlideInterval()
|
|
{
|
|
if (interval <= 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if(slideInterval)
|
|
{
|
|
clearInterval(slideInterval);
|
|
}
|
|
slideInterval = setInterval(function() {
|
|
|
|
jumpToNextSlide();
|
|
}, interval);
|
|
}
|
|
|
|
function jumpToNextSlide()
|
|
{
|
|
setActiveSlide(slideIndex === slideCount - 1 ? 0 : slideIndex + 1);
|
|
setSlideInterval();
|
|
}
|
|
|
|
function setActiveSlide(newIndex)
|
|
{
|
|
slide$s[slideIndex].removeClass('active');
|
|
slideIndex = newIndex;
|
|
slide$s[slideIndex].addClass('active');
|
|
}
|
|
|
|
var slides$ = $('.slide', ctx$);
|
|
var slideCount = slides$.length;
|
|
if(slideCount > 1)
|
|
{
|
|
var slideInterval;
|
|
|
|
var slide$s = [];
|
|
for(var i = 0; i < slideCount; ++i)
|
|
{
|
|
slide$s.push($(slides$.get(i)));
|
|
}
|
|
|
|
var slideIndex = 0;
|
|
setSlideInterval();
|
|
|
|
$('.item-button-next', ctx$).click(function() {
|
|
jumpToNextSlide();
|
|
});
|
|
$('.item-button-prev', ctx$).click(function() {
|
|
setActiveSlide(slideIndex === 0 ? slideCount - 1 : slideIndex - 1);
|
|
setSlideInterval();
|
|
});
|
|
}
|
|
}
|
|
$('.box-slider').each(function() {
|
|
createSlider($(this));
|
|
});
|
|
|
|
|
|
/* ==============================================
|
|
nav-tabs -->
|
|
=============================================== */
|
|
|
|
/*
|
|
var scrollBarWidths = 40;
|
|
var windowW = $(window).width();
|
|
|
|
|
|
var widthOfList = function(){
|
|
var itemsWidth = 0;
|
|
$('.list-nav-tabs li').each(function(){
|
|
var itemWidth = $(this).outerWidth();
|
|
itemsWidth+=itemWidth;
|
|
});
|
|
return itemsWidth;
|
|
};
|
|
|
|
var widthOfHidden = function(){
|
|
return (($('.wrapper-nav-tabs').outerWidth())-widthOfList()-getLeftPosi())-scrollBarWidths;
|
|
};
|
|
|
|
var getLeftPosi = function(){
|
|
if($('.list-nav-tabs').length){
|
|
return $('.list-nav-tabs').position().left;
|
|
}else{
|
|
return 0;
|
|
}
|
|
};
|
|
|
|
var reAdjust = function(){
|
|
if (($('.wrapper-nav-tabs').outerWidth()) < widthOfList()) {
|
|
$('.scroller-right-nav-tabs').show();
|
|
}
|
|
else {
|
|
$('.scroller-right-nav-tabs').hide();
|
|
}
|
|
|
|
if (getLeftPosi()<0) {
|
|
$('.scroller-left-nav-tabs').show();
|
|
}
|
|
else {
|
|
$('.item').animate({left:"-="+getLeftPosi()+"px"},'slow');
|
|
$('.scroller-left-nav-tabs').hide();
|
|
}
|
|
}
|
|
|
|
if(windowW <= 992){
|
|
reAdjust();
|
|
}
|
|
$(window).on('resize',function(e){
|
|
var windowW = $(window).width();
|
|
if(windowW <= 992){
|
|
reAdjust();
|
|
}else{
|
|
$('.scroller-right-nav-tabs').hide();
|
|
$('.scroller-left-nav-tabs').hide();
|
|
}
|
|
});
|
|
|
|
|
|
$('.scroller-right-nav-tabs').click(function() {
|
|
|
|
if(((getLeftPosi()*-1) + $('.wrapper-nav-tabs').outerWidth()) < (widthOfHidden()*-1)){
|
|
$('.scroller-left-nav-tabs').fadeIn('slow');
|
|
$('.list-nav-tabs').animate({left:"+="+($('.wrapper-nav-tabs').outerWidth()*-1)+"px"},'slow',function(){
|
|
|
|
});
|
|
}else{
|
|
$('.scroller-left-nav-tabs').fadeIn('slow');
|
|
$('.scroller-right-nav-tabs').fadeOut('slow');
|
|
$('.list-nav-tabs').animate({left:"+="+widthOfHidden()+"px"},'slow',function(){
|
|
|
|
});
|
|
}
|
|
|
|
});
|
|
|
|
$('.scroller-left-nav-tabs').click(function() {
|
|
|
|
|
|
|
|
if(((getLeftPosi()) + $('.wrapper-nav-tabs').outerWidth()) < 0){
|
|
$('.scroller-left-nav-tabs').fadeIn('slow');
|
|
$('.list-nav-tabs').animate({left:"-="+($('.wrapper-nav-tabs').outerWidth()*-1)+"px"},'slow',function(){
|
|
|
|
});
|
|
}else{
|
|
$('.scroller-right-nav-tabs').fadeIn('slow');
|
|
$('.scroller-left-nav-tabs').fadeOut('slow');
|
|
$('.list-nav-tabs').animate({left:"-="+getLeftPosi()+"px"},'slow',function(){
|
|
$('.list-nav-tabs').css({'left': 0});
|
|
});
|
|
}
|
|
|
|
|
|
});
|
|
|
|
*/
|
|
|
|
/* ==============================================
|
|
MENU HOVER -->
|
|
=============================================== */
|
|
if($(window).width() > 768){
|
|
|
|
$(".header .navbar-nav .dropdown:not(.openClick)").hover(
|
|
function() {
|
|
$(".dropdown.openClick").removeClass('open');
|
|
$('.dropdown-menu', this).stop( true, true ).slideDown("fast");
|
|
$('.bootstrap-select.open').removeClass('open');
|
|
$(this).toggleClass('open');
|
|
},
|
|
function() {
|
|
$('.dropdown-menu', this).stop( true, true ).slideUp("fast");
|
|
$(this).toggleClass('open');
|
|
}
|
|
);
|
|
|
|
$(".header .dropdown:not(.openClick) .nav-first-a").click(
|
|
function ()
|
|
{
|
|
if($(window).width() > 768){
|
|
window.location.href = $(this).attr('href');
|
|
}
|
|
}
|
|
);
|
|
}
|
|
|
|
|
|
$('.selectpicker').selectpicker({
|
|
dropupAuto: false
|
|
});
|
|
|
|
|
|
/* ==============================================
|
|
nav-tabs -->
|
|
=============================================== */
|
|
$('.nav-tabs li a').click(function (e) {
|
|
//get selected href
|
|
var href = $(this).attr('href');
|
|
|
|
//set all nav tabs to inactive
|
|
$('.nav-tabs li').removeClass('active');
|
|
|
|
//get all nav tabs matching the href and set to active
|
|
$('.nav-tabs li a[href="'+href+'"]').closest('li').addClass('active');
|
|
|
|
//active tab
|
|
$('.tab-pane').removeClass('active');
|
|
$('.tab-pane'+href).addClass('active');
|
|
|
|
if($('#position-scroll-tab').length){
|
|
$('html, body').animate({
|
|
scrollTop: ($("#position-scroll-tab").offset().top - 220)
|
|
}, 500);
|
|
}
|
|
});
|
|
|
|
/* ==============================================
|
|
tooltip -->
|
|
=============================================== */
|
|
|
|
$(function () {
|
|
$('[data-toggle="tooltip"]').tooltip()
|
|
});
|
|
|
|
|
|
|
|
/* ==============================================
|
|
ACCORDION -->
|
|
=============================================== */
|
|
|
|
function toggleChevron(e) {
|
|
var $i = $(e.target)
|
|
.parent('.panel-group')
|
|
.find("i.indicator");
|
|
|
|
$i.toggleClass('icon-minus icon-plus');
|
|
|
|
if($i.hasClass('icon-minus')){
|
|
$i.parent('h3').find('span').html('Reiseleistungen ausblenden');
|
|
}
|
|
if($i.hasClass('icon-plus')){
|
|
$i.parent('h3').find('span').html('Reiseleistungen einblenden');
|
|
}
|
|
}
|
|
$('#accordion').on('hidden.bs.collapse', toggleChevron);
|
|
$('#accordion').on('shown.bs.collapse', toggleChevron);
|
|
|
|
function toggleChevron2(e) {
|
|
var $i = $(e.target)
|
|
.parent('.panel-group')
|
|
.find("i.indicator");
|
|
|
|
$i.toggleClass('icon-minus icon-plus');
|
|
|
|
if($i.hasClass('icon-minus')){
|
|
$i.parent('h3').find('span').html('Reiseablauf mit Reisetagen ausblenden');
|
|
}
|
|
if($i.hasClass('icon-plus')){
|
|
$i.parent('h3').find('span').html('Reiseablauf mit Reisetagen einblenden');
|
|
}
|
|
}
|
|
$('#accordion_pd').on('hidden.bs.collapse', toggleChevron2);
|
|
$('#accordion_pd').on('shown.bs.collapse', toggleChevron2);
|
|
|
|
function toggleChevron3(e) {
|
|
var $i = $(e.target)
|
|
.parent('.panel-group')
|
|
.find("i.indicator");
|
|
|
|
$i.toggleClass('icon-minus icon-plus');
|
|
|
|
if($i.hasClass('icon-minus')){
|
|
$i.parent('h3').find('span').html('Flugdaten ausblenden');
|
|
}
|
|
if($i.hasClass('icon-plus')){
|
|
$i.parent('h3').find('span').html('Flugdaten einblenden');
|
|
}
|
|
}
|
|
$('#accordion_fd').on('hidden.bs.collapse', toggleChevron3);
|
|
$('#accordion_fd').on('shown.bs.collapse', toggleChevron3);
|
|
|
|
/* ==============================================
|
|
carousel -->
|
|
=============================================== */
|
|
|
|
$('.carousel').carousel({
|
|
interval: 5000, //changes the speed
|
|
});
|
|
|
|
/*$('#myCarousel').find(".fill[data-src]:not(.loaded)").each(function(i,v){
|
|
$(v).addClass("loaded").css("background-image", "url("+$(v).attr("data-src")+")");
|
|
});
|
|
|
|
|
|
$('.travel-wrapper').find(".img-background[data-src]:not(.loaded)").each(function(i,v){
|
|
$(v).addClass("loaded").css("background-image", "url("+$(v).attr("data-src")+")");
|
|
});
|
|
*/
|
|
|
|
|
|
/* ==============================================
|
|
OWL CAROUSEL -->
|
|
=============================================== */
|
|
var owl = $('.owl-fullwidth').owlCarousel({
|
|
loop:true,
|
|
margin:0,
|
|
nav:true,
|
|
dots:false,
|
|
navText: [
|
|
"<i class='fa fa-angle-right'></i>",
|
|
"<i class='fa fa-angle-left'></i>"],
|
|
responsive:{
|
|
0:{
|
|
items:1
|
|
},
|
|
600:{
|
|
items:2
|
|
},
|
|
1000:{
|
|
items:3
|
|
}
|
|
},
|
|
});
|
|
|
|
/* onTranslated: function(me){
|
|
$(me.target).find(".owl-item.active [data-src]:not(.loaded)").each(function(i,v){
|
|
$(v).addClass("loaded").css("background-image", "url("+$(v).attr("data-src")+")");
|
|
});
|
|
},
|
|
onInitialized: function(me){
|
|
$(me.target).find(".owl-item.active [data-src]:not(.loaded)").each(function(i,v){
|
|
$(v).addClass("loaded").css("background-image", "url("+$(v).attr("data-src")+")");
|
|
});
|
|
},*/
|
|
|
|
/* ==============================================
|
|
BOX LINK -->
|
|
=============================================== */
|
|
|
|
$('.get-box-link').click(function() {
|
|
var el$ = $(this);
|
|
var url = el$.find('.is-box-link').attr('href');
|
|
if (el$.attr('target') === '_blank')
|
|
{
|
|
window.open(url);
|
|
}
|
|
else
|
|
{
|
|
location.href = url;
|
|
}
|
|
return false;
|
|
});
|
|
|
|
|
|
|
|
/* ==============================================
|
|
DATEPICKER -->
|
|
=============================================== */
|
|
|
|
$(".datepicker").each(function(){
|
|
var windowW = $(window).width();
|
|
if(windowW <= 768){
|
|
$(this).attr('readonly', 'true');
|
|
}
|
|
});
|
|
$( ".datepicker" ).datepicker({
|
|
dateFormat: 'dd.mm.yy', prevText: '<zurück', prevStatus: '',
|
|
prevJumpText: '<<', prevJumpStatus: '',
|
|
nextText: 'Vor>', nextStatus: '',
|
|
nextJumpText: '>>', nextJumpStatus: '',
|
|
currentText: 'heute', currentStatus: '',
|
|
todayText: 'heute', todayStatus: '',
|
|
clearText: '-', clearStatus: '',
|
|
closeText: 'schließen', closeStatus: '',
|
|
monthNames: ['Januar','Februar','März','April','Mai','Juni',
|
|
'Juli','August','September','Oktober','November','Dezember'],
|
|
monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
|
|
'Jul','Aug','Sep','Okt','Nov','Dez'],
|
|
dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
|
|
dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
|
|
dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
|
|
firstDay: 1,
|
|
beforeShowDay: function(date) {
|
|
var allowedDateStrListStr = $(this).attr('data-allowed-dates');
|
|
if (allowedDateStrListStr)
|
|
{
|
|
var allowedDatesStrList = allowedDateStrListStr.split(';');
|
|
for (var i = 0; i < allowedDatesStrList.length; ++i)
|
|
{
|
|
var allowedDate = new Date(allowedDatesStrList[i]);
|
|
if (allowedDate.getDate() === date.getDate() && allowedDate.getMonth() === date.getMonth() &&
|
|
allowedDate.getYear() === date.getYear())
|
|
{
|
|
return [true, '', ''];
|
|
}
|
|
}
|
|
return [false, '', '']
|
|
}
|
|
return [true, '', ''];
|
|
}
|
|
});
|
|
|
|
function initAutoEndDate(startTxt$, endTxt$)
|
|
{
|
|
startTxt$.add(endTxt$).change(function() {
|
|
|
|
var startDate = startTxt$.datepicker('getDate');
|
|
if (startDate > endTxt$.datepicker('getDate'))
|
|
{
|
|
endTxt$.datepicker('setDate', new Date(startDate.getFullYear(), startDate.getMonth(),
|
|
startDate.getDate() + 14));
|
|
}
|
|
});
|
|
}
|
|
var ttSearchForm$ = $('.st-tt-search-form');
|
|
if (ttSearchForm$.length)
|
|
{
|
|
initAutoEndDate(ttSearchForm$.find('[name=termin]'), ttSearchForm$.find('[name=ruecktermin]'));
|
|
}
|
|
var searchForm$ = $('.st-search-form');
|
|
if (searchForm$.length)
|
|
{
|
|
initAutoEndDate(searchForm$.find('[name=b]'), searchForm$.find('[name=e]'));
|
|
}
|
|
|
|
});
|
|
|
|
|
|
$("a.scroll-to-jump").click(function(e)
|
|
{
|
|
$(window).t
|
|
rigger('resize');
|
|
e.preventDefault();
|
|
var aid = $(this).attr('href');
|
|
aid = aid.replace("#", "");
|
|
aTag = $("[id='"+ aid +"']");
|
|
if(aTag !== null && aTag.offset() !== null){
|
|
$("html, body").animate({
|
|
scrollTop: aTag.offset().top - 220
|
|
}, 1000);
|
|
|
|
|
|
}
|
|
}
|
|
);
|
|
|
|
function initGoTo() {
|
|
|
|
//Variables
|
|
if(!$('.js-go-to').length){
|
|
return;
|
|
}
|
|
var $this = $('.js-go-to'),
|
|
$target = $this.data('target'),
|
|
showEffect = $this.data('show-effect'),
|
|
position = $this.data('position'),
|
|
type = $this.data('type'),
|
|
hideEffect = $this.data('hide-effect'),
|
|
offsetTop = $this.data('offset-top'),
|
|
targetOffsetTop = function () {
|
|
return $target ? $($target).offset().top : 0;
|
|
};
|
|
|
|
if (type == 'static') {
|
|
$this.css({
|
|
'display': 'inline-block'
|
|
});
|
|
} else {
|
|
$this.addClass('animated').css({
|
|
'display': 'inline-block',
|
|
'position': type,
|
|
'opacity': 0
|
|
});
|
|
}
|
|
|
|
if (type == 'fixed' || type == 'absolute') {
|
|
$this.css(position);
|
|
}
|
|
|
|
$this.on('click', function (e) {
|
|
e.preventDefault();
|
|
$('html, body').stop().animate({
|
|
'scrollTop': targetOffsetTop()
|
|
}, 800);
|
|
});
|
|
|
|
if (!$this.data('offset-top') && !$this.hasClass('js-animation-was-fired') && type != 'static') {
|
|
if ($this.offset().top <= $(window).height()) {
|
|
$this.show();
|
|
|
|
setTimeout(function () {
|
|
$this.addClass('js-animation-was-fired ' + showEffect).css({
|
|
'opacity': ''
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
if (type != 'static') {
|
|
$(window).on('scroll', function () {
|
|
if ($this.data('offset-top')) {
|
|
if ($(window).scrollTop() >= offsetTop && !$this.hasClass('js-animation-was-fired')) {
|
|
$this.show();
|
|
|
|
setTimeout(function () {
|
|
$this.addClass('js-animation-was-fired ' + showEffect).css({
|
|
'opacity': ''
|
|
});
|
|
});
|
|
} else if ($(window).scrollTop() <= offsetTop && $this.hasClass('js-animation-was-fired')) {
|
|
$this.removeClass('js-animation-was-fired ' + showEffect);
|
|
|
|
setTimeout(function () {
|
|
$this.addClass(hideEffect).css({
|
|
'opacity': 0
|
|
});
|
|
}, 100);
|
|
|
|
setTimeout(function () {
|
|
$this.removeClass(hideEffect).hide();
|
|
}, 400);
|
|
}
|
|
} else {
|
|
var thisOffsetTop = $this.offset().top;
|
|
|
|
if (!$this.hasClass('js-animation-was-fired')) {
|
|
if ($(window).scrollTop() >= thisOffsetTop - $(window).height()) {
|
|
$this.show();
|
|
|
|
setTimeout(function () {
|
|
$this.addClass('js-animation-was-fired ' + showEffect).css({
|
|
'opacity': ''
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
$(window).trigger('scroll');
|
|
}
|
|
}
|
|
|
|
initGoTo(); |