From 5bfad54ef7bbceda542db89f0bce7dc35c89a2ac Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Fri, 8 Oct 2010 11:55:50 +0200 Subject: [PATCH] =?UTF-8?q?Updated=20minified=20version=20to=20reflect=20t?= =?UTF-8?q?emp01=E2=80=99s=20awesome=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jquery.placeholder.js | 11 ++++++----- jquery.placeholder.min.js | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/jquery.placeholder.js b/jquery.placeholder.js index 91862a4..03b04d1 100644 --- a/jquery.placeholder.js +++ b/jquery.placeholder.js @@ -14,9 +14,10 @@ function args(elem) { // Return an object of element attributes - var newAttrs = {}, rinlinejQuery = /^jQuery\d+$/; - $.each(elem.attributes, function(i, attr){ - if( !rinlinejQuery.test(attr.name) ){ + var newAttrs = {}, + rinlinejQuery = /^jQuery\d+$/; + $.each(elem.attributes, function(i, attr) { + if (!rinlinejQuery.test(attr.name)) { newAttrs[attr.name] = attr.value; } }); @@ -39,11 +40,11 @@ $input = $(this); if ($input.val() === '' || $input.val() === $input.attr('placeholder')) { if ($input.is(':password')) { - if(!$input.data('placeholder-textinput')){ + if (!$input.data('placeholder-textinput')) { try { $replacement = $input.clone().attr({ type: 'text' }); } catch(e) { - $replacement = $('').attr( $.extend(args($input[0]), {type: 'text'}) ); + $replacement = $('').attr($.extend(args($input[0]), { type: 'text' })); } $replacement .removeAttr('name') diff --git a/jquery.placeholder.min.js b/jquery.placeholder.min.js index a3e0ded..1a3d6ad 100644 --- a/jquery.placeholder.min.js +++ b/jquery.placeholder.min.js @@ -3,4 +3,4 @@ * @link http://github.com/mathiasbynens/Placeholder-jQuery-Plugin * @author Mathias Bynens */ -(function(d){if('placeholder' in document.createElement('input')){d.fn.placeholder=function(){return this};return}function a(f){var h=d('
').append(f.clone()).html().replace(/<(\w+)\s+(.*)>/,'$2'),e,g={};while((e=h.match(/\s*([\w\-]+)=("[^"]*"|'[^']*'|\w+)/))){g[e[1]]=e[2].replace(/^(["'])(.*?)\1$/,'$2');h=h.replace(e[0],'')}return g}function b(){var e=d(this);if(e.val()===e.attr('placeholder')&&e.hasClass('placeholder')){if(e.data('placeholder-password')){e.next().show().focus().end().remove()}else{e.val('').removeClass('placeholder')}}}function c(g){var i,f=d(this);if(f.val()===''||f.val()===f.attr('placeholder')){if(f.is(':password')){try{i=f.clone().attr({type:'text'})}catch(h){i=d('',d.extend(a(f),{type:'text'}))}i.data('placeholder-password',true).bind('focus.placeholder',b);f.hide().before(i);f=i}f.addClass('placeholder').val(f.attr('placeholder'))}else{f.removeClass('placeholder')}}d(function(){d('form').bind('submit.placeholder',function(){d('.placeholder',this).val('')})});d(window).bind('unload.placeholder',function(){d('.placeholder').val('')});d.fn.placeholder=function(){return this.filter(':input[placeholder]').bind({'focus.placeholder':b,'blur.placeholder':c}).trigger('blur.placeholder').end()}})(jQuery); \ No newline at end of file +(function(d){if('placeholder' in document.createElement('input')){d.fn.placeholder=function(){return this};return}function a(f){var e={},g=/^jQuery\d+$/;d.each(f.attributes,function(j,h){if(!g.test(h.name)){e[h.name]=h.value}});return e}function b(){var e=d(this);if(e.val()===e.attr('placeholder')&&e.hasClass('placeholder')){if(e.data('placeholder-password')){e.hide().next().show().focus()}else{e.val('').removeClass('placeholder')}}}function c(f){var i,h=d(this);if(h.val()===''||h.val()===h.attr('placeholder')){if(h.is(':password')){if(!h.data('placeholder-textinput')){try{i=h.clone().attr({type:'text'})}catch(g){i=d('').attr(d.extend(a(h[0]),{type:'text'}))}i.removeAttr('name').data('placeholder-password',true).bind('focus.placeholder',b);h.data('placeholder-textinput',i).before(i)}h=h.hide().prev().show()}h.addClass('placeholder').val(h.attr('placeholder'))}else{h.removeClass('placeholder')}}d(function(){d('form').bind('submit.placeholder',function(){d('.placeholder',this).val('')})});d(window).bind('unload.placeholder',function(){d('.placeholder').val('')});d.fn.placeholder=function(){return this.filter(':input[placeholder]').bind('focus.placeholder',b).bind('blur.placeholder',c).trigger('blur.placeholder').end()}})(jQuery); \ No newline at end of file