Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove whitespace

  • Loading branch information...
commit abf1ef1c4757cfac49052f522c586644f406b11b 1 parent 13f95ad
@Godisemo authored
Showing with 9 additions and 7 deletions.
  1. +6 −5 example.html
  2. +3 −2 jquery.auto-placeholders.coffee
View
11 example.html
@@ -2,7 +2,7 @@
<head>
<meta charset="utf-8">
<title>jQuery auto-placeholders</title>
-
+
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
<script type="text/javascript" src="min/jquery.auto-placeholders.js"></script>
@@ -35,18 +35,19 @@
<label for="phone">Phone:</label>
<input type="text" name="phone" id="phone" placeholder="123456" />
</div>
-
-
+
+
<div>
<label for="message">Message:</label>
<textarea cols="40" rows="8" name="message" placeholder="Put your message here!"></textarea>
</div>
-
+
<div>
<input type="submit" />
</div>
+
</form>
-
+
</body>
<script>
$("#example_form").autoPlaceholders()
View
5 jquery.auto-placeholders.coffee
@@ -29,11 +29,12 @@ $.fn.autoPlaceholders = ->
# Find all inputs and textareas in the selected element.
$("input, textarea", this).each ->
-
+
# Get their placeholder value(if they have any) and add it as value.
# Also add a CSS-class for blurred inputs to mimic the placeholder look.
if $(this).attr("placeholder")?
placeholder = $(this).attr "placeholder"
+
$(this).val(placeholder).addClass "placeholder"
# Bind focus event, so when user clicks the input the value disapears,
@@ -41,7 +42,7 @@ $.fn.autoPlaceholders = ->
$(this).bind "focus", ->
if $(this).hasClass("placeholder")
$(this).val("").removeClass "placeholder"
-
+
# Bind blur event, so when user exit the input the value resets if
# the input is empty.
Please sign in to comment.
Something went wrong with that request. Please try again.