From d63190b067ddbf6beb150c924b3efe2f4c67c85e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Mon, 18 Nov 2013 12:02:10 +0100 Subject: [PATCH 1/1] Handle textarea max_length better in older browsers --- wtem/static/wtem/wtem.js | 13 +++++++++++++ wtem/templates/wtem/exercises/open.html | 6 +++--- 2 files changed, 16 insertions(+), 3 deletions(-) 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 %} -- 2.20.1