Created
August 10, 2016 14:54
-
-
Save Krato/646d67995855b99739e94a9af67613e5 to your computer and use it in GitHub Desktop.
This file contains 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
/* | |
Redactor 10.2.3 | |
License: http://imperavi.com/redactor/license/ | |
Updated: August 8, 2016 | |
Modded by Eric Lagarda https://github.com/Krato | |
*/ | |
(function($) | |
{ | |
$.Redactor.prototype.limiter = function() | |
{ | |
return { | |
init: function() | |
{ | |
if (!this.opts.limiter) | |
{ | |
return; | |
} | |
console.log(this); | |
this.$editor.on('keydown.redactor-plugin-limiter', $.proxy(function(e) | |
{ | |
var key = e.which; | |
var ctrl = e.ctrlKey || e.metaKey; | |
if (key === this.keyCode.BACKSPACE | |
|| key === this.keyCode.DELETE | |
|| key === this.keyCode.ESC | |
|| key === this.keyCode.SHIFT | |
|| (ctrl && key === 65) | |
|| (ctrl && key === 82) | |
|| (ctrl && key === 116) | |
) | |
{ | |
return; | |
} | |
var text = this.$editor.text(); | |
text = text.replace(/\u200B/g, ''); | |
var count = text.length; | |
if (count >= this.opts.limiter) | |
{ | |
return false; | |
} | |
}, this)); | |
} | |
}; | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment