Skip to content

Commit

Permalink
Merge pull request #1 from kdrdgn/master
Browse files Browse the repository at this point in the history
Remaning message is parametrised.
  • Loading branch information
joshmcrty committed Jan 17, 2013
2 parents 3799b05 + 716e8cd commit ae53d46
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions jquery.SimpleMaxChars.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,17 @@
$.fn.SimpleMaxChars.message = function( chars, opts, maxLength ) {

var remainingChars = maxLength - chars;
var lineBreak = "";
var html = "";
var messageClass = opts.messageClass;
lineBreak = "";
html = "";
messageClass = opts.messageClass,
remainingMessage = opts.remainingMessage.replace('__remaining_chars__', remainingChars)
if ( opts.lineBreak === true ) {
lineBreak = '<br />';
}
if ( remainingChars < opts.warningLimit ) {
messageClass += " " + opts.warningClass;
}
html = lineBreak + '<span class="' + messageClass + '">' + remainingChars + ' characters remaining.</span>';
html = lineBreak + '<span class="' + messageClass + '">' + remainingMessage + '</span>';
return html;
};

Expand All @@ -108,8 +109,9 @@
warningLimit: 20,
messageClass: 'simple-maxchars-message',
warningClass: 'warning',
remainingMessage:'__remaining_chars__ characters remaining.',
lineBreak: false,
debug: false
};

})( jQuery );
})( jQuery );

0 comments on commit ae53d46

Please sign in to comment.