Created
November 20, 2012 01:40
-
-
Save SoftwareMaven/4115396 to your computer and use it in GitHub Desktop.
jEditable autocounter plugin (combination of autogrow and charcounter plugins)
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
/* | |
* A combination of jquery.editable's charcounter and autogrow plugins. | |
*/ | |
$.editable.addInputType('autocounter', { | |
element : function(settings, original) { | |
var textarea = $('<textarea />'); | |
if (settings.rows) { | |
textarea.attr('rows', settings.rows); | |
} else { | |
textarea.height(settings.height); | |
} | |
if (settings.cols) { | |
textarea.attr('cols', settings.cols); | |
} else { | |
textarea.width(settings.width); | |
} | |
textarea.addClass('charCounter'); | |
textarea.addClass('autogrow'); | |
$(this).append(textarea); | |
return(textarea); | |
}, | |
plugin : function(settings, original) { | |
var char_settings = settings.autocounter.charcounter; | |
var grow_settings = settings.autocounter.autogrow; | |
$('textarea', this).autogrow(grow_settings).charCounter(char_settings.characters, char_settings); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment