1
0
Fork 0
forked from OpenNeo/impress
impress/public/assets/placeholder-b442f41fce42c9a05f952a63a6e2cd0e.js

2 lines
1.6 KiB
JavaScript
Raw Normal View History

/*! http://mths.be/placeholder v1.8.4 by @mathias */
(function(e){function r(t){var n={},r=/^jQuery\d+$/;return e.each(t.attributes,function(e,t){t.specified&&!r.test(t.name)&&(n[t.name]=t.value)}),n}function i(){var t=e(this);t.val()===t.attr("placeholder")&&t.hasClass("placeholder")&&(t.data("placeholder-password")?t.hide().next().attr("id",t.removeAttr("id").data("placeholder-id")).show().focus():t.val("").removeClass("placeholder"))}function s(){var t,n=e(this),s=n,o=this.id;if(n.val()===""){if(n.is(":password")){if(!n.data("placeholder-textinput")){try{t=n.clone().attr({type:"text"})}catch(u){t=e("<input>").attr(e.extend(r(this),{type:"text"}))}t.removeAttr("name").data("placeholder-password",!0).data("placeholder-id",o).bind("focus.placeholder",i),n.data("placeholder-textinput",t).data("placeholder-id",o).before(t)}n=n.removeAttr("id").hide().prev().attr("id",o).show()}n.addClass("placeholder").val(n.attr("placeholder"))}else n.removeClass("placeholder")}var t="placeholder"in document.createElement("input"),n="placeholder"in document.createElement("textarea");t&&n?(e.fn.placeholder=function(){return this},e.fn.placeholder.input=e.fn.placeholder.textarea=!0):(e.fn.placeholder=function(){return this.filter((t?"textarea":":input")+"[placeholder]").bind("focus.placeholder",i).bind("blur.placeholder",s).trigger("blur.placeholder").end()},e.fn.placeholder.input=t,e.fn.placeholder.textarea=n,e(function(){e("form").bind("submit.placeholder",function(){var t=e(".placeholder",this).each(i);setTimeout(function(){t.each(s)},10)})}),e(window).bind("unload.placeholder",function(){e(".placeholder").val("")}))})(jQuery);