Commit b4302fbf authored by Hugues's avatar Hugues

#66 : amélioration de la restitution du décompte + maj doc

parent 0bb12931
......@@ -6,18 +6,21 @@
function textareaCounter() {
var $textAreaField = $("textarea[maxlength]");
var stepPolite = 100;
var stepAssertive = 20;
var stepPolite = 100;
var stepAssertive = 20;
$textAreaField.each(function (index, textarea) {
var maxLength = $(textarea).attr("maxlength");
var messageLength = $(textarea).val().length;
var activeValue = countRest(maxLength, messageLength);
var $textarea = undefined;
var $paragraph = undefined;
var maxLength = $(textarea).attr("maxlength");
var messageLength = $(textarea).val().length;
var activeValue = countRest(maxLength, messageLength);
var idTextarea = $(textarea).attr("id");
var $textarea = undefined;
var $paragraph = undefined;
$(textarea).after('<p class="textarea-counter"><span class="textarea-counter-nb">' + activeValue +'</span> caractères restants</p>');
$(textarea).attr('aria-describedby', idTextarea + '-counter');
$(textarea).after('<p class="textarea-counter" id="' + idTextarea + '-counter"><span class="textarea-counter-nb">' + activeValue + '</span> caractères restants</p>');
$(textarea).on("input", function (e) {
$textarea = $(e.currentTarget);
......@@ -40,7 +43,7 @@ function textareaCounter() {
}
function updateAria(maxLengthValue, messageLength, $paragraph) {
politeFlag = countStepPolite(maxLengthValue);
politeFlag = countStepPolite(maxLengthValue);
assertiveFlag = countStepAssertive(maxLengthValue);
if (messageLength < politeFlag) {
......@@ -71,6 +74,6 @@ function textareaCounter() {
}
$(document).ready(function(){
$(document).ready(function () {
textareaCounter();
});
......@@ -30,8 +30,8 @@ Exemple
```html
<div class="form-group">
<label for="envoi-mail-1">Test maxlength à 240</label>
<textarea class="form-control" id="envoi-mail-1" cols="30" rows="4" maxlength="240"></textarea>
<label for="textarea-1">Test maxlength à 240</label>
<textarea class="form-control" id="textarea-1" cols="30" rows="4" maxlength="240"></textarea>
</div>
```
......@@ -39,9 +39,9 @@ Exemple
```html
<div class="form-group">
<label for="envoi-mail-1">Test maxlength à 240</label>
<textarea class="form-control" id="envoi-mail-1" cols="30" rows="4" maxlength="240"></textarea>
<p class="textarea-counter"><span class="textarea-counter-nb">500</span> caractères restants</p>
<label for="textarea-1">Test maxlength à 240</label>
<textarea class="form-control" id="textarea-1" cols="30" rows="4" maxlength="240" ariadescribedby="textarea-1-counter"></textarea>
<p class="textarea-counter" id="textarea-1-counter"><span class="textarea-counter-nb">500</span> caractères restants</p>
</div>
```
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment