From 4e2a345e897bffd764026ae6a0c57ba822cfadb9 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Sat, 11 Feb 2012 07:51:15 +0100 Subject: [PATCH] Tag the 2.0.2 release --- jquery.placeholder.js | 31 ++++++++++++++----------------- jquery.placeholder.min.js | 4 ++-- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/jquery.placeholder.js b/jquery.placeholder.js index 8fea7f0..d0f2753 100644 --- a/jquery.placeholder.js +++ b/jquery.placeholder.js @@ -1,4 +1,4 @@ -/*! http://mths.be/placeholder v2.0.1 by @mathias */ +/*! http://mths.be/placeholder v2.0.2 by @mathias */ ;(function(window, document, $) { var isInputSupported = 'placeholder' in document.createElement('input'), @@ -26,7 +26,7 @@ 'focus.placeholder': clearPlaceholder, 'blur.placeholder': setPlaceholder }) - .data('jquery-placeholder-enabled', true) + .data('placeholder-enabled', true) .trigger('blur.placeholder').end(); }; @@ -35,23 +35,20 @@ hooks = { 'get': function(element) { - var $element = $(element), - isPlaceholderEnabled = $element.data('jquery-placeholder-enabled'); - return (isPlaceholderEnabled && $element.hasClass('placeholder')) ? '' : element.value; + var $element = $(element); + return $element.data('placeholder-enabled') && $element.hasClass('placeholder') ? '' : element.value; }, 'set': function(element, value) { - var $element = $(element) - isPlaceholderEnabled = $element.data('jquery-placeholder-enabled'); - if (isPlaceholderEnabled) { - if (value == '') { - element.value = value; - // We can’t use `triggerHandler` here because of dummy text/password inputs :( - setPlaceholder.call(element); - } else if ($element.hasClass('placeholder')) { - clearPlaceholder.call(element, true, value) || (element.value = value); - } else { - element.value = value; - } + var $element = $(element); + if (!$element.data('placeholder-enabled')) { + return $element.value = value; + } + if (value == '') { + element.value = value; + // We can’t use `triggerHandler` here because of dummy text/password inputs :( + setPlaceholder.call(element); + } else if ($element.hasClass('placeholder')) { + clearPlaceholder.call(element, true, value) || (element.value = value); } else { element.value = value; } diff --git a/jquery.placeholder.min.js b/jquery.placeholder.min.js index 7e4a97a..dbd8ab6 100644 --- a/jquery.placeholder.min.js +++ b/jquery.placeholder.min.js @@ -1,2 +1,2 @@ -/*! http://mths.be/placeholder v2.0.1 by @mathias */ -;(function(f,h,$){var a="placeholder" in h.createElement("input"),d="placeholder" in h.createElement("textarea"),i=$.fn,c=$.valHooks,k,j;if(a&&d){j=i.placeholder=function(){return this};j.input=j.textarea=true}else{j=i.placeholder=function(){return this.filter((a?"textarea":":input")+"[placeholder]").not(".placeholder").bind({"focus.placeholder":b,"blur.placeholder":e}).trigger("blur.placeholder").end()};j.input=a;j.textarea=d;k={get:function(m){var l=$(m);return l.hasClass("placeholder")?"":m.value},set:function(m,n){var l=$(m);if(n==""){m.value=n;e.call(m)}else{if(l.hasClass("placeholder")){b.call(m,true,n)||(m.value=n)}else{m.value=n}}return l}};a||(c.input=k);d||(c.textarea=k);$(function(){$(h).delegate("form","submit.placeholder",function(){var l=$(".placeholder",this).each(b);setTimeout(function(){l.each(e)},10)})});$(f).bind("beforeunload.placeholder",function(){$(".placeholder").each(function(){this.value=""})})}function g(m){var l={},n=/^jQuery\d+$/;$.each(m.attributes,function(p,o){if(o.specified&&!n.test(o.name)){l[o.name]=o.value}});return l}function b(m,n){var l=this,o=$(l);if(l.value==o.attr("placeholder")&&o.hasClass("placeholder")){if(o.data("placeholder-password")){o=o.hide().next().show().attr("id",o.removeAttr("id").data("placeholder-id"));if(m===true){return o[0].value=n}o.focus()}else{l.value="";o.removeClass("placeholder")}}}function e(){var q,l=this,p=$(l),m=p,o=this.id;if(l.value==""){if(l.type=="password"){if(!p.data("placeholder-textinput")){try{q=p.clone().attr({type:"text"})}catch(n){q=$("").attr($.extend(g(this),{type:"text"}))}q.removeAttr("name").data({"placeholder-password":true,"placeholder-id":o}).bind("focus.placeholder",b);p.data({"placeholder-textinput":q,"placeholder-id":o}).before(q)}p=p.removeAttr("id").hide().prev().attr("id",o).show()}p.addClass("placeholder");p[0].value=p.attr("placeholder")}else{p.removeClass("placeholder")}}}(this,document,jQuery)); \ No newline at end of file +/*! http://mths.be/placeholder v2.0.2 by @mathias */ +;(function(f,h,$){var a='placeholder' in h.createElement('input'),d='placeholder' in h.createElement('textarea'),i=$.fn,c=$.valHooks,k,j;if(a&&d){j=i.placeholder=function(){return this};j.input=j.textarea=true}else{j=i.placeholder=function(){return this.filter((a?'textarea':':input')+'[placeholder]').not('.placeholder').bind({'focus.placeholder':b,'blur.placeholder':e}).data('placeholder-enabled',true).trigger('blur.placeholder').end()};j.input=a;j.textarea=d;k={get:function(m){var l=$(m);return l.data('placeholder-enabled')&&l.hasClass('placeholder')?'':m.value},set:function(m,n){var l=$(m);if(!l.data('placeholder-enabled')){return l.value=n}if(n==''){m.value=n;e.call(m)}else{if(l.hasClass('placeholder')){b.call(m,true,n)||(m.value=n)}else{m.value=n}}return l}};a||(c.input=k);d||(c.textarea=k);$(function(){$(h).delegate('form','submit.placeholder',function(){var l=$('.placeholder',this).each(b);setTimeout(function(){l.each(e)},10)})});$(f).bind('beforeunload.placeholder',function(){$('.placeholder').each(function(){this.value=''})})}function g(m){var l={},n=/^jQuery\d+$/;$.each(m.attributes,function(p,o){if(o.specified&&!n.test(o.name)){l[o.name]=o.value}});return l}function b(m,n){var l=this,o=$(l);if(l.value==o.attr('placeholder')&&o.hasClass('placeholder')){if(o.data('placeholder-password')){o=o.hide().next().show().attr('id',o.removeAttr('id').data('placeholder-id'));if(m===true){return o[0].value=n}o.focus()}else{l.value='';o.removeClass('placeholder')}}}function e(){var q,l=this,p=$(l),m=p,o=this.id;if(l.value==''){if(l.type=='password'){if(!p.data('placeholder-textinput')){try{q=p.clone().attr({type:'text'})}catch(n){q=$('').attr($.extend(g(this),{type:'text'}))}q.removeAttr('name').data({'placeholder-password':true,'placeholder-id':o}).bind('focus.placeholder',b);p.data({'placeholder-textinput':q,'placeholder-id':o}).before(q)}p=p.removeAttr('id').hide().prev().attr('id',o).show()}p.addClass('placeholder');p[0].value=p.attr('placeholder')}else{p.removeClass('placeholder')}}}(this,document,jQuery)); \ No newline at end of file