Skip to content
This repository
Browse code

Updated author/copyright information

  • Loading branch information...
commit 749fff4cc23b8de8a90da5f805ad0042d69b33cd 1 parent a369eab
Josh McCarty authored March 13, 2012
14  README
... ...
@@ -1,5 +1,15 @@
1  
-SimpleMaxChars jQuery plugin
  1
+SimpleMaxChars jQuery plugin v1.0
2 2
 Author: Josh McCarty
3 3
 Website: http://joshmccarty.com
  4
+Copyright (c)2012 Josh McCarty
  5
+License: GPL Version 2
  6
+http://www.gnu.org/licenses/gpl-2.0.txt
4 7
 
5  
-This plugin adds a message displaying the number of characters remaining in an input or textarea when they have a maxlength set.
  8
+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!
  9
+
  10
+Highlights:
  11
+- Less than 2KB minified.
  12
+- Uses .prop() and .attr() correctly (.attr() is often used incorrectly for setting/getting DOM properties)
  13
+- Can be used on individual elements with unique options for each element
  14
+- Can be used on multiple elements with the same options
  15
+- Message formatting function can be customized via $.fn.SimpleMaxChars.message = function(){ customFunction });
21  jquery.SimpleMaxChars.js
... ...
@@ -1,7 +1,13 @@
1  
-// SimpleMaxChars jQuery Plugin
2  
-// Copyright (c)2011 by Josh McCarty
3  
-// http://joshmccarty.com
4  
-// Tested with jQuery 1.7, IE8+, Chrome 17
  1
+/**
  2
+ * SimpleMaxChars jQuery Plugin
  3
+ * http://joshmccarty.com
  4
+ *
  5
+ * Copyright (c)2012, Josh McCarty
  6
+ * License: GPL Version 2
  7
+ * http://www.gnu.org/licenses/gpl-2.0.txt
  8
+ *
  9
+ * Tested with jQuery 1.7.1, IE8+, Chrome 17
  10
+ */
5 11
 
6 12
 ;( function( $ ) {
7 13
 	$.fn.SimpleMaxChars = function( options ) {
@@ -65,7 +71,7 @@
65 71
 			});
66 72
 		});
67 73
 		
68  
-	}
  74
+	};
69 75
 	
70 76
 	// Private function to display debugging information
71 77
 	function debug( $obj, opts ) {
@@ -82,6 +88,7 @@
82 88
 		
83 89
 		var remainingChars = maxLength - chars;
84 90
 		var lineBreak = "";
  91
+		var html = "";
85 92
 		var messageClass = opts.messageClass;
86 93
 		if ( opts.lineBreak === true ) {
87 94
 			lineBreak = '<br />';
@@ -91,7 +98,7 @@
91 98
 		}
92 99
 		html = lineBreak + '<span class="' + messageClass + '">' + remainingChars + ' characters remaining.</span>';
93 100
 		return html;
94  
-	}
  101
+	};
95 102
 
96 103
 	// Default plugin options
97 104
 	// Can be overwritten with new defaults. Example: $.fn.SimpleMaxChars.defaults.warningClass = 'invalid';
@@ -103,6 +110,6 @@
103 110
 		warningClass: 'warning',
104 111
 		lineBreak: false,
105 112
 		debug: false
106  
-	}
  113
+	};
107 114
 
108 115
 })( jQuery );

0 notes on commit 749fff4

Please sign in to comment.
Something went wrong with that request. Please try again.