Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions src/jquery.infieldlabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
base.showing = false;
};

// Occasionally check to see if the field was autofilled by the browser (Chrome is the worst offender)
setInterval(base.checkForAutofill, 200);

base.$field.focus(function(){
base.fadeOnFocus();
}).blur(function(){
Expand Down Expand Up @@ -72,6 +75,18 @@
base.showing = (opacity > 0.0);
};

// See if the field already has
// a value. Make sure the label is hidden
base.checkForAutofill = function () {
if (base.$field.val() != "") {
base.$label.css({
opacity: 0.0
}).show();
} else if(!base.$field.is(":focus")) {
base.setOpacity(1.0);
}
};

// Checks for empty as a fail safe
// set blur to true when passing from
// the blur event
Expand Down Expand Up @@ -134,13 +149,17 @@
// Find the referenced input or textarea element
var $field = $(
"input#" + for_attr + "[type='text']," +
"input#" + for_attr + "[type='password']," +
"input#" + for_attr + "[type='email']," +
"input#" + for_attr + "[type='numeric']," +
"input#" + for_attr + "[type='url']," +
"input#" + for_attr + "[type='color']," +
"input#" + for_attr + "[type='password']," +
"textarea#" + for_attr
);

if( $field.length == 0) return; // Again, nothing to attach

// Only create object for input[text], input[password], or textarea
// Only create object for input[text] type fields (including HTML5 types), or textarea
(new $.InFieldLabels(this, $field[0], options));
});
};
Expand Down
3 changes: 2 additions & 1 deletion src/jquery.infieldlabel.min.js

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