All Downloads are FREE. Search and download functionalities are using the official Maven repository.

uicore.jqueryplaceholder.2.1.2.jquery.placeholder.min.js Maven / Gradle / Ivy

There is a newer version: 8.2.4
Show newest version
(function(c){"function"===typeof define&&define.amd?define(["jquery"],c):"object"===typeof module&&module.exports?c(require("jquery")):c(jQuery)})(function(c){function q(a){var b={},d=/^jQuery\d+$/;c.each(a.attributes,function(a,c){c.specified&&!d.test(c.name)&&(b[c.name]=c.value)});return b}function h(a,b){var d=c(this);if(this.value==d.attr("placeholder")&&d.hasClass(f.customClass))if(d.data("placeholder-password")){d=d.hide().nextAll('input[type="password"]:first').show().attr("id",d.removeAttr("id").data("placeholder-id"));
if(!0===a)return d[0].value=b;d.focus()}else this.value="",d.removeClass(f.customClass),this==m()&&this.select()}function l(){var a,b=c(this),d=this.id;if(""===this.value){if("password"===this.type){if(!b.data("placeholder-textinput")){try{a=b.clone().prop({type:"text"})}catch(e){a=c("").attr(c.extend(q(this),{type:"text"}))}a.removeAttr("name").data({"placeholder-password":b,"placeholder-id":d}).bind("focus.placeholder",h);b.data({"placeholder-textinput":a,"placeholder-id":d}).before(a)}b=
b.removeAttr("id").hide().prevAll('input[type="text"]:first').attr("id",d).show()}b.addClass(f.customClass);b[0].value=b.attr("placeholder")}else b.removeClass(f.customClass)}function m(){try{return document.activeElement}catch(a){}}var g="[object OperaMini]"==Object.prototype.toString.call(window.operamini),k="placeholder"in document.createElement("input")&&!g,g="placeholder"in document.createElement("textarea")&&!g,n=c.valHooks,p=c.propHooks,e;if(k&&g)e=c.fn.placeholder=function(){return this},
e.input=e.textarea=!0;else{var f={};e=c.fn.placeholder=function(a){f=c.extend({},{customClass:"placeholder"},a);this.filter((k?"textarea":":input")+"[placeholder]").not("."+f.customClass).bind({"focus.placeholder":h,"blur.placeholder":l}).data("placeholder-enabled",!0).trigger("blur.placeholder");return this};e.input=k;e.textarea=g;e={get:function(a){var b=c(a),d=b.data("placeholder-password");return d?d[0].value:b.data("placeholder-enabled")&&b.hasClass(f.customClass)?"":a.value},set:function(a,
b){var d=c(a),e=d.data("placeholder-password");if(e)return e[0].value=b;if(!d.data("placeholder-enabled"))return a.value=b;""===b?(a.value=b,a!=m()&&l.call(a)):d.hasClass(f.customClass)?h.call(a,!0,b)||(a.value=b):a.value=b;return d}};k||(n.input=e,p.value=e);g||(n.textarea=e,p.value=e);c(function(){c(document).delegate("form","submit.placeholder",function(){var a=c("."+f.customClass,this).each(h);setTimeout(function(){a.each(l)},10)})});c(window).bind("beforeunload.placeholder",function(){c("."+
f.customClass).each(function(){this.value=""})})}});




© 2015 - 2025 Weber Informatics LLC | Privacy Policy