Skip to content

Commit

Permalink
Pass clicks on the placeholder through to the input. Rename minified …
Browse files Browse the repository at this point in the history
…file
  • Loading branch information
Mike Singleton committed Sep 12, 2011
1 parent 8e7f143 commit 5a9ba10
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 0 additions & 1 deletion jquery.placeholder-min.js

This file was deleted.

9 changes: 6 additions & 3 deletions jquery.placeholder.js
Expand Up @@ -8,19 +8,22 @@
if(placeholder != undefined && placeholder != '') {
// Remove the placeholder attribute
$this.removeAttr('placeholder');

// Create and wrap the input in the input-holder
var inputHolder = $this.wrap($(document.createElement('span')).addClass('input-holder')).parent();

// Create the span that holds the default value
var inputDefault = $(document.createElement('span')).text(placeholder).addClass('input-default');
inputHolder.append(inputDefault);


// Pass clicks on the placeholder text through to the input
inputDefault.click(function() { $this.focus(); });

// Hide if it's not the delete, tab or shift keys
$this.keydown(function(event) {
if(event.keyCode != '8' && event.keyCode != '9' && event.keyCode != '16') { inputDefault.hide(); }
});

// Show if the field is empty
$this.keyup(function(event) {
if($this.val().length == 0) { inputDefault.show(); }
Expand Down
1 change: 1 addition & 0 deletions jquery.placeholder.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5a9ba10

Please sign in to comment.