From: Aleksander Łukasz Date: Mon, 18 Nov 2013 11:02:10 +0000 (+0100) Subject: Handle textarea max_length better in older browsers X-Git-Url: https://git.mdrn.pl/edumed.git/commitdiff_plain/d63190b067ddbf6beb150c924b3efe2f4c67c85e Handle textarea max_length better in older browsers --- diff --git a/wtem/static/wtem/wtem.js b/wtem/static/wtem/wtem.js index 1c61498..a65bb7f 100644 --- a/wtem/static/wtem/wtem.js +++ b/wtem/static/wtem/wtem.js @@ -56,4 +56,17 @@ $(function() { } } + var sms_handler = function() { + var textarea = $(this), + label_suffix = textarea.parent().find('.label_suffix'), + left = 140 - textarea.val().length; + to_insert = '(pozostało: ' + left + ')'; + if(left < 0) { + to_insert = '' + to_insert + ''; + } + label_suffix.html(to_insert); + }; + + $('#wtem_sms').change(sms_handler).keyup(sms_handler); + }); \ No newline at end of file diff --git a/wtem/templates/wtem/exercises/open.html b/wtem/templates/wtem/exercises/open.html index f12e052..8645d46 100644 --- a/wtem/templates/wtem/exercises/open.html +++ b/wtem/templates/wtem/exercises/open.html @@ -15,12 +15,12 @@ {% if exercise.fields %} {% for field in exercise.fields %}
- - + +
{% endfor %} {% else %} - + {% endif %} {% if exercise.description_after %}