var chat;
function tryPaymentOplatainfo(url)
{
if (isGuestUser) {
showLoginRegForm();
return false;
}
$.get("/ajax/paymentTry", function() {
return true;
})
location.href = url;
}
function showLoginRegForm()
{
jQuery('.ui-widget-overlay').click();
$('#login_form_open').dialog({
width:700,
modal: true,
dialogClass: "login_form_open",
bgiframe: true,
resizable: false,
open: function() {
jQuery('.ui-widget-overlay').bind('click', function() {
jQuery('#login_form_open').dialog('close');
});
jQuery('[data-action="do-register"]').on('click', function(){
showRegForm();
return false;
});
jQuery('[data-action="do-forget"]').on('click', function(){
showForgetForm();
return false;
});
}
});
return false;
}
function showRegForm()
{
jQuery('.ui-widget-overlay').click();
$('#register_form_open').dialog({
width:700,
modal: true,
dialogClass: "register_form_open",
bgiframe: true,
resizable: false,
open: function() {
jQuery('.ui-widget-overlay').bind('click', function() {
jQuery('#register_form_open').dialog('close');
});
jQuery('[data-action="do-login"]').on('click', function(){
showLoginRegForm();
return false;
});
jQuery('[data-action="do-forget"]').on('click', function(){
showForgetForm();
return false;
});
}
});
return false;
}
function showForgetForm()
{
jQuery('.ui-widget-overlay').click();
$('#forget_form_open').dialog({
width:700,
modal: true,
dialogClass: "forget_form_open",
bgiframe: true,
resizable: false,
open: function() {
jQuery('.ui-widget-overlay').bind('click', function() {
jQuery('#forget_form_open').dialog('close');
});
jQuery('[data-action="do-login"]').on('click', function(){
showLoginRegForm();
return false;
});
jQuery('[data-action="do-register"]').on('click', function(){
showRegForm();
return false;
});
}
});
return false;
}
function reload_account_data() {
var all_sum = 0;
$(".imagesToBuy:checked:visible").each(function () {
all_sum += parseFloat($(this).closest(".item_pic").find(".price b").html());
console.log(all_sum)
})
var k=1;
$(".basket:visible:eq(0) .number").each(function() {
$(this).html(k);
k++;
})
$(".imagesSummary:visible").html($(".imagesToBuy:visible").size());
$(".selectedSummary:visible").html($(".imagesToBuy:visible:checked").size());
$(".priceSummary:visible").html(all_sum.toFixed(2));
var sum=parseFloat($("#balance").html()) - all_sum
$(".restSummary:visible").html(sum.toFixed(2));
$('form input[type=checkbox]').unbind('change');
$('form input[type=checkbox]').on("change", function(e){
data_image_id = $(this).attr('data-image_id');
if (typeof data_image_id !== "undefined") {
$('form input[data-image_id="' + data_image_id + '"]').each(function() {
if (e.target != this) {
this.checked = false;
recalcForDiscount();
}
});
}
});
}
//пересчитываем цены, исходя из скидок
function recalcForDiscount() {
if(isGuestUser)
return showLoginRegForm();
var ids=[]
$(".imagesToBuy:checked").each(function() {
ids.push($(this).val())
})
$.get('/ajax/getDiscountPrices', {ids:ids}, function(d) {
$(".imagesToBuy").not(':checked').each(function() {
$(this).closest('.item').find('.price b').text('0');
});
$(".imagesToBuy:checked").each(function() {
var $b = $(this).closest('.item').find('.price b');
if($b.attr('data-price'))
$b.html( $b.attr('data-price') );
});
if(d.data!=undefined && d.data.length>0) {
for(i in d.data) {
var item=d.data[i]
$(".item[rel="+item.hash+"]").find(".price b").html(item.price)
}
}
//$(".discountVal:visible").html(d.discountVal);
//$(".discountCnt:visible").html(d.discountCntNext);
$(".discount").empty();
if(d.discountVal!=false) {
if(d.discountCntNext<=0)
$(".discount").attr("title", "Ви досягли максимальний рівень знижки. Щоб отримати індивідуальну знижку зв'язуйтеся з тех. підтримкою")
else
$(".discount").attr("title", "Через "+d.discountCntNext+" завантажень буде новий рівень знижки")
}
for (i = 0; i < 3; i++) {
var html=' ';
$(".discount").append(html);
}
reload_account_data()
})
}
//пересчитываем цены, исходя из скидок (из отложенных)
function recalcFavForDiscount() {
if(isGuestUser)
return showLoginRegForm();
var ids=[]
$(".fav_images:checked").each(function() {
ids.push($(this).val())
})
$.get('/ajax/getDiscountPrices', {ids:ids}, function(d) {
if(d.data!=undefined && d.data.length>0) {
for(i in d.data) {
var item=d.data[i]
if($(".item[rel="+item.hash+"]").length>0)
$(".item[rel="+item.hash+"]").find(".price b").html(item.price)
$(".fav_images[value="+item.hash+"]").data('price', item.price).attr('data-price', item.price)
}
}
//$(".discountVal:visible").html(d.discountVal);
//$(".discountCnt:visible").html(d.discountCntNext);
$(".discount").empty();
if(d.discountVal!=false)
$(".discount").attr("title", "Через "+d.discountCntNext+" завантажень буде новий рівень знижки")
for (i = 0; i < 3; i++) {
var html=' ';
$(".discount").append(html);
}
recalcFavs(false);
})
}
function recalcFavs(makeAjax) {
if(isGuestUser)
return showLoginRegForm();
var selectedFavs=$(".fav_images:checked").size();
var price=0;
$(".fav_images:checked").each(function() {
price+=parseFloat($(this).data('price'));
})
$("#selectedFavs").html(selectedFavs);
$("#selectedFavsPrice").html(price.toFixed(2));
if(makeAjax==true) {
$.get("/ajax/getFavInfo", function(d) {
$("#buyAllFav").val("Завантажити всі "+d.count+" файла за "+d.price+" USD")
$("#countAllFavs").html(d.count);
}
)
}
var sum=parseFloat($("#balance").html()) - price
$("#restFav").html(Math.round(sum*100)/100);
}
function toggle_tumbler(state) {
$.post("/ajax/changeState", {type: 'tumbler', state: state});
$(".am-tumbler").val(state);
if(state=='multi'){
$(".related_checkbox").prop("checked",false).hide()
var placeholder="Введіть номер малюнка або посилання на сторінку з малюнком (кожну з нового рядка)";
var placeholder_files="Введіть посилання на сторінку з файлом (кожну з нового рядка)";
$(".search input.img").replaceWith('');
$("form.buyImages[rel=7] textarea.img").attr("placeholder", placeholder_files);
} else {
$(".related_checkbox").show();
var placeholder="Введіть номер малюнка або посилання на сторінку з малюнком";
var placeholder_files="Введіть посилання на сторінку з файлом";
$(".search textarea.img").replaceWith(' ');
$("form.buyImages[rel=7] input.img").attr("placeholder", placeholder_files);
}
reloadChangeTypeSearch();
}
$(function(){
$(".show_related").on("change", function() {
var val=$(this).is(":checked")?1:0;
$.post("/ajax/changeState", {type: 'show_related', state: val});
if(val==1) {
$(".show_related").prop("checked", true);
} else {
$(".show_related").prop("checked", null);
}
})
//проверяем открытые закачки в облака и чекаем их
setInterval(function() {
$(".dload[data-isloading=1]").each(function() {
var that=this;
$.get("/ajax/checkCloudStatus", {hash:$(this).data("hash"), cloud:$(this).data("cloud")}, function(d) {
if(d.ok==1) {
if($(that).data("cloud")=='google')
$(".gdrive-button[data-hash="+$(that).data("hash")+"] img").attr("src", "/images/google_drive_done.png")
else if($(that).data("cloud")=='yandex')
$(".yandex-button[data-hash="+$(that).data("hash")+"] img").attr("src", "/images/yandex_disk_done.png")
else if($(that).data("cloud")=='dropbox')
$(".dbox-button[data-hash="+$(that).data("hash")+"] img").attr("src", "/images/dropbox_done.png")
$(that).attr("data-isloading",0);
}
})
})
}, 10000);
//отслеживаем попытки оплатить баланс
// $("#balans_open").on("click", "input[type=submit]", function(e) {
// e.preventDefault();
// var that=this;
// $.get("/ajax/paymentTry", function() {
// $(that).off("click").click()
// })
// })
//костыль для оплаты payeer
$("#payeer_form").on("submit", function(e){
e.preventDefault()
var that=this;
$.ajax({
url:"/site/getPayeerSign",
type:'POST',
data: $(this).serialize(),
success:function(d) {
$(that).find("input[name=m_orderid]").val(d.m_orderid);
$(that).find("input[name=m_key]").val(d.m_key);
$(that).find("input[name=m_shop]").val(d.m_shop);
$(that).find("input[name=m_desc]").val(d.m_desc);
$(that).find("input[name=m_curr]").val(d.m_curr);
$(that).find("input[name=m_sign]").val(d.sign);
$(that).find("input[name=m_amount]").val(d.m_amount);
$(that).off('submit').submit();
}
})
})
//костыль для оплаты payeer
$("#obmenka_form").on("submit", function(e){
e.preventDefault()
var that=this;
$.ajax({
url:"/obmenka/sign",
type:'POST',
data: $(this).serialize(),
success:function(d) {
$(that).find("input[name=CLIENT_ID]").val(d.CLIENT_ID);
$(that).find("input[name=SIGN]").val(d.SIGN);
$(that).find("input[name=SIGN_ORDER]").val(d.SIGN_ORDER);
$(that).find("input[name=INVOICE_ID]").val(d.INVOICE_ID);
$(that).find("input[name=SUCCESS_URL]").val(d.SUCCESS_URL);
$(that).find("input[name=FAIL_URL]").val(d.FAIL_URL);
$(that).find("input[name=STATUS_URL]").val(d.STATUS_URL);
$(that).off('submit').submit();
}
})
})
//инициация платежа zpayment
$("#pay_zpayment").on("submit", function(e){
e.preventDefault()
var that=this;
var price=parseFloat(($(this).find("input[name=val]").val().replace(',','.'))*$("#balans_currency").val());
$(this).find("input[name=LMI_PAYMENT_AMOUNT]").val(price.toFixed(2));
$.ajax({
url:"/site/getZpaymentOrder",
type:'GET',
type:'POST',
data: $(this).serialize(),
success:function(d) {
$(that).find("input[name=LMI_PAYMENT_NO]").val(d.order);
$(that).off('submit').submit();
}
})
})
//костыль для оплаты yandex card
$("#yandex_card_form").on("submit", function(e){
e.preventDefault()
var that=this;
var price=parseFloat(($(this).find("input[name=val]").val().replace(',','.'))*$("#balans_currency").val());
$(this).find("input[name=sum]").val(price.toFixed(2));
$.ajax({
url:"/site/getYandexOrder",
type:'POST',
data: {sum:$(this).find("input[name=val]").val(), source:$(this).find("input[name=sum]").val()},
success:function(d) {
$(that).find("input[name=label]").val(d.order);
$(that).off('submit').submit();
}
})
//return false;
})
//костыль для оплаты yandex card
$("#yandex_form").on("submit", function(e){
e.preventDefault()
var that=this;
var price=parseFloat(($(this).find("input[name=val]").val().replace(',','.'))*$("#balans_currency").val());
$(this).find("input[name=sum]").val(price.toFixed(2));
$.ajax({
url:"/site/getYandex2Order",
type:'POST',
data: {sum:$(this).find("input[name=val]").val(), source:$(this).find("input[name=sum]").val()},
success:function(d) {
$(that).find("input[name=label]").val(d.order);
$(that).off('submit').submit();
}
})
//return false;
})
//костыль для оплаты webmoney card
$("#webmoney_card_form").on("submit", function(e){
var price=parseFloat(($(this).find("input[name=val]").val().replace(',','.'))*$("#balans_currency").val());
$(this).find("input[name=LMI_PAYMENT_AMOUNT]").val(price.toFixed(2));
return true;
})
//проверка заполненности полей при пополнении баланса
$("#balans_open input[type=submit]").on("click", function(e) {
e.preventDefault();
this_data = this;
if (isGuestUser)
return showLoginRegForm();
$.ajax({
url: '/ajax/getPaymentP2P',
type: 'POST',
cache: false,
dataType: 'json',
success: function(json) {
//console.log(json);
//console.log(json['p2p_status']);
if ((json['p2p_status'] != "6") && (json['p2p_status'] != "7")) {
if ($(this_data).closest("form").find("input[type=text]").val()=="") {
console.log("empty data");
$(this_data).closest("form").find("td").first().append("Необхідно заповнити суму поповнення ");
return false;
} else if (($(this_data).closest("form").find("input[type=text]").attr('min') !== undefined) || ($(this_data).closest("form").find("input[type=text]").attr('max') !== undefined)) {
error = false;
actual_val = parseFloat($(this_data).closest("form").find("input[type=text]").val());
if ($(this_data).closest("form").find("input[type=text]").attr('min') !== undefined) {
min = parseFloat($(this_data).closest("form").find("input[type=text]").attr('min'));
if (actual_val < min) {
error = true;
}
}
if ($(this_data).closest("form").find("input[type=text]").attr('max') !== undefined) {
max = parseFloat($(this_data).closest("form").find("input[type=text]").attr('max'));
if (actual_val > max) {
error = true;
}
}
if (error) {
$(this_data).closest('form').find('td strong').css('color', 'red');
return false;
} else {
$.get("/ajax/paymentTry", function() {
console.log("full data"+$(this_data).closest("form").find("input[type=text]").val());
$(this_data).closest("form").find("td").first().find("span").remove();
$(this_data).off("click").click()
return true;
})
}
} else {
$.get("/ajax/paymentTry", function() {
console.log("full data"+$(this_data).closest("form").find("input[type=text]").val());
$(this_data).closest("form").find("td").first().find("span").remove();
$(this_data).off("click").click()
return true;
})
}
} else {
$('.form_add_pay_ajax').trigger('submit');
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
//тоггл селекта типа выборки
$(".am-tumbler").on("change", function() {
toggle_tumbler($(this).val())
})
//кнопки-сейверы в облака
// $("body").on("click", ".dropbox-button", function(e) {
// e.preventDefault();
// $.get('/ajax/cloudUsage', {cloud:'dropbox'});
// Dropbox.save($(this).attr("href"), $(this).attr("rel"));
// })
$("body").on("click", ".gdrive-button", function(e) {
e.preventDefault();
//Dropbox.save($(this).attr("href"), $(this).attr("rel"));
//window.open('/site/socialAuth/?hash='+$(this).data("hash"), "googleDriveUpload");
$.get('/ajax/cloudUsage', {cloud:'googledrive'});
window.open('/site/socialAuth/'+$(this).data("hash")+'/', "googleDriveUpload", 'left=50%,top=20,width=436,height=200,toolbar=0,resizable=0,location=0');
})
$("body").on("click", ".yandex-button", function(e) {
e.preventDefault();
$.get('/ajax/cloudUsage', {cloud:'yandexdisk'});
window.open('/site/yandexAuth/'+$(this).data("hash")+'/', "yandexDriveUpload", 'left=50%,top=20,width=436,height=300,toolbar=0,resizable=0,location=0');
})
$("body").on("click", ".dbox-button", function(e) {
e.preventDefault();
// $.get('/ajax/cloudUsage', {cloud:'dropbox'});
// window.open('/site/dropboxAuth/'+$(this).data("hash")+'/', "dropboxDriveUpload", 'left=50%,top=20,width=436,height=300,toolbar=0,resizable=0,location=0');
window.open('/ajax/dropboxUpload?id='+$(this).data("hash"), "dropboxUpload", 'left=50%,top=20,width=436,height=300,toolbar=0,resizable=0,location=0');
})
$("body").on("click", ".mail-button", function(e) {
e.preventDefault();
console.log('mail cloud');
$.get('/ajax/cloudUsage', {cloud:'mailru'});
//$.get('/ajax/mailRuUpload', {id:$(this).data("hash")});
// $.fancybox({
// width: 500,
// height: 200,
// autoSize: false,
// href: '/ajax/mailRuUpload?id='+$(this).data("hash"),
// type: 'ajax'
// });
window.open('/ajax/mailRuUpload?id='+$(this).data("hash"), "mailruUpload", 'left=50%,top=20,width=436,height=300,toolbar=0,resizable=0,location=0');
});
$("body").on("click", ".wetransfer-button", function(e) {
e.preventDefault();
window.open('/ajax/wetransferUpload?id='+$(this).data("hash"), "wetransferUpload", 'left=50%,top=20,width=436,height=300,toolbar=0,resizable=0,location=0');
});
////////////заметки
$(document).click(function(e) {
if( !$(e.target).hasClass('edit_note_input')
&& !$(e.target).hasClass('edit_note')
&& !$(e.target).hasClass('edit_note_text')
&& !$(e.target).hasClass('edit_note_pic')
&& !$(e.target).children().hasClass('edit_note_input')
&& !$(e.target).hasClass('edit_note_button')
&& !$(e.target).children().hasClass('edit_note_button')
&& $(".edit_note_button:visible").length>0
) {
$(".edit_note_button:visible").click();
}
});
$("body").on("click", ".edit_note_pic_thumb", function(e) {
e.preventDefault();
var text=$(this).prop("data-title");
var that=this
$.fancybox.open({
content:$(that).parent().find(".note_popup").html(),
// width:1060,
// height:59,
// maxWidth:800,
minHeight:59,
// autoSize:false,
beforeShow: function() {
$(this.inner).find("textarea").text(text)
var width =Math.round($(window).width()/2) ;
$(this.inner).find("textarea").width(width);
}
})
})
$("body").on("click", ".note_popup_button", function(e) {
e.preventDefault();
var that=this;
var text=$(this).parent().find(".note_popup_input").val();
$.post("/ajax/editNote", {id:$(that).attr("rel"), text:text},function() {
$(".edit_note_pic_thumb[rel="+$(that).attr("rel")+"]").attr("title", "Ваша заметка: "+text).prop("data-title", text);
$.fancybox.close()
})
})
$("body").on("click", ".edit_note_pic, .edit_note_text", function(e) {
if($(this).parent().find(".edit_note_button").is(":hidden"))
$(this).parent().find(".edit_note").click();
})
$("body").on("click", ".edit_note", function(e) {
var text;
var text2=$(this).parent().find(".note_more").attr("title");
if(text2!=undefined) {
text=text2;
} else {
text=$(this).html();
}
$(this).parent().find(".note_more").remove();
text=$.trim(text)
if(text=="undefined") text=""
$(this).parent().find(".edit_note_button").show();
$(this).replaceWith($(''));
})
$("body").on("click", ".edit_note_button", function(e) {
e.preventDefault();
var that=this;
var text=$(this).parent().find(".edit_note_input").val();
$.post("/ajax/editNote", {id:$(that).closest(".item_pic").attr("rel"), text:text},function() {
$(that).parent().find(".edit_note_button").hide();
if(text.length>100) {
var text2=text.slice(0,100)
$(that).parent().find(".edit_note_input").replaceWith($(''+text2+' >> '));
} else {
$(that).parent().find(".edit_note_input").replaceWith($(''+text+' '));
}
})
})
$(".username").mouseenter(function(){
$(this).addClass("hovered");
$("#header .limit").addClass("uhovered")
});
$(".username").mouseleave(function(){
$(this).removeClass("hovered");
$("#header .limit").removeClass("uhovered")
});
//слайдер подсказок
var sudoSlider = $("#slider").sudoSlider({
pause: 3000,
auto:true,
numeric: true,
continuous: true
});
//смена темы
$(".themes_in a").click(function(e) {
e.preventDefault();
var obj=$(this);
var docHeight = $(document).height();
$("body").append("
");
$("#overlay")
.height(docHeight)
.css({
'position': 'absolute',
'top': 0,
'left': 0,
'width': '100%',
'z-index': 5000
}).animate({
'background-color': 'black',
}, "slow", function() {
var state=obj.attr("rel");
obj.parent().find("a").removeClass("selected");
obj.addClass("selected");
$("#chat_open").find(".your_message .image img").attr("src", "/themes/"+state+"/images/admin.jpg");
if(state!="") {
$("#theme_css").attr("href", "/themes/"+state+"/css/style.css?v=3");
$("#theme_css2").attr("href", "/themes/"+state+"/css/adaptive.css?v=3");
$("#theme_css").data("name", state).attr('data-name', state);
if($("#chat img").data("notify")==$("#chat img").attr("src"))
$("#chat img").attr("src","/themes/"+state+"/images/new_message_chat.gif");
$("#chat img").data("notify", "/themes/"+state+"/images/new_message_chat.gif").attr('data-notify', "/themes/"+state+"/images/new_message_chat.gif");
$(".loadbar").attr("src", "/themes/"+state+"/images/loading.gif");
$(".deleteUserSearch").attr("src", "/themes/"+state+"/images/close.png");
}
else
$("#theme_css").attr("href", "");
// // if($("li[aria-controls=ordertabs2] a").hasClass("blink")) {
// // $("li[aria-controls=ordertabs2] a").removeClass("blink");
// // setTimeout(function(){$("li[aria-controls=ordertabs2] a").addClass("blink");}, 500)
// }
$.post("/ajax/changeState", {type:'theme', state:state}, function() {
$.get("/ajax/getTips", function(d) {
$("#slider").html(d);
sudoSlider.destroy();
sudoSlider.init();
});
$("#overlay").animate({opacity:0}, "slow", function(){$(this).remove()});
})
});
})
//автоподсчет суммы оплаты на сайте
$(".form_pay_ajax input").on("keyup", function() {
var price=parseFloat(($(this).val().replace(',','.'))*41.37);
$(this).closest("form").find(".currSum").html(price.toFixed(2));
})
$("#pay input").on("keyup", function() {$(this).val($(this).val().replace(',','.'))})
//проверка полей формы заказа поиска
$("#orderSearch").closest("form").submit(function() {
if(isGuestUser)
return showLoginRegForm();
if($(this).find("input[name=search]").val()=='Вкажіть посилання на зразок для пошуку' && $(this).find("input[name=file]").val()=='') {
alert('Вкажіть посилання на малюнок-зразок для пошуку, або прикріпіть її за допомогою кнопки "огляд"');
return false;
}
return true;
})
//формирование ссылки оплаты для онпей
$("#pay_onpay").submit(function() {
var url=$(this).attr("action");
url+="&price="+$(this).find("input[name=val]").val();
location.href=url;
return false;
})
//событие на псевдо кнопке файла
$(".fileButton").click(function() {
$(this).closest("form").find("input[name=file]").click();
})
$("input[name=file]").change(function() {
var file = this.files;
if(file[0].size>20*1024*1024) {
alert("Файл должен быть меньше 20мб");
$(this).val("")
}
if(file[0]!=undefined)
$(this).closest("form").find(".fileName").html(file[0].name);
else
$(this).closest("form").find(".fileName").html('');
})
//проходимся по кнопкам и отмечаем их как :visited
var visited=$.cookie('visited');
if(visited!=undefined) {
visited=unescape($.cookie('visited'))
visited=visited.split(',')
for(i in visited) {
$("a[href='"+visited[i]+"']").css("color", "#D7D7D7");
$("button[rel='"+visited[i]+"']").css("color", "#D7D7D7");
}
}
//кнопки смены вида
$(".view .table").click(function() {
$(".view img").removeClass("active");
$(this).addClass("active");
loadSellitems((parseInt($(".pagination span.current").html())-1)*perPage, perPage)
loadFavItems((parseInt($(".pagination2 span.current").html())-1)*perPage, perPage)
$.post("/ajax/changeState", {type: 'view_type', state: 'table'});
$(".download_images").attr("checked", null);
$("#selected_download").val("Завантажити одним архівом з декількох файлів");
return false;
})
$(".view .thumbs").click(function() {
$(".view img").removeClass("active");
$(this).addClass("active");
loadSellitems((parseInt($(".pagination span.current").html())-1)*perPage, perPage)
loadFavItems((parseInt($(".pagination2 span.current").html())-1)*perPage, perPage)
$.post("/ajax/changeState", {type: 'view_type', state: 'thumbs'});
$(".download_images").attr("checked", null);
$("#selected_download").val("Завантажити одним архівом з декількох файлів");
return false;
})
//пагинация
function loadSellitems(showFrom, showTo) {
if($(".simple-pagination").size()==0) return;
if($(".view").hasClass('inactive')) return;
$(".view").addClass('inactive');
$(".table_view .item_pic").remove();
$(".thumbs_view").html('');
var type=$(".view .table").hasClass("active")?'table':'thumbs';
$.get("/ajax/offsetSells", {from:showFrom, to:showTo, type: type, filter:$("input[name=txtSearch]").val()}, function(d) {
if(type=='table') {
var items = $(".table_view").prepend(d.html);
} else {
$(".thumbs_view").html(d.html);
}
$(".view").removeClass('inactive');
gapi.savetodrive.go();
})
}
if(typeof($(".pagination"))!=undefined) {
if(typeof countSells !='undefined') {
var numItems = countSells;
var perPage = 20;
}
$(".pagination").pagination({
prevText: 'Поп.',
nextText: 'Наст.',
items: numItems,
itemsOnPage: perPage,
cssStyle: "light-theme",
onPageClick: function(pageNumber) {
var showFrom = perPage * (pageNumber - 1);
var showTo = perPage;
loadSellitems(showFrom, showTo)
}
});
loadSellitems(0, perPage)
}
if(typeof($(".pagination2"))!=undefined) {
if(typeof countFavs2 !='undefined') {
var numItems2 = countFavs2;
var perPage = 20;
}
$(".pagination2").pagination({
prevText: 'Поп.',
nextText: 'Наст.',
items: numItems2,
itemsOnPage: perPage,
cssStyle: "light-theme",
onPageClick: function(pageNumber) {
var showFrom = perPage * (pageNumber - 1);
var showTo = perPage;
loadFavItems(showFrom, showTo)
}
});
loadFavItems(0, perPage)
}
function loadFavItems(showFrom, showTo, callback) {
//if($(".simple-pagination").size()==0) return;
if($(".view").hasClass('inactive_fav')) return;
$(".view").addClass('inactive_fav');
$(".fav_table_view .item_pic").remove();
$(".fav_thumbs_view").html('');
var type=$(".view .table").hasClass("active")?'table':'thumbs';
$.get("/ajax/offsetFavs", {from:showFrom, to:showTo, type: type, filter:''}, function(d) {
if(type=='table') {
var items = $(".fav_table_view").prepend(d.html);
} else {
$(".fav_thumbs_view").html(d.html);
}
$(".view").removeClass('inactive_fav');
//добавляем мерцание
// if($(".fav_table_view .item_pic").length>0 || $(".fav_thumbs_view div.image").length>0) {
// $("li[aria-controls=ordertabs2] a").addClass("blink");
// }
if(callback!=undefined)
callback();
})
}
$("input[name=txtSearch]").closest("form").submit(function() {
loadSellitems(0, perPage)
return false;
})
$(".fancy").fancybox();
$(".fancyVideo").fancybox({type:'ajax', width:'410px', height:'300px'});
$("#tabs").tabs({
create:function(event,ui) {
$.get("/ajax/getRulesText?type=1", function (d) {
$("#descr2").html(d.text);
})
},
select:function(event,ui) {
$.post("/ajax/changeState", {type: 'tabs', state: ui.index});
$.get("/ajax/getRulesText?type=" + ui.tab.rel, function (d) {
$("#descr2").html(d.text);
})
$("#tabs .basket .item_pic").remove()
reload_account_data();
}
});
$("#ordertabs").tabs();
$('#message').click(function(){
$('#message_open').dialog({
width:600,
modal: true,
dialogClass: "message_open",
bgiframe: true,
resizable: false,
open: function() {
jQuery('.ui-widget-overlay').bind('click', function() {
jQuery('#message_open').dialog('close');
})
}
});
return false;
});
$('#faq').click(function(){
$('#faq_open').dialog({
width:600,
modal: true,
dialogClass: "faq_open",
bgiframe: true,
resizable: false,
open: function() {
jQuery('.ui-widget-overlay').bind('click', function() {
jQuery('#faq_open').dialog('close');
})
}
});
return false;
});
$('#balans, .usermoney, .footer_balans').click(function(){
// check user login
if( location.href.indexOf('/site/account') > -1 ){
var isGuest = false;
$.ajax({
url: "/site/is_guest",
type: "POST",
dataType: "json",
async: false
}).always(function(data){
isGuest = data;
});
if( isGuest ){
location.href = '/';
return;
}
}
$('#balans_open').dialog({
width:600,
modal: true,
dialogClass: "balans_open",
bgiframe: true,
resizable: false,
open: function() {
jQuery('.ui-widget-overlay').bind('click', function() {
jQuery('#balans_open').dialog('close');
})
}
});
return false;
});
$('#settings').click(function(){
$('#settings_open').dialog({
width:600,
modal: true,
dialogClass: "settings_open",
bgiframe: true,
resizable: false,
open: function() {
jQuery('.ui-widget-overlay').bind('click', function() {
jQuery('#settings_open').dialog('close');
})
}
});
return false;
});
// добавляем предупреждение о повторном скачивании картинки
window.downloadClickDialog = function(){
$('#downloads_open').dialog({
width:600,
modal: true,
dialogClass: "downloads_open",
bgiframe: true,
resizable: false,
open: function() {
jQuery('.ui-widget-overlay').bind('click', function() {
jQuery('#downloads_open').dialog('close');
})
}
});
return false;
}
setInterval(function(){
if( $('.download_img.downloaded').length ){
$('.download_img.downloaded')
.one('click', window.downloadClickDialog)
.addClass('downloaded-dialog')
.removeClass('downloaded');
}
}, 500);
// ---
$('#rupor').click(function(){
$('#rupor_open').dialog({
width:600,
modal: true,
dialogClass: "rupor_open",
bgiframe: true,
resizable: false,
open: function() {
jQuery('.ui-widget-overlay').bind('click', function() {
jQuery('#rupor_open').dialog('close');
})
}
});
return false;
});
$('[data-action="show-login-form"]').click(function(){
showLoginRegForm();
return false;
});
$('#prices').click(function(){
$('#prices_open').dialog({
width:700,
modal: true,
dialogClass: "prices_open",
bgiframe: true,
resizable: false,
open: function() {
jQuery('.ui-widget-overlay').bind('click', function() {
jQuery('#prices_open').dialog('close');
})
}
});
return false;
});
$('#chat,[data-action="show-chat"]').click(function(){
$('#chat_open').dialog({
width:600,
modal: true,
dialogClass: "chat_open",
bgiframe: true,
resizable: false,
open: function() {
jQuery('.ui-widget-overlay').bind('click', function() {
jQuery('#chat_open').dialog('close');
})
chat.getCurrMessages();
chat.checkCurrMessages();
}
});
return false;
});
$('#about_us,[data-action="show-about-us"]').click(function(){
$('#about_us_open').dialog({
width:600,
modal: true,
dialogClass: "about_us_open",
bgiframe: true,
resizable: false,
open: function() {
jQuery('.ui-widget-overlay').bind('click', function() {
jQuery('#about_us_open').dialog('close');
})
}
});
return false;
});
//беремся за макет
$("#ordertabs3").on("click", ".joinRequest", function() {
$.fancybox.open({
href: "/ajax/requestAgreement",
type: "ajax",
ajax: {
type: "GET",
data: {
id: $(this).attr("rel")
}
}
});
return false;
})
//отсылаем файл по макету
$("#ordertabs3").on("click", ".completeRequest", function() {
$.fancybox.open({
href: "/ajax/sendRequestResult",
type: "ajax",
ajax: {
type: "POST",
data: {
id: $(this).attr("rel")
}
}
});
return false;
})
// $("#ordertabs3").on("change", ".sendSearchRequest", function() {
// $(this).closest("form").submit();
// });
//проверяем статус загрузок
setInterval(function () {
var Ids = new Array();
$(".item.process").each(function () {
Ids.push($(this).attr("rel"))
});
if (Ids.length > 0)
$.post("/ajax/checkLoadingProcess", {ids: Ids}, function (d) {
if (d.ok == 1) {
for (i in d.data) {
var item = d.data[i];
var obj = $(".process[rel=" + item.hash + "]");
if(obj==undefined) continue;
if (item.link != undefined) {
var num=obj.find(".trNum").html();
obj.replaceWith(item.html);
obj.find(".trNum").html(num);
obj.removeClass('process');
// obj.find("td.loading").html('');
// obj.removeClass('process');
// obj.find("td:eq(0) input").show();
// obj.find("td:eq(0) input").data('size', item.size);
// obj.find(".size_field").html('('+item.size+' MB)');
// if(item.is_file==1)
// obj.find("td:eq(4)").html(' ' + item.name + ' ');
// else
// obj.find("td:eq(4)").html(' № ' + item.image_id + ' ');
// obj.find(".download_img").show();
// obj.find(".download_img").attr("rel", item.link);
} else {
//obj.find(".percent").html(item.percent + "%");
obj.find(".loading img").attr('title', "У процесі' "+ item.percent + "%");
obj.find(".loading img").attr('alt', "У процесі' "+ item.percent + "%");
}
}
}
})
}, 10000);
//Обработка подсказок для полей инпута
$("body").on('focus', "input", function () {
if ($(this).data("value") != undefined) {
if ($(this).val() == $(this).data("value")) $(this).val('');
}
})
$("body").on('focus', "textarea", function () {
if ($(this).data("value") != undefined) {
if ($(this).html() == $(this).data("value")) $(this).html('');
}
})
$("body").on('blur', "input", function () {
if ($(this).data("value") != undefined) {
if ($(this).val() == '') $(this).val($(this).data("value"));
}
})
$("body").on('blur', "textarea", function () {
if ($(this).data("value") != undefined) {
if ($(this).html() == '') $(this).html($(this).data("value"));
}
})
$("form input").each(function () {
if ($(this).data("value") != undefined) {
$(this).val($(this).data("value"));
}
})
$("form textarea").each(function () {
if ($(this).data("value") != undefined) {
$(this).html($(this).data("value"));
}
})
$(".buyImages").on('click', '.imagesToBuy', function () {
recalcForDiscount();
//reload_account_data();
});
$(".buyImages").on('paste', 'input[name=image],textarea[name=image]', function (e) {
var lines = 50;
var ddd=e.originalEvent.clipboardData.getData('text').split("\n");
console.log(ddd)
var newLines = e.originalEvent.clipboardData.getData('text').split("\n").length;
if(newLines >= lines) {
var obb=$(this);
setTimeout(function () {
//console.log(ddd.splice(0, lines))
obb.val(ddd.splice(0, lines).join("\n"));
},200)
}
if($(".am-tumbler").val()=="auto") {
$(this).trigger('keyup')
}
})
$(".buyImages").on('click', '.search[type=submit]', function () {
if($(".am-tumbler").val()=="auto")
return false;
processWithData($(this).closest('form'));
return false;
});
var timer = null;
$(".buyImages").on('keyup', 'input[name=image],textarea[name=image]', function () {
if($(".am-tumbler").val()=="auto") {
var obj = $(this).closest('form');
clearTimeout(timer);
timer = setTimeout(function () {
processWithData(obj);
}, 1000);
}
});
$(".buyImages").on('keydown', 'textarea[name=image]', function (e) {
var lines = 50;
var newLines = $(this).val().split("\n").length;
//console.log(newLines)
if(e.keyCode == 13 && newLines >= lines) {
return false;
}
});
//обработка загрузки изображения через форму
function processWithData(form) {
var obj=form;
var img_val=obj.find(".search .img").val();
var imgs=img_val.split("\n");
imgs = imgs.filter(Boolean);
var imgs_count = imgs.length;
obj.find(".loadingPreview").show();
obj.find(".search .img_2022").val('');
var objectsInRam=new Array();
for(i in imgs) {
$.post("/ajax/imagePreview", {str: imgs[i], type:obj.attr("rel")}, function (d) {
imgs_count--;
if(imgs_count == 0){
obj.find(".loadingPreview").hide();
}
if (d.ok == 2) {
remaining_images = obj.find(".search .img_2022").val();
remaining_images += d.str + "\n";
obj.find(".search .img_2022").val(remaining_images);
try_parsing_ids = obj.find(".search .try_parsing_id_2022").val();
try_parsing_ids += d.try_parsing_id + "\n";
obj.find(".search .try_parsing_id_2022").val(try_parsing_ids);
obj.find(".loadingPreview").show();
setTimeout(function() {
processWithData2022(obj);
}, 5000);
} else if (d.ok == 1) {
obj.find("input[name=image]").val('');
var html = '';
for (i in d.objects) {
var object = d.objects[i];
if($.inArray(object.id, objectsInRam)!=-1) continue;
objectsInRam.push(object.id);
//console.log( object.type_orig );
if(object.object_type=="file") {
html += '';
html += '
';
html += '
'+(1+parseInt(i))+'
';
html += '
';
html += '
№ '+object.name+'
';
html += '
'+object.project+'
';
html += '
'+object.size+'
';
html += '
0 USD
';
html += '
Відкласти
';
html += '
';
html += '
';
html += '
';
} else if (object.object_type=="video") {
html += '';
html += '
';
html += '
'+(1+parseInt(i))+'
';
html += '
';
html += '
№ '+object.image_id+'
';
html += '
'+object.type+'
';
html += '
'+object.resolution+'
';
html += '
0 USD
';
html += '
Відкласти
';
html += '
';
html += '
';
html += '
';
}else {
html += '';
html += '
';
html += '
'+(1+parseInt(i))+'
';
html += '
';
html += '
№ '+object.image_id+'
';
html += '
'+object.type+'
';
var style=(object.resolution=='Збільшується без втрати якості')?'style="padding:23px 0"':'';
if( object.resolution == '0 x 0' ) object.resolution = '';
html += '
'+object.resolution;
if (object.type_orig != 'jpg') {
}
html+='
';
html += '
0 USD
';
html += '
Відкласти
';
html += '
';
html += '
';
html += '
';
}
}
html+='';
obj.find(".basket").prepend(html);
if(d.related!=null && d.related.length>0 && obj.find(".to_related").length==0) {
html= ' ';
obj.find(".basket").find(".item_pic:last").after(html);
}
if(d.related!=null && d.related.length>0) {
var html2='';
for (i in d.related) {
var object = d.related[i];
html2 += '';
html2 += '
';
html2 += '
'+(1+parseInt(i))+'
';
html2 += '
';
html2 += '
№ '+object.image_id+'
';
html2 += '
'+object.type+'
';
var style=(object.resolution=='Збільшується без втрати якості')?'style="padding:23px 0"':'';
html2 += '
'+object.resolution+'
';
html2 += '
0 USD
';
html2 += '
Відкласти
';
html2 += '
';
html2 += '
';
html2 += '
';
}
$("h2.to_related").after(html2);
//obj.find(".basket").append(html);
}
reload_account_data();
if(d.mess!="")
alert(d.mess);
} else {
alert("Помилка доступу до сервера");
}
})
}
}
//обработка загрузки изображения через форму 2022
function processWithData2022(form) {
var obj=form;
var img_val = obj.find(".search .img_2022").val();
var imgs = img_val.split("\n");
var try_parsing_id_val = obj.find(".search .try_parsing_id_2022").val();
var parsing_ids = try_parsing_id_val.split("\n");
imgs = imgs.filter(Boolean);
parsing_ids = parsing_ids.filter(Boolean);
var imgs_count = imgs.length;
obj.find(".loadingPreview").show();
obj.find(".search .img_2022").val('');
obj.find(".search .try_parsing_id_2022").val('');
var objectsInRam = new Array();
for(i in imgs) {
$.post("/ajax/checkTryParsing", {str: imgs[i], type:obj.attr("rel"), try_parsing_id: parsing_ids[i]}, function (d) {
imgs_count--;
if(imgs_count == 0){
obj.find(".loadingPreview").hide();
}
if (d.ok == 2) {
remaining_images = obj.find(".search .img_2022").val();
remaining_images += d.str + "\n";
obj.find(".search .img_2022").val(remaining_images);
try_parsing_ids = obj.find(".search .try_parsing_id_2022").val();
try_parsing_ids += d.try_parsing_id + "\n";
obj.find(".search .try_parsing_id_2022").val(try_parsing_ids);
obj.find(".loadingPreview").show();
setTimeout(function() {
processWithData2022(obj);
}, 5000);
} else if (d.ok == 1) {
obj.find("input[name=image]").val('');
var html = '';
for (i in d.objects) {
var object = d.objects[i];
if($.inArray(object.id, objectsInRam)!=-1) continue;
objectsInRam.push(object.id);
if(object.object_type=="image") {
html += '';
html += '
';
html += '
'+(1+parseInt(i))+'
';
html += '
';
html += '
№ '+object.image_id+'
';
html += '
'+object.type+'
';
var style=(object.resolution=='Збільшується без втрати якості')?'style="padding:23px 0"':'';
if( object.resolution == '0 x 0' ) object.resolution = '';
html += '
'+object.resolution;
if (object.type_orig != 'jpg') {
}
html+='
';
html += '
0 USD
';
html += '
Відкласти
';
html += '
';
html += '
';
html += '
';
} else if (object.object_type=="video") {
html += '';
html += '
';
html += '
'+(1+parseInt(i))+'
';
html += '
';
html += '
№ '+object.image_id+'
';
html += '
'+object.type+'
';
html += '
'+object.resolution+'
';
html += '
0 USD
';
html += '
Відкласти
';
html += '
';
html += '
';
html += '
';
}
}
html+='';
obj.find(".basket").prepend(html);
reload_account_data();
if (d.mess!="") {
alert(d.mess);
}
} else {
alert("Помилка доступу до сервера");
}
})
}
}
$(".basket").on("click", ".item_pic .delete", function() {
if($(this).find("a").hasClass('delFavOne')) return;
$(this).closest(".item").remove();
reload_account_data();
return false;
})
//Последние проверки перед покупкой
$(".buyImages").on("click", ".buy", function (e) {
if(isGuestUser)
return showLoginRegForm();
e.preventDefault(e);
var obj = $(this).closest("form");
obj.find("input.buy").prop("disabled", "disabled");
$.post('/ajax/checkBeforeLoad', obj.serialize(), function (d) {
if (d.ok == 1) {
obj.submit();
return true;
}
else {
alert(d.mess);
obj.find("input.buy").prop("disabled", null);
return false;
}
});
})
function add_items(objects) {
var html = '';
for (i in objects) {
var object = objects[i];
html += '';
}
return html;
}
//подгрузка страниц для видео
$(".nextButton").click(function() {
var obj=$(this).closest('form');
obj.find(".loading").show();
$.post("/ajax/searchVideo", {str: obj.find("input[name=video]").val(),page:$(this).attr("rel"),filter:$("input[name=videoRel]").val()}, function (d) {
obj.find(".loading").hide();
if (d.ok == 1) {
var html=add_items(d.objects);
if(d.next>0) {
$(".nextButton").attr("rel", d.next);
$(".nextButton").show();
} else
$(".nextButton").hide();
$(".img_info_video").remove();
obj.closest('.download').find(".image_info").append(html);
reload_account_data();
}
else {
alert(d.mess);
}
})
return false;
})
//поиск видео
$("#videoSearch, #aeSearch, #popSearch").click(function() {
var obj=$(this).closest('form');
obj.find(".loading[rel=begin]").show();
$("input[name=videoRel]").val($(this).attr('rel'));
$.post("/ajax/searchVideo", {str: obj.find("input[name=video]").val(),filter:$("input[name=videoRel]").val()}, function (d) {
obj.find(".loading[rel=begin]").hide();
if (d.ok == 1) {
var html=add_items(d.objects);
if(d.next>0) {
$(".nextButton").attr("rel", d.next);
$(".nextButton").show();
}
obj.closest('.download').find(".image_info").html(html);
reload_account_data();
}
else {
alert(d.mess);
}
})
return false;
})
// выгрузка в облачные сервисы через таблкиу cloud_upload
$('body').on('click', '.upload-cloud-storage', function(e) {
e.preventDefault();
$('#cloud_upload .cloud-upload-link').val('');
$('#cloud_upload .cloud-upload-generation-link').removeClass('hidden');
$('#cloud_upload .cloud-upload-link-copy').removeClass('disabled');
$('#cloud_upload .cloud-upload-link-container').addClass('hidden');
cloud = $(this).data('cloud');
file = $(this).data('file');
data = [];
data['cloud'] = cloud;
data['file'] = file;
processUploadCloudStorage(data);
$('#cloud_upload').dialog({
width:600,
modal: true,
dialogClass: "cloud_upload",
bgiframe: true,
resizable: false,
open: function() {
$('.ui-widget-overlay').bind('click', function() {
$('#cloud_upload').dialog('close');
})
}
});
});
// выгрузка в облачные сервисы через таблкиу cloud_upload
function processUploadCloudStorage(data) {
cloud = data['cloud'];
file = data['file'];
if(typeof data['cloud_upload_id'] !== "undefined") {
cloud_upload_id = data['cloud_upload_id'];
} else {
cloud_upload_id = null;
}
$.ajax({
type: 'POST',
url: '/ajax/checkCloudUpload',
data: {
cloud: cloud,
file: file,
cloud_upload_id: cloud_upload_id,
},
cache: false,
dataType: 'json',
success: function(data) {
//console.log(data);
if (data['waiting']) {
setTimeout(function() {
processUploadCloudStorage(data);
}, 20000);
} else if (data['success']) {
$('#cloud_upload .cloud-upload-link').val(data['link']);
$('#cloud_upload .cloud-upload-generation-link').addClass('hidden');
$('#cloud_upload .cloud-upload-link-container').removeClass('hidden');
} else if (data['error']) {
$('#cloud_upload').dialog('close');
alert("Виникла помилка! Повторіть спробу пізніше");
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
// copy input
$('.cloud-upload-link-copy').on('click', function() {
href = $(this).parent().find('input').val();
navigator.clipboard.writeText(href);
$(this).addClass('disabled');
});
$("body").on("change", ".fav_images", function() {
recalcFavForDiscount();
//recalcFavs(false);
})
//клик покупки избранного
$("body").on('click', '#buyFav', function (e) {
if(isGuestUser)
return showLoginRegForm();
e.preventDefault(e);
var obj = $(this).closest("form");
obj.find("#buyFav").prop("disabled", "disabled");
if($(".fav_images:checked").length==0) {
alert("Не вибрано жодного файлу для завантаження");
obj.find("#buyFav").prop("disabled", null);
return false;
}
$.post('/ajax/checkBeforeLoad', obj.serialize(), function (d) {
if (d.ok == 1) {
var ids=[]
$(".fav_images:checked").each(function() {
ids.push($(this).val());
})
$.post("/ajax/delFavIds", {ids: ids}, function(d) {
obj.submit();
});
return true;
}
else {
alert(d.mess);
obj.find("#buyFav").prop("disabled", null);
return false;
}
});
if(parseFloat($(".balance1 span").html()-($(this).closest("form").find(".price_val").val())*$(this).closest("form").find("input:checked").size())<0) {
alert("Недостатньо коштів на рахунку");
return false;
} else {
return true;
}
})
//клик удаления избранного
$("body").on('click', '#delFav', function (e) {
e.preventDefault(e);
var form=$(this).closest("form");
var type=$(".view .table").hasClass("active")?'table':'thumbs';
if(type==undefined)
type='table';
var blocks=form.find(".fav_images:checked");
var ids=[]
blocks.each(function() {
ids.push($(this).val());
})
if(ids.length==0) {
alert("Не вибрано жодного файла для видалення")
return false;
}
$.post("/ajax/delFavIds", {ids: ids}, function(d) {
loadFavItems(0, 20, function() {
if(type=="thumbs") {
if($(".fav_thumbs_view").closest("form").find("div.image").length==0) {
$(".emptyFavsMessage").show();
$(".noneEmptyFavs").hide();
// if($("li[aria-controls=ordertabs2] a").hasClass("blink"))
// $("li[aria-controls=ordertabs2] a").removeClass("blink");
}
} else {
if($(".fav_table_view").find(".item_pic").length==0) {
$(".emptyFavsMessage").show();
$(".noneEmptyFavs").hide();
// if($("li[aria-controls=ordertabs2] a").hasClass("blink"))
// $("li[aria-controls=ordertabs2] a").removeClass("blink");
}
}
recalcFavs(true)
$(".pagination2").pagination('updateItems', d.num);
});
})
})
//клик удаления избранного (одной картинки)
$("body").on('click', '.delFavOne', function (e) {
console.log("del fav");
e.preventDefault(e);
var type=$(".view .table").hasClass("active")?'table':'thumbs';
if(type==undefined)
type='table';
var ids=[];
ids.push($(this).attr("rel"));
var obj=$(this);
$.post("/ajax/delFavIds", {ids: ids}, function(d) {
loadFavItems(0, 20, function() {
if(type=="thumbs") {
if($(".fav_thumbs_view").closest("form").find("div.image").length==0) {
$(".emptyFavsMessage").show();
$(".noneEmptyFavs").hide();
// if($("li[aria-controls=ordertabs2] a").hasClass("blink"))
// $("li[aria-controls=ordertabs2] a").removeClass("blink");
}
} else {
if($(".fav_table_view").find(".item_pic").length==0) {
$(".emptyFavsMessage").show();
$(".noneEmptyFavs").hide();
// if($("li[aria-controls=ordertabs2] a").hasClass("blink"))
// $("li[aria-controls=ordertabs2] a").removeClass("blink");
}
}
recalcFavs(true)
$(".pagination2").pagination('updateItems', d.num);
});
})
})
$("body").on('click', '.fav', function () {
var obj=$(this);
obj.attr("disabled", "disabled");
var type=$(".view .table").hasClass("active")?'table':'thumbs';
if(type==undefined)
type='table';
$.post("/ajax/addFav", {hash: $(this).val(), type: type}, function(d) {
obj.attr("disabled", null);
if(d.ok==1) {
var id=obj.val();
obj.closest('.item_pic').remove();
$(".emptyFavsMessage").hide();
$(".noneEmptyFavs").show();
// if(!$("li[aria-controls=ordertabs2] a").hasClass("blink"))
// $("li[aria-controls=ordertabs2] a").addClass("blink");
loadFavItems(0, 20, function() {
recalcFavs(true)
$(".pagination2").pagination('updateItems', d.num);
});
} else {
alert(d.mess)
}
});
return false;
})
$(".fav_chosen").on('click', function () {
if(isGuestUser)
return showLoginRegForm();
var obj=$(this);
obj.attr("disabled", "disabled");
var ids=new Array();
$("input.imagesToBuy:checked").each(function() {ids.push($(this).val());})
$.post("/ajax/addFavIds", {ids: ids}, function(d) {
obj.attr("disabled", null);
if(d.ok==1) {
$("input.imagesToBuy:checked").each(function() {$(this).closest(".item_pic").remove()})
$(".emptyFavsMessage").hide();
$(".noneEmptyFavs").show();
// if(!$("li[aria-controls=ordertabs2] a").hasClass("blink+"))
// $("li[aria-controls=ordertabs2] a").addClass("blink");
loadFavItems(0, 20, function() {
recalcFavs(true)
$(".pagination2").pagination('updateItems', d.num);
});
} else {
alert(d.mess)
}
});
return false;
})
//обработка клика по чекбоксам пакетной загрузки
$("body").on("change", ".download_images", function () {
var allsum = 0;
var num = 0;
var allsize=0
$(".download_images:checked").each(function () {
num++;
allsum += parseFloat($(this).closest(".itemOne").find(".imgPrice").html());
allsize+=parseFloat($(this).data('size'));
})
$("#selected_download").val('Зберегти на комп\'ютері одним архівом з '+num+'-х файлів ('+allsize.toFixed(2)+' MB)');
})
//собираем файл для пакетной загрузки и отдаем его пользователям
$("#selected_download").click(function () {
if($(".download_images:checked").size()==0) {
alert("виберіть один або кілька файлів");
return false;
}
$("#loadingBatch").show();
$.post("/ajax/prepareBatchFile", $(this).closest("form").serialize(), function (d) {
$("#loadingBatch").hide();
if (d.ok == 1) {
window.location.href = '/site/batchFile';
return false;
} else {
alert(d.mess);
return false;
}
})
return false;
})
//отправка формы фидбека
$("form.feedback").submit(function () {
$.post("/ajax/feedback", $(this).serialize(), function (d) {
if (d.ok == 1) {
jQuery('#message_open').dialog('close');
} else {
$("form.feedback .errors").html(d.mess);
}
})
return false;
})
//новый пароль
$("form.new_pass").submit(function () {
var that=this;
$.post("/ajax/settings", $(this).serialize(), function (d) {
if (d.ok == 1) {
$("#settings_open .errors").html('Ви успішно змінили пароль
');
$("form.new_pass")[0].reset();
//jQuery('#settings_open').dialog('close');
} else {
$("#settings_open .errors").html(d.mess);
}
})
return false;
})
//уведомления
$("#UserOptions_notify, #UserOptions_notifyAudio").click(function () {
$.post("/ajax/settings", {notify:$("#UserOptions_notify").is(':checked')?1:0, notifyAudio:$("#UserOptions_notifyAudio").is(':checked')?1:0}, function (d) {
if (d.ok == 1) {
return true;
} else {
$("#settings_open .errors").html(d.mess);
return true;
}
})
if(!$("#UserOptions_notify").is(':checked'))
$(".nnotify").html('(вимкнено)');
else
$(".nnotify").html('(включено)');
if(!$("#UserOptions_notifyAudio").is(':checked'))
$(".nnotifyAudio").html('(вимкнено)');
else
$(".nnotifyAudio").html('(включено)');
})
$("body").on("click", ".ui-icon-closethick", function() {
$(".errors").html('');
return true;
})
$("input[name=checkaAll]").click(function() {
if($(this).is(":checked")) {
$(this).closest(".basket").find(".imagesToBuy").attr("checked", "checked");
} else {
$(this).closest(".basket").find(".imagesToBuy").attr("checked", null);
}
recalcForDiscount();
//reload_account_data();
})
$("input[name=checkAll2]").click(function() {
if($(this).is(":checked")) {
$(this).closest("form").find(".download_images:visible").attr("checked", "checked");
} else {
$(this).closest("form").find(".download_images:visible").attr("checked", null);
}
$(".download_images").change()
})
$("input[name=checkAll3]").click(function() {
if($(this).is(":checked")) {
$(this).closest("form").find(".fav_images:visible").attr("checked", "checked");
} else {
$(this).closest("form").find(".fav_images:visible").attr("checked", null);
}
//$(".fav_images").change()
recalcFavForDiscount();
recalcFavs(false);
})
//покупаем все изображения из отложенных
$("#buyAllFav").on("click", function(e) {
if(isGuestUser)
return showLoginRegForm();
e.preventDefault();
var obj = $(this).closest("form");
obj.find("#buyFav").prop("disabled", "disabled");
obj.find("#buyAllFav").prop("disabled", "disabled");
$.get("/ajax/getFavInfo", function(info) {
$.post('/ajax/checkBeforeLoad', {imagesId:info.ids}, function (d) {
if (d.ok == 1) {
mess="Ви впевнені, що бажаєте завантажити "+info.count+" файлів "+info.price+" USD? На вашому рахунку залишиться "+info.rest+" USD";
if(confirm(mess)) {
location.href="/site/buyAllFav";
}
}
else {
alert(d.mess);
obj.find("#buyFav").prop("disabled", null);
obj.find("#buyAllFav").prop("disabled", null);
}
});
})
})
//кликаем по картинке
$("body").on('click', '.basket .articul a', function () {
$(this).closest('.item').find('.articul a').css("color", '#D7D7D7');
$(this).closest('.item').find('.download_img').css("color", '#D7D7D7');
var visited=$.cookie('visited');
if(visited==undefined) {
visited=[];
} else {
visited=unescape($.cookie('visited'))
visited=visited.split(',')
}
visited.push($(this).attr("rel"));
$.cookie('visited', escape(visited.join(',')));
return true;
})
$("body").on('click', '.download_img', function () {
$(this).closest('.item').find('.articul a').css("color", '#D7D7D7');
$(this).closest('.item').find('.download_img').css("color", '#D7D7D7');
// добавляем метку для предупреждения о повторном скачивании картинки
if( !$(this).closest('.item').find('.download_img').is('.downloaded-dialog') ){
$(this).closest('.item').find('.download_img').addClass('downloaded');
}
// ---
var visited=$.cookie('visited');
if(visited==undefined)
var visited=[];
else {
visited=unescape($.cookie('visited'))
visited=visited.split(',')
}
visited.push($(this).attr("rel"));
$.cookie('visited', escape(visited.join(',')));
location.href=$(this).attr("rel");
return false;
})
});
var chat_dialog=0;
chat_dialog=0;var curr_chat_dialog=3;
//чат
$(function () {
chat = {
messages: $("#new_messages"),
textarea: $("#send_message_content"),
init: function () {
var obj = this;
//obj.getCurrMessages();
},
send: function (callback) {
var obj = this;
mess = obj.textarea.val();
$.post("/chat/default/chatSend", {mess: mess}, function (d) {
if (d.ok == 1) {
obj.textarea.val('');
obj.getCurrMessages();
chat_dialog=1;
intervalChatCheck();
} else alert("Помилка при відправці");
if(callback!=undefined)
callback();
})
},
checkCurrMessages: function() {
$.get("/chat/default/checkNewMessages", function (d) {
if (d.ok == 1) {
if(d.num!=undefined && d.num>0) {
$("#chat img").attr("src", $("#chat img").data("notify"));
if(d.alarm==1) {
var alarm = document.getElementById("message_alarm");
alarm.play();
}
chat_dialog=0;
intervalChatCheck();
$('#chat').click()
} else {
$("#chat img").attr("src", $("#chat img").data("src"));
}
} else {
$("#chat img").attr("src", $("#chat img").data("src"));
}
})
},
getCurrMessages: function () {
var obj = this;
$.get("/chat/default/getNewMessages?rand=" + Math.random(), function (d) {
if (d.ok == 1) {
var html = '';
for (i in d.data) {
var item = d.data[i];
html+=''+
'
'+
'
'+
'
'+
'' + item.name + ' '+
'(' + item.date + ') '+
'
'
+ item.content +
'
'+
'
'+
'
'+
'
';
// html += '' + item.name + ' ' + item.date + ' ' + item.content +
// '
';
}
obj.messages.html(html);
var objDiv = document.getElementById("new_messages");
if(objDiv != null)
objDiv.scrollTop = objDiv.scrollHeight;
// if ($("#new_messages div").last().size() > 0)
// $("#new_messages div").last()[0].scrollIntoView(true);
} else alert("Помилка при відправці");
})
},
close: function () {
$.fancybox.close();
}
}
chat.init();
$("#send_message_content").on("keydown", function(e) {
if (e.ctrlKey && e.keyCode == 13) {
$("#send_message_btn").prop("disabled", "disabled");
chat.send(function() {$("#send_message_btn").prop("disabled", null)});
}
})
//закрываем окно
$(".message_close").click(function () {
chat.close();
chat.checkCurrMessages();
return false;
})
//отправляем пост
$("#send_message_btn").click(function () {
if($("#send_message_content").val()=='') return false;
$("#send_message_btn").prop("disabled", "disabled");
chat.send(function() {$("#send_message_btn").prop("disabled", null)});
return false;
})
var intervalId;
function intervalChatCheck() {
if(curr_chat_dialog!=chat_dialog) {
clearInterval(intervalId);
curr_chat_dialog=chat_dialog;
if(chat_dialog==1) {
var timeout=60000;
} else {
var timeout=5*60000;
}
intervalId=setInterval(intervalChatCheck, timeout);
return;
}
chat.checkCurrMessages();
if($("#new_messages").is(":visible")) {
chat.getCurrMessages();
}
}
//обновляем раз в 60 секунд чат
if($("#new_messages").length>0) {
chat.checkCurrMessages();
intervalChatCheck();
}
})
$(document).ready(function(){
$('.stars-rating').on('click',function(){
$('.show-chat a').trigger('click');
})
});
$(document).ready(function(){
var image = new Image();
image.src = '/images/loading.gif';
});
$(document).ready(function(){
reloadChangeTypeSearch();
});
function reloadChangeTypeSearch() {
$('.search .img').unbind('change');
$('.search .img').unbind('input');
$('.search .img').unbind('cut');
$('.search .img').unbind('copy');
$('.search .img').unbind('paste');
$('.search .img').on('change input cut copy paste', function() {
if ($(this).parent().find('.img_2022').length) {
$(this).parent().find('.img_2022').val($(this).val());
}
});
}