mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
ENHANCEMENT: Ajax spam/ham/approve/delete ressurected. Added confirm box for delete
This commit is contained in:
parent
7721c20e80
commit
fd153265e9
@ -422,6 +422,7 @@ class CommentsExtension extends DataExtension {
|
|||||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
|
Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
|
||||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery-validate/lib/jquery.form.js');
|
Requirements::javascript(THIRDPARTY_DIR . '/jquery-validate/lib/jquery.form.js');
|
||||||
Requirements::javascript(COMMENTS_THIRDPARTY . '/jquery-validate/jquery.validate.min.js');
|
Requirements::javascript(COMMENTS_THIRDPARTY . '/jquery-validate/jquery.validate.min.js');
|
||||||
|
Requirements::add_i18n_javascript('comments/javascript/lang');
|
||||||
Requirements::javascript('comments/javascript/CommentsInterface.js');
|
Requirements::javascript('comments/javascript/CommentsInterface.js');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,9 +137,17 @@
|
|||||||
* Clicking one of the metalinks performs the operation via ajax
|
* Clicking one of the metalinks performs the operation via ajax
|
||||||
* this inclues the spam and approve links
|
* 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);
|
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');
|
var comment = link.parents('.comment:first');
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -149,34 +157,34 @@
|
|||||||
if(link.hasClass('ham')) {
|
if(link.hasClass('ham')) {
|
||||||
// comment has been marked as not spam
|
// comment has been marked as not spam
|
||||||
comment.html(html);
|
comment.html(html);
|
||||||
comment.removeClass('spam').hide().fadeIn();
|
comment.removeClass('spam');
|
||||||
}
|
}
|
||||||
else if(link.hasClass('approve')) {
|
else if(link.hasClass('approve')) {
|
||||||
// comment has been approved
|
// comment has been approved
|
||||||
comment.html(html);
|
comment.html(html);
|
||||||
comment.removeClass('unmoderated').hide().fadeIn();
|
comment.removeClass('unmoderated');
|
||||||
}
|
}
|
||||||
else if(link.hasClass('delete')) {
|
else if(link.hasClass('delete')) {
|
||||||
comment.fadeOut(1000, function() {
|
comment.fadeOut(1000, function() {
|
||||||
comment.remove();
|
comment.remove();
|
||||||
|
|
||||||
if(commentsList.children().length == 0) {
|
if(commentsList.children().length === 0) {
|
||||||
noCommentsYet.show();
|
noCommentsYet.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if(link.hasClass('spam')) {
|
else if(link.hasClass('spam')) {
|
||||||
comment.html(html).addClass('spam').hide().fadeIn();
|
comment.html(html).addClass('spam');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
failure: function(html) {
|
failure: function(html) {
|
||||||
alert(html)
|
var errorMsg = ss.i18n._t('CommentsInterface_singlecomment_ss.AJAX_ERROR');
|
||||||
|
alert(errorMsg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ajax pagination
|
* 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();
|
$cf = $item->CommentsForm();
|
||||||
|
|
||||||
$backend = Requirements::backend();
|
$backend = Requirements::backend();
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array(
|
array(
|
||||||
'framework/thirdparty/jquery/jquery.js',
|
'framework/thirdparty/jquery/jquery.js',
|
||||||
'framework/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js',
|
'framework/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js',
|
||||||
'framework/thirdparty/jquery-validate/lib/jquery.form.js',
|
'framework/thirdparty/jquery-validate/lib/jquery.form.js',
|
||||||
'comments/thirdparty/jquery-validate/jquery.validate.min.js',
|
'comments/thirdparty/jquery-validate/jquery.validate.min.js',
|
||||||
|
'framework/javascript/i18n.js',
|
||||||
|
'comments/javascript/lang/en.js',
|
||||||
'comments/javascript/CommentsInterface.js'
|
'comments/javascript/CommentsInterface.js'
|
||||||
),
|
),
|
||||||
$backend->get_javascript()
|
$backend->get_javascript()
|
||||||
|
Loading…
Reference in New Issue
Block a user