From 235f7cda75fe0425ad04064672225b99e335fc02 Mon Sep 17 00:00:00 2001 From: Daniel Stocks Date: Thu, 8 Jul 2010 14:29:50 +0200 Subject: [PATCH] removed redundant checks for password inputs --- demo.html | 2 +- jquery.placeholder.js | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/demo.html b/demo.html index ec95232..6212f77 100644 --- a/demo.html +++ b/demo.html @@ -6,7 +6,7 @@ jQuery-Placeholder diff --git a/jquery.placeholder.js b/jquery.placeholder.js index 4ab6f17..54def14 100644 --- a/jquery.placeholder.js +++ b/jquery.placeholder.js @@ -9,20 +9,21 @@ // Special treatment for password inputs if (input.attr('type') == 'password') { input.attr('realType', 'password'); + this.isPassword = true; } this.input = input; // IE doesn't allow changing the type of password inputs this.fakePassword = $("").val(input.attr('placeholder')).focus(function() { input.trigger("focus") $(this).hide(); - }).css({width : input.width()}); + }); } Placeholder.prototype = { show : function(loading) { // FF and IE saves values when you refresh the page. If the user refreshes the page with // the placeholders showing they will be the default values and the input fields won't be empty. if (this.input[0].value == '' || (loading && this.valueIsPlaceholder())) { - if (this.isPassword()) { + if (this.isPassword) { try { // IE doesn't allow us to change the input type this.input[0].setAttribute('type', 'input'); } catch (e) { @@ -35,7 +36,7 @@ }, hide : function() { if (this.valueIsPlaceholder() && this.input.hasClass('placeholder')) { - if (this.isPassword()) { + if (this.isPassword) { try { this.input[0].setAttribute('type', 'password'); } catch (e) { } @@ -47,9 +48,6 @@ this.input.removeClass('placeholder'); } }, - isPassword: function() { - return this.input.attr('realType') == 'password'; - }, valueIsPlaceholder : function() { return this.input[0].value == this.input.attr('placeholder'); }