Permalink
Browse files

Updated author/copyright information

  • Loading branch information...
1 parent a369eab commit 749fff4cc23b8de8a90da5f805ad0042d69b33cd @joshmcrty committed Mar 14, 2012
Showing with 26 additions and 9 deletions.
  1. +12 −2 README
  2. +14 −7 jquery.SimpleMaxChars.js
View
14 README
@@ -1,5 +1,15 @@
-SimpleMaxChars jQuery plugin
+SimpleMaxChars jQuery plugin v1.0
Author: Josh McCarty
Website: http://joshmccarty.com
+Copyright (c)2012 Josh McCarty
+License: GPL Version 2
+http://www.gnu.org/licenses/gpl-2.0.txt
-This plugin adds a message displaying the number of characters remaining in an input or textarea when they have a maxlength set.
+This plugin adds a message displaying the number of characters remaining in an input or textarea when they have a maxlength set. It's a bit rough around the edges, but I needed a fairly basic solution quickly and most of the existing plugins that offer a similar function were too big, too small, or didn't meet my specific needs. If this looks like it will work for you, feel free to use it!
+
+Highlights:
+- Less than 2KB minified.
+- Uses .prop() and .attr() correctly (.attr() is often used incorrectly for setting/getting DOM properties)
+- Can be used on individual elements with unique options for each element
+- Can be used on multiple elements with the same options
+- Message formatting function can be customized via $.fn.SimpleMaxChars.message = function(){ customFunction });
View
21 jquery.SimpleMaxChars.js
@@ -1,7 +1,13 @@
-// SimpleMaxChars jQuery Plugin
-// Copyright (c)2011 by Josh McCarty
-// http://joshmccarty.com
-// Tested with jQuery 1.7, IE8+, Chrome 17
+/**
+ * SimpleMaxChars jQuery Plugin
+ * http://joshmccarty.com
+ *
+ * Copyright (c)2012, Josh McCarty
+ * License: GPL Version 2
+ * http://www.gnu.org/licenses/gpl-2.0.txt
+ *
+ * Tested with jQuery 1.7.1, IE8+, Chrome 17
+ */
;( function( $ ) {
$.fn.SimpleMaxChars = function( options ) {
@@ -65,7 +71,7 @@
});
});
- }
+ };
// Private function to display debugging information
function debug( $obj, opts ) {
@@ -82,6 +88,7 @@
var remainingChars = maxLength - chars;
var lineBreak = "";
+ var html = "";
var messageClass = opts.messageClass;
if ( opts.lineBreak === true ) {
lineBreak = '<br />';
@@ -91,7 +98,7 @@
}
html = lineBreak + '<span class="' + messageClass + '">' + remainingChars + ' characters remaining.</span>';
return html;
- }
+ };
// Default plugin options
// Can be overwritten with new defaults. Example: $.fn.SimpleMaxChars.defaults.warningClass = 'invalid';
@@ -103,6 +110,6 @@
warningClass: 'warning',
lineBreak: false,
debug: false
- }
+ };
})( jQuery );

0 comments on commit 749fff4

Please sign in to comment.