Created
September 5, 2015 08:34
-
-
Save flayder/799289ae4c9b6ef891a0 to your computer and use it in GitHub Desktop.
Плавное появление popup - который можно убрать при клике на любой участок документа, но не при клике на область popup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
$('.carousel').carousel(); | |
$('.btn-button-blue a').click(function() { | |
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') || location.hostname == this.hostname) { | |
var target = $(this.hash); | |
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); | |
if (target.length) { | |
$('html,body').animate({ | |
scrollTop: target.offset().top | |
}, 1000); | |
return false; | |
} | |
} | |
}); | |
(function(){ | |
var form = $('#form form'), | |
name = form.find('.name'), | |
nameInput = form.find('.name input'), | |
email = form.find('.email'), | |
emailInput = form.find('.email input'), | |
phone = form.find('.phone'), | |
phoneInput = form.find('.phone input'); | |
nameInput.bind('keyup', function(){ | |
var label = name.find('label'), | |
valid = name.find('.valid'), | |
req = /\D/i; | |
if(!req.test($(this).val()) || $(this).val().length < 3){ | |
$(valid).removeClass('okey'); | |
$(label).css('color', 'red').html('Неправильное имя'); | |
$(this).css('borderColor', 'red'); | |
} else { | |
$(valid).addClass('okey'); | |
$(label).css('color', '').html('Ваше имя'); | |
$(this).css('borderColor', ''); | |
} | |
}); | |
$(phoneInput).mask("+9(999) 999-99-99"); | |
// $(phoneInput).bind('keyup', function(){ | |
// var label = phone.find('label'), | |
// valid = phone.find('.valid'); | |
// if(!req.test($(this).val())){ | |
// $(valid).removeClass('okey'); | |
// $(label).css('color', 'red').html('Неправильное телефон'); | |
// $(this).css('borderColor', 'red'); | |
// } else { | |
// $(valid).addClass('okey'); | |
// $(label).css('color', '').html('Ваше телефон'); | |
// $(this).css('borderColor', ''); | |
// } | |
// }); | |
emailInput.bind('keyup', function(){ | |
var label = email.find('label'), | |
valid = email.find('.valid'), | |
req = /^(\w|[.])+@[a-z]+[.][a-z]{2,3}$/i; | |
if(!req.test($(this).val())){ | |
$(valid).removeClass('okey'); | |
$(label).css('color', 'red').html('Неправильное email'); | |
$(this).css('borderColor', 'red'); | |
} else { | |
$(valid).addClass('okey'); | |
$(label).css('color', '').html('Ваше email'); | |
$(this).css('borderColor', ''); | |
} | |
}); | |
}()); | |
(function(){ | |
var form = $('#form-phone'), | |
name = form.find('.name'), | |
nameInput = form.find('.name input'), | |
email = form.find('.email'), | |
emailInput = form.find('.email input'), | |
phone = form.find('.phone'), | |
phoneInput = form.find('.phone input'); | |
nameInput.bind('keyup', function(){ | |
var label = name.find('label'), | |
valid = name.find('.valid'), | |
req = /\D/i; | |
if(!req.test($(this).val()) || $(this).val().length < 3){ | |
$(valid).removeClass('okey'); | |
$(label).css('color', 'red').html('Неправильное имя'); | |
$(this).css('borderColor', 'red'); | |
} else { | |
$(valid).addClass('okey'); | |
$(label).css('color', '').html('Ваше имя'); | |
$(this).css('borderColor', ''); | |
} | |
}); | |
$(phoneInput).mask("+9(999) 999-99-99"); | |
// $(phoneInput).bind('keyup', function(){ | |
// var label = phone.find('label'), | |
// valid = phone.find('.valid'); | |
// if(!req.test($(this).val())){ | |
// $(valid).removeClass('okey'); | |
// $(label).css('color', 'red').html('Неправильное телефон'); | |
// $(this).css('borderColor', 'red'); | |
// } else { | |
// $(valid).addClass('okey'); | |
// $(label).css('color', '').html('Ваше телефон'); | |
// $(this).css('borderColor', ''); | |
// } | |
// }); | |
emailInput.bind('keyup', function(){ | |
var label = email.find('label'), | |
valid = email.find('.valid'), | |
req = /^(\w|[.])+@[a-z]+[.][a-z]{2,3}$/i; | |
if(!req.test($(this).val())){ | |
$(valid).removeClass('okey'); | |
$(label).css('color', 'red').html('Неправильный email'); | |
$(this).css('borderColor', 'red'); | |
} else { | |
$(valid).addClass('okey'); | |
$(label).css('color', '').html('Ваш email'); | |
$(this).css('borderColor', ''); | |
} | |
}); | |
$(window).scroll(function(){ | |
var scrollTop = $(this).scrollTop(), | |
heightScroll = $('.border').height(), | |
divScroll = $('.border'); | |
if(scrollTop > heightScroll){ | |
divScroll.addClass('scroll'); | |
} else { | |
divScroll.removeClass('scroll'); | |
} | |
}); | |
(function(){ | |
var scrollTop = $(this).scrollTop(), | |
heightScroll = $('.border').height(), | |
divScroll = $('.border'); | |
if(scrollTop > heightScroll){ | |
divScroll.addClass('scroll'); | |
} else { | |
divScroll.removeClass('scroll'); | |
} | |
}()); | |
$('.product-img').find('.min').click(function(){ | |
var attribute = $(this).find('img').attr('src'); | |
$('.product-img .img img').attr('src', attribute); | |
$('.product-img .active').removeClass('active'); | |
$(this).addClass('active'); | |
}); | |
$('.contact .search').click(function(e){ | |
if($('#search').css('display') != 'block'){ | |
$('#search').fadeIn(); | |
$(this).addClass('searchClick'); | |
var clicker = true; | |
$(document).bind('click.myEvent', function(e){ | |
if(!clicker && $(e.target).closest('#search').length == 0){ | |
$(search).fadeOut(); | |
$('.contact .search').removeClass('searchClick'); | |
$(document).unbind('click.myEvent'); | |
} | |
clicker = false; | |
}); | |
e.preventDefault(); | |
} | |
}); | |
$('#search .search, #searchin .search').focus(function(){ | |
$('#search .result, #searchin .result').fadeIn(); | |
$('#search .search-btn, #searchin .search-btn').fadeIn(); | |
}).blur(function(){ | |
$('#search .result, #searchin .result').fadeOut(); | |
$('#search .search-btn, #searchin .search-btn').fadeOut(); | |
}); | |
$('.panel-quest').click(function(){ | |
var reply = $(this).find('.reply'); | |
if(reply.css('display') != 'block'){ | |
reply.slideDown(); | |
$(this).addClass('active'); | |
return; | |
} else { | |
reply.slideUp(); | |
} $(this).removeClass('active'); | |
}); | |
}()); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment