/* ================================================== Custom jQuery functions. ================================================== */ ///////////////////////////////////////////// // NO CONFLICT ///////////////////////////////////////////// var $j = jQuery.noConflict(); var onLoad = { init: function(){ var deviceAgent = navigator.userAgent.toLowerCase(); var agentID = deviceAgent.match(/(iphone|ipad|ipod|android)/); if (!agentID) { header.init(); } nav.init(); slider.init(); contactForm.init(); reloadFunctions.init(); baseFunctions.init(); } }; ///////////////////////////////////////////// // HEADER ///////////////////////////////////////////// var header = { init: function () { var $header = $j('#header-section'), $logo = $j('#logo').find('img'), $nav = $j('#main-navigation'), $window = $j(window); if (1) { $window.scroll(function () { if ($window.scrollTop() > 70 && $window.width() > 959) { header.animate($header, $logo, $nav); } else { setTimeout(function () { if ($window.scrollTop() < 70) { header.reset($header, $logo, $nav); } }, 700); } }); } }, animate: function ($header, $logo, $nav) { $header.filter(':not(:animated)').animate({ "height": 60, "borderTopWidth": 5 }); $logo.filter(':not(:animated)').animate({ "height": 51 }); $nav.filter(':not(:animated)').animate({ "marginTop": 23, "marginBottom": 23 }); }, reset: function ($header, $logo, $nav) { $header.filter(':not(:animated)').animate({ "height": 95, "borderTopWidth": 10 }); $logo.filter(':not(:animated)').animate({ "height": 80 }); $nav.filter(':not(:animated)').animate({ "marginTop": 38, "marginBottom": 38 }); } }; ///////////////////////////////////////////// // NAVIGATION ///////////////////////////////////////////// var nav = { init: function(){ // Main Nav var $body = $j('body'), $current_page = $j('.current-menu-item'), $header = $j('#header-section'), $logo = $j('#logo').find('img'), $nav = $j('#main-navigation').find('ul.menu'), $window = $j(window); var $offset = 0, $standard_offset = 0, $home_offset = -145; if ($window.width() < 1024) { $standard_offset = -15; } else if (!1) { $standard_offset = -110; }else { $standard_offset = -45; } $current_page.addClass('current'); if ($body.hasClass('home')) { var $nav_link_parent = $j('.menu').find('li'); $nav_link_parent.on('click', 'a', function(e) { var $nav_link_title = $j(this).attr('class'); if ($nav_link_title) { e.preventDefault(); } if ($j(this).parent().is(':first-child')) { $offset = $home_offset; } else { $offset = $standard_offset; } $j.smoothScroll({ scrollTarget: '#' + $nav_link_title, offset: $offset, easing: 'easeInOutExpo', speed: 700 }); var $current = $j(this); $nav_link_parent.removeClass('current'); $current.parent().addClass('current'); // $current.addClass('current'); }); } // Mobile Nav var $mobile_select = $j('.dropdown-menu'); if ($body.hasClass('home')) { $mobile_select.change(function(e) { e.preventDefault(); var $mob_nav_selected = '#' + $j('.dropdown-menu option:selected').attr('class'); var $offset = -20; $j.smoothScroll({ scrollTarget: $mob_nav_selected, offset: $offset, easing: 'easeInOutExpo', speed: 700 }); }); } else { $mobile_select.change(function() { window.location = $j(this).find("option:selected").val(); }); } } }; // Change menu active when scroll through sections $j(window).scroll(function () { var $inview = $j('#content > section:in-viewport:first').attr('id'); var $menu_item = $j('.menu li a'); var $link = $menu_item.filter('[class=' + $inview + ']'); if ($link.length && !$link.is('.current')) { $menu_item.parent().removeClass('current'); $link.parent().addClass('current'); } }); ///////////////////////////////////////////// // Flexslider ///////////////////////////////////////////// var slider = { init: function() { $j('.flexslider').flexslider({ animation: "fade", //String: Select your animation type, "fade" or "slide" slideDirection: "horizontal", //String: Select the sliding direction, "horizontal" or "vertical" slideshow: true, //Boolean: Animate slider automatically slideshowSpeed: 5000, //Integer: Set the speed of the slideshow cycling, in milliseconds animationDuration: 400, //Integer: Set the speed of animations, in milliseconds directionNav: true, //Boolean: Create navigation for previous/next navigation? (true/false) controlNav: true, //Boolean: Create navigation for paging control of each clide? Note: Leave true for manualControls usage keyboardNav: true, //Boolean: Allow slider navigating via keyboard left/right keys mousewheel: false, //Boolean: Allow slider navigating via mousewheel prevText: "Previous", //String: Set the text for the "previous" directionNav item nextText: "Next", //String: Set the text for the "next" directionNav item pausePlay: false, //Boolean: Create pause/play dynamic element pauseText: 'Pause', //String: Set the text for the "pause" pausePlay item playText: 'Play', //String: Set the text for the "play" pausePlay item randomize: false, //Boolean: Randomize slide order slideToStart: 0, //Integer: The slide that the slider should start on. Array notation (0 = first slide) animationLoop: true, //Boolean: Should the animation loop? If false, directionNav will received "disable" classes at either end pauseOnAction: true, //Boolean: Pause the slideshow when interacting with control elements, highly recommended. pauseOnHover: false, //Boolean: Pause the slideshow when hovering over slider, then resume when no longer hovering controlsContainer: "", //Selector: Declare which container the navigation elements should be appended too. Default container is the flexSlider element. Example use would be ".flexslider-container", "#container", etc. If the given element is not found, the default action will be taken. manualControls: "", //Selector: Declare custom control navigation. Example would be ".flex-control-nav li" or "#tabs-nav li img", etc. The number of elements in your controlNav should match the number of slides/tabs. start: function(slider){ $j(slider).css('background-image', 'none'); }, //Callback: function(slider) - Fires when the slider loads the first slide before: function(){}, //Callback: function(slider) - Fires asynchronously with each slider animation after: function(){}, //Callback: function(slider) - Fires after each slider animation completes end: function(){} //Callback: function(slider) - Fires when the slider reaches the last slide (asynchronous) }); } } ///////////////////////////////////////////// // Contact Form Functions ///////////////////////////////////////////// var contactForm = { init: function() { $j('form#contactForm').submit(function() { $j('form#contactForm label.error').remove(); $j('form#contactForm span.error').remove(); var hasError = false; $j('.requiredField').each(function() { $this = $j(this); if($j.trim($this.val()) == '') { $this.addClass('invalid'); hasError = true; } else if($this.hasClass('email-input')) { var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; if(!emailReg.test($j.trim($this.val()))) { $this.addClass('invalid'); hasError = true; } else { $this.removeClass('invalid'); } } else { $this.removeClass('invalid'); } }); if(!hasError) { $j('form#contactForm li.buttons button').fadeOut('normal', function() { $j(this).parent().append(''); }); var formInput = $j(this).serialize(); $j.post($j(this).attr('action'),formInput, function(data){ $j('form#contactForm').slideUp("fast", function() { $j('p.thanks').fadeIn(1000); }); }); } return false; }); } } ///////////////////////////////////////////// // Reload Functions ///////////////////////////////////////////// var reloadFunctions = { init:function() { // Remove title attributes from images to avoid showing on hover $j('img[title]').each(function() { $j(this).removeAttr('title'); }); $j('.gallery-icon a[title]').each(function() { $j(this).removeAttr('title'); }); // Tabs Shortcode Function $j('.tabbed-asset').tabs(); } } ///////////////////////////////////////////// // Base Functions ///////////////////////////////////////////// var baseFunctions = { init: function() { // Back to top scroll button $j('.back-to-top').click(function() { $j('body,html').animate({scrollTop:0},800); }); // Site loading $j('.site-loading').fadeOut(200); $j('.nav-wrap').fadeIn(1000); // Remove last divider on homepage $j('.home').find('.divider:last').hide(); } } /* $j("a.").mouseover(function () { $j(this).css("color","red"); }); a.CLASS - get ID -> 4 hoch -> find "leistungenInfos" -> show "ID"-Item */ $j(".leistungsItemLink").click(function () { var linkAttribute = $j(this).attr("href"); $j(this).parent().parent().parent().parent().find('.leistungenInfos').find('.visible').removeClass("visible"); $j(this).parent().parent().parent().parent().find('.leistungenInfos').find(linkAttribute).addClass("visible"); $j.smoothScroll({ scrollTarget: linkAttribute, offset: -275, easing: 'easeInOutExpo', speed: 700 }); }); $j(document).ready(onLoad.init);