/* * home.js * Home Page Functions * * www.anwalt-schulrecht-berlin.de * © 2014 Anreas Jakubietz Berlin * */ $(document).ready(function () { /* ================================================== Retina Images ================================================== */ if (retina===true) { $("#image_1").attr("src", "/images/kanzlei-schulrecht-berlin@2x.jpg"); $("#image_2").attr("src", "/images/rechtsanwaltskanzlei-schulrecht-berlin@2x.jpg"); } /* ================================================== Elastislide Carousel ================================================== */ $('#carousel').elastislide({ speed: 450, imageW: 195, margin: 0, border: 0, minItems: 3, current: 0, onClick: true }); /* ================================================== Theme Area Teaser Boxes ================================================== */ var tbox_max_height, tbox_default_height, tbox_default_top, tbox_default_bottom, tbox_animate_height, tbox_animate_top; var hover_delay = 300; var mql = window.matchMedia?window.matchMedia("only screen and (min-width: 900px) and (max-width: 1050px)"):1; mq_check(mql); if(window.matchMedia)mql.addListener(mq_check); function mq_check(mql) { // smaller screen (min-width: 900px, max-width: 1050px) if (mql.matches) { // fixed values (as defined in style sheet) tbox_max_height = "340"; // max height (.theme_area height) tbox_default_height = "100"; // default height (teaser_box height) tbox_default_top = "230"; // default distance from top (teaser_box top) tbox_default_bottom = "15"; // default distance from bottom (teaser_box bottom) tbox_animate_height = "270"; // animated height tbox_animate_top = "60"; // animated distance from top (tbox_max_height - tbox_animate_height - tbox_default_bottom) $("div.teaser_box").show(); } // big screen else { tbox_max_height = "400"; tbox_default_height = "120"; tbox_default_top = "265"; tbox_default_bottom = "20"; tbox_animate_height = "310"; tbox_animate_top = "75"; } tbox_max_height+="px"; tbox_default_height+="px"; tbox_default_top+="px"; tbox_default_bottom+="px"; tbox_animate_height+="px"; tbox_animate_top+="px"; for (i=1; i<=3; i++) $("#teaser_box_"+i).css({ "height": tbox_default_height, "top": tbox_default_top }); } function teaserBoxMinimize(id, auto_minimize) { if($(id).css('height')!=tbox_default_height) $(id).animate({ "height": tbox_default_height, "top": tbox_default_top }, 300); if(auto_minimize) setTimeout(function () { teaserBoxMinimize(id); }, 8000); } function teaserBoxMaximize(id, touch) { // touch screen (mobile) devices if(touch==true) { $(id).on('click touchstart', function(event) { // disable ghost clicks if (event.type=="touchstart") $(id).off('click'); // enable link $(".teaser_box_more a, .teaser_box_more img").on('touchstart', function () { window.location.href = $(".teaser_box_more a").attr('href'); }); // maximize clicked teaser box if($(id).css('height')==tbox_default_height) $(id).animate({ "height": tbox_animate_height, "top": tbox_animate_top }, 300); // minimize teaser boxes for (i=1; i<=3; i++) teaserBoxMinimize("#teaser_box_"+i, 1); }); } // non touch screen (desktop) devices else { $(function () { $(id).hover( function () {$(id).animate({ "height": tbox_animate_height, "top": tbox_animate_top }, 300); }, function () {$(id).delay(hover_delay).animate({ "height": tbox_default_height, "top": tbox_default_top }, 300); } ); }); } } for (i=1; i<=3; i++) teaserBoxMaximize("#teaser_box_"+i, touch_support); }); // end $(document).ready