]> git.openstreetmap.org Git - osqa.git/blob - forum/skins/default/templates/node/award_points.html
Merge pull request #42 from aniketschneider/validation-email-template
[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                 show_no: true,
42                 no_callback: function() {
43                     $(".dialog").fadeOut("fast", function() {
44                         $('.dialog').remove();
45                     })
46                 },
47
48                 no_text: messages.no
49             }
50
51             doptions.event = event;
52             show_dialog(doptions);
53         }
54     }
55
56     $('.award_points_slider').slider({
57         min: 1, max: user_reputation,
58         slide: function(evt, ui) {
59             $('#points_input').val(ui.value);
60             points_award_confirm(Number(ui.value), evt)
61         }
62     });
63
64     $('#points_input').live('change keyup', function(evt) {
65         if ($(this).val() > user_reputation) {
66             $(this).attr('value', user_reputation);
67         }
68
69         points_award_confirm(Number($(this).val()), evt);
70
71         $('.award_points_slider').slider('option', 'value', $(this).val());
72
73     });
74
75 </script>