Created
May 17, 2016 00:42
-
-
Save cballou/0d8507970e6f03c80461305a29871cbc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Default config values. Can be overridden globally. | |
* | |
* maxLength [int] - The maximum length of the input, textarea, or editable field | |
* countWords [bool] - Whether to count by word or by length | |
* countContainer [jQuery element | DOM selector string] - The container to display the count and message | |
* countDown [bool] - Whether the counter displays a remaining count or current count | |
* errorClass [string] - The class to apply to countContainer when an overage occurs | |
* countWordStr [string] - The string to use after the word length | |
* countLengthStr [string] - The string to use after the length | |
*/ | |
$.fn.textCounter.defaults = { | |
maxLength: 140, | |
countWords: true, | |
preventNegative: false, | |
countContainer: null, | |
countDown: true, | |
errorClass: 'error', | |
countWordStr: 'words remaining', | |
countLengthStr: 'characters remaining' | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// specify your special options | |
var options = {}; | |
// your target element can be an input, textarea, or contendEditable container | |
$('#my-target-elem').textCounter([options]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment