]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/skins/default/templates/node/award_points.html
the variable needs to be defined with var in front of it, because otherwise it is...
[osqa.git] / forum / skins / default / templates / node / award_points.html
index 82100694d26bb2a117ffd6fe5413376e32a3da2d..a23ac5488daf039ffd81278737cd3537f6b757c9 100644 (file)
@@ -1,23 +1,67 @@
 {% load i18n %}
 
 <p>
-{% blocktrans %}
-Award {{ awarded_user }} with reputation points.
-{% endblocktrans %}
+    {% blocktrans %}
+    If you like this answer you can award {{ awarded_user }} with reputation points.
+    {% endblocktrans %}
 </p>
 
 <p>
-    Points:
-    <span id="reputation_points_award">1</span>
+    {% blocktrans %}
+    Use the slider below or the input field to choose the amount of points you would like to give.
+    {% endblocktrans %}
 </p>
 
+<table>
+    <tr>
+        <td width="50%">{% trans "Points:" %}</td>
+        <td width="50%"><input type="text" name="points" id="points_input" value="1" style="border: 1px solid #ccc; padding: 1px 2px;" /></td>
+    </tr>
+</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,
+                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) {
-        $('#reputation_points_award').html(ui.value)
+        $('#points_input').val(ui.value);
+        points_award_confirm(Number(ui.value), evt)
+    }
+    });
+
+    $('#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