var ga_exist = false; console.log('GA: ' + typeof ga); if (typeof ga == "undefined") { console.log('GA is not function and not detected'); } $(".btn-product-details").click(function(e) { var raw_data = $(this).closest(".item_container").attr("data-json"); if (!is_undef(raw_data) && raw_data != '') { if (e.preventDefault) e.preventDefault(); if (e.stopPropagation) e.stopPropagation(); e.cancelBubble = true; e.returnValue = false; var raw_data = decodeURIComponent(raw_data); var data = JSON.parse(raw_data); ga('ec:addProduct', { 'id': data.id, 'name': data.model, 'category': data.categoryPath, 'brand': data.brand, 'prodType': data.prod_type, 'position': data.posIndex }); ga('ec:setAction', 'click', { 'list': data.listType }); var tmp_url = data.url; if (ga.hasOwnProperty('loaded') && ga.loaded === true) { ga('send', 'event', { 'eventCategory': 'UX', 'eventAction': 'productDetailsClick', 'eventLabel': tmp_url, 'eventValue': 1, 'hitCallback': function() { console.log(tmp_url); document.location = data.url; } }); } else { console.log('No GA'); document.location = tmp_url; } } }); $(document).ready(function() { console.log('Ready GA: ' + typeof ga); ga_exist = (typeof ga === "function"); $('.catalog_item .item_container').each(function() { var raw_data = $(this).attr("data-json"); if (!is_undef(raw_data) && raw_data != '') { var raw_data = decodeURIComponent(raw_data); var data = JSON.parse(raw_data); ga('ec:addImpression', { 'id': data.id, 'name': data.model, 'category': data.categoryPath, 'brand': data.brand, 'prodType': data.prod_type, 'list': data.listType, 'position': data.posIndex }); } }); }); function ga_cart_remove(raw_data) { if (!is_undef(raw_data) && raw_data != '') { var raw_data = decodeURIComponent(raw_data); var data = JSON.parse(raw_data); console.log('remove data:', data); ga('ec:addProduct', { 'id': data.id, 'name': data.model, 'price': data.price, 'brand': data.brand, 'category': data.categoryPath, 'prodType': data.prod_type, 'position': data.position, 'quantity': $("input[id=qty_" + data.id + ']').val() }); ga("ec:setAction", "remove"); ga("send", "event", "UX", "click", "removeFromCart"); } } function ga_cart_add(raw_data) { if (!is_undef(raw_data) && raw_data != '') { var raw_data = decodeURIComponent(raw_data); var data = JSON.parse(raw_data); console.log('add data:', data); var modalBox = $('#buyForm'); ga('ec:addProduct', { 'id': data.id, 'name': data.model, 'category': data.categoryPath, 'brand': data.brand, 'prodType': data.prod_type, 'price': data.price, 'quantity': $("input.prod_count", modalBox).val() }); ga('ec:setAction', 'add'); ga('send', 'event', 'UX', 'click', 'addToCart'); } } function ga_order_preview() { var is_cart_empty = 1; $('.order_item').each(function() { var raw_data = $(this).attr("data-json"); if (!is_undef(raw_data) && raw_data != '') { var raw_data = decodeURIComponent(raw_data); var data = JSON.parse(raw_data); console.log('add data:', data); ga('ec:addProduct', { 'id': data.id, 'name': data.model, 'price': data.price, 'brand': data.brand, 'category': data.categoryPath, 'prodType': data.prod_type, 'position': data.position, 'quantity': $("input[id=qty_" + data.id + ']').val() }); is_cart_empty = 0; } }); if (is_cart_empty == 0) ga("ec:setAction", "checkout", { "step": 1 }); } function ga_order_submit() { var is_cart_empty = 1; $('.order_item').each(function() { var raw_data = $(this).attr("data-json"); if (!is_undef(raw_data) && raw_data != '') { var raw_data = decodeURIComponent(raw_data); var data = JSON.parse(raw_data); console.log('add data:', data); ga('ec:addProduct', { 'id': data.id, 'name': data.model, 'price': data.price, 'brand': data.brand, 'category': data.categoryPath, 'prodType': data.prod_type, 'position': data.position, 'quantity': $("input[id=qty_" + data.id + ']').val() }); is_cart_empty = 0; } }); }; var cart_items = new Array(); var debug_cart = false; debug_cart = true; $(document).ready(function() { $('.buy_button').on('click', function() { var cart = $('#top-cart'); var modalBox = $('#buyForm'); if (!$(this).hasClass("btn-large") && !$(this).hasClass("btnBuy")) { var imgtodrag = $(this).parent().parent('.img').find("img").eq(0); } if (typeof imgtodrag == 'object' && typeof imgtodrag.offset() !== 'undefined') { var imgclone = imgtodrag.clone().offset({ top: imgtodrag.offset().top, left: imgtodrag.offset().left }).css({ 'opacity': '0.5', 'position': 'absolute', 'height': '150px', 'width': '150px', 'z-index': '100' }).appendTo($('body')).animate({ 'top': cart.offset().top + 10, 'left': cart.offset().left + 10, 'width': 75, 'height': 75 }, 1000, 'easeInOutExpo'); setTimeout(function() { cart.effect("shake", { times: 2 }, 200); }, 1500); imgclone.animate({ 'width': 0, 'height': 0 }, function() { $(this).detach() }); } var prod_id = $(this).prop('lang'); console.log('prod_id:' + prod_id); $("#prod_id", modalBox).val(prod_id); var prod_count = 0; if (typeof cart_items[prod_id] !== 'undefined') prod_count = parseInt(cart_items[prod_id]); if (debug_cart) console.log(cart_items[prod_id] + 'prod_count:' + prod_count); $("input.prod_count", modalBox).val(prod_count); $('.plus', modalBox).click(); $(".tovar .title", modalBox).html('hfdhfg'); $(".total_prod", modalBox).html('hgjhgjghk'); update_count_basket(4, 54); //save_cart($("#prod_id", modalBox).val(), $("input.prod_count", modalBox).val()); $(this).html('Купить еще'); if (ga_exist) { var raw_data = $(this).closest(".item_container").attr("data-json"); ga_cart_add(raw_data); } }); $.mask.definitions['~'] = '[+-]'; $('.customerphone, .phone').mask('+380 (99) 999-99-99', { completed: function() { $("button, .btn", $(this).parent()).removeClass('disabled'); } }); $('.phone_short').mask('(099)999-99-99', { completed: function() { $("button, .btn", $(this).parent()).removeClass('disabled'); } }); $('#buy_back_call_submit').bind('click', function() { var modalBox = $('#buyForm'); var prod_id = $("#prod_id", modalBox).val(); var phone_el = $("input[name=customerphone]", modalBox); var tmp_phone = $(phone_el).val(); if (empty(tmp_phone)) { $(phone_el).focus(); alert('Пожалуйста введите номер телефона!'); } else { send_feedback(tmp_phone, 'prod_id:' + prod_id, { 'type': 'fastOrder' }); } if (debug_cart) console.log(prod_id); }); $('.fast_order_form .btn').bind('click', function() { var modalBox = $('#buyForm'); var phone_el = $(".fast_order_form input[name=phone]"); var tmp_phone = $(phone_el).val(); var prod_id = $(this).prop('lang'); if (empty(tmp_phone)) { $(phone_el).focus(); alert('Пожалуйста введите номер телефона!'); } else { if (typeof ga == "function") ga('send', 'event', 'Карточка товара', 'Купить в 1 клик'); send_feedback(tmp_phone, 'prod_id:' + prod_id, { 'type': 'fastOrder' }); } }); }); function save_cart(prod_id, prod_count, sender) { var cart = $('#top-cart'); var modalBox = $('#buyForm'); if (!sender) sender = modalBox; cart_items[prod_id] = prod_count; JsHttpRequest.query('hr_gate.php?test=500&r=' + Math.random(), { 'sp': "prod_in_basket", 'prod_id': prod_id, 'prod_count': prod_count }, function(result, errors) { if (errors) console.log('Errors: ' + errors); if (result) { if (debug_cart) console.log(result); if (result.prod_info) { var prod = result.prod_info; if (debug_cart) console.log(prod); if (typeof prod === 'object') { var modelTitle = ((prod.prod_type) ? prod.prod_type + '
' : '') + prod.brand + ' ' + prod.model; $(".tovar .title", modalBox).html(modelTitle); var tmp_count = parseInt($("input.prod_count", sender).val()); if (debug_cart) console.log('count: ' + tmp_count); $(".total_prod", sender).html(format_money(tmp_count * parseFloat(prod.price))); if (prod.photo_path) { var photo = prod.photo_path; if (debug_cart) console.log('photo: ' + photo); $(".tovar img", modalBox).prop('src', photo); } } } if (result.count_prod && result.total_sum) { update_count_basket(result.count_prod, result.total_sum); } } }, true); } function update_count_basket(count, sum) { console.log(count + ' s:' + sum); var cart = $('#top-cart'); var modalBox = $('#buyForm'); if (count > 0) { var sum_str = format_money(sum); cart.find('.btn.btn-cart').addClass('not_empty'); cart.find('#top-cart-content').html('В корзине' + count + ' товар' + ((count > 4) ? 'ов' : ((count > 1) ? 'а' : '')) + '
на ' + sum_str + '
оформить покупку
'); $(".cart_count", modalBox).html(count); $(".cart_total").html(sum_str); } else { cart.find('.btn.btn-cart').removeClass('not_empty'); cart.find('#top-cart-content').html('

Корзина пуста

'); $(".cart_count", modalBox).html('--'); $(".cart_total").html('--'); } if (sum < 1000) var free_delivery = "Для бесплатной доставки осталось добавить в заказ товаров на " + format_money(1000 - sum) + " "; else var free_delivery = "Бесплатная доставка!!!"; $('.dostavka').html(free_delivery + '

'); }; jQuery(function($) {}); function send_feedback(tel, reason, opt) { var feedback_type = ''; if (opt && opt.type) feedback_type = opt.type; console.log(tel + ' | ' + reason + ' | ' + opt); if (typeof ga == "function") ga('send', 'event', 'callback', 'click'); JsHttpRequest.query('hr_gate.php?test=500&r=' + Math.random(), { 'sp': "callback", 'tel': tel, 'feedback_type': feedback_type, 'reason': reason, 'href': location.href }, function(result, errors) { if (errors) console.log('errors: ' + errors); var msg = ''; if (result) { $('#errormessage').hide(); msg = 'Спасибо за обращение. Наши менеджеры свяжуться с Вами в ближайшее время'; } else { $('#errormessage').hide(); msg = 'Извините. Сервис временно не доступен'; } alert(msg); }, true); } $(document).ready(function() { $('#header_feedback .btn').click(function(event) { tel = $('#header_feedback input[name=phone]').val(); var reason = ''; console.log('callback :: tel:' + tel + ' reason: ' + reason); if (tel == '') { $('#errormessage').show(); console.log('feedback error'); } else { $('#errormessage').hide(); send_feedback(tel, reason); } }); });; function onRegistrationFormSubmit(form) { if (!empty(form)) { form.submit(); return true; $("#botmena").click(); result_msg = "Успешно зарегистрирован!"; $().message(result_msg); } else alert('Form empty'); return false; } $(document).ready(function() {});; jQuery(function($) { $.mask.definitions['~'] = '[+-]'; $('#pc_phone').mask('+380 (99) 999-99-99'); $('#pc_code').mask('9999'); }); $(document).ready(function() { $('#btnPromoBuy').click(function(event) { login = $('#popup_getpromoprod #pc_login').val(); phone = $('#popup_getpromoprod #pc_phone').val(); code = $('#popup_getpromoprod #pc_code').val(); err_msg = $('#popup_getpromoprod #errormessage'); err_msg_promo = $('#popup_getpromoprod #errormessagepromo'); $(err_msg_promo).hide(); if (empty(login) || empty(phone) || empty(code)) { $(err_msg).show(); return; } else if (!in_array(code, new Array(1001, 2002, 3003, 4004))) { $(err_msg_promo).show(); return; } else { $(err_msg).hide(); JsHttpRequest.query('hr_gate.php?test=500&r=' + Math.random(), { 'sp': "promoprod", 'login': login, 'phone': phone, 'code': code, 'href': location.href }, function(result, errors) { if (errors) alert(errors); if (result) { $(err_msg).hide(); $('#promoprodTbl').html('

Ваша заявка принята. Ваш код "' + result.code + '"
В ближайшее время менеджер с Вами свяжется.

'); } else { $(err_msg).hide(); $('#promoprodTbl').html('

Извините.
Сервис временно не доступен

'); } }, true); } }); });; $(document).ready(function() { $('#toogle_seo_text').after('Развернуть текст'); $('#toogle_seo_text').css('display', 'none'); $('#toogle_seo_button').click(function() { if ($('#toogle_seo_text').is(":hidden")) { $('#toogle_seo_text').show(1500); $('#toogle_seo_button').html("Свернуть текст"); } else { $('#toogle_seo_text').hide(1500); $('#toogle_seo_button').html("Развернуть текст"); } }); });; $(document).ready(function() { $('a:not([href-data=""])').each(function() { $(this).attr('href', $(this).attr('href-data')); }); });; var compareWindow; var new_window = ''; var name_cookie = 'compare_id'; $(document).ready(function() { $("a.compare_href, a.compare_menu, a.compare_delete_basket").css('display', "inline"); check_id_compare(); var a; if (getCookie(name_cookie)) a = explode(',', getCookie(name_cookie)); if (a) { $('a.compare_menu').html("В корзине сравнения: " + a.length + " тов."); $('a.compare_basket').html('Сравнить товары (' + a.length + ' шт.)').attr('href', '?p=compare&' + name_cookie + '=' + getCookie(name_cookie)); $('a.compare_delete_basket').html('').attr('href', ""); } $('a.compare_menu').bind('click', function() { if (getCookie(name_cookie)) a = explode(',', getCookie(name_cookie)); if ($.cookie(name_cookie)) { compareWindow = open('?p=compare&' + name_cookie + '=' + getCookie(name_cookie), 'compareWindow', 'scrollbars=1'); } }); $('a.close_compare').bind('click', function() { window.close(); }); $('a.compare_delete').bind('click', function() { var t = get_current_compare($(this).attr('name')); if (t['data']) { set_cookie(name_cookie, t['data']); $(this).attr('href', '?p=compare&' + name_cookie + '=' + t['data']); if (window.opener && !window.opener.closed) window.opener.check_id_compare(); } else { set_cookie(name_cookie, ";"); if (window.opener && !window.opener.closed) window.opener.check_id_compare(); window.close(); delete(compareWindow); } }); $('a.compare_delete_basket').bind('click', function() { set_cookie(name_cookie, ";"); $('a.compare_menu').html('Сравнить товары (0 шт.)'); $('a.go_to_compare').each(function() { if ($(this).attr('lang')) $(this).html("Сравнить"); else $(this).html("Сравнить товар"); $(this).attr('class', 'compare_href'); $(this).unbind(); bind_event_compare(); }); return false; }); $('a.compare_zakaz').bind('mouseover', function() { var id_img = $(this).attr('name'); $('img#' + id_img).attr('src', '/images/compare/basket_h.png'); }); $('a.compare_zakaz').bind('mouseout', function() { var id_img = $(this).attr('name'); $('img#' + id_img).attr('src', '/images/compare/basket.png'); }); }); function bind_event_compare() { $('a.compare_href').bind('click', function() { var length = set_cookie_s(name_cookie, $(this).attr('name')); $('a.compare_menu').html("В корзине сравнения: " + length + " тов.") $('a.compare_delete_basket').html('').attr('href', ""); check_id_compare(); compareWindow = openWindowAdv('?p=compare&' + name_cookie + '=' + getCookie(name_cookie), 'compareWindow'); return false; }); } function check_id_compare() { var a; if (getCookie(name_cookie)) a = explode(',', getCookie(name_cookie)); if (a) { $('a.compare_href').each(function() { if ($.inArray($(this).attr('name'), a) > -1) { $(this).html('К сравнению'); $(this).attr('class', 'go_to_compare compare'); $(this).unbind(); $(this).bind('click', function() { compareWindow = openWindowAdv('?p=compare&' + name_cookie + '=' + getCookie(name_cookie), 'compareWindow'); }); } else { if ($(this).attr('lang')) $(this).html("Сравнить"); else $(this).html("Сравнить товар"); } }); $('a.go_to_compare').each(function() { if ($.inArray($(this).attr('name'), a) < 0) { $(this).unbind(); if ($(this).attr('lang')) $(this).html("Сравнить"); else $(this).html("Сравнить товар"); $(this).attr('class', 'compare_href'); } else { $(this).unbind(); $(this).bind('click', function() { compareWindow = openWindowAdv('?p=compare&' + name_cookie + '=' + getCookie(name_cookie), 'compareWindow'); }); } }); $('a.compare_menu').html("В корзине сравнения: " + a.length + " тов."); } else { $('a.compare_menu').html("В корзине сравнения: 0 тов."); $('a.go_to_compare').each(function() { $(this).unbind(); if ($(this).attr('lang')) $(this).html("Сравнить"); else $(this).html("Сравнить товар"); $(this).attr('class', 'compare_href'); }); } bind_event_compare(); } function get_current_compare(delete_prod_number) { var a; if (getCookie(name_cookie)) a = explode(',', getCookie(name_cookie)); var d = ''; var x = 0; if (a) { for (var b = 0; b < a.length; b++) { if (a[b] != delete_prod_number) { d += a[b] + ','; x++; } } var data = []; data['count'] = x; data['data'] = d.substr(0, d.length - 1); return data; } else { return ''; } } function set_cookie_s(name, value) { var a = Array(0); if (getCookie(name)) a = explode(',', getCookie(name)); a.push(value); var len = unique(a); set_cookie(name, implode(',', len)); return len.length; } function set_cookie(name, value) { if (empty(name)) return; var cookie_clause = name + "=" + value; if (window.opener && !window.opener.closed) { try { window.opener.document.cookie = cookie_clause; } catch (e) { document.cookie = cookie_clause; } } else document.cookie = cookie_clause; return true; } function getCookie(name) { if (window.opener && !window.opener.closed) { try { var cookie = " " + window.opener.document.cookie; } catch (e) { var cookie = " " + document.cookie; } } else var cookie = " " + document.cookie; var search = " " + name + "="; var setStr = null; var offset = 0; var end = 0; if (cookie.length > 0) { offset = cookie.indexOf(search); if (offset != -1) { offset += search.length; end = cookie.indexOf(";", offset) if (end == -1) { end = cookie.length; } setStr = unescape(cookie.substring(offset, end)); } } return (setStr); } function implode(glue, pieces) { return ((pieces instanceof Array) ? pieces.join(glue) : pieces); } function explode(delimiter, string, limit) { var emptyArray = { 0: '' }; if (arguments.length < 2 || typeof arguments[0] == 'undefined' || typeof arguments[1] == 'undefined') { return null; } if (delimiter === '' || delimiter === false || delimiter === null) { return false; } if (typeof delimiter == 'function' || typeof delimiter == 'object' || typeof string == 'function' || typeof string == 'object') { return emptyArray; } if (delimiter === true) { delimiter = '1'; } if (!limit) { return string.toString().split(delimiter.toString()); } else { var splitted = string.toString().split(delimiter.toString()); var partA = splitted.splice(0, limit - 1); var partB = splitted.join(delimiter.toString()); partA.push(partB); return partA; } } function unique(arrayName) { var newArray = new Array(); label: for (var i = 0; i < arrayName.length; i++) { for (var j = 0; j < newArray.length; j++) { if (newArray[j] == arrayName[i]) continue label; } newArray[newArray.length] = arrayName[i]; } return newArray; } function openWindowAdv(url, wnd) { var theName = null; theName = wnd; eval('var wind=' + wnd + ';'); if (!theName || theName.closed || !is_object(wind) || wind.closed) { var windowHeight, windowWidth, windowTop, windowLeft; windowHeight = $(window).height(); windowWidth = $(window).width(); windowTop = 0; windowLeft = 0; var varStore = ""; varStore = varStore + "width=" + windowWidth; varStore = varStore + ",height=" + windowHeight; varStore = varStore + ",resizable=" + "1"; varStore = varStore + ",scrollbars=" + "1"; varStore = varStore + ",menubar=" + "0"; varStore = varStore + ",toolbar=" + "0"; varStore = varStore + ",directories=" + "0"; varStore = varStore + ",location=" + "0"; varStore = varStore + ",status=" + "0"; varStore = varStore + ",left=" + windowLeft; varStore = varStore + ",top=" + windowTop; varStore = varStore + ",ScreenX=" + windowLeft; varStore = varStore + ",ScreenY=" + windowTop; wind = window.open(url, theName, varStore) wind.focus(); } else { wind.focus(); } return wind; }; $(document).ready(function() { var count = 5; var def_val = 0; var title_txt = "Поставить "; $('div.rate').each(function() { var id_prod = 0; var param = $(this).attr('name').split(','); for (q in param) { var data = param[q].split('.'); if (data[0] == 'count') count = data[1]; if (data[0] == 'def_val') def_val = data[1]; if (data[0] == 'id_prod') id_prod = data[1]; } render($(this), count, def_val, id_prod); }); function render(elem, c, v, id_prod) { $(elem).html(''); var color; if (v < 0) { color = 'red'; $('span[name=rate_' + id_prod + ']').html(v); } else { color = 'green'; $('span[name=rate_' + id_prod + ']').html('+' + v); } var pos = position_start(c, v); var counter = Math.abs(v); for (var x = 0; x < (c * 2); x++) { var css_class = "passive"; if (x >= pos && counter > 0) { css_class = color; counter--; } else css_class = "passive"; var pos_rate = ((x - c) >= 0) ? "+" + (x - c + 1) : x - c; css_class = ((x % 2 == 1) ? css_class + '2' : css_class + '1'); var otstup = ((x % 2 == 1) ? ' ' : ''); $(elem).append(''); } bind_stars(id_prod); } function position_start(count_stars, rate) { count_stars = parseInt(count_stars); if (rate < 0) { var result = count_stars - Math.abs(rate); if (result > 0) return result; else return 0; } else { return count_stars; } } function paint_stars(pos_start, length, id_prod, color, curr_css_class) { var current_arr_stars = Array(0); var arr_stars = $('div#rate_' + id_prod + ' a[name=a_rate]'); for (var x = pos_start; x < (parseInt(pos_start) + parseInt(length)); x++) { var css_class; if (color != '') { css_class = ((x % 2 == 1) ? color + '2' : color + '1'); } else { css_class = (curr_css_class != '') ? curr_css_class : ''; } current_arr_stars[x] = $(arr_stars[x]).attr('class'); $(arr_stars[x]).removeClass().addClass(css_class); } return current_arr_stars; } function bind_stars(id_prod) { $('div#rate_' + id_prod + ' a[name=a_rate]').each(function() { var data = $(this).attr('lang').split(':'); if (parseInt(data[0]) == 0 || parseInt(data[1]) == 0) return 0; $(this).attr('title', title_txt + data[0]); var current_arr_stars = Array(0); $(this).bind('mouseover', function() { var rate = $(this).attr('lang').split(':'); if (parseInt(rate[0]) == 0) return 0; var color; var pos; if (rate[0] < 0) { color = 'red'; pos = (Math.abs(rate[0]) < count) ? count - Math.abs(rate[0]) : 0; } else { color = 'green'; pos = count; } current_arr_stars = paint_stars(pos, Math.abs(rate[0]), data[1], color, ''); }); $(this).bind('mouseout', function() { if (current_arr_stars.length > 0) { for (q in current_arr_stars) { paint_stars(q, 1, data[1], '', current_arr_stars[q]); } } }); $(this).bind('click', function() { var id = data[1]; JsHttpRequest.query('hr_gate.php?test=500&r=' + Math.random(), { 'sp': "rate", 'id': id, 'abs': data[0] }, function(result, errors) { if (errors) alert(errors); if (result) { if (result.yet_voting > 0) { alert('Вы уже голосовали!'); return; } if (result.not_registered > 0) { alert('Чтобы проголосовать Вам необходимо зарегистрироваться!'); return; } if (result.new_data) render($('div#rate_' + id), result.new_data.count, result.new_data.rate, id); } }, true); }) }); } });