Jamesgolovich has uploaded a new change for review.
https://gerrit.wikimedia.org/r/146795
Change subject: Allow empty comments to be left (ratings only)
......................................................................
Allow empty comments to be left (ratings only)
Change-Id: I91597ab7d6114ccf19538861c188e9da462a1340
---
M SemanticComments.php
M includes/CE_GlobalFunctions.php
M languages/CE_Messages.php
M scripts/Comment/CE_Comment.js
M specials/Comment/CE_CommentParserFunctions.php
5 files changed, 26 insertions(+), 2 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticComments
refs/changes/95/146795/1
diff --git a/SemanticComments.php b/SemanticComments.php
index 719dd37..dcf5b53 100644
--- a/SemanticComments.php
+++ b/SemanticComments.php
@@ -107,6 +107,11 @@
###
$cegDefaultDelimiter = ',';
+###
+# Allow empty comments to be left, basically ratings only
+# Default is false (do not allow empty comments)
+###
+$cegAllowEmptyComments = false;
###
# Use ScriptManager
diff --git a/includes/CE_GlobalFunctions.php b/includes/CE_GlobalFunctions.php
index 7d6efce..f77075d 100644
--- a/includes/CE_GlobalFunctions.php
+++ b/includes/CE_GlobalFunctions.php
@@ -130,6 +130,7 @@
'ce_com_default_header',
'ce_com_ext_header',
'ce_invalid',
+ 'ce_invalid_rating',
'ce_reload',
'ce_deleting',
'ce_full_deleting',
diff --git a/languages/CE_Messages.php b/languages/CE_Messages.php
index 0491214..a0ac663 100644
--- a/languages/CE_Messages.php
+++ b/languages/CE_Messages.php
@@ -87,6 +87,7 @@
'ce_com_default_header' => 'Add comment',
'ce_com_ext_header' => 'Community comments',
'ce_invalid' => 'You didn\'t enter a valid
comment.',
+ 'ce_invalid_rating' => 'You didn\'t enter a valid
rating.',
'ce_reload' => ' Page is reloading ...',
'ce_deleting' => 'Deleting comment ...',
'ce_full_deleting' => 'Completely deleting comments ...',
diff --git a/scripts/Comment/CE_Comment.js b/scripts/Comment/CE_Comment.js
index 241edbb..d9ab107 100644
--- a/scripts/Comment/CE_Comment.js
+++ b/scripts/Comment/CE_Comment.js
@@ -96,7 +96,7 @@
// textarea
var textArea = ( $( '#collabComFormTextarea' ).val())? $(
'#collabComFormTextarea' ).val(): '';
- if ( textArea.length === 0 || this.textareaIsDefault ) {
+ if ( wgCEAllowEmptyComments !== true && ( textArea.length === 0
|| this.textareaIsDefault ) ) {
this.pendingIndicatorCF.hide();
$( '#collabComFormMessage' ).attr( 'class', 'failure' );
$( '#collabComFormMessage' ).html(
ceLanguage.getMessage( 'ce_invalid' ) );
@@ -108,6 +108,21 @@
// hide possibly shown message div
$( '#collabComFormMessage' ).hide( 'slow' );
}
+ if ( wgCEAllowEmptyComments === true && this.textareaIsDefault
) {
+ // If we allow Empty Comments, set the field to empty
instead of the default
+ textArea = '';
+ if ( this.ratingValue === null ) {
+ // If we are allowing Empty Comments, make sure
they enter a rating
+ this.pendingIndicatorCF.hide();
+ $( '#collabComFormMessage' ).attr( 'class',
'failure' );
+ $( '#collabComFormMessage' ).html(
ceLanguage.getMessage( 'ce_invalid_rating' ) );
+ $( '#collabComFormMessage' ).show( 'slow' );
+ // enable form again
+ $( '#collabComForm *:input' ).removeAttr(
'disabled' );
+ return false;
+ }
+ }
+
// escape html chars
textArea = textArea.replace( /&/g, '&' );
textArea = textArea.replace( /</g, '<' );
diff --git a/specials/Comment/CE_CommentParserFunctions.php
b/specials/Comment/CE_CommentParserFunctions.php
index f4b028b..f04a41f 100644
--- a/specials/Comment/CE_CommentParserFunctions.php
+++ b/specials/Comment/CE_CommentParserFunctions.php
@@ -269,8 +269,10 @@
XML::closeElement('span') .
XML::closeElement('div');
+ global $cegAllowEmptyComments;
$script = '<script
type="'.$wgJsMimeType.'">/*<![CDATA[*/'.
'var wgCEEnableRating = true;' .
+ 'var wgCEAllowEmptyComments = ' .
($cegAllowEmptyComments ? 'true' : 'false') . ';' .
'/*]]>*/</script>';
SMWOutputs::requireHeadItem('CEJS_Variables2', $script);
}
@@ -617,4 +619,4 @@
return $html;
}
-} //end class CECommentParserFunctions
\ No newline at end of file
+} //end class CECommentParserFunctions
--
To view, visit https://gerrit.wikimedia.org/r/146795
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I91597ab7d6114ccf19538861c188e9da462a1340
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticComments
Gerrit-Branch: master
Gerrit-Owner: Jamesgolovich <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits