]> git.openstreetmap.org Git - osqa.git/blob - forum/skins/default/templates/node/award_points.html
Users should be warned before getting their karma points decreased to certain values...
[osqa.git] / forum / skins / default / templates / node / award_points.html
1 {% load i18n %}
2
3 <p>
4     {% blocktrans %}
5     If you like this answer you can award {{ awarded_user }} with reputation points.
6     {% endblocktrans %}
7 </p>
8
9 <p>
10     {% blocktrans %}
11     Use the slider below or the input field to choose the amount of points you would like to give.
12     {% endblocktrans %}
13 </p>
14
15 <table>
16     <tr>
17         <td width="50%">{% trans "Points:" %}</td>
18         <td width="50%"><input type="text" name="points" id="points_input" value="1" style="border: 1px solid #ccc; padding: 1px 2px;" /></td>
19     </tr>
20 </table>
21
22 <div class="award_points_slider"></div>
23
24 <script>
25     var awardPointsNotified = false;
26     var reputation_to_comment = {{ reputation_to_comment }};
27     var user_reputation = {{ user.reputation }};
28
29     function points_award_confirm(reputation, event) {
30         var message = '<div style="max-width: 300px !important; text-align: left;">';
31         message += "{% blocktrans %}Your karma points will be below the minimum reputation to comment. Are you sure you want to award points?{% endblocktrans %}";
32         message += "</div>";
33
34         if ((user_reputation - reputation) < reputation_to_comment && !awardPointsNotified) {
35             awardPointsNotified = true;
36
37             var doptions = {
38                 html: message,
39                 extra_class: 'confirm',
40                 yes_text: messages.yes,
41                 no_callback: function() {
42                     $(".dialog").fadeOut("fast", function() {
43                         $('.dialog').remove();
44                     })
45                 },
46                 show_no: true,
47                 no_text: messages.no
48             }
49
50             doptions.event = event;
51             show_dialog(doptions);
52         }
53     }
54
55     $('.award_points_slider').slider({
56         min: 1, max: user_reputation,
57     slide: function(evt, ui) {
58         $('#points_input').val(ui.value);
59         points_award_confirm(Number(ui.value), evt)
60     }
61     });
62
63     $('#points_input').bind('change keydown', function(evt) {
64         if ($(this).val() > user_reputation) {
65         $(this).attr('value', user_reputation);
66     }
67     $('.award_points_slider').slider('option', 'value', $(this).val())
68
69     points_award_confirm(Number($(this).val()), evt);
70     });
71
72 </script>