function translate($string)
{
$url = 'https://translate.yandex.net/api/v1.5/tr.json/translate?';
$aParams = array();
$aParams['key'] = 'ключ';
$aParams['text'] = $string;
$aParams['lang'] = 'ru-en';
$aParams['format'] = 'plain';
$url = $url . http_build_query($aParams);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, 156, 5000);
curl_setopt($ch, CURLOPT_ENCODING , "");
$data = curl_exec($ch);
curl_close($ch);
if (strlen($data))
{
$oData = json_decode($data);
if (is_object($oData) && $oData->code == 200 && isset($oData->text[0]))
{
return $oData->text[0];
}
}
return NULL;
}
(function($) {
$.fn.totop = function(options) {
options = $.extend(
{
height : 300, // позиция появления
speed : 1000 // скорость прокрутки наверх
}, options);
return this.each(function() {
button = $(this);
$(window).scroll( function() {
if ( $(window).scrollTop() > options.height ) {
if (!button.attr('data-x')) {
button.fadeIn();
}
} else {
if (!button.attr('data-x')) {
button.fadeOut();
}
}
});
button.click(function(e) {
if ($(this).attr('data-x')) {
var top = parseInt($(this).attr('data-x'));
e.preventDefault();
$('html, body').stop().animate({scrollTop: top}, options.speed, function(){
button.removeAttr('data-x');
});
button.html('<i class="icon-arrow-up"></i>');
return false;
}
var top = $(window).scrollTop();
button.attr('data-x',top);
button.html('<i class="icon-arrow-down"></i>');
e.preventDefault();
$('html, body').stop().animate({scrollTop: "0px"}, options.speed );
return false;
});
$(window).scroll();
})
}
})(jQuery);
$(window).resize(function() {
console.log("resize");
$('.main-product .product-frame').each(function() {
var $this = $(this);
var height = $this.find('.product-section h3').height();
if (height > 21) {
if (!$this.find('.variations_form').length) {
var width = $(window).width();
console.log("simple");
if (width >= 992 && width < 1200) {
console.log("simple price");
}
if (width >= 768 && width <= 991) {
console.log("simple price");
}
}
}
});
});