mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
Merge pull request #167 from gordonbanderson/issue_162
ENHANCEMENT: Ressurect AJAX spam/ham/approve
This commit is contained in:
commit
c2fee6bd33
@ -422,6 +422,7 @@ class CommentsExtension extends DataExtension {
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery-validate/lib/jquery.form.js');
|
||||
Requirements::javascript(COMMENTS_THIRDPARTY . '/jquery-validate/jquery.validate.min.js');
|
||||
Requirements::add_i18n_javascript('comments/javascript/lang');
|
||||
Requirements::javascript('comments/javascript/CommentsInterface.js');
|
||||
}
|
||||
|
||||
|
@ -137,9 +137,17 @@
|
||||
* Clicking one of the metalinks performs the operation via ajax
|
||||
* this inclues the spam and approve links
|
||||
*/
|
||||
/* @todo Migrate to work with nested comments
|
||||
commentsList.on('click', '.action-links a', function(e) {
|
||||
|
||||
$('.comments-holder .comments-list').on('click', 'div.comment-moderation-options a', function(e) {
|
||||
var link = $(this);
|
||||
if (link.hasClass('delete')) {
|
||||
var confirmationMsg = ss.i18n._t('CommentsInterface_singlecomment_ss.DELETE_CONFIRMATION');
|
||||
var confirmation = window.confirm(confirmationMsg);
|
||||
if (!confirmation) {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
var comment = link.parents('.comment:first');
|
||||
|
||||
$.ajax({
|
||||
@ -149,34 +157,34 @@
|
||||
if(link.hasClass('ham')) {
|
||||
// comment has been marked as not spam
|
||||
comment.html(html);
|
||||
comment.removeClass('spam').hide().fadeIn();
|
||||
comment.removeClass('spam');
|
||||
}
|
||||
else if(link.hasClass('approve')) {
|
||||
// comment has been approved
|
||||
comment.html(html);
|
||||
comment.removeClass('unmoderated').hide().fadeIn();
|
||||
comment.removeClass('unmoderated');
|
||||
}
|
||||
else if(link.hasClass('delete')) {
|
||||
comment.fadeOut(1000, function() {
|
||||
comment.remove();
|
||||
comment.remove();
|
||||
|
||||
if(commentsList.children().length == 0) {
|
||||
if(commentsList.children().length === 0) {
|
||||
noCommentsYet.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
else if(link.hasClass('spam')) {
|
||||
comment.html(html).addClass('spam').hide().fadeIn();
|
||||
comment.html(html).addClass('spam');
|
||||
}
|
||||
},
|
||||
failure: function(html) {
|
||||
alert(html)
|
||||
var errorMsg = ss.i18n._t('CommentsInterface_singlecomment_ss.AJAX_ERROR');
|
||||
alert(errorMsg);
|
||||
}
|
||||
});
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ajax pagination
|
||||
|
10
javascript/lang/en.js
Normal file
10
javascript/lang/en.js
Normal file
@ -0,0 +1,10 @@
|
||||
// This file was generated by silverstripe/cow from javascript/lang/src/en.js.
|
||||
// See https://github.com/tractorcow/cow for details
|
||||
if (typeof(ss) == 'undefined' || typeof(ss.i18n) == 'undefined') {
|
||||
if (typeof(console) != 'undefined') console.error('Class ss.i18n not defined');
|
||||
} else {
|
||||
ss.i18n.addDictionary('en', {
|
||||
"CommentsInterface_singlecomment_ss.DELETE_CONFIRMATION": "Are you sure?",
|
||||
"CommentsInterface_singlecomment_ss.AJAX_ERROR": "An error occurred whilst updating the comment",
|
||||
});
|
||||
}
|
@ -243,12 +243,14 @@ class CommentsExtensionTest extends SapphireTest {
|
||||
$cf = $item->CommentsForm();
|
||||
|
||||
$backend = Requirements::backend();
|
||||
$this->assertEquals(
|
||||
$this->assertEquals(
|
||||
array(
|
||||
'framework/thirdparty/jquery/jquery.js',
|
||||
'framework/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js',
|
||||
'framework/thirdparty/jquery-validate/lib/jquery.form.js',
|
||||
'comments/thirdparty/jquery-validate/jquery.validate.min.js',
|
||||
'framework/javascript/i18n.js',
|
||||
'comments/javascript/lang/en.js',
|
||||
'comments/javascript/CommentsInterface.js'
|
||||
),
|
||||
$backend->get_javascript()
|
||||
|
Loading…
Reference in New Issue
Block a user