aboutsummaryrefslogtreecommitdiff
path: root/mod/tinymce/vendor/tinymce/jscripts/tiny_mce/plugins/wordcount/editor_plugin_src.js
diff options
context:
space:
mode:
Diffstat (limited to 'mod/tinymce/vendor/tinymce/jscripts/tiny_mce/plugins/wordcount/editor_plugin_src.js')
-rw-r--r--mod/tinymce/vendor/tinymce/jscripts/tiny_mce/plugins/wordcount/editor_plugin_src.js20
1 files changed, 14 insertions, 6 deletions
diff --git a/mod/tinymce/vendor/tinymce/jscripts/tiny_mce/plugins/wordcount/editor_plugin_src.js b/mod/tinymce/vendor/tinymce/jscripts/tiny_mce/plugins/wordcount/editor_plugin_src.js
index e94743bae..34b265553 100644
--- a/mod/tinymce/vendor/tinymce/jscripts/tiny_mce/plugins/wordcount/editor_plugin_src.js
+++ b/mod/tinymce/vendor/tinymce/jscripts/tiny_mce/plugins/wordcount/editor_plugin_src.js
@@ -16,10 +16,12 @@
cleanre : null,
init : function(ed, url) {
- var t = this, last = 0;
+ var t = this, last = 0, VK = tinymce.VK;
t.countre = ed.getParam('wordcount_countregex', /[\w\u2019\'-]+/g); // u2019 == ’
t.cleanre = ed.getParam('wordcount_cleanregex', /[0-9.(),;:!?%#$?\'\"_+=\\\/-]*/g);
+ t.update_rate = ed.getParam('wordcount_update_rate', 2000);
+ t.update_on_delete = ed.getParam('wordcount_update_on_delete', false);
t.id = ed.id + '-word-count';
ed.onPostRender.add(function(ed, cm) {
@@ -49,12 +51,18 @@
t._count(ed);
});
- ed.onKeyUp.add(function(ed, e) {
- if (e.keyCode == last)
- return;
+ function checkKeys(key) {
+ return key !== last && (key === VK.ENTER || last === VK.SPACEBAR || checkDelOrBksp(last));
+ }
+
+ function checkDelOrBksp(key) {
+ return key === VK.DELETE || key === VK.BACKSPACE;
+ }
- if (13 == e.keyCode || 8 == last || 46 == last)
+ ed.onKeyUp.add(function(ed, e) {
+ if (checkKeys(e.keyCode) || t.update_on_delete && checkDelOrBksp(e.keyCode)) {
t._count(ed);
+ }
last = e.keyCode;
});
@@ -94,7 +102,7 @@
if (!ed.destroyed) {
var tc = t._getCount(ed);
tinymce.DOM.setHTML(t.id, tc.toString());
- setTimeout(function() {t.block = 0;}, 2000);
+ setTimeout(function() {t.block = 0;}, t.update_rate);
}
}, 1);
},