}
}
+ 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 = '<span style="color:red">' + to_insert + '</span>';
+ }
+ label_suffix.html(to_insert);
+ };
+
+ $('#wtem_sms').change(sms_handler).keyup(sms_handler);
+
});
\ No newline at end of file
{% if exercise.fields %}
{% for field in exercise.fields %}
<div class="wtem-open-field">
- <label class="wtem-caption">{{field.caption}}</label>
- <textarea style="width: 100%;" rows="{{field.rows|default:10}}" data-field-id="{{field.id}}" {% if field.max_length %}maxlength="{{field.max_length}}"{% endif %}></textarea>
+ <label class="wtem-caption">{{field.caption}} <span class="label_suffix"></span></label>
+ <textarea style="width: 100%;" rows="{{field.rows|default:10}}" data-field-id="{{field.id}}" {% if field.max_length %}maxlength="{{field.max_length}}"{% endif %} {% if field.input_id %}id="{{field.input_id}}"{% endif %}></textarea>
</div>
{% endfor %}
{% else %}
- <textarea style="width: 100%; margin-top:10px;" rows="{{field.rows|default:10}}" {% if field.max_length %}maxlength="{{field.max_length}}"{% endif %}></textarea>
+ <textarea style="width: 100%; margin-top:10px;" rows="{{field.rows|default:10}}" {% if field.max_length %}maxlength="{{field.max_length}}"{% endif %} {% if field.input_id %}id="#{{field.input_id}}"{% endif %}></textarea>
{% endif %}
{% if exercise.description_after %}