Last active
September 10, 2019 12:32
-
-
Save andrei99/1b255c00dfb94fea127f6237a6f27848 to your computer and use it in GitHub Desktop.
jQuery
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
if (typeof yaCounterXXXXXX !== 'undefined') { | |
yaCounterXXXXXX.reachGoal('Form_click'); | |
} |
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
//event sensitive scroll | |
window.scrollPage = false; | |
var ts; | |
$(document).bind('touchstart', function (e){ | |
ts = e.originalEvent.touches[0].clientY; | |
}); | |
$(document).bind('touchmove', function (e){ | |
var te = e.originalEvent.changedTouches[0].clientY; | |
var resultTouch = ts - te; | |
resultTouch = Math.abs(resultTouch); | |
window.scrollPage = false; | |
if(resultTouch < 50){ | |
window.scrollPage = true; | |
} | |
/* | |
if(ts > te+5){ | |
console.log('ts' + ts); | |
console.log('te ' + te); | |
}else if(ts < te-5){ | |
console.log('ts' + ts); | |
console.log('te ' + te); | |
} | |
*/ | |
console.log('resultTouch ' + resultTouch); | |
console.log('window.scrollPage ' + window.scrollPage); | |
}); |
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
<!-- 2 items --- start --> | |
//js | |
if ($('#slider_price_filter').length) { | |
setTimeout(function () { | |
var slider = document.getElementById('slider_price_filter'); | |
var initialStartPrice = Number($('#slider_price_filter_min').text()); | |
var initialEndPrice = Number($('#slider_price_filter_max').text()); | |
var posPriceMin = $('.wrap_slider_price').find('.min-price').val(); | |
var posPriceMax = $('.wrap_slider_price').find('.max-price').val(); | |
noUiSlider.create(slider, { | |
start: [posPriceMin, posPriceMax], | |
connect: true, | |
step: 100, | |
range: { | |
'min': initialStartPrice, | |
'max': initialEndPrice | |
}, | |
format: wNumb({ | |
decimals: 0, | |
thousand: ' ' | |
}) | |
}); | |
var marginMin = document.getElementById('slider_price_filter_min'), | |
marginMax = document.getElementById('slider_price_filter_max'); | |
slider.noUiSlider.on('update', function (values, handle) { | |
if (handle) { | |
marginMax.innerHTML = values[handle]; | |
} else { | |
marginMin.innerHTML = values[handle]; | |
} | |
}); | |
slider.noUiSlider.on('change', function (values, handle) { | |
var arPrice = slider.noUiSlider.get(); | |
$('.wrap_slider_price').find('.min-price').attr('value', arPrice[0].replace(' ', '')); | |
$('.wrap_slider_price').find('.max-price').attr('value', arPrice[1].replace(' ', '')); | |
$('.smartfilter input.min-price').keyup(); | |
}); | |
}, 300); | |
} | |
//html | |
<div class="inner_items_filter"> | |
<div class="departures-line1" id="slider_price_filter"></div> | |
<div class="items_slider_price_filter"> | |
<p> | |
<span id="slider_price_filter_min">0</span> | |
<i>руб.</i> | |
</p> | |
<p> | |
<span id="slider_price_filter_max">10500</span> | |
<i>руб.</i> | |
</p> | |
</div> | |
</div> | |
<!-- 2 items --- start --> | |
// reset NOUISlider | |
jQuery('.search_fields_line_slider_1')[0].noUiSlider.reset(); |
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
//script | |
$('body').on('click','.btn_send',function () { | |
if ($(this).closest('form').find('.name_form').val() == '') { | |
alert('Заполните поле Имя!'); | |
return false; | |
}else if($(this).closest('form').find('.phone_form').val() == ''){ | |
alert('Заполните поле Телефон!'); | |
return false; | |
} | |
else { | |
var obj = new Object(); | |
obj.name = $(this).closest('form').find('.name_form').val(); | |
obj.phone = $(this).closest('form').find('.phone_form').val(); | |
$.ajax( | |
{ | |
url: "/sendmail.php", | |
dataType: "text", | |
data: obj, | |
type: "post", | |
success: function (ans) { | |
//array send | |
var result = JSON.parse(ans); | |
alert('Сообщение отправлено!'); | |
$('.name_form').val(''); | |
$('.phone_form').val(''); | |
} | |
}); | |
return false; | |
} | |
}); | |
//php | |
<? | |
$adminemail="test@test.ru"; | |
$name=strip_tags(trim($_POST['name'])); | |
$phone=strip_tags(trim($_POST['phone'])); | |
mail("$adminemail", "Сообщение c лендинга drymorning.ru ". date('d-m-Y H:m:s'), "\nимя:\t$name\nтелефон:\t$phone"); | |
//send array | |
echo json_encode($arResult); | |
?> |
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
//send callback | |
$('body').on('click', '.send_callback', function () { | |
requiredItems($(this)); | |
if (!window.sendBool) { | |
return false; | |
} else { | |
showSpinner(); | |
var formData = new FormData($('#callback form')[0]); | |
$.ajax( | |
{ | |
url: "", | |
data: formData, | |
type: "post", | |
processData: false, | |
contentType: false, | |
success: function (ans) { | |
setTimeout(function () { | |
hideSpinner(); | |
messageSuccess('Сообщение отправлено!'); | |
}, 1000); | |
} | |
}); | |
} | |
return false; | |
}); | |
//spinner | |
function showSpinner() { | |
$('.wrap_container_spinner').show(); | |
} | |
function hideSpinner() { | |
$('.wrap_container_spinner').hide(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment