Skip to content

Commit 0685632

Browse files
committed
autocustom support
1 parent 41aa6b0 commit 0685632

File tree

3 files changed

+32
-27
lines changed

3 files changed

+32
-27
lines changed

README.md

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -109,32 +109,37 @@ Fires when counter is under min limit.
109109
## Options
110110

111111
```javascript
112-
type : "character", // "character" or "word"
113-
min : 0, // minimum number of characters/words
114-
max : 200, // maximum number of characters/words, -1 for unlimited, 'auto' to use maxlength attribute
115-
countContainerElement : "div", // HTML element to wrap the text count in
116-
countContainerClass : "text-count-wrapper", // class applied to the countContainerElement
117-
textCountClass : "text-count", // class applied to the counter length
118-
inputErrorClass : "error", // error class appended to the input element if error occurs
119-
counterErrorClass : "error", // error class appended to the countContainerElement if error occurs
120-
counterText : "Total Count: %d", // counter text, %d replaced with count value
121-
errorTextElement : "div", // error text element
122-
minimumErrorText : "Minimum not met", // error message for minimum not met,
123-
maximumErrorText : "Maximum exceeded", // error message for maximum range exceeded,
124-
displayErrorText : true, // display error text messages for minimum/maximum values
125-
stopInputAtMaximum : true, // stop further text input if maximum reached
126-
countSpaces : false, // count spaces as character (only for "character" type)
127-
countDown : false, // if the counter should deduct from maximum characters/words rather than counting up
128-
countDownText : "Remaining: %d", // count down text, %d replaced with remaining value
129-
countExtendedCharacters : false, // count extended UTF-8 characters as 2 bytes (such as Chinese characters)
130-
twoCharCarriageReturn : false, // count carriage returns/newlines as 2 characters
112+
type : "character", // "character" or "word"
113+
min : 0, // minimum number of characters/words
114+
max : 200, // maximum number of characters/words, -1 for unlimited, 'auto' to use maxlength attribute, 'autocustom' to use a custom attribute for the length (must set "autoCustomAttr")
115+
autoCustomAttr : "counterlimit", // custom attribute name with the counter limit if the max is 'autocustom'
116+
countContainerElement : "div", // HTML element to wrap the text count in
117+
countContainerClass : "text-count-wrapper", // class applied to the countContainerElement
118+
textCountMessageClass : "text-count-message", // class applied to the counter message
119+
textCountClass : "text-count", // class applied to the counter length (the count number)
120+
inputErrorClass : "error", // error class appended to the input element if error occurs
121+
counterErrorClass : "error", // error class appended to the countContainerElement if error occurs
122+
counterText : "Total Count: %d", // counter text
123+
errorTextElement : "div", // error text element
124+
minimumErrorText : "Minimum not met", // error message for minimum not met,
125+
maximumErrorText : "Maximum exceeded", // error message for maximum range exceeded,
126+
displayErrorText : true, // display error text messages for minimum/maximum values
127+
stopInputAtMaximum : true, // stop further text input if maximum reached
128+
countSpaces : false, // count spaces as character (only for "character" type)
129+
countDown : false, // if the counter should deduct from maximum characters/words rather than counting up
130+
countDownText : "Remaining: %d", // count down text
131+
countExtendedCharacters : false, // count extended UTF-8 characters as 2 bytes (such as Chinese characters)
132+
twoCharCarriageReturn : false, // count carriage returns/newlines as 2 characters
133+
countOverflow : false, // display text overflow element
134+
countOverflowText : "Maximum %type exceeded by %d", // count overflow text
135+
countOverflowContainerClass : "text-count-overflow-wrapper", // class applied to the count overflow wrapper
131136

132137
// Callback API
133-
maxunder : function(el){}, // Callback: function(element) - Fires when counter is under max limit
134-
minunder : function(el){}, // Callback: function(element) - Fires when counter is under min limit
135-
maxcount : function(el){}, // Callback: function(element) - Fires when the counter hits the maximum word/character count
136-
mincount : function(el){}, // Callback: function(element) - Fires when the counter hits the minimum word/character count
137-
init : function(el){} // Callback: function(element) - Fires after the counter is initially setup
138+
maxunder : function(el){}, // Callback: function(element) - Fires when counter under max limit
139+
minunder : function(el){}, // Callback: function(element) - Fires when counter under min limit
140+
maxcount : function(el){}, // Callback: function(element) - Fires when the counter hits the maximum word/character count
141+
mincount : function(el){}, // Callback: function(element) - Fires when the counter hits the minimum word/character count
142+
init : function(el){} // Callback: function(element) - Fires after the counter is initially setup
138143
```
139144

140145
## Development
@@ -159,4 +164,4 @@ init : function(el){} // Callback: function(element
159164
- [juliovedovatto](https://github.com/juliovedovatto) / [alvaro-canepa](https://github.com/alvaro-canepa) - multiple classes support for counter container
160165
- [dtipson](https://github.com/dtipson) - multiple classes error fix
161166
- [jmichalicek](https://github.com/jmichalicek) - count carriage returns/newlines as 2 characters
162-
- [diptopol](https://github.com/diptopol) - `stopInputAtMaximum` with `twoCharCarriageReturn` count fix, trimmed newline calculation fix, maximum text reached condition fix, text count overflow notification
167+
- [diptopol](https://github.com/diptopol) - `stopInputAtMaximum` with `twoCharCarriageReturn` count fix, trimmed newline calculation fix, maximum text reached condition fix, text count overflow notification

textcounter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@
304304
$.textcounter.defaultOptions = {
305305
'type' : "character", // "character" or "word"
306306
'min' : 0, // minimum number of characters/words
307-
'max' : 200, // maximum number of characters/words, -1 for unlimited, 'auto' to use maxlength attribute, 'autocustom' to use a custom attribute for the length (must)
307+
'max' : 200, // maximum number of characters/words, -1 for unlimited, 'auto' to use maxlength attribute, 'autocustom' to use a custom attribute for the length (must set "autoCustomAttr")
308308
'autoCustomAttr' : "counterlimit", // custom attribute name with the counter limit if the max is 'autocustom'
309309
'countContainerElement' : "div", // HTML element to wrap the text count in
310310
'countContainerClass' : "text-count-wrapper", // class applied to the countContainerElement

textcounter.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)