Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chrome issue #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- version: 2.0.4
- tholder: fixed issue with \r's not working in Google Chrome. Now just strips \n or \r
- version: 2.0.3
- glennfu: added support for title's with \r's in them
- version: 2.0.3
Expand Down
16 changes: 9 additions & 7 deletions jquery.labelify.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
* @author Stuart Langridge
* @author Garrett LeSage
* @author Glenn Sidney
* @version 2.0.3
* @author Tom Holder
* @version 2.0.4
*/

/**
Expand Down Expand Up @@ -78,20 +79,21 @@
if (typeof lookup !== "function" || !lookup(this)) { return; }

$item.bind('focus.label',function() {
if (this.value.replace(/\n/g, "\r") === $(this).data("label")) { hideLabel(this); }
if (this.value.replace(/\n|\r/g, "") === $(this).data("label").replace(/\n|\r/g, "")) { hideLabel(this); }
}).bind('blur.label',function(){
if (this.value === '') { showLabel(this); }
}).data('label',lookup(this).replace(/\n/g,'')); // strip label's newlines
}).data('label',lookup(this).replace(/\n/g,'\r')); // strip label's newlines

removeValuesOnExit = function() {
$labelified_elements.each(function(){
if (this.value.replace(/\n/g, "\r") === $(this).data("label")) { hideLabel(this); }
var $label = $(this).data("label");
if ($label && this.value.replace(/\n|\r/g, "") === $label.replace(/\n|\r/g, "")) { hideLabel(this); }
});
};

$item.parents("form").submit(removeValuesOnExit);
$(window).unload(removeValuesOnExit);

if (this.value !== '') {
// user started typing; don't overwrite his/her text!
return;
Expand Down