File: D:/HostingSpaces/SBogers10/fietsparkeer.komma-mediadesign.nl/wwwroot/js/main.js
/**
* Created by Komma Mediadesign.
* User: mike
* Date: 3/12/13
*/
var activeLabel = null;
// Save viewport
$('body').append('<div id="jsLoad" style="display:none"></div>');
$(document).ready(function()
{
$('.save_viewport').click(function(e)
{
e.preventDefault();
var $link = $(this);
var url = '/mvc/controllers/c_saveViewport.php?offsetTop='+$(document).scrollTop();
$('#jsLoad').load(url, function()
{
window.location.href = $link.attr('href');
});
});
/*
* Animate Objects when hovered
*/
var obj = $('.simpleHover');
var speed = 200;
$(obj).hover(function(){
$('.hover',this).stop().animate({opacity:1},speed);
},
function(){
$('.hover',this).stop().animate({opacity:0},speed);
});
/*
* Make every productBlock completely clickable.
*/
var pBlock = $('.pBlock');
/*
$(pBlock).click(function(){
window.location.href = $('.pBlockLink',this).attr('href');
});*/
/*
* Animate projectBlock when hovered
*/
$(pBlock).hover(function(){
$('.pBlockOverlay',this).stop().animate({bottom:'-10px'},speed);
$('.pBlockArrowActive',this).stop().animate({rotate: '0', opacity: 1 }, speed);
$('.pBlockArrow',this).stop().animate({rotate: '-90deg' }, speed);
},
function(){
$('.pBlockOverlay',this).stop().animate({bottom:0},speed);
$('.pBlockArrowActive',this).stop().animate({rotate: '90deg', opacity: 0 }, speed);
$('.pBlockArrow',this).stop().animate({rotate: '0deg' }, speed);
});
/*
* Initialize Gallery
*/
var gallery = new SimpleGallery('#productSlider','#productSliderNav','#counter');
gallery.init();
var gallery2 = new SimpleGallery('#velockProductSlider','#velockSliderNav','#counter');
gallery2.init();
/*
* Animate SubMenu when hovered
*/
obj = $('.simpleHover','.submenu');
$(obj).hover(function(){
$('.hover',this).stop().animate({opacity:1},speed);
if(!$(this).parent().hasClass('active')) $('.arrow',this).stop().animate({rotate: '90deg' }, speed);
},
function(){
$('.hover',this).stop().animate({opacity:0},speed);
if(!$(this).parent().hasClass('active')) $('.arrow',this).stop().animate({rotate: '0' }, speed);
});
/*
* Show Details
*/
$('.hasDetail').hover(function()
{
var $detail = $('.detail', this);
var $obj = $(this);
var objPos = { x : Math.round($obj.offset().left), y : ($obj.offset().top - $(document).scrollTop()) };
var dPos = { x : Math.round(objPos.x + $obj.width() / 2), y : (objPos.y + $obj.height()) };
$detail.css({ top: dPos.y + 'px', left: dPos.x+'px' });
$detail.css({ display: 'block'});
$detail.stop().animate({ opacity: 1, top: (dPos.y + 10)+'px'},200);
var w = $('.label',$detail).width() + parseInt($detail.css('paddingLeft')) + parseInt($detail.css('paddingRight')) ;
var ml = Math.round( w / -2 );
$detail.css({ marginLeft: ml+'px' });
},
function(){
var $detail = $('.detail', this);
var $obj = $(this);
var objPos = { x : Math.round($obj.offset().left), y : $obj.offset().top };
var dPos = { x : Math.round(objPos.x + $obj.width() / 2), y : (objPos.y + $obj.height()) };
$detail.stop().animate({ opacity: 0, top: dPos.y + 'px'},100,function(){ $(this).css({ display: 'none'}); });
});
$('html,body').scroll(function(){
var $detail = $('.detail');
var $obj = $(this);
var objPos = { x : Math.round($obj.offset().left), y : $obj.offset().top };
var dPos = { x : Math.round(objPos.x + $obj.width() / 2), y : (objPos.y + $obj.height()) };
$detail.stop().animate({ opacity: 0, top: dPos.y + 'px'},100,function(){ $(this).css({ display: 'none'}); });
});
/*
* Contact formulier
*/
var textField = $('.textField');
var textArea = $('.textArea');
$(textField).focus(function(){
var target = $(this).siblings('.textLabel');
var w = $(target).width() + parseInt($(target).css('paddingLeft')) + parseInt($(target).css('paddingRight'));
var l = Math.floor(w*-1);
$(target).stop().animate({ left: l+'px' },200);
});
$(textField).blur(function(){
if($(this).val() == '')
{
var target = $(this).siblings('.textLabel');
$(target).stop().animate({ left: '1px' },200);
}
});
$(textArea).focus(function(){
var target = $(this).siblings('.textLabel');
var w = $(target).width() + parseInt($(target).css('paddingLeft')) + parseInt($(target).css('paddingRight'));
var l = Math.floor(w*-1);
$(target).stop().animate({ left: l+'px' },200);
});
$(textArea).blur(function(){
if($(this).val() == '')
{
var target = $(this).siblings('.textLabel');
$(target).stop().animate({ left: '1px' },200);
}
});
$(textField).each(function(){
if($(this).val() != '')
{
var t = this;
setTimeout(function(){
var target = $(t).siblings('.textLabel');
var w = $(target).width() + parseInt($(target).css('paddingLeft')) + parseInt($(target).css('paddingRight'));
var l = Math.floor(w*-1);
$(target).css({ left: l+'px' });
},100);
}
});
$(textArea).each(function(){
if($(this).val() != '')
{
var t = this;
setTimeout(function(){
var target = $(t).siblings('.textLabel');
var w = $(target).width() + parseInt($(target).css('paddingLeft')) + parseInt($(target).css('paddingRight'));
var l = Math.floor(w*-1);
$(target).css({ left: l+'px' });
},100);
}
});
$('#submitForm').click(function() {
$('#contactForm').submit();
});
/*
$('.textLabel').each(function(index)
{
$(this).click(function(e){
if(activeLabel != null) $('.textLabel').eq(activeLabel).stop().animate({ left: 0 },200);
activeLabel = index;
var w = $(this).width() + parseInt($(this).css('paddingLeft')) + parseInt($(this).css('paddingRight'));
var l = w*-1;
$(this).stop().animate({ left: l+'px' },200);
});
});*/
$('a','#main_footer').hover(
function() {
if(!$(this).hasClass('komma'))
{
$(this).stop().animate({ color: "#ffffff" },300);
}
else
{
$(this).stop().animate({ opacity: 1 },300);
}
},
function()
{
if(!$(this).parent().hasClass('active'))
{
if( !$(this).hasClass('komma'))
{
$(this).stop().animate({ color: "#B9BEC3" },300);
}
else
{
$(this).stop().animate({ opacity: 0.4 },300);
}
}
}
);
$('#main_header a, .content a').hover(
function() {
if(!$(this).parent().hasClass('active'))
{
$(this).stop().animate({ color: "#E22330" },300);
}
},
function()
{
if(!$(this).parent().hasClass('active'))
{
$(this).stop().animate({ color: "#777777" },300);
}
}
);
/*
* Animate SubMenuList when hovered
*/
obj = $('.subMenuList a');
speed = 100;
$(obj).hover(function(){
if( ! $(this).parent().hasClass('active'))
{
$(this).stop().animate({ backgroundColor: "#FFFFFF", color: "#E22330" },speed);
}
},
function(){
if( ! $(this).parent().hasClass('active'))
{
$(this).stop().animate({ backgroundColor: "#E22330", color: "#FFFFFF" },speed);
}
});
var callToAction = '.ctaBlock';
$(callToAction).click(function(e){
if(typeof e.target.href == 'undefined' || !e.target.href )
{
window.location.href = $('a.arrow',this).attr('href');
}
});
$(callToAction).hover(function(){
$('.hover',this).stop().animate({ opacity: 1 },300);
},function(){
$('.hover',this).stop().animate({ opacity: 0 },300);
});
$('.footerIcon').click(function()
{
$("html, body").animate({ scrollTop: "0" },500);
});
});