/** * Placeholder * Crowd Favorite * @requires jQuery v1.2 or above * * Version: 1.0.1 * Patches the HTML5 placeholder atttribute functionality for browsers that don't support it */ ;(function(c){function f(a,b){var d=b.classname;if(a.val()==""||a.val()==a.attr(b.attribute)){a.addClass(d);a.val()==""&&a.attr("value",a.attr(b.attribute))}else a.removeClass(d)}function e(a,b){if(a.val()&&a.val()!=a.attr(b.attribute))return false;if(a.val()==a.attr(b.attribute))a.attr("value","");else a.val()||a.attr("value",a.attr(b.attribute));a.toggleClass(b.classname)}function g(a){c("form").submit(function(){clearPlaceholders(this,a)})}c.fn.placeholder=function(a){var b=c.extend({},c.fn.placeholder.settings, a);if(b.attribute=="placeholder"&&b.disableIfSupported==true&&"placeholder"in document.createElement("input"))return null;this.each(function(){var d=c(this);f(d,b);d.focus(function(){e(d,b)});d.blur(function(){e(d,b)})});g(b)};c.fn.placeholder.settings={classname:"cfp-placeholder",attribute:"placeholder",disableIfSupported:true};c.placeholders=function(a){c("input[placeholder]").placeholder(a)};clearPlaceholders=function(a,b){c(a).find("input").each(function(){_this=c(this);_this.val()==_this.attr(b.attribute)&& _this.attr("value","")})}})(jQuery);