diff --git a/jquery.placeholder.js b/jquery.placeholder.js index 53774ee..dd34bb0 100644 --- a/jquery.placeholder.js +++ b/jquery.placeholder.js @@ -2,19 +2,21 @@ ;(function(window, document, $) { var isInputSupported = 'placeholder' in document.createElement('input'), - isTextareaSupported = 'placeholder' in document.createElement('textarea'); + isTextareaSupported = 'placeholder' in document.createElement('textarea'), + prototype = $.fn, + placeholder; if (isInputSupported && isTextareaSupported) { - $.fn.placeholder = function() { + placeholder = prototype.placeholder = function() { return this; }; - $.fn.placeholder.input = $.fn.placeholder.textarea = true; + placeholder.input = placeholder.textarea = true; } else { - $.fn.placeholder = function() { + placeholder = prototype.placeholder = function() { return this .filter((isInputSupported ? 'textarea' : ':input') + '[placeholder]') .not('.placeholder') @@ -23,8 +25,8 @@ .trigger('blur.placeholder').end(); }; - $.fn.placeholder.input = isInputSupported; - $.fn.placeholder.textarea = isTextareaSupported; + placeholder.input = isInputSupported; + placeholder.textarea = isTextareaSupported; $(function() { // Look for forms diff --git a/jquery.placeholder.min.js b/jquery.placeholder.min.js index f65e6bb..d5fa02f 100644 --- a/jquery.placeholder.min.js +++ b/jquery.placeholder.min.js @@ -1,2 +1,2 @@ -/*! http://mths.be/placeholder v1.8.5 by @mathias */ -(function(g,a,$){var f='placeholder' in a.createElement('input'),b='placeholder' in a.createElement('textarea');if(f&&b){$.fn.placeholder=function(){return this};$.fn.placeholder.input=$.fn.placeholder.textarea=true}else{$.fn.placeholder=function(){return this.filter((f?'textarea':':input')+'[placeholder]').bind('focus.placeholder',c).bind('blur.placeholder',e).trigger('blur.placeholder').end()};$.fn.placeholder.input=f;$.fn.placeholder.textarea=b;$(function(){$('form').bind('submit.placeholder',function(){var h=$('.placeholder',this).each(c);setTimeout(function(){h.each(e)},10)})});$(g).bind('unload.placeholder',function(){$('.placeholder').val('')})}function d(i){var h={},j=/^jQuery\d+$/;$.each(i.attributes,function(l,k){if(k.specified&&!j.test(k.name)){h[k.name]=k.value}});return h}function c(){var h=$(this);if(h.val()===h.attr('placeholder')&&h.hasClass('placeholder')){if(h.data('placeholder-password')){h.hide().next().show().focus().attr('id',h.removeAttr('id').data('placeholder-id'))}else{h.val('').removeClass('placeholder')}}}function e(){var l,k=$(this),h=k,j=this.id;if(k.val()===''){if(k.is(':password')){if(!k.data('placeholder-textinput')){try{l=k.clone().attr({type:'text'})}catch(i){l=$('').attr($.extend(d(this),{type:'text'}))}l.removeAttr('name').data('placeholder-password',true).data('placeholder-id',j).bind('focus.placeholder',c);k.data('placeholder-textinput',l).data('placeholder-id',j).before(l)}k=k.removeAttr('id').hide().prev().attr('id',j).show()}k.addClass('placeholder').val(k.attr('placeholder'))}else{k.removeClass('placeholder')}}}(this,document,jQuery)); \ No newline at end of file +/*! http://mths.be/placeholder v1.8.6 by @mathias */ +(function(e,g,$){var a='placeholder' in g.createElement('input'),c='placeholder' in g.createElement('textarea'),h=$.fn,i;if(a&&c){i=h.placeholder=function(){return this};i.input=i.textarea=true}else{i=h.placeholder=function(){return this.filter((a?'textarea':':input')+'[placeholder]').not('.placeholder').bind('focus.placeholder',b).bind('blur.placeholder',d).trigger('blur.placeholder').end()};i.input=a;i.textarea=c;$(function(){$('form').bind('submit.placeholder',function(){var j=$('.placeholder',this).each(b);setTimeout(function(){j.each(d)},10)})});$(e).bind('unload.placeholder',function(){$('.placeholder').val('')})}function f(k){var j={},l=/^jQuery\d+$/;$.each(k.attributes,function(n,m){if(m.specified&&!l.test(m.name)){j[m.name]=m.value}});return j}function b(){var j=$(this);if(j.val()===j.attr('placeholder')&&j.hasClass('placeholder')){if(j.data('placeholder-password')){j.hide().next().show().focus().attr('id',j.removeAttr('id').data('placeholder-id'))}else{j.val('').removeClass('placeholder')}}}function d(){var n,m=$(this),j=m,l=this.id;if(m.val()===''){if(m.is(':password')){if(!m.data('placeholder-textinput')){try{n=m.clone().attr({type:'text'})}catch(k){n=$('').attr($.extend(f(this),{type:'text'}))}n.removeAttr('name').data('placeholder-password',true).data('placeholder-id',l).bind('focus.placeholder',b);m.data('placeholder-textinput',n).data('placeholder-id',l).before(n)}m=m.removeAttr('id').hide().prev().attr('id',l).show()}m.addClass('placeholder').val(m.attr('placeholder'))}else{m.removeClass('placeholder')}}}(this,document,jQuery)); \ No newline at end of file