927 lines
26 KiB
JavaScript
927 lines
26 KiB
JavaScript
|
|
var A;
|
|||
|
|
|
|||
|
|
A = {
|
|||
|
|
init: function() {
|
|||
|
|
A.w = $(window);
|
|||
|
|
A.P.init();
|
|||
|
|
A.W.init();
|
|||
|
|
A.FORM.init();
|
|||
|
|
return A.w.scroll(A.scroll);
|
|||
|
|
},
|
|||
|
|
scroll: function() {
|
|||
|
|
return A.P.scroll();
|
|||
|
|
},
|
|||
|
|
isMobile: function() {
|
|||
|
|
return $(window).width() <= 520;
|
|||
|
|
},
|
|||
|
|
// Работа с формами в этом проекте
|
|||
|
|
mail: /^([A-Za-z0-9_-]+\.)*[A-Za-z0-9_-]+@[A-Za-z0-9_-]+(\.[A-Za-z0-9_-]+)*\.[A-Za-z]{2,6}$/,
|
|||
|
|
FORM: {
|
|||
|
|
globalPrepareValidate: function(i, r) {
|
|||
|
|
$(".error_text", i.$wrap).remove();
|
|||
|
|
return i.$wrap.removeClass('error good');
|
|||
|
|
},
|
|||
|
|
globalGood: function(i, r) {
|
|||
|
|
return i.$wrap.addClass('good');
|
|||
|
|
},
|
|||
|
|
globalBad: function(i, r) {
|
|||
|
|
i.$wrap.addClass('error');
|
|||
|
|
return i.$wrap.append($('<div class="error_text">' + r.errors.join("<br/>") + '</div>'));
|
|||
|
|
},
|
|||
|
|
init: function() {
|
|||
|
|
$.fn.FORM('setGlobalGood', A.FORM.globalGood);
|
|||
|
|
$.fn.FORM('setGlobalBad', A.FORM.globalBad);
|
|||
|
|
return $.fn.FORM('setPrepareValidate', A.FORM.globalPrepareValidate);
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
setCookie: function(k, v, date) {
|
|||
|
|
var cook, domain;
|
|||
|
|
domain = ' domain=' + window.location.host + ';';
|
|||
|
|
cook = k + "=" + v + '; expires=' + new Date(date ? date : new Date().getTime() + 5184000000).toGMTString() + '; path=/;';
|
|||
|
|
document.cookie = cook + domain;
|
|||
|
|
console.log(cook + domain);
|
|||
|
|
return cook;
|
|||
|
|
},
|
|||
|
|
getCookie: function(name) {
|
|||
|
|
var pattern, regexp;
|
|||
|
|
pattern = "(?:; )?" + name + "=([^;]*);?";
|
|||
|
|
regexp = new RegExp(pattern);
|
|||
|
|
if (regexp.test(document.cookie)) {
|
|||
|
|
return decodeURIComponent(RegExp["$1"]);
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
},
|
|||
|
|
reach: function(x) {
|
|||
|
|
A.reachYandex(x);
|
|||
|
|
return A.reachGoogle(x);
|
|||
|
|
},
|
|||
|
|
reachYandex: function(x) {
|
|||
|
|
console.log('yandex', x);
|
|||
|
|
return typeof yaCounter56139889 !== "undefined" && yaCounter56139889 !== null ? yaCounter56139889.reachGoal(x) : void 0;
|
|||
|
|
},
|
|||
|
|
reachGoogle: function(x, y, z) {
|
|||
|
|
console.log('google', x, y, z);
|
|||
|
|
return typeof gtag === "function" ? gtag('event', x, {
|
|||
|
|
'event_category': 'conversion',
|
|||
|
|
'event_action': x
|
|||
|
|
}) : void 0;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
$(document).ready(A.init);
|
|||
|
|
|
|||
|
|
// u - url
|
|||
|
|
// d - data
|
|||
|
|
// c - callback
|
|||
|
|
// cd - callback data
|
|||
|
|
var API, API_THEME, API_THEME2;
|
|||
|
|
|
|||
|
|
API = function(u, d = {}, c = null, cd = {}) {
|
|||
|
|
var url;
|
|||
|
|
d['nocache'] = (new Date()).getTime();
|
|||
|
|
url = "/api/" + u + "/";
|
|||
|
|
console.log(url, d);
|
|||
|
|
return $.ajax({
|
|||
|
|
url: url,
|
|||
|
|
type: "POST",
|
|||
|
|
dataType: d.dataType !== void 0 ? d.dataType : "html",
|
|||
|
|
data: d,
|
|||
|
|
success: function(data) {
|
|||
|
|
if (c !== null) {
|
|||
|
|
return typeof c === "function" ? c(data, cd) : void 0;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
error: function() {
|
|||
|
|
return typeof c === "function" ? c({
|
|||
|
|
error: 1
|
|||
|
|
}, cd) : void 0;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
API_THEME = 'themes.merakomis/';
|
|||
|
|
|
|||
|
|
API_THEME2 = 'themes.merakomis';
|
|||
|
|
|
|||
|
|
A.F = {
|
|||
|
|
recall: function(f) {
|
|||
|
|
var $f, $res, s;
|
|||
|
|
f = ($f = $(f)).FORM();
|
|||
|
|
s = f.json();
|
|||
|
|
//s.dataType="JSON"
|
|||
|
|
$res = $(".res", $f).hide(300);
|
|||
|
|
console.log('recall', s);
|
|||
|
|
f.validate({
|
|||
|
|
success: function() {
|
|||
|
|
console.log(s);
|
|||
|
|
API(API_THEME + 'sendForm', s, function(data) {
|
|||
|
|
return console.log(data);
|
|||
|
|
});
|
|||
|
|
//A.W.openThankYou()
|
|||
|
|
return $f.replaceWith('<p class="send_success">Данные успешно отправлены</p>');
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
return false;
|
|||
|
|
},
|
|||
|
|
recallFile: function(f) {
|
|||
|
|
var $f, $res, s;
|
|||
|
|
f = ($f = $(f)).FORM();
|
|||
|
|
s = f.json();
|
|||
|
|
//s.dataType="JSON"
|
|||
|
|
$res = $(".res", $f).hide(300);
|
|||
|
|
console.log('recall', s);
|
|||
|
|
f.validate({
|
|||
|
|
success: function() {
|
|||
|
|
var url;
|
|||
|
|
console.log(s);
|
|||
|
|
//API API_THEME+'sendForm',s,(data)->console.log(data)
|
|||
|
|
//A.W.openThankYou()
|
|||
|
|
//$f.replaceWith('<p class="send_success">Данные успешно отправлены</p>')
|
|||
|
|
$f.ajaxForm();
|
|||
|
|
url = '/api/' + API_THEME + 'sendForm/';
|
|||
|
|
return $f.ajaxSubmit({
|
|||
|
|
url: url,
|
|||
|
|
data: s,
|
|||
|
|
type: "POST",
|
|||
|
|
method: "POST",
|
|||
|
|
success: function(data) {
|
|||
|
|
console.log(data);
|
|||
|
|
$f.replaceWith('<div class="send_success">Данные успешно отправлены</div>');
|
|||
|
|
return A.W.openThankYou();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
//callback?(data,cd)
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
review:(f)->
|
|||
|
|
f = ($f = $(f)).FORM()
|
|||
|
|
s = f.json()
|
|||
|
|
$res = $(".res",$f).hide(300)
|
|||
|
|
s.mark = parseInt($(".catalog-rate",$f).attr('data-value'));
|
|||
|
|
#console.log s
|
|||
|
|
if(s.mark < 0)
|
|||
|
|
A.notify($res,'Выберите оценку')
|
|||
|
|
return false
|
|||
|
|
f.validate
|
|||
|
|
success:->
|
|||
|
|
if s.phone==''
|
|||
|
|
A.notify($res,'Введите номер телефона')
|
|||
|
|
else if s.text==''
|
|||
|
|
A.notify($res,'Введите текст отзыва')
|
|||
|
|
else
|
|||
|
|
API API_THEME+'addReviewForItem',s, #(data)->console.log(data)
|
|||
|
|
A.W.openThankYouReview()
|
|||
|
|
#$f.replaceWith('<p>Данные успешно отправлены</p>')
|
|||
|
|
|
|||
|
|
false
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
var H;
|
|||
|
|
|
|||
|
|
H = {
|
|||
|
|
menu: {},
|
|||
|
|
selected: {},
|
|||
|
|
top_selected: null,
|
|||
|
|
inited: false,
|
|||
|
|
dir: '', // up | down | left | right
|
|||
|
|
title: null,
|
|||
|
|
data: null,
|
|||
|
|
scroll: [],
|
|||
|
|
isLoading: false,
|
|||
|
|
ready: function() {
|
|||
|
|
if (!H.inited) {
|
|||
|
|
$(window).on('popstate', H.switchByWindow);
|
|||
|
|
H.inited = true;
|
|||
|
|
H.body = $("#content");
|
|||
|
|
H.title = $("title");
|
|||
|
|
H.keywords = $("meta[name=keywords]");
|
|||
|
|
H.description = $("meta[name=description]");
|
|||
|
|
H.title = $("title");
|
|||
|
|
//H.switch()
|
|||
|
|
H.$html = $("html,body");
|
|||
|
|
$(window).on('scroll', H.onScroll);
|
|||
|
|
return H.checkPage();
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
onScroll: function() {
|
|||
|
|
if (!H.isLoading) {
|
|||
|
|
return H.scroll[window.location.href] = H.$html.scrollTop();
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
checkPage: function() {
|
|||
|
|
var path;
|
|||
|
|
path = H.parse();
|
|||
|
|
console.log('checkPage', path, path[0] === '');
|
|||
|
|
return $("body").toggleClass('main', path.length === 0);
|
|||
|
|
},
|
|||
|
|
reload: function() {
|
|||
|
|
return H.switch();
|
|||
|
|
},
|
|||
|
|
formGo: function(form) {
|
|||
|
|
var $f, action, path, s;
|
|||
|
|
s = ($f = $(form)).serialize();
|
|||
|
|
action = $f.attr('action');
|
|||
|
|
if (action === void 0) {
|
|||
|
|
action = window.location.pathname;
|
|||
|
|
}
|
|||
|
|
//console.log action
|
|||
|
|
H.go(path = action + '?' + s);
|
|||
|
|
return false;
|
|||
|
|
},
|
|||
|
|
go: function(x, data = null, title = '', reload = true) {
|
|||
|
|
var y;
|
|||
|
|
if (x.substr(0, 1) === '/') {
|
|||
|
|
x = x.substr(1);
|
|||
|
|
}
|
|||
|
|
y = '/' + x;
|
|||
|
|
H.data = data;
|
|||
|
|
history.pushState(data, title, y);
|
|||
|
|
if (reload) {
|
|||
|
|
return H.switch();
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
setTitle: function(x) {
|
|||
|
|
return H.title.text(x);
|
|||
|
|
},
|
|||
|
|
switchByWindow: function(x) {
|
|||
|
|
return H.switch(x);
|
|||
|
|
},
|
|||
|
|
switch: function(event = null) {
|
|||
|
|
var path, url;
|
|||
|
|
//console.log 'switch',x
|
|||
|
|
path = H.parse();
|
|||
|
|
url = path.join("/");
|
|||
|
|
if (url === "/" || url === "") {
|
|||
|
|
url = "/?justContent=1";
|
|||
|
|
} else {
|
|||
|
|
url = `/${url}/?justContent=1`;
|
|||
|
|
}
|
|||
|
|
if (window.location.search.length > 0) {
|
|||
|
|
url += '&' + window.location.search.substr(1);
|
|||
|
|
}
|
|||
|
|
//console.log url
|
|||
|
|
H.isLoading = true;
|
|||
|
|
return $.ajax({
|
|||
|
|
url: url,
|
|||
|
|
//url:"/#{url}/?mini=1"
|
|||
|
|
dataType: "JSON",
|
|||
|
|
success: function(data) {
|
|||
|
|
var $data, $html, i, j, ref, ref1, s, scrollTo;
|
|||
|
|
//console.log data
|
|||
|
|
console.log('time_compile', data.time_compile, 'bd_time', data.time_bd);
|
|||
|
|
if (typeof data.location === "string" && data.location !== "") {
|
|||
|
|
return H.go(data.location);
|
|||
|
|
} else {
|
|||
|
|
console.log('TITLE', data.title);
|
|||
|
|
H.title.text(data.title);
|
|||
|
|
$data = $(data.content);
|
|||
|
|
$html = $($data[0]);
|
|||
|
|
H.setTitle(data.data.title);
|
|||
|
|
H.keywords.attr('content', data.keywords);
|
|||
|
|
H.description.attr('content', data.description);
|
|||
|
|
scrollTo = 0;
|
|||
|
|
if (H.scroll[window.location.href] !== void 0 && event !== null) {
|
|||
|
|
scrollTo = H.scroll[window.location.href];
|
|||
|
|
}
|
|||
|
|
//$hide = $(".b_content:not(.hide)").addClass('hide')
|
|||
|
|
//$(".b_content").remove()
|
|||
|
|
//$.fn.TABLE('allDestroy')
|
|||
|
|
H.body.html($html);
|
|||
|
|
A.P.initMini($html);
|
|||
|
|
if ($data.length > 1) {
|
|||
|
|
for (i = j = 1, ref = $data.length - 1; (1 <= ref ? j <= ref : j >= ref); i = 1 <= ref ? ++j : --j) {
|
|||
|
|
s = document.createElement('script');
|
|||
|
|
if ((ref1 = $data[i].tagName) === 'SCRIPT' || ref1 === 'script') {
|
|||
|
|
s.innerHTML = $($data[i]).html();
|
|||
|
|
H.body[0].appendChild(s);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
H.checkPage();
|
|||
|
|
H.$html.scrollTop(scrollTo);
|
|||
|
|
return H.isLoading = false;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
error: function() {
|
|||
|
|
return console.log('history error ');
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
SEARCH: {
|
|||
|
|
set: function(s, reload = false) {
|
|||
|
|
var x;
|
|||
|
|
x = window.location.pathname + '?' + s;
|
|||
|
|
return H.go(x, null, '', reload);
|
|||
|
|
},
|
|||
|
|
parse: function() {
|
|||
|
|
var i, pos, res, v, x;
|
|||
|
|
res = {};
|
|||
|
|
if (window.location.search.length > 0) {
|
|||
|
|
x = window.location.search.substr(1).split('&');
|
|||
|
|
for (i in x) {
|
|||
|
|
v = x[i];
|
|||
|
|
pos = v.indexOf('=');
|
|||
|
|
if (pos >= 0) {
|
|||
|
|
res[v.substr(0, pos)] = v.substr(pos + 1);
|
|||
|
|
} else {
|
|||
|
|
res[v] = null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return res;
|
|||
|
|
},
|
|||
|
|
setValue: function(key, value, reload = false) {
|
|||
|
|
var s, x;
|
|||
|
|
x = H.SEARCH.parse();
|
|||
|
|
x[key] = value;
|
|||
|
|
s = H.SEARCH.toString(x);
|
|||
|
|
return H.SEARCH.set(s);
|
|||
|
|
},
|
|||
|
|
toString: function(a) {
|
|||
|
|
var i, res, v;
|
|||
|
|
res = [];
|
|||
|
|
for (i in a) {
|
|||
|
|
v = a[i];
|
|||
|
|
res.push(i + '=' + (v != null ? v : ''));
|
|||
|
|
}
|
|||
|
|
return res.join('&');
|
|||
|
|
},
|
|||
|
|
get: function(x) {
|
|||
|
|
var e;
|
|||
|
|
try {
|
|||
|
|
return decodeURI(H.SEARCH.parse()[x]);
|
|||
|
|
} catch (error) {
|
|||
|
|
e = error;
|
|||
|
|
return H.SEARCH.parse()[x];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
//H.SEARCH.parse()[x]
|
|||
|
|
parse: function(x = null) {
|
|||
|
|
var a, i, j, len, o;
|
|||
|
|
a = x !== null ? x.split('/') : window.location.pathname.split("/");
|
|||
|
|
o = [];
|
|||
|
|
for (j = 0, len = a.length; j < len; j++) {
|
|||
|
|
i = a[j];
|
|||
|
|
if (i !== "") {
|
|||
|
|
o.push(i);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return o;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
$(window).ready(H.ready);
|
|||
|
|
|
|||
|
|
//-------------------------------------------------
|
|||
|
|
// A.I = РАБОТА С ПОЛЯМИ ВВОДА
|
|||
|
|
//-------------------------------------------------
|
|||
|
|
A.I = {
|
|||
|
|
waitInput: function(x) {
|
|||
|
|
return $(x).each(function() {
|
|||
|
|
var button, click, val;
|
|||
|
|
button = $(this);
|
|||
|
|
click = button.attr('onclick');
|
|||
|
|
val = $.trim(button.val());
|
|||
|
|
return button.attr('onclick', '').attr('data-val', val).val(val === "" ? '' : 'Отправляется...').addClass("wait").attr('data-onclick', click).attr('disabled', 'disabled');
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
unwaitInput: function(x) {
|
|||
|
|
return $(x).each(function() {
|
|||
|
|
var b;
|
|||
|
|
b = $(this);
|
|||
|
|
return b.val(b.attr('data-val')).removeClass("wait").attr('onclick', b.attr('data-onclick')).removeAttr('disabled');
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
waitButton: function(x) {
|
|||
|
|
return $(x).each(function() {
|
|||
|
|
var button, click, val;
|
|||
|
|
button = $(this);
|
|||
|
|
click = button.attr('onclick');
|
|||
|
|
val = $.trim(button.html());
|
|||
|
|
if (val !== "?") {
|
|||
|
|
return button.attr('onclick', '').attr('data-val', val).html(val === "" || val === " " ? '' : 'Отправляется...').addClass("wait").attr('data-onclick', click).attr('disabled', 'disabled');
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
unwaitButton: function(x) {
|
|||
|
|
return $(x).each(function() {
|
|||
|
|
var b;
|
|||
|
|
b = $(this);
|
|||
|
|
return b.html(b.attr('data-val')).removeClass("wait").attr('onclick', b.attr('data-onclick')).removeAttr('disabled');
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
A.P = {
|
|||
|
|
scrollTimeout: null,
|
|||
|
|
$scrollNumber: null,
|
|||
|
|
getScrollTop: function() {
|
|||
|
|
return Math.max(A.P.body.scrollTop(), A.P.$body.scrollTop(), A.P.$html.scrollTop());
|
|||
|
|
},
|
|||
|
|
scrollToTop: function(x = 0) {
|
|||
|
|
A.P.$body.scrollTop(x);
|
|||
|
|
return A.P.$html.scrollTop(x);
|
|||
|
|
},
|
|||
|
|
scrollToTopAnimate: function() {
|
|||
|
|
A.P.$body.animate({
|
|||
|
|
scrollTop: 0
|
|||
|
|
}, 500);
|
|||
|
|
return A.P.$html.animate({
|
|||
|
|
scrollTop: 0
|
|||
|
|
}, 500);
|
|||
|
|
},
|
|||
|
|
scrollToAnimate: function(y) {
|
|||
|
|
A.P.$body.animate({
|
|||
|
|
scrollTop: y
|
|||
|
|
}, 500);
|
|||
|
|
return A.P.$html.animate({
|
|||
|
|
scrollTop: y
|
|||
|
|
}, 500);
|
|||
|
|
},
|
|||
|
|
init: function() {
|
|||
|
|
//alert(window.innerWidth+'x'+window.innerHeight)
|
|||
|
|
A.P.body = $("body");
|
|||
|
|
A.P.$body = $("body");
|
|||
|
|
A.P.$html = $("html");
|
|||
|
|
A.P.html = $("html,body");
|
|||
|
|
A.P.initMini();
|
|||
|
|
$('#b_add-basket .btn').click(function() {
|
|||
|
|
return $('#b_add-basket').removeClass('open');
|
|||
|
|
});
|
|||
|
|
A.P.$totop = $("#totop");
|
|||
|
|
A.P.$footer = $("#b_footer");
|
|||
|
|
A.P.$soc = $("#b_footer .soc");
|
|||
|
|
return $(document).click(function(e) {});
|
|||
|
|
},
|
|||
|
|
removeSearch: function(id) {
|
|||
|
|
event.stopPropagation();
|
|||
|
|
event.preventDefault();
|
|||
|
|
$(`.search[data-id=${id}]`).remove();
|
|||
|
|
return API(API_THEME2 + '.search/remove', {id}, function(data) {
|
|||
|
|
return console.log(data);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
scroll: function() {
|
|||
|
|
A.P.$totop.toggleClass('show', A.w.scrollTop() > 10);
|
|||
|
|
return A.P.html.toggleClass('scroll', A.w.scrollTop() > 1);
|
|||
|
|
},
|
|||
|
|
aScroll: function() {
|
|||
|
|
return A.P.$html.removeClass('scroll');
|
|||
|
|
},
|
|||
|
|
firstInit: function($html = A.P.body) {},
|
|||
|
|
openMenu: function() {
|
|||
|
|
var body;
|
|||
|
|
$("body").addClass('open_menu');
|
|||
|
|
body = document.body;
|
|||
|
|
A.P.scrollPosition = window.pageYOffset;
|
|||
|
|
body.style.overflow = 'hidden';
|
|||
|
|
body.style.position = 'fixed';
|
|||
|
|
body.style.top = '-' + A.P.scrollPosition + 'px';
|
|||
|
|
return body.style.width = '100%';
|
|||
|
|
},
|
|||
|
|
closeMenu: function() {
|
|||
|
|
var body;
|
|||
|
|
$("body").removeClass('open_menu');
|
|||
|
|
body = document.body;
|
|||
|
|
body.style.removeProperty('overflow');
|
|||
|
|
body.style.removeProperty('position');
|
|||
|
|
body.style.removeProperty('top');
|
|||
|
|
body.style.removeProperty('width');
|
|||
|
|
return window.scrollTo(0, A.P.scrollPosition);
|
|||
|
|
},
|
|||
|
|
toMobMenu: function() {
|
|||
|
|
$("#mob_menu .back").hide();
|
|||
|
|
$("#mob_menu .blocks").hide();
|
|||
|
|
$("#mob_menu .menu_footer2").hide();
|
|||
|
|
$("#mob_menu .menu_footer").show();
|
|||
|
|
return $("#mob_menu .menu").show();
|
|||
|
|
},
|
|||
|
|
openMobMenu: function() {
|
|||
|
|
var $t, id;
|
|||
|
|
$("#mob_menu .back").show();
|
|||
|
|
$("#mob_menu .blocks").show();
|
|||
|
|
$("#mob_menu .blocks").html('');
|
|||
|
|
$("#mob_menu .menu_footer2").show();
|
|||
|
|
$("#mob_menu .menu_footer").hide();
|
|||
|
|
$("#mob_menu .menu").hide();
|
|||
|
|
$t = $(this);
|
|||
|
|
id = $t.attr('data-group');
|
|||
|
|
return API(API_THEME2 + '/menu', {id}, function(data) {
|
|||
|
|
$("#mob_menu .blocks").replaceWith(data);
|
|||
|
|
return A.P.initMini($("#mob_menu .blocks"));
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
initMini: function($html = A.P.body) {
|
|||
|
|
$("#mob_menu .subel").click(A.P.openMobMenu);
|
|||
|
|
//if A.isMobile()
|
|||
|
|
// if $("#mob_header_menu").length > 0
|
|||
|
|
// $("#mob_header_menu").append( $(".sidebar-right"))
|
|||
|
|
$('.news', $html).owlCarousel({
|
|||
|
|
loop: true,
|
|||
|
|
nav: true,
|
|||
|
|
//autoWidth : true
|
|||
|
|
margin: 0,
|
|||
|
|
items: 1
|
|||
|
|
});
|
|||
|
|
$(".copy", $html).click(function(e) {
|
|||
|
|
var $div, $t, range, success;
|
|||
|
|
e.stopPropagation();
|
|||
|
|
e.preventDefault();
|
|||
|
|
$t = $(this);
|
|||
|
|
$div = $('<div class="copy_text">' + $t.attr('data-copy') + '</div>');
|
|||
|
|
$t.append($div);
|
|||
|
|
window.getSelection().removeAllRanges();
|
|||
|
|
range = document.createRange();
|
|||
|
|
range.selectNode($div[0]);
|
|||
|
|
window.getSelection().addRange(range);
|
|||
|
|
success = document.execCommand('copy');
|
|||
|
|
range.setEnd($t[0], 0);
|
|||
|
|
$t.addClass('copied');
|
|||
|
|
return setTimeout(function() {
|
|||
|
|
$t.removeClass('copied');
|
|||
|
|
return $div.remove();
|
|||
|
|
}, 2000);
|
|||
|
|
});
|
|||
|
|
$(".i.phone").mask("+7 (999) 999-99-99");
|
|||
|
|
return A.P.initPreventLink($html);
|
|||
|
|
},
|
|||
|
|
getPropsForCart: function() {
|
|||
|
|
var res;
|
|||
|
|
res = {};
|
|||
|
|
$(".prop_price.selected").each(function() {
|
|||
|
|
var $t;
|
|||
|
|
$t = $(this);
|
|||
|
|
return res[$t.attr("data-prop-id")] = $t.attr("data-id");
|
|||
|
|
});
|
|||
|
|
return res;
|
|||
|
|
},
|
|||
|
|
initPreventLink: function(x) {},
|
|||
|
|
// $("a:not(.prevented):not(.slide)",$(x)).addClass('prevented').click A.P.preventALink
|
|||
|
|
preventALink: function(e) {
|
|||
|
|
var $c, $t, href;
|
|||
|
|
href = ($t = $(this)).attr('href');
|
|||
|
|
console.log(href, href.substr(0, 1) === "#", href === "" || href === "#");
|
|||
|
|
if ($t.hasClass('propagation')) {
|
|||
|
|
e.preventDefault();
|
|||
|
|
return e.stopPropagation();
|
|||
|
|
} else if (href === "" || href === "#") {
|
|||
|
|
return e.preventDefault();
|
|||
|
|
//e.stopPropagation()
|
|||
|
|
} else if (href.substr(0, 1) === "#") {
|
|||
|
|
console.log('sex');
|
|||
|
|
//e.preventDefault();
|
|||
|
|
e.stopPropagation();
|
|||
|
|
$c = $(href);
|
|||
|
|
if ($c.length > 0) {
|
|||
|
|
return A.P.scrollToAnimate($c.offset().top - 60);
|
|||
|
|
}
|
|||
|
|
} else if (href !== void 0) {
|
|||
|
|
if ($t.hasClass('_to_card')) {
|
|||
|
|
e.preventDefault();
|
|||
|
|
e.stopPropagation();
|
|||
|
|
return $.fn.CARD('openNew', {
|
|||
|
|
api: $t.attr('data-module'),
|
|||
|
|
id: $t.attr('data-id')
|
|||
|
|
});
|
|||
|
|
} else if (href.substr(0, 1) === '/') {
|
|||
|
|
e.preventDefault();
|
|||
|
|
e.stopPropagation();
|
|||
|
|
H.go($(this).attr('href'));
|
|||
|
|
return A.P.closeMenu();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
//-----------------------------------------------
|
|||
|
|
// A.W - Работа со всплывающими окнами
|
|||
|
|
//-----------------------------------------------
|
|||
|
|
A.W = {
|
|||
|
|
back: null,
|
|||
|
|
w: null,
|
|||
|
|
i: null,
|
|||
|
|
init: function() {
|
|||
|
|
console.log('ready', $("#wback"));
|
|||
|
|
A.W.back = $("#wback");
|
|||
|
|
if (A.W.back.length > 0) {
|
|||
|
|
A.W.w = $("#window");
|
|||
|
|
return A.W.i = $("#w_inner");
|
|||
|
|
} else {
|
|||
|
|
return delete A.W;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
startLoad: function() {
|
|||
|
|
return A.W.i.addClass("load").html("Загрузка данных");
|
|||
|
|
},
|
|||
|
|
finishLoad: function(data) {
|
|||
|
|
var $data;
|
|||
|
|
$data = $(data);
|
|||
|
|
A.W.i.removeClass("load").html($data);
|
|||
|
|
return A.P.initMini($data);
|
|||
|
|
},
|
|||
|
|
//$(".window_inner input[name=phone]").mask("+7 (999) 999-99-99");
|
|||
|
|
setHtml: function(data) {
|
|||
|
|
return A.W.finishLoad(data);
|
|||
|
|
},
|
|||
|
|
open: function(w) {
|
|||
|
|
A.P.body.css('overflow', 'hidden');
|
|||
|
|
A.W.back.addClass('open');
|
|||
|
|
return A.W.w.css({
|
|||
|
|
maxWidth: (w !== void 0 ? w + 'px' : 'auto')
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
close: function() {
|
|||
|
|
var base;
|
|||
|
|
A.W.back.removeClass('open');
|
|||
|
|
A.P.body.css('overflow', 'auto');
|
|||
|
|
A.W.i.html("");
|
|||
|
|
return typeof (base = A.W).onClose === "function" ? base.onClose() : void 0;
|
|||
|
|
},
|
|||
|
|
openCase: function(id) {
|
|||
|
|
A.W.open();
|
|||
|
|
A.W.startLoad();
|
|||
|
|
return API(API_THEME + 'case', {id}, A.W.setHtml);
|
|||
|
|
},
|
|||
|
|
openActivity: function(id) {
|
|||
|
|
A.W.open();
|
|||
|
|
A.W.startLoad();
|
|||
|
|
return API(API_THEME + 'activity', {id}, A.W.setHtml);
|
|||
|
|
},
|
|||
|
|
openRecall: function(data = {
|
|||
|
|
title: 'Обратный звонок',
|
|||
|
|
form_type: 'recall'
|
|||
|
|
}) {
|
|||
|
|
A.W.open(400);
|
|||
|
|
A.W.startLoad();
|
|||
|
|
return API(API_THEME + 'formRecall', data, A.W.setHtml);
|
|||
|
|
},
|
|||
|
|
openAuth: function() {
|
|||
|
|
A.W.open(600);
|
|||
|
|
A.W.startLoad();
|
|||
|
|
return API(API_THEME + 'formAuth', {}, A.W.setHtml);
|
|||
|
|
},
|
|||
|
|
openReg: function() {
|
|||
|
|
A.W.open(600);
|
|||
|
|
A.W.startLoad();
|
|||
|
|
return API(API_THEME + 'formReg', {}, A.W.setHtml);
|
|||
|
|
},
|
|||
|
|
openRestore: function() {
|
|||
|
|
A.W.open(600);
|
|||
|
|
A.W.startLoad();
|
|||
|
|
return API(API_THEME + 'formRestore', {}, A.W.setHtml);
|
|||
|
|
},
|
|||
|
|
openThankYou: function() {
|
|||
|
|
A.W.open(600);
|
|||
|
|
A.W.startLoad();
|
|||
|
|
return API(API_THEME + 'formThankYou', {}, A.W.setHtml);
|
|||
|
|
},
|
|||
|
|
openAbuy: function(id) {
|
|||
|
|
A.W.open(400);
|
|||
|
|
A.W.startLoad();
|
|||
|
|
return API(API_THEME + 'abuy', {
|
|||
|
|
id: id
|
|||
|
|
}, A.W.setHtml);
|
|||
|
|
},
|
|||
|
|
openOneClick: function(id) {
|
|||
|
|
A.W.open(400);
|
|||
|
|
A.W.startLoad();
|
|||
|
|
return API(API_THEME + 'oneClick', {
|
|||
|
|
id: id
|
|||
|
|
}, A.W.setHtml);
|
|||
|
|
},
|
|||
|
|
openCartOneClick: function() {
|
|||
|
|
A.W.open(400);
|
|||
|
|
A.W.startLoad();
|
|||
|
|
return API(API_THEME + 'cartOneClick', {}, A.W.setHtml);
|
|||
|
|
},
|
|||
|
|
openMap: function() {
|
|||
|
|
A.W.open(1000);
|
|||
|
|
A.W.startLoad();
|
|||
|
|
return API(API_THEME + 'openMap', {}, A.W.setHtml);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
(function($) {
|
|||
|
|
var F;
|
|||
|
|
$.fn.PROFILE = function(method) {
|
|||
|
|
if (F[method]) {
|
|||
|
|
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
|
|||
|
|
} else if (typeof method === "object" || !method) {
|
|||
|
|
return F.init.apply(this, arguments);
|
|||
|
|
} else {
|
|||
|
|
return $.error('Метод с именем ' + method + ' не существует для jQuery.PROFILE');
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
return F = {
|
|||
|
|
exit: function() {
|
|||
|
|
return API(API_THEME2 + '.emp/exit', {}, function(data) {
|
|||
|
|
return window.location.href = "/";
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
admin: function(f) {
|
|||
|
|
var $f, $res, s;
|
|||
|
|
f = ($f = $(f)).FORM();
|
|||
|
|
s = f.json();
|
|||
|
|
s.dataType = "JSON";
|
|||
|
|
$res = $(".res", $f).hide(300);
|
|||
|
|
console.log(s);
|
|||
|
|
f.validate({
|
|||
|
|
success: function() {
|
|||
|
|
var $btn;
|
|||
|
|
A.I.waitButton($btn = $("button", $f));
|
|||
|
|
return API(API_THEME2 + '.emp/login', s, function(data) {
|
|||
|
|
A.I.unwaitButton($btn);
|
|||
|
|
console.log(data);
|
|||
|
|
if (data.e === false) {
|
|||
|
|
return window.location.reload();
|
|||
|
|
} else {
|
|||
|
|
return $res.html(data.e).show(300);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
return false;
|
|||
|
|
},
|
|||
|
|
to_sign: function(f) {
|
|||
|
|
$(".window").hide();
|
|||
|
|
return $("#sign").show();
|
|||
|
|
},
|
|||
|
|
new_pass: function(f) {
|
|||
|
|
var $f, $res, s;
|
|||
|
|
f = ($f = $(f)).FORM();
|
|||
|
|
s = f.json();
|
|||
|
|
s.dataType = "JSON";
|
|||
|
|
$res = $(".res", $f).hide(300);
|
|||
|
|
console.log(s);
|
|||
|
|
f.validate({
|
|||
|
|
success: function() {
|
|||
|
|
var $btn;
|
|||
|
|
A.I.waitButton($btn = $("button", $f));
|
|||
|
|
return API(API_THEME2 + '.emp/new_pass', s, function(data) {
|
|||
|
|
A.I.unwaitButton($btn);
|
|||
|
|
console.log(data);
|
|||
|
|
if (data.e === 0) {
|
|||
|
|
$("#sign").hide();
|
|||
|
|
return $("#new_pass").show();
|
|||
|
|
} else if (data.e === 1) {
|
|||
|
|
return alert(data.m);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
return false;
|
|||
|
|
},
|
|||
|
|
remind: function(f) {
|
|||
|
|
var $f, $res, s;
|
|||
|
|
f = ($f = $(f)).FORM();
|
|||
|
|
s = f.json();
|
|||
|
|
s.dataType = "JSON";
|
|||
|
|
$res = $(".res", $f).hide(300);
|
|||
|
|
console.log(s);
|
|||
|
|
f.validate({
|
|||
|
|
success: function() {
|
|||
|
|
var $btn;
|
|||
|
|
A.I.waitButton($btn = $("button", $f));
|
|||
|
|
return API(API_THEME2 + '.emp/remind', s, function(data) {
|
|||
|
|
A.I.unwaitButton($btn);
|
|||
|
|
console.log(data);
|
|||
|
|
if (data.e === 0) {
|
|||
|
|
$("#sign").hide();
|
|||
|
|
return $("#check_mail").show();
|
|||
|
|
} else if (data.e === 1) {
|
|||
|
|
$(".unknown_login").text(s.login);
|
|||
|
|
$("#sign").hide();
|
|||
|
|
return $("#unknown").show();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
return false;
|
|||
|
|
},
|
|||
|
|
login: function(f) {
|
|||
|
|
var $f, $res, s;
|
|||
|
|
f = ($f = $(f)).FORM();
|
|||
|
|
s = f.json();
|
|||
|
|
s.dataType = "JSON";
|
|||
|
|
$res = $(".res", $f).hide(300);
|
|||
|
|
f.validate({
|
|||
|
|
success: function() {
|
|||
|
|
var $btn;
|
|||
|
|
A.I.waitButton($btn = $("button", $f));
|
|||
|
|
return API(API_THEME2 + '.emp/login', s, function(data) {
|
|||
|
|
A.I.unwaitButton($btn);
|
|||
|
|
console.log(data);
|
|||
|
|
if (data.e === false) {
|
|||
|
|
return window.location.reload();
|
|||
|
|
} else if (data.e === 1) {
|
|||
|
|
$(".unknown_login").text(s.login);
|
|||
|
|
$("#sign").hide();
|
|||
|
|
return $("#unknown").show();
|
|||
|
|
} else if (data.e === 2) {
|
|||
|
|
return $res.text("Неверный пароль").show(300);
|
|||
|
|
//alert("Неверный пароль")
|
|||
|
|
} else if (data.e === 3) {
|
|||
|
|
$("[data-name=code]").show();
|
|||
|
|
$("[data-name=key]").val(data.key);
|
|||
|
|
//alert("Введите код, отправленный в телеграм")
|
|||
|
|
return $res.text("Введите код, отправленный в телеграм").show(300);
|
|||
|
|
} else if (data.e === 4) {
|
|||
|
|
//alert("Неверный код")
|
|||
|
|
return $res.text("Неверный код").show(300);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
return false;
|
|||
|
|
},
|
|||
|
|
reg: function(f) {
|
|||
|
|
var $f, $res, s;
|
|||
|
|
f = ($f = $(f)).FORM();
|
|||
|
|
s = f.json();
|
|||
|
|
s.dataType = "JSON";
|
|||
|
|
$res = $(".res", $f).hide(300);
|
|||
|
|
console.log(s);
|
|||
|
|
f.validate({
|
|||
|
|
success: function() {
|
|||
|
|
var $btn;
|
|||
|
|
A.I.waitButton($btn = $("button", $f));
|
|||
|
|
return API(API_THEME2 + '.emp/reg', s, function(data) {
|
|||
|
|
console.log(data);
|
|||
|
|
A.I.unwaitButton($btn);
|
|||
|
|
if (data.e === false || data.e === 0) {
|
|||
|
|
return window.location.href = "/";
|
|||
|
|
} else if (data.e === 2) {
|
|||
|
|
$(".unknown_login").text(s.login);
|
|||
|
|
$("#sign").hide();
|
|||
|
|
return $("#repeat_reg").show();
|
|||
|
|
} else if (data.e === 1) {
|
|||
|
|
$(".unknown_login").text(s.login);
|
|||
|
|
$("#sign").hide();
|
|||
|
|
return $("#unknown").show();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
})(jQuery);
|
|||
|
|
|
|||
|
|
var indexOf = [].indexOf;
|
|||
|
|
|
|||
|
|
(function($) {
|
|||
|
|
var F;
|
|||
|
|
$.fn.PROJECT = function(method) {
|
|||
|
|
if (F[method]) {
|
|||
|
|
return F[method].apply(this, Array.prototype.slice.call(arguments, 1));
|
|||
|
|
} else if (typeof method === "object" || !method) {
|
|||
|
|
return F.init.apply(this, arguments);
|
|||
|
|
} else {
|
|||
|
|
return $.error('Метод с именем ' + method + ' не существует для jQuery.PROJECT');
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
return F = {
|
|||
|
|
init: function($html) {
|
|||
|
|
return $(".project_filter", $html).each(function() {
|
|||
|
|
var $p, $sections, setFilter;
|
|||
|
|
$p = $(this);
|
|||
|
|
$sections = $(".section", $p);
|
|||
|
|
setFilter = function() {
|
|||
|
|
var $t, id, selected;
|
|||
|
|
$t = $(this);
|
|||
|
|
id = $t.attr('data-id');
|
|||
|
|
selected = $t.hasClass('selected');
|
|||
|
|
$sections.removeClass('selected');
|
|||
|
|
if (selected) {
|
|||
|
|
id = 0;
|
|||
|
|
} else {
|
|||
|
|
$t.addClass('selected');
|
|||
|
|
}
|
|||
|
|
console.log(id, selected);
|
|||
|
|
return $(".project").each(function() {
|
|||
|
|
var e, sections;
|
|||
|
|
$t = $(this);
|
|||
|
|
try {
|
|||
|
|
sections = JSON.parse($t.attr('data-sections'));
|
|||
|
|
} catch (error) {
|
|||
|
|
e = error;
|
|||
|
|
sections = [];
|
|||
|
|
}
|
|||
|
|
if (!Array.isArray(sections)) {
|
|||
|
|
sections = [];
|
|||
|
|
}
|
|||
|
|
return $t.toggleClass('show', indexOf.call(sections, id) >= 0 || id === 0);
|
|||
|
|
});
|
|||
|
|
};
|
|||
|
|
return $sections.click(setFilter);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
})(jQuery);
|