var timeOut = 10000;
function startLoadingBar() {
if (mainJS.isClickButton === true)
return;
$("#al_loading").show();
$('#m #mcont').empty();
}
function stopLoadingBar() {
if (mainJS.isClickButton === true) {
mainJS.isClickButton = false;
return;
}
$('#al_loading').hide();
}
function updateDataNotif() {
var node;
var isUser = parseInt($('body').attr('data-user'));
if (isUser <= 0) {
return;
}
$.get("/files/js/count/", function (a) {
if (a.knew) {
var allCount = parseInt(a.knew);
$('a[data-mail]').each(function (i, e) {
var node = $(e).find('em[data-count]');
if (allCount === 0) {
if (node.hasClass('countHide') === false) {
node.addClass('countHide').text('0');
}
} else {
if (node.hasClass('countHide') === true)
node.removeClass('countHide');
node.text(allCount).fadeTo(500, .2).fadeTo(499, 1).fadeTo(500, .2).fadeTo(499, 1).fadeTo(500, .2).fadeTo(499, 1);
}
})
}
if (a.knotifi) {
var allCount = parseInt(a.knotifi);
$('a[data-notifi]').each(function (i, e) {
var node = $(e).find('em[data-count]');
if (allCount === 0) {
if (node.hasClass('countHide') === false) {
node.addClass('countHide').text('0');
}
} else {
if (node.hasClass('countHide') === true)
node.removeClass('countHide');
node.text(allCount).fadeTo(500, .2).fadeTo(499, 1).fadeTo(500, .2).fadeTo(499, 1).fadeTo(500, .2).fadeTo(499, 1);
}
})
}
if (a.k_group) {
var allCount = parseInt(a.k_group);
$('a[data-group]').each(function (i, e) {
var node = $(e).find('em[data-count]');
if (allCount === 0) {
if (node.hasClass('countHide') === false) {
node.addClass('countHide').text('0');
}
} else {
if (node.hasClass('countHide') === true)
node.removeClass('countHide');
node.text(allCount).fadeTo(500, .2).fadeTo(499, 1).fadeTo(500, .2).fadeTo(499, 1).fadeTo(500, .2).fadeTo(499, 1);
}
})
}
if (a.k_friend) {
var allCount = parseInt(a.k_friend);
$('a[data-friend]').each(function (i, e) {
var node = $(e).find('em[data-count]');
if (allCount === 0) {
if (node.hasClass('countHide') === false) {
node.addClass('countHide').text('0');
}
} else {
if (node.hasClass('countHide') === true)
node.removeClass('countHide');
node.text(allCount).fadeTo(500, .2).fadeTo(499, 1).fadeTo(500, .2).fadeTo(499, 1).fadeTo(500, .2).fadeTo(499, 1);
}
})
}
});
}
$(document).ajaxRequest('a:not([data-noajax])', '#m #mcont', {timeout: timeOut});
$(document).on('submit', 'form:not([data-noajax])', function (event) {
$.ajaxRequest.submit(event, '#m #mcont', {timeout: timeOut});
});
$(document).on('click', '[type=submit]:not([data-noajax])', function (event) {
$.ajaxRequest.pressingButton(event);
});
$(document).on('ajaxRequest:start', function () {
startLoadingBar();
Tick.clearTick();
audioplayer.isOpenPlayer = false;
$('#vk_wrap').removeClass('lm_opened');
$('body').removeClass('lm_opened');
});
$(document).on('ajaxRequest:end', function () {
stopLoadingBar();
Tick.clearTick();
Tick.setTick(updateDataNotif);
audioplayer.isOpenPlayer = false;
$('.aic_volume_wrap .aic_line').css('display', (browser.mobile === false ? 'block' : 'none'));
$('#vk_wrap').removeClass('lm_opened');
$('body').removeClass('lm_opened');
$('h1.mh_header.mhi_back').text(document.title);
$('img').show();
});
function getCw() {
return Math.max(window.innerWidth || 0, (window.htmlNode || {}).clientWidth || 0)
}
function getCh(){return Math.max(window.innerHeight||0,(window.htmlNode||{}).clientHeight||0)}
function scrollLeft() {
return htmlNode.scrollLeft || bodyNode.scrollLeft || window.scrollX || 0
}
function scrollTop(e, t) {
var n = window, i = n.htmlNode, o = n.bodyNode;
return "undefined" == typeof e ? i.scrollTop || o.scrollTop || window.scrollY || 0 : void(t ? setTimeout(function () {
window.scrollTo(0, Math.max(0, e))
}, t) : window.scrollTo(0, Math.max(0, e)))
}
if (function (e, t) {
var a = !1, n = [], o = function () {
if (!a && (a = !0, e.htmlNode = geByTag1("html"), e.bodyNode = geByTag1("body"), n)) {
for (var o = null; o = n.shift();) o.call(t);
n = null
}
};
t.addEventListener ? t.addEventListener("DOMContentLoaded", function () {
t.removeEventListener("DOMContentLoaded", arguments.callee, !1), o()
}, !1) : t.attachEvent && t.attachEvent("onreadystatechange", function () {
"complete" === t.readyState && (t.detachEvent("onreadystatechange", arguments.callee), o())
}), e.addEventListener ? e.addEventListener("load", o, !1) : e.attachEvent ? e.attachEvent("onload", o) : e.onload = o;
function i(e) {
a ? e.call(t) : n.push(e)
}
e.onDOMReady = i
}(window, document), !window._ua) var _ua = navigator.userAgent.toLowerCase();
var UI = {
ajaxLoad: '',
photoView: function () {
var b = $("body");
if (b.hasClass("z_opened")) {
b.removeClass("z_opened");
} else {
b.addClass("z_opened");
}
},
albumsToggle: function () {
var b = $(".head_actions_wrap");
if (b.hasClass("head_actions_opened")) {
b.removeClass("head_actions_opened");
} else {
b.addClass("head_actions_opened");
}
},
answerToggle: function () {
var b = $(".head_actions_wrap");
if (b.hasClass("head_actions_opened")) {
b.removeClass("head_actions_opened");
} else {
b.addClass("head_actions_opened");
}
},
sidebarToggle: function () {
toggleMenu();
},
esheToggle: function () {
var b = $("#menu_dop");
if (b.hasClass("menu_dop")) {
b.removeClass("menu_dop");
} else {
b.addClass("menu_dop");
}
var b = $("#menu_dop1");
if (b.hasClass("menu_dop1")) {
b.removeClass("menu_dop1");
} else {
b.addClass("menu_dop1");
}
},
emojiToggle: function () {
var b = $(".stickers_panel");
if (b.hasClass("st_opened")) {
b.removeClass("st_opened");
} else {
b.addClass("st_opened");
}
var b = $(".cp_sticker_btn");
if (b.hasClass("cp_sticker_btn_sel")) {
b.removeClass("cp_sticker_btn_sel");
} else {
b.addClass("cp_sticker_btn_sel");
}
},
topicToggle: function () {
var b = $(".head_actions_wrap");
if (b.hasClass("head_actions_opened")) {
b.removeClass("head_actions_opened");
} else {
b.addClass("head_actions_opened");
}
},
}
function getW(e) {
return e = ge(e), e && e.offsetWidth || 0
}
function fix_size (e, ScrollTop) {
var t = ge("l"), n = ge("m"), i = ge("mhead"), o = i && i.offsetHeight || 0, a = ScrollTop || 0;
t && (e ? n.style.minHeight = "0" : (a = a > o ? a : 0, n.style.minHeight = t.offsetHeight + a + "px"), !true || getCw() < 320 ? e ? n.style.marginTop = "0" : (t.style.minHeight = getCh() + "px", n.style.marginTop = -a + "px") : t.style.minHeight = "0")
}
function blockScroll (e) {
hasClass('lm_opened', window.bodyNode) && getW('vk_wrap') < 882 && preventEvent(e)
}
function blockMenuScroll (e) {
var t = ge("vk_wrap");
if (hasClass('lm_opened', t) && t.offsetWidth < 882) {
if (getCh() >= 440) {
var a = ge("lm_cont");
a && (a.scrollHeight - a.offsetHeight) <= 0 && preventEvent(e)
}
}
}
function toggleMenu() {
var vk_wrap = $('#vk_wrap');
vk_wrap.toggleClass('lm_opened');
$('body').toggleClass('lm_opened');
var h = ge('l'), b = ge('vk_wrap'), m = scrollTop() || 0, v = scrollTop(), g = ge('m');
if(vk_wrap.hasClass('lm_opened')) {
addEvent(g,"scroll touchmove",blockScroll);
addEvent(h,"scroll touchmove",blockMenuScroll);
addEvent(geByClass1('head_search', g ),"scroll touchmove",blockMenuScroll);
var M = h.offsetHeight, E = b.offsetWidth >= 480, C = g.offsetHeight;
E ? m = v <= M - getCh() ? Math.min(v, M - getCh()) : 0 : m > v ? m = v : v - m > C - M && C > M && (m = v - C + M);
fix_size(false, Math.max(0, v - m));
} else {
fix_size(true, 0);
removeEvent(g,"scroll touchmove",blockScroll);
removeEvent(h,"scroll touchmove",blockMenuScroll);
removeEvent(geByClass1('head_search', g ),"scroll touchmove",blockMenuScroll);
}
}
function setMinHeightBody() {
var M = scrollTop();
window.bodyNode.style.overflow = "hidden", window.bodyNode.style.minHeight = "5000px", scrollTop(10);
var t = getCh() + (browser.android ? 1 : 0);
scrollTop(M),window.bodyNode.style.minHeight = t + "px", window.bodyNode.style.overflow = "";
}
$(function () {
Tick.setTick(updateDataNotif);
$('.aic_volume_wrap .aic_line').css('display', (browser.mobile === false ? 'block' : 'none'));
setMinHeightBody();
var nodeVK = $('#vk');
!0===isTouch?!1===nodeVK.hasClass()&&nodeVK.addClass("_touch"):!0===nodeVK.hasClass()&&nodeVK.removeClass("_touch");
onBodyResize(function () {
var e = ge("vk_wrap").offsetWidth;
e >= 480 && hasClass("lm_opened", bodyNode) && toggleMenu();
setMinHeightBody();
})
if (addEvent(window, "orientationchange", function () {
var e = ge("vk_wrap").offsetWidth;
e >= 480 && hasClass("lm_opened", bodyNode) && toggleMenu();
}), addEvent(document, "keydown", function (e) {
e && e.shiftKey && (e.ctrlKey || e.metaKey) && e.keyCode == 77 && (cancelEvent(e), toggleMenu())
}), isTouch) {
var e = !1, t = !1, a = 10, n = Math.min(604, getCw()) / 3, o = 30;
function i(e) {
var t = e.touches, a = scrollTop(), n = (t && t[0] ? t[0].pageX : e.pageX) || 0,
o = (t && t[0] ? t[0].pageY : e.pageY) || 0;
return {x: n, y: o - a}
}
function r(e, t) {
var a = t.x - e.x, n = t.y - e.y;
return Math.sqrt(a * a + n * n)
}
function s(e, t) {
var a = t.x - e.x, n = e.y - t.y;
return Math.abs(Math.atan2(n, a) * 180 / Math.PI)
}
addEvent(document, "touchstart", function (a) {
geByClass1("mhb_home", "mhead") && (scrollLeft() > 0 || (e = t = i(a)))
}), addEvent(document, "touchmove touchend touchcancel", function (l) {
if (e) {
l.type == "touchmove" && (t = i(l));
var c = r(e, t), u = s(e, t);
if ((l.type != "touchend" && l.type != "touchcancel" || (e = !1, l.type != "touchcancel")) && !(a > c)) {
if (hasClass("lm_opened", bodyNode) && (u = 180 - u), u > o) return e = !1, void 0;
preventEvent(l), c > n && (e = !1, toggleMenu())
}
}
})
}
});
var browser = {
version: (_ua.match(/.+(?:me|ox|on|rv|it|era|ie)[\/: ]([\d.]+)/) || [0, "0"])[1],
opera: /opera/i.test(_ua),
msie: /msie/i.test(_ua) && !/opera/i.test(_ua),
msie6: /msie 6/i.test(_ua) && !/opera/i.test(_ua),
msie7: /msie 7/i.test(_ua) && !/opera/i.test(_ua),
msie8: /msie 8/i.test(_ua) && !/opera/i.test(_ua),
msie9: /msie 9/i.test(_ua) && !/opera/i.test(_ua),
mozilla: /firefox/i.test(_ua),
chrome: /chrome/i.test(_ua),
safari: !/chrome/i.test(_ua) && /webkit|safari|khtml/i.test(_ua),
iphone: /iphone/i.test(_ua),
ipod: /ipod/i.test(_ua),
iphone4: /iphone.*OS 4/i.test(_ua),
ipod4: /ipod.*OS 4/i.test(_ua),
ipad: /ipad/i.test(_ua),
ios: +(_ua.match(/.+(?:ipod|ipad|iphone.*os) ([\d.]+)_/i) || [0, 0])[1],
android: /android/i.test(_ua),
bada: /bada/i.test(_ua),
opera_mini: /opera mini/i.test(_ua),
uc_mini: /mobile safari.*ucbrowser/i.test(_ua),
mobile: /iphone|ipod|ipad|opera mini|opera mobi|iemobile/i.test(_ua),
msie_mobile: /iemobile/i.test(_ua),
safari_mobile: /iphone|ipod|ipad/i.test(_ua),
opera_mobile: /opera mini|opera mobi/i.test(_ua),
mac: /mac/i.test(_ua)
};
browser.desktop = (browser.opera || browser.msie || browser.mozilla || browser.chrome || browser.safari) && !browser.mobile;
var isTouch = "ontouchstart" in window;
window.onBodyResize = se();
function isArray(e) {
return "[object Array]" === Object.prototype.toString.call(e)
}
function isObject(e) {
return "[object Object]" === Object.prototype.toString.call(e)
}
function escapeRE(e) {
return e ? e.replace(/([.*+?^${}()|[\]\/\\])/g, "\\$1") : ""
}
function htsc(e) {
return e.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/\'/g, "'").replace(/%/g, "%")
}
function stripTags(e) {
return e.replace(/<[^>]+>/g, "")
}
function timeNow() {
return +new Date
}
function lsSet(e, t) {
if ("undefined" != typeof t) try {
return localStorage.setItem(e, JSON.stringify(t))
} catch (a) {
} else try {
return localStorage.removeItem(e)
} catch (a) {
}
return !1
}
function lsGet(e) {
try {
return JSON.parse(localStorage.getItem(e))
} catch (t) {
}
return !1
}
function ssSet(e, t) {
if ("undefined" != typeof t) try {
return sessionStorage.setItem(e, JSON.stringify(t))
} catch (a) {
} else try {
return sessionStorage.removeItem(e)
} catch (a) {
}
return !1
}
function ssGet(e) {
try {
return JSON.parse(sessionStorage.getItem(e))
} catch (t) {
}
return !1
}
function getValues(e) {
if (!isArray(e)) return e.call ? e() : e;
for (var t = [], a = 0, n = e.length; n > a; a++) t.push(getValues(e[a]));
return t
}
function ce(e, t, a) {
var n = document.createElement(e);
return t && extend(n, t), a && setStyle(n, a), n
}
function extend() {
var e = Array.prototype.slice.call(arguments), t = e.shift();
if (!e.length) return t;
for (var a = 0, n = e.length; n > a; a++) for (var o in e[a]) "layerX" != o && "layerY" != o && (t[o] = e[a][o]);
return t
}
function setStyle(e, t, n) {
if (e = ge(e), e && e.style) {
if (isObject(t)) return each(t, function (t, n) {
setStyle(e, t, n)
});
var i = "number" == typeof n;
i && /height|width/i.test(t) && (n = Math.abs(n)), (!/transform(-origin)?|transition(-duration)?/i.test(t) || (t = getCssPropertyName(e, t))) && (e.style[t] = i && !/z-?index|font-?weight|opacity|zoom|line-?height/i.test(t) ? n + "px" : n)
}
}
function each(e, t) {
if (!e) return e;
var a, n = 0, o = e.length;
if ("undefined" == typeof o) {
for (a in e) if (t.call(e[a], a, e[a]) === !1) break
} else for (var i = e[0]; o > n && t.call(i, n, i) !== !1; i = e[++n]) ;
return e
}
function getCssPropertyName(e, t, a) {
e = ge(e) || ce("div");
for (var n = ["webkit", "Moz", "ms", "O", ""], o = ["-webkit-", "-moz-", "-ms-", "-o-", ""], i = 0, r = n.length; r > i; i++) {
var s = n[i], l = cssToJs(t, s);
if (typeof e.style[l] != "undefined") return a ? o[i] + t : l
}
return !1
}
function cssToJs(e, t) {
return t ? t + (e || "").replace(/(?:^|-)([a-z])/g, function (e, t) {
return (t || "").toUpperCase()
}) : (e || "").replace(/-([a-z])/g, function (e, t) {
return (t || "").toUpperCase()
})
}
var rf = function () {
return !1
};
function preventEvent(e){return(e=e||window.event)?(e=e.originalEvent||e,e.preventDefault&&e.preventDefault(),e.returnValue=!1,!1):!1}
function addEvent(e, t, a) {
if (e = ge(e), a = a || rf, e && 3 != e.nodeType && 8 != e.nodeType) {
e.setInterval && e != window && (e = window);
for (var t = t.split(" "), n = 0, o = t.length; o > n; n++) {
var i = t[n];
e.addEventListener ? e.addEventListener(i, a, !1) : e.attachEvent && e.attachEvent("on" + i, a)
}
}
}
function removeEvent(e, t, a) {
if (e = ge(e), a = a || rf, e && 3 != e.nodeType && 8 != e.nodeType) for (var t = t.split(" "), n = 0, o = t.length; o > n; n++) {
var i = t[n];
e.removeEventListener ? e.removeEventListener(i, a, !1) : e.detachEvent && e.detachEvent("on" + i, a)
}
}
function cancelEvent(e) {
return (e = e || window.event) ? (e = e.originalEvent || e, e.preventDefault && e.preventDefault(), e.stopPropagation && e.stopPropagation(), e.cancelBubble = !0, e.returnValue = !1, !1) : !1
}
function se() {
var e = [], t = Array.prototype.slice.call(arguments);
return function (a, n) {
if (a) if (a.apply) e.push(a); else if ("__clear" === a) if (n) {
for (var o = 0, i = e.length; i > o; o++) if (e[o] === n) {
e.splice(o, 1);
break
}
} else e = []; else {
var r = Array.prototype.slice.call(arguments);
r.shift();
for (var s = 0, i = e.length; i > s; s++) e[s].apply(window, getValues(t).concat(r))
}
}
}
function S(e) {
if (e = ge(e), !e || !attr(e, "data-id")) {
return !1;
}
var t = attr(e, "data-id"), a = val(geByTag1("input", e)), n = attr(geByClass1("ai_dur", e), "data-dur"),
o = val(geByClass1("ai_artist", e)), i = val(geByClass1("ai_title", e)),
c = attr(geByClass1("ai_play", e), "style");
return {id: t, src: a, cover: c, dur: n, artist: htsc(stripTags(o)), title: htsc(stripTags(i))};
}
function B(e, t, a) {
if (!e) {
return "";
}
var n = htsc(e.id), o = htsc(e.src), i = +e.dur, r = e.artist, s = e.title, l = e.can_add, c = e.can_del,
u = s ? '<span class="divider"> – </span>' : "", d = isTouch ? "ontouchstart" : "onmousedown", p = "",
v = "";
}
function z(e) {
var t, a, n, o = 0 > e;
return e = Math.round(o ? -e : e), a = e % 60, t = 10 > a ? "0" + a : a, e = Math.floor(e / 60), n = e % 60, t = n + ":" + t, e = Math.floor(e / 60), e > 0 && (10 > n && (t = "0" + t), t = e + ":" + t), o && (t = "-" + t), t;
}
function T(t, a) {
return z(e && a ? t - a : t);
}
function ge(e) {
return "string" == typeof e ? document.getElementById(e) : e
}
function geByClass(e, t, a) {
if (t = ge(t) || document, a = a || "*", t.getElementsByClassName) {
var n = t.getElementsByClassName(e);
if ("*" == a) return Array.prototype.slice.call(n);
var o = [];
a = a.toUpperCase();
for (var i = 0, r = n.length; r > i; i++) n[i].tagName.toUpperCase() == a && o.push(n[i]);
return o
}
for (var n = geByTag(a, t), o = [], s = new RegExp("(^|\\s)" + escapeRE(e) + "(\\s|$)"), i = 0, r = n.length; r > i; i++) s.test(n[i].className) && o.push(n[i]);
return o
}
function geByClass1(e, t, a) {
return geByClass(e, t, a)[0]
}
function gpeByClass(e, t) {
if (t = ge(t), !t) return null;
for (; t = t.parentNode;) if (hasClass(e, t)) return t;
return null
}
function geByTag(e, t) {
return (ge(t) || document).getElementsByTagName(e)
}
function geByTag1(e, t) {
return geByTag(e, t)[0]
}
function remove(e) {
return e = ge(e), e && e.parentNode ? e.parentNode.removeChild(e) : !1
}
function tag(e) {
return e = ge(e), (e && e.tagName || "").toLowerCase()
}
function show(e) {
var t = ge(e);
t && (t.style.display = t.oldstyle || (hasClass("_ib", t) ? "inline-block" : hasClass("_i", t) || "span" == tag(t) ? "inline" : "block"))
}
function hide(e) {
var t = ge(e);
t && ("none" != t.style.display && (t.oldstyle = t.style.display), t.style.display = "none")
}
function val(e, t) {
if (e = ge(e), !e) return "";
var a = e.tagName.toLowerCase(), n = "input" == a || "textarea" == a || "select" == a,
o = n && ("radio" == e.type || "checkbox" == e.type);
return "undefined" == typeof t ? n ? o ? e.checked : e.value : e.innerHTML : void(n ? o ? e.checked = t : e.value = t : (e.innerHTML = t))
}
function attr(e, t, a) {
return (e = ge(e)) ? "undefined" == typeof a ? "data-" == t.substr(0, 5) && e.dataset ? e.dataset[t.substr(5).replace(/-([a-z0-9])/, function (e, t) {
return t.toUpperCase()
})] || !1 : e.getAttribute && e.getAttribute(t) || !1 : a === !1 ? e.removeAttribute && e.removeAttribute(t) || !1 : void(e.setAttribute && e.setAttribute(t, a)) : void 0
}
function hasClass(e, t, a) {
return (t = ge(t)) ? new RegExp("(^|\\s)" + (a ? e : escapeRE(e)) + "(\\s|$)").test(t.className) : void 0
}
function addClass(e, t) {
(t = ge(t)) && !hasClass(e, t) && (t.className = (t.className ? t.className + " " : "") + e)
}
function removeClass(e, t, a) {
(t = ge(t)) && hasClass(e, t, a) && (t.className = (t.className || "").replace(new RegExp("(^|\\s)" + (a ? e : escapeRE(e)) + "(\\s|$)"), function (e, t, a) {
return t && a ? " " : ""
}))
}
function getXY(e) {
if (e = ge(e), !e) return [0, 0];
var t = 0, a = 0;
if (e.offsetParent) do t += e.offsetLeft, a += e.offsetTop; while (e = e.offsetParent);
return [t, a]
}
function getX(e) {
return getXY(e)[0]
}
function getY(e) {
var t = getXY(e)[1];
return t
}
function scrollToEl(e, t, n) {
e = ge(e) || window, t = t || 0;
var i = (e === window ? 1 : getY(e)) - t;
scrollTop(i, n)
}
function des2num(int, array) {
var cases = [2, 0, 1, 1, 1, 2];
return int + array[(int % 100 > 4 && int % 100 < 20) ? 2 : cases[Math.min(int % 10, 5)]]
}
function messageBox(type, text) {
$('#service_msg_box').remove();
var node = $('.vk_mail');
node.prepend('<div id="service_msg_box" class="service_msg_box"><div class="service_msg service_msg_' + type + '">' + text + '</div></div>');
setTimeout(function () {
node = $('#service_msg_box');
node.slideUp(1e3, function (e) {
node.remove();
})
}, 2e3)
return node;
}
function vibrate(val) {
if(val === null)
val = 0;
if ("vibrate" in navigator)
return navigator.vibrate(val);
if ("oVibrate" in navigator)
return navigator.oVibrate(val);
if ("mozVibrate" in navigator)
return navigator.mozVibrate(val);
if ("webkitVibrate" in navigator)
return navigator.webkitVibrate(val);
}
MessagesActions = function () {
return {
BoxClose: function (d) {
d = $(d.parentNode);
d.slideUp(400, function (e) {
d.remove();
})
},
actionsOpened: function (t, e) {
cancelEvent(e);
$(t.parentNode).toggleClass('head_actions_opened');
},
onMessageClick: function (e, t) {
if ("A" == e.target.tagName || "VIDEO" == e.target.tagName)
return true;
var n = $('.messagesActions').css('width', t.parentNode.clientWidth + "px");
if (!n.hasClass('resizePanel'))
n.addClass('resizePanel vk_messages_actions_visible');
n = $('.vk_mail');
if (!n.hasClass('vk_messages_actions_visible'))
n.addClass('vk_messages_actions_visible');
$(t).toggleClass('mi_selected');
var count = $('.mi_selected').length;
if (count >= 1)
$('.messagesActions__row_counter').text('Выбрано ' + des2num(count, [' сообщение', ' сообщения', ' сообщений']));
else
this.close();
},
close: function () {
var n = $('.vk_mail');
if (n.hasClass('vk_messages_actions_visible')) {
n.removeClass('vk_messages_actions_visible');
n = $('.mi_selected');
n.removeClass('mi_selected');
}
return false;
},
remove: function (peer_id) {
var n = $('.vk_mail'), data = [];
if (n.hasClass('vk_messages_actions_visible')) {
n = $('.mi_selected');
for (var i = 0; i < n.length; i++)
data.push($(n[i]).attr('data-id'));
$.post('/mail/?act=dataSend&func=remove', {
im_ajax: true,
peer: peer_id,
dataID: data.join(',')
}, function () {
$.ajaxRequest({url: '/mail/?act=show&peer=' + peer_id, container: '#m #mcont'});
});
}
return false;
},
toggleImportant: function (peer_id) {
var n = $('.vk_mail'), data = [];
if (n.hasClass('vk_messages_actions_visible')) {
n = $('.mi_selected');
for (var i = 0; i < n.length; i++) {
var s = $(n[i]);
data.push(s.attr('data-id'));
s.toggleClass('msg_item_important');
}
this.close();
$.post('/mail/?act=dataSend&func=important', {im_ajax: true, peer: peer_id, dataID: data.join(',')});
}
},
reply: function (t, peer_id) {
t = $(t);
var n = $('.vk_mail'), data = [], text = t.text();
if (n.hasClass('vk_messages_actions_visible')) {
n = $('.mi_selected');
for (var i = 0; i < n.length; i++)
data.push($(n[i]).attr('data-id'));
t.html('<span class="button_locked"><b class="button_locked_label">' + text + '</b></span>');
setTimeout(function () {
MessagesActions.close();
t.html(text);
$.post('/mail/?act=dataSend&func=reply', {
im_ajax: true,
peer: peer_id,
dataID: data.join(',')
}, function () {
$.ajaxRequest({url: '/mail/?act=show&peer=' + peer_id, container: '#m #mcont', clickButtonMail: true});
});
}, 500);
}
return false;
},
reset: function (t, peer_id, type) {
$('#attachments').slideUp(400, function (e) {
$(this).remove();
});
$('.cp_attach_btn_sel').removeClass('cp_attach_btn_sel');
$.post('/mail/?act=dataSend&func=reset', {im_ajax: true, peer: peer_id}, function (data) {
if (data.location)
$.ajaxRequest({url: data.location, container: '#m #mcont'});
}, 'json');
return false;
}
}
}(), mail = function () {
var interval = (new Date).getTime() + 5e3;
var isLoad = false;
var pageLoadMess = 2;
function generateMess(data) {
var tmpNode = '<div class="msg_item' + data.mess.mi_unread + '" data-id="' + data.mess.id + '" onclick="return MessagesActions.onMessageClick(event, this);">' +
'<div class="mi_iwrap"><a href="/id' + data.user.id_user + '">' + data.user.avatar + '</a></div>' +
'<div class="mi_cont"><div class="mi_head">' +
'<a class="mi_date" href="/mail?act=msg&id=' + data.mess.id + '">' + data.mess.time + '</a>' +
'<a class="mi_author" href="/id' + data.user.id_user + '">' + data.user.group + data.user.nick + data.user.medal + data.user.online + '</a>' +
'</div><div class="mi_body"><div class="mi_text">' + data.mess.msg + '</div>' +
(data.mess.attachments === undefined ? '' : data.mess.attachments) +
'</div></div></div>';
return tmpNode;
}
return {
keyup: function (e, t) {
var a = $(e).val() || "";
(a.length > 0) && (this.myTyping(t))
},
myTyping: function (peer_id) {
var date = (new Date).getTime();
if (interval <= date) {
interval = date + 2e3;
$.post('/mail/?act=dataSend&func=myTyping', {im_ajax: true, peer: peer_id});
return false
}
},
send: function (t, peer_id) {
var config = $('#data-text'), attachments = $('#attachments'), text = $('textarea'), n = $('.vk_mail');
var data = {min: config.attr('data-min'), max: config.attr('data-max'), textLength: text.val().length};
if (attachments.length == 0 && data.textLength < data.min || data.textLength > data.max) {
messageBox('warning', 'Сообщение должно быть длиной не менее ' + des2num(data.min, ['-го', '-х', '-ти']) + ' и не более ' + des2num(data.max, ['-го', '-х', '-ти']) + ' символов.</div>');
return false;
}
t = $(t);
t.before(ce('button', {
className: 'button',
id: 'nowrite_submit',
innerHTML: '<span class="button_locked"><b class="button_locked_label">Отправить</b></span>',
disabled: "disabled"
}));
t.hide();
var node = $('#messages').children();
vibrate(100);
$.post('/mail/?act=dataSend&func=dialog', {
im_ajax: true,
to: peer_id,
from: 'dialog',
message: text.val()
}, function (data, textStatus, jqXHR) {
$('#nowrite_submit').remove();
t.show();
if (!data.mail)
messageBox('error', 'Неизвестная ошибка.');
if (textStatus != 'success' || isObject(data) === false) {
messageBox('error', 'Неизвестная ошибка.');
return false;
}
if (data.msg_box && data.type)
messageBox(data.type, data.msg_box);
if ('ok' == data.type) {
text.val('');
attachments.length >= 1 && (attachments.slideUp(400, function (e) {
$(this).remove();
$('.cp_attach_btn_sel').removeClass('cp_attach_btn_sel');
}));
n = $('#messages');
n.find('#show_msg_box').length > 0 && (n.find('#show_msg_box').remove());
n.prepend(generateMess(data));
n = n.children();
n.first().hide().fadeIn(400);
if (10 < n.length) {
n.not('div.show_more_wrap').last().fadeOut(400, function () {
$(this).remove();
});
}
}
}, 'json');
return false;
},
updateMail: function updateMail(peer_id) {
$.post('/mail/?act=dataSend&func=update', {im_ajax: true, peer: peer_id}, function (data) {
if (isObject(data) === false || data.length === 0)
return false;
var n = $('#messages');
if (data.typing)
$('.near_btn').addClass('di_typing_now di_typing_animated');
else
$('.near_btn').removeClass('di_typing_now di_typing_animated');
if (data.read)
n.find('.mi_unread').removeClass('mi_unread');
if (data.message.length > 0) {
for (var i = 0; i < data.message.length; i++) {
n.prepend($(generateMess(data.message[i])).hide().fadeIn(400));
}
n.children().not('div.show_more_wrap').each(function (key, item) {
if (10 <= key) {
$(item).fadeOut(400, function () {
$(this).remove();
});
}
});
if (data.message.length > 0) {
n.find('#show_msg_box').length > 0 && (n.find('#show_msg_box').remove());
}
vibrate(100);
}
}, 'json');
}, updateContact: function updateContact() {
var n = $('#contactUpdate');
var contactID = [], timeMsg = [];
n.children().each(function (indx, element) {
var el = $(element);
contactID.push(el.attr('data-contact'));
timeMsg.push(el.attr('data-time'));
});
$.post('/mail/?act=dataSend&func=contact', {
im_ajax: true,
page: n.attr('data-page'),
contact_id: contactID.join(','),
time_msg: timeMsg.join(',')
}, function (data) {
if (isObject(data) === false || data.length === 0)
return false;
if (data.contact.length > 0) {
for (var i = 0, contactNode = null, listNode = null; i < data.contact.length; i++) {
listNode = $(data.contact[i]);
contactNode = n.find(".dialog_item[data-contact='" + listNode.attr('data-contact') + "']");
if (contactNode.length === 0 || listNode.attr('data-time') == contactNode.attr('data-time')) {
continue;
} else {
contactNode.remove();
n.prepend(listNode);
}
}
}
}, 'json');
}, loadMess: function (peer_id) {
if (isLoad) {
return;
}
isLoad = true;
$('#show_more').removeClass('show_more').addClass('show_more_loading').html('<span class="button_locked"></span>');
var match = location.search.match(/page=(\d+)/i);
if (match !== null && match[1] !== null)
pageLoadMess = parseInt(match[1]) + 1;
var node = $('#messages');
$.ajax({
url: '/mail/?act=dataSend&func=load_mess',
type: 'post',
data: {im_ajax: true, peer: peer_id, page: pageLoadMess},
success: function (data) {
if (isObject(data) === false || data.length === 0)
return false;
if (data.message.length > 0) {
$('.show_more_wrap').remove();
node.append('<h1 class="sub_header ">Страница: ' + pageLoadMess + '</h1>');
for (var i = 0; i < data.message.length; i++) {
node.append(data.message[i]);
}
var link = '/mail/?act=show&peer=' + peer_id + '&page=' + pageLoadMess;
window.history.pushState({path: link}, null, link);
pageLoadMess++;
} else {
pageLoadMess = 2;
var link = '/mail/?act=show&peer=' + peer_id + '&page=' + pageLoadMess;
window.history.pushState({path: link}, null, link);
}
},
complete: function () {
isLoad = false;
$('.show_more_wrap').show();
}
})
}
}
}();
var SmileButton = function () {
return {
click: function (e, a, c) {
var b = $("textarea");
if (b.length <= 0)
b = $('[data-id=emoji-block_1]');
b = b.get(0);
b.focus();
a || (a = "");
if (window.attachEvent && -1 === navigator.userAgent.indexOf("Opera")) {
if (c = b.sel) {
b = c.text.length, c.text = e + c.text + a, c.moveEnd("character", -a.length), c.moveStart("character", -b), c.select();
}
} else {
var h = b.scrollTop, f = b.value.substr(0, b.selectionStart), k = b.value.substr(b.selectionEnd),
g = b.value.substr(b.selectionStart, b.selectionEnd - b.selectionStart);
b.value = f + e + g + a + k;
c ? (b.selectionStart = f.length + e.length + g.length + a.length, b.selectionEnd = b.selectionStart) : (b.selectionStart = f.length + e.length, b.selectionEnd = b.selectionStart + g.length);
b.scrollTop = h;
}
return !1;
}
}
}();