File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change 4
4
* elements.
5
5
*
6
6
* @author Sacha Schmid (<https://github.com/RadLikeWhoa>)
7
- * @version 1.4.0
7
+ * @version 1.4.1
8
8
* @license MIT
9
9
* @see <http://radlikewhoa.github.io/Countable/>
10
10
*/
39
39
* the result. The callback should
40
40
* accept only one parameter. (default:
41
41
* logs to console)
42
- * @param {Boolean } [options] hardReturns: Use two line breaks
42
+ * @param {Object } [options] hardReturns: Use two line breaks
43
43
* instead of one.
44
44
* stripTags: Strip HTML tags before
45
45
* counting.
46
+ * once: Execute the callback only once
47
+ * and don't bind any events.
46
48
*
47
49
* @example new Countable(elem, function (counter) {
48
50
* alert(counter.words)
81
83
82
84
self . options = {
83
85
hardReturns : false ,
84
- stripTags : false
86
+ stripTags : false ,
87
+ once : false
85
88
}
86
89
87
90
/**
103
106
104
107
self . callback ( self . count ( ) )
105
108
109
+ if ( self . options . once ) return
110
+
106
111
if ( element . addEventListener ) {
107
112
element . addEventListener ( ( hasInput ? 'input' : 'keydown' ) , function ( ) {
108
113
self . callback ( self . count ( ) )
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " Countable" ,
3
- "version" : " 1.4.0 " ,
3
+ "version" : " 1.4.1 " ,
4
4
"main" : " Countable.js" ,
5
5
"ignore" : [ " CONTRIBUTING.md" ]
6
6
}
You can’t perform that action at this time.
0 commit comments