').parent().children('[data-type="'+type+'"]');
d.addClass('active');
console.log($(data));
// alert(type);
$("#witget-icons-choose").html(d);
}
});
}
ActiveMenu.witgets.iconsCats = function(e) {
$(e).parent().find('.active').removeClass('active');
$(e).addClass('active');
type = $(e).data('type');
$('#witget-icons-cat').val($(e).index());
ActiveMenu.witgets.icons(null);
// $("#witget-icons-choose").children('.active').removeClass('active');
// $("#witget-icons-choose").children('[data-type="'+type+'"]').addClass('active');
}
ActiveMenu.witgets.presets = function() {
Styles.presets.set(this.props.presetType, String(this.state.href));
}
ActiveMenu.witgets.position = function() {
Styles.fn.function('changePosition', {
value: String(this.state.href)
});
}
ActiveMenu.witgets.fontFamily = function() {
Styles.fontChange({
'font-family': String(this.state.href)
})
}
ActiveMenu.witgets.sectionControls = function() {
obj = {};
obj.controls = {}
obj.controls[this.props.type] = String(this.state.href);
Witgets.change({
slider: obj
});
}
ActiveMenu.witgets.productTemplate = function() {
Witgets.change({
template: String(this.state.href)
});
}
ActiveMenu.witgets.slideshowControls = function() {
Witgets.change({
slideshow: {
controls: String(this.state.href)
}
});
}
ActiveMenu.witgets.imageHover = function() {
Witgets.change({
actions: {
hover: {
type: String(this.state.href)
}
}
});
}
ActiveMenu.witgets.editor = function() {
value = this.state.href;
if(value == 'desktop') {
Holder.enable();
Hover.enable();
} else {
Holder.disable();
Hover.disable();
}
if(value == 'mobile') {
$('#editor-mobile-text').fadeIn(200);
} else {
$('#editor-mobile-text').hide();
}
$('#editor').removeClass('desktop tablet mobile').addClass(value);
}
ActiveMenu.witgets.tabs = function() {
value = this.state.href;
$('#modal div[id^=witget-content-]').hide();
$('#witget-content-'+value).show();
}
ActiveMenu.witgets.formPosition = function() {
Witgets.change({
form: {
position: this.state.href
}
});
}
ActiveMenu.statistic = {};
ActiveMenu.statistic.dateChange = function() {
value = this.state.href;
today = new Date();
today.setHours(0, 0, 0, 0);
if(value == 'day') {
range = [today];
} else if(value == 'week') {
date = new Date();
date.setDate(date.getDate() - 7);
range = [date, today];
} else if(value == 'month') {
date = new Date();
date.setDate(date.getDate() - 30);
range = [date, today];
} else if(value == '3months') {
date = new Date();
date.setDate(date.getDate() - 90);
console.log(today, date);
range = [date, today];
} else if(value == 'year') {
date = new Date();
date.setDate(date.getDate() - 365);
range = [date, today];
}
id = $('#'+this.props.calendar).data('ui');
ui.compiles[id].setState({
range: range,
month: today
});
}
ActiveMenu.billing = {};
ActiveMenu.billing.chooseTable = function() {
var _this = this;
tariff = parseInt(this.state.href);
// alert(tariff);
// _this.props.listElements.removeC
this.props.listElements.removeClass('outlined-blue').removeClass('active');
this.props.listElements.filter('[data-type="'+tariff+'"]').addClass('outlined-blue');
$.ajax({
url: '/scr/getPaymentPeriod',
type: 'post',
data: {
tariff: tariff
},
success: function (data) {
var block = $('#payment-block');
data = $(data);
if(block.length == 0) {
data.hide();
data.insertAfter($('#table-block'));
data.slideDown(400);
} else {
block.replaceWith(data);
}
block = $('#payment-block');
$("html, body").animate({
scrollTop: block.offset().top - 100
}, 400);
ui.mountAll();
ui.start();
}
});
// tariff = parseInt(this.props.tariff);
// tables = [5, 6, 7];
// $.each(tables, function(i, v) {
// if(v < tariff) {
// _this.props.listElements.eq(i).hide();
// }
// });
// alert(tariff)
}
ActiveMenu.billing.changeTariff = function() {
var _this = this;
tariff = parseInt(this.props.tariff);
// tables = [7, 6, 5];
// $.each(tables, function(i, v) {
// if(v < tariff) {
// _this.props.listElements.eq(i).hide();
// }
// });
// alert(tariff)
}
ActiveMenu.billing.period = function() {
price = this.props.price;
months = this.state.href;
multiuser = $('#price-multiuser');
userCount = multiuser.data('users');
multiuser.hide();
if(userCount > 0) {
multiuser.show();
multiuser.find('.check').html('Многопользовательский режим: '+userCount+' x 490 руб. = '+(userCount*490)+' рублей/месяц');
price += userCount * 490;
}
priceOne = price;
priceSix = (price * 0.85) - ((price * 0.85) % 10);
priceTwelve = (price * 0.75) - ((price * 0.75) % 10);
if(price == 590) {
priceTwelve = 190;
this.element.find('.label.corner.top.right').css('opacity', 0);
} else {
this.element.find('.label.corner.top.right').css('opacity', 1);
}
if(months == 1) total = priceOne;
if(months == 6) total = priceSix * months;
if(months == 12) total = priceTwelve * months;
// alert(total);
econom = Math.abs(priceOne * months - total);
this.props.listElements.eq(0).find('.cost').html(priceTwelve.commafy());
this.props.listElements.eq(1).find('.cost').html(priceSix.commafy());
this.props.listElements.eq(2).find('.cost').html(priceOne.commafy());
monthText = months.text(['месяц', 'месяца', 'месяцев'], true);
$('#'+this.props.total).html('\
Итого: '+total.commafy()+'
');
$('#'+this.props.button).data({
'tariff': this.props.tariff,
'months': months
});
}
colorPicker.witgets = {}
colorPicker.multipleInputColor = function() {
label = this.element.closest('.label');
input = this.element.closest('.input.multiple');
i = label.data('index');
hex = toHEX(this.state.color);
state = input.ui('getState');
state.value[i].value = '#' + hex;
label.find('.button.color').css('background', '#' + hex);
}
toHEX = function(c){
return ("0" + parseInt(c[0], 10).toString(16)).slice(-2) +
("0" + parseInt(c[1], 10).toString(16)).slice(-2) +
("0" + parseInt(c[2], 10).toString(16)).slice(-2);
}
colorPicker.witgets.styles = function() {
var c = this.state.color;
obj = {};
obj[this.props.type] = 'rgba('+c[0]+','+c[1]+','+c[2]+','+c[3]+')';
Styles.change(obj, false);
hex = Styles.colors.toHEX(c);
this.element.closest('.dropdown-input').find('input').val(hex);
this.element.closest('.dropdown-input').find('.label.start').find('.color')
.css('background-color', obj[this.props.type]);
this.props.opacity.css('background-color', 'rgb('+c[0]+','+c[1]+','+c[2]+')');
if(this.props.type == 'background-color') {
Styles.fn.shadowBlock(obj[this.props.type]);
}
}
colorPicker.witgets.fontStyles = function() {
var c = this.state.color;
obj = {};
obj[this.props.type] = 'rgba('+c[0]+','+c[1]+','+c[2]+','+c[3]+')';
Styles.fontChange(obj);
hex = Styles.colors.toHEX(c);
this.element.closest('.dropdown-input').find('input').val(hex);
this.element.closest('.dropdown-input').find('.label.start').find('.color')
.css('background-color', obj[this.props.type]);
this.props.opacity.css('background-color', 'rgb('+c[0]+','+c[1]+','+c[2]+')');
}
ActiveSlider.styles = {};
ActiveSlider.styles.fz = function() {
obj = {};
obj['font-size'] = this.state.value;
Styles.change(obj);
}
ActiveSlider.styles.fontStyles = function() {
obj = {};
obj['font-size'] = this.state.value;
Styles.fontChange(obj);
}
ActiveSlider.styles.bradius = function() {
obj = {};
type = this.props.style;
console.log(type, this.state.value);
if(type == 'all') {
obj['border-top-left-radius'] = this.state.value;
obj['border-top-right-radius'] = this.state.value;
obj['border-bottom-left-radius'] = this.state.value;
obj['border-bottom-right-radius'] = this.state.value;
} else {
obj['border-'+type+'-radius'] = this.state.value;
}
Styles.change(obj);
}
ActiveSlider.styles.indent = function() {
obj = {};
type = this.props.styleType;
prop = this.props.style;
aprop = (prop == 'border') ? '-width' : '';
console.log(prop, type, this.state.value);
if(type == 'all') {
obj[prop+'-top'+aprop] = this.state.value;
obj[prop+'-bottom'+aprop] = this.state.value;
obj[prop+'-left'+aprop] = this.state.value;
obj[prop+'-right'+aprop] = this.state.value;
} else {
obj[prop+'-'+type+aprop] = this.state.value;
}
Styles.change(obj);
}
ActiveSlider.generator = {};
ActiveSlider.generator.color = function() {
value = this.state.value + 25;
value = value <= 360 ? value : 360;
Generator.beauty.mode = 'color';
Generator.pallete(value);
Generator.beauty.mode = 'all';
}
ActiveSlider.generator.size = function() {
value = this.state.max - this.state.value;
// alert(value);
Generator.templateNumber = parseInt(value);
template = Generator.templates[Generator.landingType].templates[Generator.templateNumber];
text = '('+template.length.text(['секция', 'секции', 'секций'], true)+')';
$('#Generator-landing-size-name').html(text);
}
ActiveSlider.witgets = {};
ActiveSlider.witgets.slideshow = function() {
value = (this.state.value > 0) ? this.state.value + ' сек.' : 'Вручную';
this.element.siblings('.value').html(value);
if(this.props.isMove) return false;
Witgets.change({
slideshow: {
time: this.state.value
}
}, false);
}
ActiveSlider.witgets.section = function() {
value = (this.state.value > 0) ? this.state.value + ' сек.' : 'Вручную';
this.element.siblings('.value').html(value);
if(this.props.isMove) return false;
Witgets.change({
slider: {
time: this.state.value
}
}, false);
}
ActiveSlider.witgets.gallery = function() {
this.element.siblings('.value').html(this.state.value);
if(this.props.isMove) return false;
Witgets.change({
gallery: {
quantity: this.state.value
}
}, false);
}
ActiveSlider.witgets.image = function() {
var self = this;
this.element.siblings('.value').html(this.state.value);
if(this.props.isMove) return false;
Caman("#canvas-id",function() {
this.revert();
brightness = $('#witget-brightness').ui('getState', 'value');
stackBlur = $('#witget-stackBlur').ui('getState', 'value');
contrast = $('#witget-contrast').ui('getState', 'value');
this.brightness(brightness);
this.stackBlur(stackBlur);
this.contrast(contrast);
this.render();
// this.crop(400, 400, 50, 50);
// this.render();
});
}
ActiveSlider.referals = function() {
value = this.state.value;
price = value*1970*0.4;
$("#slider-clients").html(Math.round(this.state.value/30).text(['клиенту', 'клиента', 'клиентов'], true));
$('#slider-1-months').html(price.commafy());
$('#slider-3-months').html((price*3).commafy());
$('#slider-6-months').html((price*6).commafy());
$('#slider-12-months').html((price*12).commafy());
$('#slider-24-months').html((price*24).commafy());
// alert(value);
}
ActiveInput.commerce = {};
colorTimeout = null;
// синий, черный, белый, красный, зеленый
getHexColorByName = function(name) {
color = false;
switch (name.toLowerCase()) {
case 'красный': color = '#FF2B2B'; break;
case 'синий': color = '#2B75FF'; break;
case 'зеленый': color = '#57D647'; break;
case 'черный': color = '#000000'; break;
case 'белый': color = '#ffffff'; break;
}
return color;
}
ActiveInput.colorParams = function() {
var _this = this;
$.each(this.state.value, function(i, v) {
if(!v.value.match(/\#/gi)) {
color = getHexColorByName(v.name);
console.log(v.name, color);
if(color !== false) {
v.value = color;
}
}
label = _this.props.input.siblings('.label[data-index="'+i+'"]');
label.children('.dropdown').remove();
label.prepend('\
');
});
// clearInterval(t);
clearTimeout(colorTimeout);
colorTimeout = setTimeout(function() {
ui.mountAll();
ui.start();
}, 400);
Product.changeParamSettings(this.element[0], {
values: this.state.value
});
}
ActiveInput.valuesParams = function() {
Product.changeParamSettings(this.element[0], {
values: this.state.value
});
}
ActiveInput.nameParams = function() {
Product.changeParamSettings(this.element[0], {
name: this.state.value
});
}
ActiveInput.valuesParamsAdditional = function() {
Product.changeParamSettings(this.element[0], {
values: [{
name: this.state.value,
value: this.state.value,
}]
});
}
ActiveInput.colorPickerShow = function(e) {
$('body')
pos = $(e).position();
picker = $(e).closest('.field').siblings('.color-picker');
picker.show();
}
ActiveInput.commerce.comment = function() {
var _this = this;
if(this.props.timeout != null) {
clearTimeout(this.props.timeout);
}
update = function() {
label = $('
Комментарий сохранен ');
_this.element.find('label.text').remove();
_this.element.append(label);
label.fadeOut(2500, function() {
label.remove();
});
$.ajax({
url: '/scr/updateOrderComment',
type: 'post',
data: 'id='+_this.props.id+'&comment='+_this.state.value
});
};
this.props.timeout = setTimeout(update, 500);
}
ActiveForm.login = function() {
answer = this.state.answer;
console.log(answer);
if(!this.state.loading) {
if(answer.status) {
YandexID.reachGoal('login');
ga('send', 'event', 'button', 'click', 'enter');
window.location.pathname = '/dashboard/';
} else {
this.setAnswer(answer.status, answer.text);
}
}
}
ActiveForm.generateSave = function() {
if(!this.state.loading) {
answer = this.state.answer;
console.log(answer);
if(answer.status) {
YandexID.reachGoal('reg');
ga('send', 'event', 'button', 'click', 'reg');
} else {
this.setAnswer(answer.status, answer.text);
}
}
}
ActiveForm.start = function() {
if(!this.state.loading) {
answer = this.state.answer;
console.log(answer);
if(answer.status) {
YandexID.reachGoal('reg');
ga('send', 'event', 'button', 'click', 'reg');
window.location.pathname = '/dashboard/';
} else {
this.setAnswer(answer.status, answer.text);
}
}
}
ActiveForm.reload = function() {
if(!this.state.loading) {
answer = this.state.answer;
console.log(answer);
if(answer.status) {
window.location.reload();
} else {
this.setAnswer(answer.status, answer.text);
}
}
}
ActiveForm.editPage = function() {
if(!this.state.loading) {
answer = this.state.answer;
console.log(answer);
if(answer.status) {
window.location.reload();
} else {
this.setAnswer(answer.status, answer.text);
}
}
}
ActiveForm.simple = function() {
if(!this.state.loading) {
answer = this.state.answer;
this.setAnswer(answer.status, answer.text);
setTimeout(function() {
Modal.hide();
}, 1500);
}
}
ActiveForm.product = {}
ActiveForm.product.create = function() {
if(!this.state.loading) {
answer = this.state.answer;
$('#products').html(answer.products);
$('#product-products').fadeIn();
$('#product-new-product').hide();
ui.mountAll();
ui.start();
}
}
ActiveForm.product.edit = function() {
if(!this.state.loading) {
answer = this.state.answer;
$('#products').html(answer.products);
$('#product-products').fadeIn();
$('#product-new-product').hide();
$('#product-edit-product').hide();
ui.mountAll();
ui.start();
}
}
ActiveForm.recovery = {}
ActiveForm.recovery.send = function() {
if(!this.state.loading) {
answer = this.state.answer;
this.setAnswer(answer.status, answer.text);
}
}
ActiveForm.recovery.pass = function() {
if(!this.state.loading) {
answer = this.state.answer;
if(answer.status) {
window.location.reload();
} else {
this.setAnswer(answer.status, answer.text);
}
}
}
ActiveForm.account = function() {
if(!this.state.loading) {
answer = this.state.answer;
if(answer.status) {
$('#button-account').ui('setState', {
isVisible: false
});
// window.location.href = '/content/' + answer.site;
} else {
alert(answer.text)
}
}
}
ActiveForm.closeModal = function() {
if(!this.state.loading) {
answer = this.state.answer;
if(answer.status) {
id = $('#modal .modal').data('ui-button');
u = ui.compiles[id];
u.setState({ isVisible: false });
} else {
this.setAnswer(answer.status, answer.text);
}
}
}
ActiveForm.billing = {};
ActiveForm.createPage = function() {
if(!this.state.loading) {
answer = this.state.answer;
if(answer.status) {
Modal.hide();
window.location.href = '/content/' + answer.site;
} else {
if(typeof answer.disallow != 'undefined') {
Modal.hide();
Modal.show({
src: 'disallowSites'
});
} else {
alert(answer.text)
}
}
}
}
ActiveForm.modalHide = function() {
if(!this.state.loading) {
answer = this.state.answer;
if(answer.status) {
Modal.hide();
} else {
alert(answer.text)
}
}
}
ActiveForm.modalHide = function() {
if(!this.state.loading) {
answer = this.state.answer;
if(answer.status) {
alert(answer.text);
} else {
alert(answer.text)
}
}
}
ActiveForm.billing.promocode = function() {
if(!this.state.loading) {
answer = this.state.answer;
if(answer.type == 'fail') {
var message = $('
');
$('#promocode-billing').html(message);
setTimeout(function() {
message.fadeOut(500, function() {
});
}, 1500)
} else {
window.location.reload();
}
}
}
ActiveForm.billing.phone = function() {
if(!this.state.loading) {
alert('Данные обновлены. Теперь вы будете получать уведомления');
}
}
ActiveForm.dashboard = {};
ActiveForm.dashboard.content = function() {
if(!this.state.loading) {
answer = this.state.answer;
console.log(answer);
if(answer.status) {
window.location.href = '/content/' + answer.site;
} else {
alert(answer.text)
}
}
}
ActiveForm.dashboard.updatePhone = function() {
if(!this.state.loading) {
id = $('#modal .modal').data('ui-button');
u = ui.compiles[id];
u.setState({ isVisible: false });
u.element.remove();
}
}
ActiveForm.dashboard.updateSeo = function() {
if(!this.state.loading) {
id = $('#modal .modal').data('ui-button');
ui.compiles[id].setState({isVisible: false});
}
}
ActiveForm.dashboard.integrationBitrix24 = function() {
if(!this.state.loading) {
answer = this.state.answer;
if(answer.status) {
if(answer.type != 'delete') {
window.location.href = answer.text;
}
} else {
alert(answer.text)
}
}
}
ActiveForm.dashboard.refresh = function() {
if(!this.state.loading) {
answer = this.state.answer;
if(answer.status) {
window.location.reload();
} else {
alert(answer.text)
}
}
}
ActiveForm.dashboard.createSite = function() {
if(!this.state.loading) {
answer = this.state.answer;
// console.log(answer);
// return;
if(answer.status) {
window.location.href = '/content/' + answer.site;
} else {
alert(answer.text)
}
}
}
ActiveForm.help = {};
ActiveForm.help.question = function() {
if(!this.state.loading) {
answer = this.state.answer;
console.log(answer);
if(answer.status) {
try {
var win = window.open('/help/question/' + answer.id, '_blank');
win.focus();
} catch (e) {
console.warn(e);
}
Modal.hide();
} else {
alert(answer.text)
}
}
}
Clickable.witgets = {};
Clickable.statistic = {};
Clickable.statistic.checkUTM = function(e) {
checked = $(e).prop('checked');
item = $(e).closest('.item');
all_items = item.parent().children();
search_query = [];
search_query_used = [];
data = item.data();
length = Object.keys(data).length;
utm_all = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content'];
i = 0;
console.log(data);
$.each(utm_all, function(i, utm_type) {
search_query_used.push(utm_type);
query = [];
console.log(search_query_used)
all_items.each(function() {
item_data = $(this).data();
allow = true;
$.each(item_data, function(utm_type, utm_value) {
if(search_query_used.indexOf(utm_type) == -1) {
allow = false;
return;
} else {
console.info(item_data[utm_type], data[utm_type]);
if(typeof data[utm_type] != 'undefined') {
if(item_data[utm_type] != data[utm_type]) {
allow = false;
return;
}
}
}
});
if(allow) {
$(this).find('input[type=checkbox]').prop('checked', checked);
}
// console.log('------');
});
});
Calendar.statistic.update(this, false);
}
Clickable.statistic.showUTM = function(e) {
var _this = this,
item = $(e).closest('.item');
show = !$(e).data('show');
if(show) {
$(e).html('
');
vars = {};
arr = window.location.search.substring(1, window.location.search.length).split('&');
$.each(arr, function(i, v) {
v = v.split('=');
vars[v[0]] = v[1];
});
calendar = $('#calendar-statisitc').ui('get');
range = calendar.element.data('range');
// utm = $('#utms-dropdown').ui('getState', 'value');
postData = {
site: vars['site'],
dates: range,
utms: item.data()
};
$.ajax({
url: '/statistic/utms',
type: 'post',
dataType: 'json',
data: postData,
success: function (data) {
// console.log(data, typeof data);
$(data.html).insertAfter(item);
ui.mountAll();
ui.start();
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(jqXHR.responseText);
}
});
} else {
$(e).html('
');
search_query = [];
$.each(item.data(), function(i, v) {
search_query.push('[data-' + i + '="' + v + '"]');
});
items = item.parent().children(search_query.join('')).not(item);
items.remove();
}
$(e).data('show', show);
}
Clickable.witgets.styles = function() {
var _this = this;
id = this.props.for;
if(!_this.element.hasClass('active')) {
this.element.parent().children('.grid.active').slideUp(200, function() {
$(this).removeClass('active');
$(this).prev().removeClass('active');
});
_this.element.addClass('active');
$('#'+id).slideDown(200, function() {
$(this).addClass('active')
});
}
}
Clickable.witgets.stylesFull = function() {
slider = this.element.prev();
full = this.element.next();
if(this.element.hasClass('active')) {
this.element.removeClass('active').css('margin-top', 0).html('Расширенные настройки');
slider.slideDown(300);
full.slideUp(300);
} else {
this.element.addClass('active').css('margin-top', 20).html('Назад к общей настройке');
slider.slideUp(300);
full.slideDown(300);
}
}
Clickable.products = {};
Clickable.products.choose = function() {
productID = this.element.closest('.site-block').data('id');
Witgets.change({
form: {
settings: {
product: productID
}
}
});
Modal.hide(true);
}
Clickable.products.edit = function() {
block = this.element.closest('.site-block');
productID = Witgets[Witgets.current.type].state.form.settings.product;
$.ajax({
url: '/scr/getProduct',
type: 'post',
data: {
productID: block.data('id')
},
dataType: 'json',
success: function (data) {
$('#product-products').hide();
$('#product-new-product').hide();
$('#product-edit-product').fadeIn();
form = $('#product-edit-product form');
form.find('input[name="name"]').val(data.name);
form.find('input[name="amount"]').val(data.amount);
form.find('input[name="id"]').val(data.id);
form.find('input[name="currency"]').val(data.currency);
form.find('.input-currency .dropdown-list li[data-type="'+data.currency+'"]').click();
}
});
}
Clickable.products.remove = function() {
block = this.element.closest('.site-block');
productID = Witgets[Witgets.current.type].state.form.settings.product;
$.ajax({
url: '/scr/deleteProduct',
type: 'post',
data: {
productID: block.data('id'),
siteID: Settings.siteID
},
success: function (data) {
block.fadeOut(200, function() {
$(this).remove();
});
}
});
if(productID == block.data('id')) {
Witgets.change({
form: {
settings: {
product: 'null'
}
}
});
}
}
Clickable.billing = {};
Clickable.billing.payment = function() {
data = $.extend(true, this.props, {
src: 'payBilling'
});
delete data.callback;
delete data.ui;
console.log(data);
Modal.show(data);
}
Clickable.billing.chooseTariff = function() {
$.ajax({
type: 'POST',
url: '/scr/getTariffPay',
data: 'tariff='+this.props.tariff,
success: function (data) {
$('#billing-table').fadeOut(300, function() {
e = $(data);
$(this).replaceWith(e);
e.hide().fadeIn(300);
ui.mountAll();
ui.start();
});
}
});
}
Clickable.commerce = {};
Clickable.commerce.export = function() {
formPayment = $('
');
formPayment.hide();
formPayment.appendTo('body');
formPayment.submit();
}
Clickable.dashboard = {};
Clickable.dashboard.getInvoice = function() {
formPayment = $('
');
formPayment.hide();
formPayment.appendTo('body');
formPayment.submit();
}
Clickable.dashboard.callbackhunter = function() {
phone = $('#callbackhunter-phone').val();
domain = $('#callbackhunter-domain').val();
if(phone == '') {
alert('Поле «Телефон» обязательно для заполнения. На этот телефон будут приходить звонки от ваших клиентов.');
return;
}
$.ajax({
url: '/scr/callbackhunter',
type: 'post',
data: {
phone: phone,
domain: domain
},
dataType: 'json',
success: function (data) {
if(data.status == 'error') {
alert(data.error_descr);
} else {
alert("Данные для входа в систему callbackhunter: " + data.email + " пароль: " + data.pass);
form = $('#callbackhunter-domain').closest('form');
form.find('input[name="apiKey"]').val(data.tracker_code);
form.submit();
}
}
});
}
Clickable.dashboard.callbackKiller = function() {
var _this = this;
domain = $('#callbackKiller-domain').val();
this.element.addClass('loading disabled');
$.ajax({
url: '/scr/callbackKiller',
type: 'post',
data: {
domain: domain
},
dataType: 'json',
success: function (data) {
_this.element.removeClass('loading disabled');
// alert(data)
if(!data.status) {
alert(data.text);
} else {
form = $('#callbackKiller-domain').closest('form');
form.find('input[name="apiKey"]').val(data.key);
form.submit();
}
}
});
}
Clickable.dashboard.endTest = function() {
if(this.element.hasClass('grey')) {
this.element.removeClass('grey').addClass('blue').html(this.props.text );
this.element.parent().parent().find('.universal-block').removeClass('choose');
this.element.parent().find('.holder').slideUp();
} else {
this.props.text = this.element.text();
this.element.addClass('grey').removeClass('blue').html('Продолжить A/B тестирование');
this.element.parent().parent().find('.universal-block').addClass('choose');
this.element.parent().find('.holder').slideDown();
}
}
Clickable.dashboard.changeSiteSettings = function(e) {
site = $(e).data('site');
type = $(e).data('type');
value = $(e).is(':checked') ? 1 : 0;
if(type == 'ssl') {
$(e).prop('disabled', 'disabled');
$(e).parent().addClass('loading-content');
setTimeout(function() {
$(e).parent().removeClass('loading-content');
$(e).prop('disabled', 'false');
}, 5 * 60 * 1000);
}
// alert(site + ' ' + type + " " + value)
$.ajax({
url: '/scr/changeSiteSettings',
type: 'post',
data: {
site: site,
type: type,
value: value
},
// dataType: 'json',
success: function (data) {
console.log(data)
// window.location.reload();
}
});
}
Clickable.dashboard.changeStatusPage = function() {
$.ajax({
url: '/scr/changeStatusPage',
type: 'post',
data: {
site: this.props.site,
status: this.props.status
},
// dataType: 'json',
success: function (data) {
// console.log(data)
window.location.reload();
}
});
}
Clickable.dashboard.createTest = function() {
$.ajax({
url: '/scr/createTest',
type: 'post',
data: {
site: this.props.site
},
dataType: 'json',
success: function (data) {
// alert(data)
if(data.status) {
window.location.reload();
} else {
Modal.show({
src: data.modal,
data: data
});
}
}
});
}
Clickable.dashboard.removeUserRule = function() {
$.ajax({
url: '/scr/removeUserRule',
type: 'post',
data: {
id: this.props.id
},
dataType: 'json',
success: function (data) {
// alert(data)
if(data.status) {
window.location.reload();
} else {
alert(data.text)
}
}
});
}
Clickable.dashboard.chooseTest = function() {
// alert(this.props.site)
$.ajax({
url: '/scr/chooseTest',
type: 'post',
data: {
site: this.props.site
},
dataType: 'json',
success: function (data) {
console.log(data);
// alert(data)
if(data.status) {
window.location.reload();
} else {
Modal.show({
src: data.modal
});
}
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(jqXHR.responseText);
}
});
}
Clickable.dashboard.createNewTest = function() {
$.ajax({
url: '/scr/createTest',
type: 'post',
data: {
test: this.props.test
},
dataType: 'json',
success: function (data) {
// alert(data)
if(data.status) {
window.location.reload();
} else {
Modal.show({
src: data.modal
});
}
}
});
}
Clickable.dashboard.copyPage = function() {
$.ajax({
url: '/scr/copyPage',
type: 'post',
data: {
site: this.props.site
},
dataType: 'json',
success: function (data) {
if(data.status) {
window.location.reload();
} else {
Modal.show({
src: 'disallowSites'
});
}
}
});
}
Clickable.dashboard.copyFullSite = function() {
$.ajax({
url: '/scr/copyFullSite',
type: 'post',
data: 'id='+this.props.site,
dataType: 'json',
success: function (data) {
// alert(data)
if(data.status) {
window.location.reload();
} else {
Modal.show({
src: 'disallowSites'
});
}
}
});
}
Clickable.dashboard.createPageEditor = function() {
Modal.show({
src: 'createPage',
site: this.props.site,
domain: this.props.domain
});
}
Clickable.dashboard.createSite = function() {
$.ajax({
url: '/scr/allow',
type: 'post',
data: {
type: 'create_site'
},
dataType: 'json',
success: function (data) {
if(data.status) {
Modal.show({
src: 'createSite'
});
} else {
Modal.show({
src: 'disallowSites'
});
}
}
});
}
Clickable.dashboard.logout = function() {
$.ajax({
url: '/scr/logout',
type: 'post',
success: function (data) {
window.location.href = '/';
}
});
}
Clickable.dashboard.createPage = function() {
Modal.show({
src: 'createPage',
site: this.props.site,
domain: this.props.domain
});
}
Clickable.dashboard.publicSite = function() {
if(this.props.status == 1) {
this.props.status = 0;
this.element.removeClass('green').addClass('red').html('Нажмите, чтобы опубликовать');
} else {
this.props.status = 1;
this.element.removeClass('red').addClass('green').html('Опубликован');
}
$.ajax({
url: '/scr/publishSite',
type: 'post',
data: 'id='+this.props.site
});
}
Clickable.dashboard.roboCall = function() {
site = $('#site-domain').text();
email = $('#user-email').val();
window.addEventListener("message", RoboCall.integrate, false);
window.open("http://rbcall.com/request.php?api=1&url=http://"+site+"&email="+email, "_blank", "height=400, width=550, status=yes, toolbar=no, menubar=no, location=no,addressbar=no");
}
RoboCall = {};
RoboCall.integrate = function(props) {
props = props.data;
// alert('Yuuuupeeeeee!!');
console.log(props);
form = $('#RoboCall');
form.find(':input[name=apiID]').val(props.u);
form.find(':input[name=apiKey]').val(props.s);
form.submit();
window.removeEventListener("message", RoboCall.integrate, false);
}
// window.opener.postMessage({ a: 'a' }, 'http://localhost/');
Dialog.dashboard = {};
Dialog.dashboard.deletePage = function() {
$.ajax({
url: '/scr/deletePage',
type: 'post',
data: {
site: this.props.site
},
dataType: 'json',
success: function (data) {
// alert(data);
window.location.reload();
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(jqXHR.responseText);
}
});
}
Dialog.dashboard.deleteFullSite = function() {
$.ajax({
url: '/scr/deleteFullSite',
type: 'post',
data: 'id='+this.props.site,
dataType: 'json',
success: function (data) {
if(data.status) {
window.location.reload();
} else {
Modal.show({
src: 'disallowSites'
});
}
}
});
}
MultiFormPrice.billing = function() {
var _this = this;
if(_this.state.currentTab == 'pay') {
$('#billing-pay-tab').show();
} else {
$('#billing-pay-tab').hide();
}
}
Calendar.statistic = {};
Calendar.statistic.lastRange = [];
Calendar.statistic.lastGoal = false;
Calendar.statistic.lastUtm = false;
Calendar.statistic.sparklineCharts = {};
Calendar.statistic.update = function(e, changeUTM) {
changeUTM = typeof changeUTM == 'undefined' ? true : changeUTM;
var _this = this;
// setTimeout(function () {
var sparklineCharts = Calendar.statistic.sparklineCharts;
vars = {};
arr = window.location.search.substring(1, window.location.search.length).split('&');
$.each(arr, function(i, v) {
v = v.split('=');
vars[v[0]] = v[1];
});
calendar = $('#calendar-statisitc').ui('get');
range = calendar.element.data('range');
goal = $('#goals-dropdown').ui('getState', 'value');
utms = {};
$('#statistic-utm-table tbody .item').each(function() {
checked = $(this).find('input[type=checkbox]').prop('checked');
if(checked) {
$.each($(this).data(), function(k, v) {
if(typeof utms[k] == 'undefined') {
utms[k] = [];
}
if(utms[k].indexOf(v) == -1) {
utms[k].push(v);
}
});
}
});
postData = {
site: vars['site'],
dates: range,
utm: utms,
goal: goal
};
condition = true;//(calendar.state.month.getMonth() == calendar.state.lastMonth || Calendar.statistic.lastRange.equals(postData.dates) || Calendar.statistic.lastGoal != postData.goal);
if (condition) {
$.ajax({
url: '/statistic/update',
type: 'post',
dataType: 'json',
data: postData,
success: function (data) {
console.log(data, typeof data);
// return;
// alert(data)
if(data.isEmpty != false) {
$('body').append(data.isEmpty);
}
$('#goals-list').html('
Все цели ');
$.each(data.goals, function(i, v) {
$('#goals-list').append('
'+v+' ');
});
ui.remount($('#goals-dropdown'));
todayTime = new Date().getTime() / 1000;
var isToday = todayTime >= data.dates[0] && todayTime <= data.dates[1];
if(changeUTM) {
$('#statistic-utm-table tbody').html(data.utms);
}
$.each(data.graph1, function(i, v) {
k = null;
if(i == 'visits') k = 1;
if(i == 'views') k = 0;
if(i == 'order') k = 2;
if(i == 'call') k = 3;
if(i == 'subscribe') k = 4;
if(k != null) {
v.data.lineWidth = 1;
window.visitChart.series[k].setData(v.data, false);
}
// if(!v.visible) {
// // window.visitChart.series[k].remove(true);
// } else {
// window.visitChart.addSeries({
// name: array.teamName,
// data: v.data
// }, false);
// }
});
$.each(data.graph2, function(i, v) {
if(i == 'all') k = 0;
if(i == 'end') k = 1;
window.ctrChart.series[k].setData(v.data, false);
});
$('#device-mobile').html(data.devices.mobile + '%');
$('#device-desktop').html(data.devices.desktop + '%');
$('#device-tablet').html(data.devices.tablet + '%');
$('.mini-statistic-rates').each(function(i) {
var type = $(this).data('type'),
info = data.sparkline[type] || data.sparkline['visits'];
$(this).find('.statistic-period').html(info.period);
$(this).find('.statistic-average').html(info.average);
$(this).find('.statistic-today').html(info.today);
if(isToday) {
$(this).find('.statistic-today-block').show();
} else {
$(this).find('.statistic-today-block').hide();
}
if(type == 'leads') {
ctr = Math.round(data.sparkline['leads'].period / data.sparkline['visits'].period * 100 * 100) / 100;
if(data.sparkline['visits'].period == 0) {
ctr = 0;
}
$(this).find('.statistic-ctr').html(ctr);
}
if(type == 'orders') {
ctr = Math.round(data.sparkline['orders'].period / data.sparkline['leads'].period * 100 * 100) / 100;
if(data.sparkline['leads'].period == 0) {
ctr = 0;
}
$(this).find('.statistic-ctr').html(ctr);
}
$(this).find('.statistic-sparkline-graphic').each(function() {
$(this).attr('data-value', JSON.stringify(info.data));
colors = ['#D95C5C', '#5BBD72', '#564F8A', '#009cff', '#E96633'];
if(typeof sparklineCharts[type] != 'undefined') {
sparklineCharts[type].series[0].setData(info.data, false);
} else {
$(this).highcharts('SparkLine', {
colors: [colors[i]],
series: [{
data: $(this).data('value'),
pointStart: 1
}],
tooltip: {
headerFormat: '
, Q{point.x}: ',
pointFormat: '
{point.y}.000 USD'
},
chart: {}
});
sparklineCharts[type] = Highcharts.charts[$(this).data('highchartsChart')];
}
});
});
for (var i = 0; i < Highcharts.charts.length; i++) {
Highcharts.charts[i].redraw();
};
ui.mountAll();
ui.start();
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(jqXHR.responseText);
}
});
}
// }, 1000)
}
// $('#container').highcharts(chart);
Modal.index = 0;
Modal.show = function(params) {
var callback = params.ready || function() {};
delete params.ready;
Modal.index++;
$.ajax({
url: '/modals/'+params.src,
type: 'post',
data: params,
success: function (data) {
$('body').css('overflow', 'hidden');
className = (params.class) ? params.class : '';
// modalID = (params.over) ? 'modal' : 'modal';
modal = $('
').hide();
modal.find('.modal').css({
'margin-top': params.marginTop || 70,
'opacity': 0
});
$('body').append(modal);
$('#modal[data-id="'+Modal.index+'"] .close-modal').on('click', function() {
Modal.hide();
})
modal.fadeIn(200);
modal.find('.modal').animate({
'margin-top': params.marginTop+30 || 100,
'opacity': 1
}, 200);
callback(modal);
ui.mountAll();
ui.start();
// alert(Modal.index + ' open ');
}, error: function(err) {
alert('/modal/'+params.src);
console.error(err);
}
});
}
Modal.hide = function(isOver) {
// alert(Modal.index + ' clsoe ');
// if(isOver) {
// modal = $('#modal-over');
// } else {
$('body').css('overflow', 'auto');
var modal = $('#modal[data-id="'+Modal.index+'"]');
// }
modal.fadeOut(200);
modal.find('.modal').animate({
'margin-top': 170,
'opacity': 0
}, 200, function() {
modal.remove();
});
Modal.index--;
// alert(Modal.index);
}
var elementsSettings = null;
setGoal = function(e) {
if($(e).hasClass('box-button')) {
e = $(e).find('.button')[0];
}
offset = $(e).offset();
body = $(e).closest('body');
height = $(e).height();
width = $(e).outerWidth();
if(elementsSettings == null)
elementsSettings = $.parseJSON(decodeURIComponent(body.find('#Setup-elements').val()));
id = $(e).closest('.drop-element').data('id');
set = elementsSettings[id].goals || {
name: '',
yandex: '',
google: '',
stats: false
};
console.log(set, id);
body.find('.goal-list').remove();
list = $('
');
list.css({
top: offset.top + 60,
left: offset.left + (width - 300)/2,
}).show();
body.append(list);
}
closeGoal = function(e) {
list = $(e).closest('.goal-list');
list.remove();
}
saveGoal = function(e, id) {
list = $(e).closest('.goal-list');
body = $(e).closest('body');
elementsSettings[id].goals = {
name: list.find(':input[name="name"]').val(),
yandex: list.find(':input[name="yandex"]').val(),
google: list.find(':input[name="google"]').val(),
stats: list.find(':input[name="stats"]').is(':checked')
};
console.log(elementsSettings[id].goals, id);
$.ajax({
url: '/scr/saveDD',
type: 'post',
data: {
'id': $('#siteID').val(),
'elements': elementsSettings,
'type': 'elements'
}
});
list.remove();
}
ui.mountAll = function() {
// $('div.history').each(function() {
// if($(this).data('type').match(/http/g) == null) {
// console.log($(this))
// ui.mount('ActiveHistory', $(this));
// }
// });
$('.dropdown-text').each(function() {
ui.mount('Dropdown', $(this), {
button: $(this).children('.text'),
dropdown: $(this).children('.list')
});
});
$('.dropdown-input').each(function() {
ui.mount('Dropdown', $(this), {
button: $(this).find('.input > :input, .input > .label'),
dropdown: $(this).children('.list'),
closeOnClick: false
});
});
$('.dropdown-full-input').each(function() {
ui.mount('Dropdown', $(this), {
button: $(this).find('.input'),
dropdown: $(this).children('.list')
});
});
$('.Dialog').each(function() {
ui.mount('Dialog', $(this));
});
$('.dropdown-button').each(function() {
ui.mount('Dropdown', $(this), {
button: $(this).children('.button'),
dropdown: $(this).children('.list')
});
});
$('.AutoResizable').each(function() {
ui.mount('AutoResizable', $(this));
});
$('.Clickable').each(function() {
ui.mount('Clickable', $(this));
});
$('.Promocode').each(function() {
ui.mount('Promocode', $(this));
});
$('.Carousel').each(function() {
ui.mount('Carousel', $(this), {
listElements: $(this).children('li, .carousel-block'),
hidenBlock: '.carousel-text'
});
});
$('.Modules').each(function() {
ui.mount('Modules', $(this), {
modules: $(this).children('.universal-block:not(.hidden)'),
});
});
$('.ActiveMenu').each(function() {
ui.mount('ActiveMenu', $(this), {
listElements: $(this).children('li, div')
});
});
$('.ActivePrice').each(function() {
ui.mount('ActiveMenu', $(this), {
listElements: $(this).find('.universal-block')
});
});
ui.mount('Integrations', $('#Integrations'));
$('.ActiveModal').each(function() {
ui.mount('Modal', $(this));
});
$('.ActiveForm').each(function() {
ui.mount('ActiveForm', $(this));
});
$('.ActiveNotification').each(function() {
ui.mount('ActiveNotification', $(this));
});
$('.ActiveProgress').each(function() {
ui.mount('ActiveProgress', $(this), {
progress: $(this).find('.line'),
text: $(this).find('.text')
});
});
$('.Domains').each(function() {
ui.mount('Domains', $(this), {
inputs: $(this).find('input[type=radio]')
});
});
$('#utm').each(function() {
ui.mount('Utm', $(this), {
link: $(this).find('.utm-link'),
site: $(this).find('[data-type=site]'),
source: $(this).find('[data-type=source]'),
medium: $(this).find('[data-type=medium]'),
campaign: $(this).find('[data-type=campaign]'),
campaign_1: $(this).find('[data-type=campaign_1]'),
campaign_2: $(this).find('[data-type=campaign_2]')
});
});
$('.ActiveTabs').each(function() {
ui.mount('ActiveTabs', $(this), {
listElements: $(this).children('li, div')
});
});
$('.ActiveSlider').each(function() {
ui.mount('ActiveSlider', $(this), {
input: $(this).parent().find('.value input'),
circle: $(this).find('.circle'),
line: $(this).find('.line'),
progress: $(this).find('.progress'),
digits: $(this).find('.digits'),
});
});
$('.ActivatedInput').each(function() {
ui.mount('ActivatedInput', $(this), {
input: $(this).find('.input input'),
inputs: $(this).children('.list'),
buttonShow: $(this).find('.button-show'),
buttonClose: $(this).find('.button-close')
});
});
$('.input:not(.upload)').each(function() {
perfect = $(this).children('.perfect-input');
isPerfect = perfect.length == 1;
ui.mount('ActiveInput', $(this), {
input: isPerfect ? perfect.find(':input') : $(this).children('input, textarea'),
isPerfect: isPerfect
});
});
$('.input:not(.upload) :input').each(function() {
ui.mount('InputSettings', $(this));
});
$('.ActiveUpload').each(function() {
ui.mount('ActiveUpload', $(this), {
holder: $(this).find('.text-holder'),
input: $(this).find('input[type=file]'),
progress: $(this).find('.ActiveProgress'),
});
});
$('.MultiForm').each(function() {
ui.mount('MultiFormPrice', $(this), {
// tabsBlock: $(this).find('.tabs-buttons'),
tabsButtons: $(this).find('.tabs-buttons .buttons > .button'),
tabsContents: $(this).find('.tabs-content > .row'),
priceTotal: $(this).find('.price-total'),
elementChoose: $(this).find('.choose-by-click')
});
});
$('.FileUpload').each(function() {
ui.mount('FileUpload', $(this), {
text: $(this).children('.text'),
input: $(this).find('input[type=file]'),
progress: $(this).children('.progress'),
progressBar: $(this).find('.ActiveProgress'),
});
});
$('.commerce-block').each(function() {
ui.mount('ActiveCommerce', $(this), {
label: $(this).find('.commerce-label'),
acceptButton: $(this).find('.commerce-accept'),
denyButton: $(this).find('.commerce-deny')
});
});
$('.ActiveIcons').each(function() {
menu = $(this).children('.menu');
images = $(this).children('.images');
ui.mount('ActiveIcons', $(this), {
menu: {
parent: menu,
li: menu.find('li')
},
images: {
parent: images,
sections: images.find('.collection'),
li: images.find('li')
}
});
});
$('.ActivePopup').each(function() {
ui.mount('ActivePopup', $(this));
});
$('.colorPicker').each(function() {
ui.mount('colorPicker', $(this), {
hue: $(this).children('.hue').first(),
color: $(this).children('.color').last(),
opacity: $(this).children('.opacity'),
controls: {
hue: $(this).find('.hue > .line'),
color: $(this).find('.color > .circle'),
opacity: $(this).find('.opacity > .line'),
input: $(this).find('.input > input'),
}
});
});
$('.Calendar').each(function() {
ui.mount('Calendar', $(this), {
prevButton: $(this).children('.button').first(),
nextButton: $(this).children('.button').last(),
group: $(this).find('.group'),
button: $(this).closest('.dropdown').children('.button').find('span')
});
});
$('.Parallax').each(function() {
ui.mount('Parallax', $(this));
});
ui.mount('TableCTR', $('#TableCTR'));
$('#browser').each(function() {
ui.mount('Browser', $(this));
});
$('#Payment').each(function() {
ui.mount('Payment', $(this));
});
$('.FormSubmit').click(function() {
$(this).closest('form').submit();
});
ui.mount('FullHeader', $('#header.login, #header.space.index, #header.generate'));
$('.tooltip').tipsy({
delayIn: 300,
fade: true,
live: true,
title: 'alt',
gravity: $.fn.tipsy.autoNS
}).on('click.tipsy', function() {
$('.tipsy').remove();
});
$('.tooltip-t').tipsy({
delayIn: 300,
fade: true,
live: true,
title: 'alt',
gravity: 's'
}).on('click.tipsy', function() {
$('.tipsy').remove();
});
$('.tooltip-b').tipsy({
delayIn: 300,
fade: true,
live: true,
title: 'alt',
gravity: 'n'
}).on('click.tipsy', function() {
$('.tipsy').remove();
});
$('.tooltip-bl').tipsy({
delayIn: 300,
fade: true,
live: true,
title: 'alt',
gravity: 'nw'
}).on('click.tipsy', function() {
$('.tipsy').remove();
});
$('.tooltip-br').tipsy({
delayIn: 300,
fade: true,
live: true,
title: 'alt',
gravity: 'ne'
}).on('click.tipsy', function() {
$('.tipsy').remove();
});
$('.tooltip-r').tipsy({
delayIn: 300,
fade: true,
live: true,
title: 'alt',
gravity: 'w'
}).on('click.tipsy', function() {
$('.tipsy').remove();
});
$('.tooltip-l').tipsy({
delayIn: 300,
fade: true,
live: true,
title: 'alt',
gravity: 'e'
}).on('click.tipsy', function() {
$('.tipsy').remove();
});
$('body').on('click.tipsy', function() {
setTimeout(function() {
$('.tipsy').remove();
}, 100);
});
}
$(document).ready(function() {
$.ajaxSetup({
headers: {
'X-Csrf-Token': CSRF_token
}
});
ui.mountAll();
ui.start();
windowHeight = $(window).height();
footerHeight = $('#footer').outerHeight();
subfooterHeight = $('#subfooter').outerHeight();
height = windowHeight - footerHeight - subfooterHeight;
// $('#history-content').css('min-height', height);
// sidebar = $('#sidebar.clear');
// if(sidebar.length == 1) {
// height = $('#header').outerHeight()-50;
// paddingTop = parseInt($('#header').css('paddingTop'));
// if($('#header').hasClass('space')) {
// $(window).scroll(function(event) {
// scroll = $(window).scrollTop();
// if(scroll > paddingTop) {
// if(sidebar.hasClass('clear')) {
// sidebar.removeClass('clear');
// sidebar.find('.logo a').html('
');
// }
// } else {
// if(!sidebar.hasClass('clear')) {
// sidebar.addClass('clear');
// sidebar.find('.logo a').html('
');
// }
// }
// });
// } else {
// sidebar.removeClass('clear');
// sidebar.find('.logo a').html('
');
// }
// }
if($('#timer-offer').length > 0) {
timer = $('#timer-offer');
// alert(1)
timer.countdown(timer.data('time')).on('update.countdown', function(event) {
w = parseInt(event.strftime('%w'));
d = parseInt(event.strftime('%d'));
h = parseInt(event.strftime('%H'));
m = parseInt(event.strftime('%M'));
s = parseInt(event.strftime('%S'));
// console.log(event, w, d, h, m, s);
str = '';
if(d > 0) {
str += d.text(['день', 'дня', 'дней'], true) + ' ';
}
if(h > 0) {
str += h.text(['час', 'часа', 'часов'], true) + ' ';
}
if(m > 0) {
str += m.text(['минута', 'минуты', 'минут'], true) + ' ';
}
$(this).html(str);
}).on('finish.countdown', function(event) {
$(this).html('Акция закончилась!');
});
}
isSidebarShowen = false;
$(window).scroll(function(event) {
scroll = $(window).scrollTop();
if(scroll > 800) {
if(!isSidebarShowen) {
$('#sidebar-scrolled').css('display', 'block');
setTimeout(function() {
$('#sidebar-scrolled').addClass('active');
}, 50);
isSidebarShowen = true;
}
} else {
if(isSidebarShowen) {
$('#sidebar-scrolled').removeClass('active');
setTimeout(function() {
$('#sidebar-scrolled').hide();
}, 350);
isSidebarShowen = false;
}
}
});
if($('#header').data('sidebar')) {
$("#sidebar").addClass($('#header').data('sidebar'));
logo = (window.location.host == 'dnk-atom.ru' || window.location.host == 'dnkatom.ru') ? 'dnklp' : 'bloxy';
$('#sidebar').find('.logo img').attr('src', '/view/images/'+logo+'_logo.white.png')
}
hash = window.location.hash;
// hash = hash.replace(/#/gi, '');
if(hash.match(/modal\//g)) {
src = hash.replace(/#modal\//gi, '');
if(['callbackhunter'].indexOf(src) > -1) {
Modal.show({
src: src
});
}
} else if($(hash).length == 1) {
e = $(hash);
height = e.outerHeight();
if(height < windowHeight) {
animateTop = $(hash).offset().top - (windowHeight-height)/2;
} else {
animateTop = $(hash).offset().top-10;
}
$("html, body").animate({
scrollTop: animateTop
}, 400);
}
});