Главная » Комментарии пользователя [Stas-29]
Найдено комментариев: 53 Показано комментариев: 31-53 |
Страницы: Назад 1 2 |
');
var elem = $(elem);
elem.find('img').hide();
elem.append(waitImg);
var messageID = elem.attr('data-message-id');
var notSpam = elem.attr('data-not-spam') ? 0 : 1; // invert - 'data-not-spam' should contain CURRENT 'notspam' status!
$.post('/index/', {
a : 101,
scope_id : uCoz.spam.config.scopeID,
message_id : messageID,
not_spam : notSpam
}).then(function(response) {
waitImg.remove();
elem.find('img').show();
if (response.error) {
alert(response.error);
return;
}
if (response.status == 'admin_message_not_spam') {
elem.attr('data-not-spam', true).find('img').attr('src', '/.s/img/spamfilter/notspam-active.gif');
$('#del-as-spam-' + messageID).hide();
} else {
elem.removeAttr('data-not-spam').find('img').attr('src', '/.s/img/spamfilter/notspam.gif');
$('#del-as-spam-' + messageID).show();
}
//console.log(response);
});
return false;
};
uCoz.spam.report = function(scopeID, messageID, notSpam, callback, context) {
return $.post('/index/', {
a: 101,
scope_id : scopeID,
message_id : messageID,
not_spam : notSpam
}).then(function(response) {
if (callback) {
callback.call(context || window, response, context);
} else {
window.console && console.log && console.log('uCoz.spam.report: message #' + messageID, response);
}
});
};
uCoz.spam.reportDOM = function(event) {
if (event.preventDefault ) event.preventDefault();
var elem = $(this);
if (elem.hasClass('spam-report-working') ) return false;
var scopeID = uCoz.spam.config.scopeID;
var messageID = elem.attr('data-message-id');
var notSpam = elem.attr('data-not-spam');
var target = elem.parents('.report-spam-target').eq(0);
var height = target.outerHeight(true);
var margin = target.css('margin-left');
elem.html('').addClass('report-spam-working');
uCoz.spam.report(scopeID, messageID, notSpam, function(response, context) {
context.elem.text('').removeClass('report-spam-working');
window.console && console.log && console.log(response); // DEBUG
response.warning && window.console && console.warn && console.warn( 'uCoz.spam.report: warning: ' + response.warning, response );
if (response.warning && !response.status) {
// non-critical warnings, may occur if user reloads cached page:
if (response.warning == 'already_reported' ) response.status = 'message_spam';
if (response.warning == 'not_reported' ) response.status = 'message_not_spam';
}
if (response.error) {
context.target.html('
' + response.error + '
');
} else if (response.status) {
if (response.status == 'message_spam') {
context.elem.text(uCoz.spam.sign.notSpam).attr('data-not-spam', '1');
var toggle = $('#report-spam-toggle-wrapper-' + response.message_id);
if (toggle.length) {
toggle.find('.report-spam-toggle-text').text(uCoz.spam.sign.hidden);
toggle.find('.report-spam-toggle-button').text(uCoz.spam.sign.show);
} else {
toggle = $('' + uCoz.spam.sign.hidden + ' ' + uCoz.spam.sign.show + '
').hide().insertBefore(context.target);
uCoz.spam.handleDOM(toggle);
}
context.target.addClass('report-spam-hidden').fadeOut('fast', function() {
toggle.fadeIn('fast');
});
} else if (response.status == 'message_not_spam') {
context.elem.text(uCoz.spam.sign.spam).attr('data-not-spam', '0');
$('#report-spam-toggle-wrapper-' + response.message_id).fadeOut('fast');
$('#' + uCoz.spam.config.idPrefix + response.message_id).removeClass('report-spam-hidden').show();
} else if (response.status == 'admin_message_not_spam') {
elem.text(uCoz.spam.sign.admSpam).attr('title', uCoz.spam.sign.admSpamTitle).attr('data-not-spam', '0');
} else if (response.status == 'admin_message_spam') {
elem.text(uCoz.spam.sign.admNotSpam).attr('title', uCoz.spam.sign.admNotSpamTitle).attr('data-not-spam', '1');
} else {
alert('uCoz.spam.report: unknown status: ' + response.status);
}
} else {
context.target.remove(); // no status returned by the server - remove message (from DOM).
}
}, { elem: elem, target: target, height: height, margin: margin });
return false;
};
uCoz.spam.handleDOM = function(within) {
within = $(within || 'body');
within.find('.report-spam-wrap').each(function() {
var elem = $(this);
elem.parent().prepend(elem);
});
within.find('.report-spam-toggle-button').not('.report-spam-handled').click(function(event) {
if (event.preventDefault ) event.preventDefault();
var elem = $(this);
var wrapper = elem.parents('.report-spam-toggle-wrapper');
var text = wrapper.find('.report-spam-toggle-text');
var target = elem.attr('data-target');
target = $(target);
target.slideToggle('fast', function() {
if (target.is(':visible')) {
wrapper.addClass('report-spam-toggle-shown');
text.text(uCoz.spam.sign.shown);
elem.text(uCoz.spam.sign.hide);
} else {
wrapper.removeClass('report-spam-toggle-shown');
text.text(uCoz.spam.sign.hidden);
elem.text(uCoz.spam.sign.show);
}
});
return false;
}).addClass('report-spam-handled');
within.find('.report-spam-remove').not('.report-spam-handled').click(function(event) {
if (event.preventDefault ) event.preventDefault();
var messageID = $(this).attr('data-message-id');
del_item(messageID, 1);
return false;
}).addClass('report-spam-handled');
within.find('.report-spam-btn').not('.report-spam-handled').click(uCoz.spam.reportDOM).addClass('report-spam-handled');
window.console && console.log && console.log('uCoz.spam.handleDOM: done.');
try { if (uCoz.manageCommentControls) { uCoz.manageCommentControls() } } catch(e) { window.console && console.log && console.log('manageCommentControls: fail.'); }
return this;
};
uCoz.spam.handleDOM();
1-30 31-53