Browse Source
Shows the user how many characters are left before hitting the max per post. Currently does not work in Quick Reply.main
fallenPineapple
7 years ago
committed by
-
2 changed files with 31 additions and 0 deletions
@ -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); |
|||
}); |
|||
}); |
Loading…
Reference in new issue