mirror of
https://github.com/vichan-devel/vichan.git
synced 2025-02-23 22:03:51 +01:00
Added Character Counter
Shows the user how many characters are left before hitting the max per post. Currently does not work in Quick Reply.
This commit is contained in:
parent
4b0b694f8a
commit
0483863503
29
js/charcount.js
Normal file
29
js/charcount.js
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* charcount.js
|
||||
*
|
||||
* Usage:
|
||||
* $config['additional_javascript'][] = 'js/jquery.min.js';
|
||||
* $config['additional_javascript'][] = 'js/charcount.js';
|
||||
*
|
||||
*/
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
// Storing this jQuery object outside of the event callback
|
||||
// prevents jQuery from having to search the DOM for it again
|
||||
// every time an event is fired.
|
||||
var $inputArea = $('#body');
|
||||
var $coundownField = $('#countchar');
|
||||
var $maxChars = 3600;
|
||||
|
||||
// Preset countdown field to max initial content length
|
||||
$coundownField.text($maxChars - $inputArea.val().length);
|
||||
|
||||
// input :: for all modern browsers [1]
|
||||
// selectionchange :: for IE9 [2]
|
||||
// propertychange :: for <IE9 [3]
|
||||
$inputArea.on('input selectionchange propertychange', function() {
|
||||
$charCount = $maxChars - $inputArea.val().length;
|
||||
$coundownField.text($charCount);
|
||||
});
|
||||
});
|
@ -59,6 +59,8 @@
|
||||
</th>
|
||||
<td>
|
||||
<textarea name="body" id="body" rows="5" cols="35"></textarea>
|
||||
<br/>
|
||||
<span ID="countchar" class="countdown"></span>
|
||||
{{ antibot.html() }}
|
||||
{% if not (not (config.field_disable_subject or (id and config.field_disable_reply_subject)) or (mod and post.mod|hasPermission(config.mod.bypass_field_disable, board.uri))) %}
|
||||
{% if not (not config.field_disable_email or (mod and post.mod|hasPermission(config.mod.bypass_field_disable, board.uri))) %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user