]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/skins/default/templates/node/award_points.html
we need to close both dialogs if users selects No on award points confirmation
[osqa.git] / forum / skins / default / templates / node / award_points.html
index 82100694d26bb2a117ffd6fe5413376e32a3da2d..ccf1028177c5817700bee1cee8047a5b127e75ef 100644 (file)
@@ -1,23 +1,73 @@
 {% 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_callback: function() {
+                    $(".dialog").fadeOut("fast", function() {
+                    $('.dialog').remove();
+                    })
+                },
+
+                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