Subversion-Projekte lars-tiefland.ci

Revision

Revision 47 | Zur aktuellen Revision | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

$(document).ready(function(){
    // current year
    if($('#year').length) {
        var year = new Date().getFullYear();
        $('#year').html(year);
    }
    // footer_height
    if($('#footer_height').length) {
        var h = $('.footer').height();
        $('#footer_height').height(h+20);
    }

    $('#post_finder').button({
        icons:{
            primary:"ui-icon-search"
                                    
        }
                            
    }).click(post_finder);
    $('#postfinder_dlg').dialog({
        autoOpen:false,
        modal:true,
        resizable:false,
        width:850,
        height:600
    })

    // IE Fix Placeholder
    $('[placeholder]').focus(function() {
        var input = $(this);
        if (input.val() == input.attr('placeholder')) {
            input.val('');
            input.removeClass('placeholder');
        }
    }).blur(function() {
        var input = $(this);
        if (input.val() == '' || input.val() == input.attr('placeholder')) {
            input.addClass('placeholder');
            input.val(input.attr('placeholder'));
        }
    }).blur();
    
    // MAINNAV
    
    $(".menue").click(function(e){
        e.preventDefault();
        $('body').toggleClass("active-nav");
        $('body').toggleClass("fixed");  
    })
    $(".suche").click(function(e){
         e.preventDefault();
        $('body').toggleClass("active-search");
    })
    $(".topnav .mobile.close").click(function(e){
        e.preventDefault();
        $('body').toggleClass("active-nav");
        $('body').toggleClass("fixed");  
    })
    $("#maincontent,.maincontent").click(function(e){
        if( $("body").hasClass("active-nav") ){
            e.preventDefault();
            $('body').toggleClass("active-nav");
            $('body').toggleClass("fixed");      
        }
    })
    $('.mainnav li a').click(function(e){
        
        e.preventDefault();
        
        $('.mainnav li').removeClass('active');
        var id = $(this).attr('id');
        var href = $(this).attr('href');
        $.ajax({ 
            typ: "GET",
            url:'/module/setSessionVars.php?mainnav='+id, 
            success:function(html){
                location.href = href;
            }
        });
    });
    var subNavClick = false;
    $('.level1').on("touchstart", function (e) {
        if( !subNavClick ){
          'use strict'; //satisfy code inspectors
          var link = $(this); //preselect the link
          
          if ( link.hasClass('hover') && !subNavClick ) {
            $('.level1').removeClass("hover");
            $('.level2').hide();
            $('.level2',this).css('display', 'block');
            return true;
          } else {
            subNavClick = false;
            $('.level1').removeClass("hover");
            $('.level2').hide();
            link.addClass('hover');
            $('.level2',this).css('display', 'block');

            return false; //extra, and to make sure the function has consistent return points
          }
        }
    });
    $(".level2").on("touchstart", function (e) {
        subNavClick = true;    
    });

    // topnav Aufklapper Hintergrundbild (Linien)
    /*
    $('.topnav li').mouseenter(function() {
        windowWidth = $(window).width();  
        if( windowWidth > 850){
            var expl = $(this).attr('id').split("_");
            var id = expl[1];
            var cols = 0;
            $('#sub_'+id+' .subdir_col').each(function(){
                if( $(this).children().length > 0 ) {
                    cols++;
                }
            }); 
            $('#sub_' + id + ' .subnav_padding').css("background","url(/images/webelemente/topnav_bg_" + cols + ".png) repeat-y");
        }
    });
    */  
    
    // ME: typo3 tabellen dürfen keine Styles haben
    $('.typo3content .contenttable td').each(function(){
        $(this).removeAttr('style');
    });
});

function initSlider( classname, windowWidth, slides, autoplay ){
    
    if(!autoplay){
        var autoplay = false;    
    }
    
    if(!slides) {
        var slides = 3;   
    }
    
    var slideWidth = $(this).width() / slides;
    
    if(slides == 1){
        slides = 0;
    }
    
    if( windowWidth < 800 && windowWidth > 350 ){
        slideWidth = $(this).width() / 2;
        if( slides > 1 ){
            slides = 2;  
        }  
    }else if( windowWidth < 350 ){
        slideWidth = $(this).width();
        slides = 1;
    }
    classname = $("."+classname).bxSlider({
        infiniteLoop: false,
        autoHover: true,
        adaptiveHeight: true,
        responsive: true,
        minSlides: slides,
        maxSlides: slides,
        slideWidth: slideWidth, 
        slideMargin: (slides > 0) ? 10: 0,           
        pager: false,
        controls: (slides > 0)? true : false,
        auto: autoplay   
    });
    return classname;
}


function reloadSlider( classname, windowWidth, slides, autoplay ){
    
    if(!autoplay){
        var autoplay = false;    
    }
    
    if(!slides) {
        var slides = 3;   
    }
        
    var slideWidth = $(this).width() / slides;
    
    if(slides == 1){
        slides = 0;
    }
            
    var slideWidth = $(this).width() / slides;
    if( windowWidth < 800 && windowWidth > 350 ){
        slideWidth = $(this).width() / 2;
        if( slides > 1 ){
            slides = 2;  
        }    
    }else if( windowWidth < 350 ){
        slideWidth = $(this).width();
        slides = 1
    }

     $("."+classname).reloadSlider({
        autoHover: true,
        adaptiveHeight: true,
        responsive: true,
        minSlides: slides,
        maxSlides: slides,
        slideWidth: slideWidth, 
        slideMargin: (slides > 0) ? 10: 0,           
        pager: false,
        controls: (slides > 0)? true : false,
        auto: autoplay  
    })
    
    return classname;
}

function initElevateZoom( zoomType, scrollZoom ){
    var image = $('#gallery a');
    if( zoomType == "" || zoomType == "undefined"){
       var zoomType = "window";
    }
    if( scrollZoom == "" || scrollZoom == "undefined"){
       var scrollZoom = false;
    }
     
    if(zoomType=="inner" && scrollZoom) {
        scrollZoom = true;
    }
    var zoomConfig = { 
        gallery:'gallery',
        responsive: true,
        galleryActiveClass: 'active',
        zoomType: zoomType,
        easing: true, 
        zoomWindowWidth: 500,
        zoomWindowHeight: 400,
        zoomWindowFadeIn: 400,
        zoomWindowFadeOut: 500,
        borderSize: 1,
        cursor: 'pointer',
        borderColor: '#666',
        zoomWindowOffetx: 5,
        zoomWindowOffety: 0,
        scrollZoom: scrollZoom,
            
    };
    var zoomImage = $('#img_zoom');

    zoomImage.elevateZoom(zoomConfig);//initialise zoom

    image.on('click', function(){
        // Remove old instance od EZ
        $('.zoomContainer').remove();
        zoomImage.removeData('elevateZoom');
        // Update source for images
        zoomImage.attr('src', $(this).data('image'));
        zoomImage.data('zoom-image', $(this).data('zoom-image'));
        // Reinitialize EZ
        zoomImage.elevateZoom(zoomConfig);
        
    });
    zoomImage.on("click", function(e) {  
           
        var ez = $('#img_zoom').data('elevateZoom');
        var g = ez.getGalleryList();
        var data = [];
        //Wenn g == "", dann gibt es nur ein Bild. Dieses soll auch in der Fancybox rauskommen
        if(g == ""){
           data[0] = { href : $(this).data('zoom-image'), title : '' };  
           g = data;
        }
        
        $.fancybox.open(g,{
            'openEffect'    :   'elastic',
            'closeEffect'   :   'elastic',
            'nextEffect'    :   'fade',
            'openSpeed'     :   600, 
            'closeSpeed'    :   200,
            helpers : {
                buttons : {}
            }
        });        
    });
}

function post_finder()
{
    daten={
        plz:$('#plz').val(),
        ort:$('#ort').val()
    }
    $('#postfinder_dlg').load("/module/standortsuche.php",daten,function(){
        $('#postfinder_dlg').dialog("open");
    });
}