function scrollTo (id) {
var y = $('#'+id).position().top;
y = y+30;
scrollTo(y, 800);
//тут клик по табу $('a[href=\'#specification\']').trigger('click');
};
Math.easeInOutQuad = function (t, b, c, d) {
t /= d/2;
if (t < 1) {
return c/2*t*t + b
}
t--;
return -c/2 * (t*(t-2) - 1) + b;
};
var requestAnimFrame = (function(){
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function( callback ){ window.setTimeout(callback, 1000 / 60); };
})();
function offsetPosition(element) {
var offsetLeft = 0, offsetTop = 0;
do {
offsetLeft += element.offsetLeft;
offsetTop += element.offsetTop
} while (element = element.offsetParent);
return [offsetLeft, offsetTop]
}
function scrollTo(to, duration, callback) {
if(!to) return;
// если передаю ид элемента а не число
if(typeof to === 'string') {
to = offsetPosition(document.querySelector(to))[1]
}
// because it's so fucking difficult to detect the scrolling element, just move them all
function move(amount) {
document.documentElement.scrollTop = amount;
document.body.parentNode.scrollTop = amount;
document.body.scrollTop = amount;
}
function position() {
return document.documentElement.scrollTop || document.body.parentNode.scrollTop || document.body.scrollTop;
}
var start = position(),
change = to - start,
currentTime = 0,
increment = 20;
duration = (typeof(duration) === 'undefined') ? 500 : duration;
var animateScroll = function() {
// increment the time
currentTime += increment;
// find the value with the quadratic in-out easing function
var val = Math.easeInOutQuad(currentTime, start, change, duration);
// move the document.body
move(val);
// do the animation unless its over
if (currentTime < duration) {
requestAnimFrame(animateScroll);
} else {
if (callback && typeof(callback) === 'function') {
// the animation is done so lets callback
callback();
}
}
};
animateScroll();
}
$(".mfp-bottom-bar").prepend("<div class='hidden-xs'><?php if (!$special) { ?><span class='priceproduct-new'><?php echo $price; ?></span><?php } else { ?><span class='priceproduct-new'><?php echo $special; ?></span> <span class='priceproduct-old'><?php echo $price; ?></span><?php } ?> <?php if ($quantity <= 0 && $status ) { ?><button type='button' class='btn-instock' onclick=\"instock.add('<?php echo $product_id; ?>');\" data-product-id='<?php echo $product_id; ?>'><?php echo $button_instock; ?></button><?php } else { ?><button type='button' id='button-cart' data-loading-text='' class='btn-cart'> <?php echo $button_cart; ?></button><?php } ?></div>");
onclick="window.open('site.ru?addCart=<?php echo $product['product_id']; ?>')"
function $_GET(key) {
var p = window.location.search;
p = p.match(new RegExp(key + '=([^&=]+)'));
return p ? p[1] : false;
}
window.onload = function() {
cart.add($_GET('addCart'));
}
$sql = "SELECT * FROM " . DB_PREFIX . "review2 WHERE 1=1";
var currentDate = new Date().toString();
data: {
input: $('input[name=\'aridiusundersell_contact\'],input[name=\'aridiusundersell_firstname\'],input[name=\'aridiusundersell_email\']'),
product: 'product_id=' + product_id
}
'add': function(product_id) { // в этой строке объявляется функция, которая ожидает в качестве аргумента product_id
/* *** */
onclick="instock.add('<?php echo $product['product_id']; ?>');" // при клике вызывается объявленная ранее функция и ей передается product_id
<!-- Кнопке добавлется data-атрибут "data-product-id", куда записывается product_id: -->
<button type="button" data-product-id="<?= $product['product_id'];?>" data-toggle="tooltip" title="<?php echo $button_wishlist; ?>" onclick="instock.add('<?php echo $product['product_id']; ?>');"><?php echo $buttonundersell_title; ?></button>
$(document).on("click touchstart", "#undersell-order-submit", function (product_id) {
var product_id = $(this).closest('form').find('button[data-product-id]').data('product-id'); // Получение product_id из data-атрибута.
$.ajax({
/* *** */