$diag.fadeOut('fast', function() {\r
$diag.remove();\r
});\r
- }\r
+ };\r
\r
var options = {\r
extra_class: '',\r
options.pos = {x: options.event.pageX, y: options.event.pageY};\r
}\r
\r
- var html = '<div class="dialog ' + options.extra_class + '" style="display: none;">'\r
+ var html = '<div class="dialog ' + options.extra_class + '" style="display: none; z-index: 999;">'\r
+ '<div class="dialog-content">' + options.html + '</div><div class="dialog-buttons">';\r
\r
if (options.show_no) {\r
message.style.visibility = "visible";\r
});\r
\r
- $dialog.find('.dialog-no').click(function() {\r
- default_close_function($dialog);\r
- });\r
-\r
$dialog.find('.dialog-yes').click(function() {\r
options.yes_callback($dialog);\r
});\r
\r
+ if (options.hasOwnProperty("no_callback")) {\r
+ $dialog.find('.dialog-no:first-child').click(function() {\r
+ options.no_callback($dialog);\r
+ });\r
+ } else {\r
+ $dialog.find('.dialog-no:first-child').click(function() {\r
+ default_close_function($dialog);\r
+ });\r
+ }\r
+\r
if (options.close_on_clickoutside) {\r
$dialog.one('clickoutside', function() {\r
default_close_function($dialog);\r
{% load i18n %}
<p>
-{% blocktrans %}
-If you like this answer you can award {{ awarded_user }} with reputation points.
-{% endblocktrans %}
+ {% blocktrans %}
+ If you like this answer you can award {{ awarded_user }} with reputation points.
+ {% endblocktrans %}
</p>
<p>
-{% blocktrans %}
-Use the slider below or the input field to choose the amount of points you would like to give.
-{% endblocktrans %}
+ {% blocktrans %}
+ Use the slider below or the input field to choose the amount of points you would like to give.
+ {% endblocktrans %}
</p>
<table>
<div class="award_points_slider"></div>
<script>
-$('.award_points_slider').slider({
- min: 1, max: {{ user.reputation }},
+ var awardPointsNotified = false;
+ var reputation_to_comment = {{ reputation_to_comment }};
+ var user_reputation = {{ user.reputation }};
+
+ function points_award_confirm(reputation, event) {
+ var message = '<div style="max-width: 300px !important; text-align: left;">';
+ message += "{% blocktrans %}Your karma points will be below the minimum reputation to comment. Are you sure you want to award points?{% endblocktrans %}";
+ message += "</div>";
+
+ if ((user_reputation - reputation) < reputation_to_comment && !awardPointsNotified) {
+ awardPointsNotified = true;
+
+ var doptions = {
+ html: message,
+ extra_class: 'confirm',
+ yes_text: messages.yes,
+ no_callback: function() {
+ $(".dialog").fadeOut("fast", function() {
+ $('.dialog').remove();
+ })
+ },
+ show_no: true,
+ no_text: messages.no
+ }
+
+ doptions.event = event;
+ show_dialog(doptions);
+ }
+ }
+
+ $('.award_points_slider').slider({
+ min: 1, max: user_reputation,
slide: function(evt, ui) {
- $('#points_input').val(ui.value)
+ $('#points_input').val(ui.value);
+ points_award_confirm(Number(ui.value), evt)
}
-});
+ });
-$('#points_input').bind('change keydown', function() {
- if ($(this).val() > {{ user.reputation }}) {
- $(this).attr('value', {{ user.reputation }})
+ $('#points_input').bind('change keydown', function(evt) {
+ if ($(this).val() > user_reputation) {
+ $(this).attr('value', user_reputation);
}
$('.award_points_slider').slider('option', 'value', $(this).val())
-})
+
+ points_award_confirm(Number($(this).val()), evt);
+ });
</script>
\ No newline at end of file
title=_("answer permanent link"), command=True, withprompt=True, copy=True))\r
\r
# Users should be able to award points for an answer. Users cannot award their own answers\r
- if user != post.author and user.is_authenticated():\r
+ if user != post.author and user.is_authenticated() and user.reputation > 1:\r
controls.append(post_control(_("award points"), reverse('award_points', kwargs={'user_id' : post.author.id,\r
'answer_id' : post.id}), title=_("award points to %s") % smart_unicode(post.author.username),\r
command=True, withprompt=True))\r
raise AnonymousNotAllowedException(_('award'))
if not request.POST:
- return render_to_response("node/award_points.html", { 'user' : user, 'awarded_user' : awarded_user, })
+ return render_to_response("node/award_points.html", {
+ 'user' : user,
+ 'awarded_user' : awarded_user,
+ 'reputation_to_comment' : str(settings.REP_TO_COMMENT)
+ })
else:
points = int(request.POST['points'])