2010-12-18 21:34:36 +00:00
|
|
|
(function($) {
|
2010-12-19 03:53:03 +00:00
|
|
|
|
2010-12-18 21:34:36 +00:00
|
|
|
$.fn.replaceholder = function(options) {
|
2010-12-19 03:53:03 +00:00
|
|
|
|
2010-12-18 21:34:36 +00:00
|
|
|
var $placeholder;
|
2010-12-19 03:53:03 +00:00
|
|
|
|
2010-12-18 21:34:36 +00:00
|
|
|
(this.length > 0) ? $this = $(this) : $this = $('input[placeholder]');
|
|
|
|
return $this.each(function() {
|
2010-12-19 03:53:03 +00:00
|
|
|
|
|
|
|
settings = jQuery.extend(options);
|
|
|
|
|
2010-12-18 21:34:36 +00:00
|
|
|
var $placeholder = $(this);
|
2010-12-19 03:53:03 +00:00
|
|
|
|
2010-12-18 21:34:36 +00:00
|
|
|
if ($placeholder.length > 0) {
|
2010-12-19 03:53:03 +00:00
|
|
|
|
2010-12-18 21:34:36 +00:00
|
|
|
var attrPh = $placeholder.attr('placeholder');
|
2010-12-19 03:53:03 +00:00
|
|
|
|
2010-12-18 21:34:36 +00:00
|
|
|
$placeholder.attr('value', attrPh);
|
2010-12-19 03:53:03 +00:00
|
|
|
$placeholder.bind('focus', function() {
|
|
|
|
|
2010-12-18 21:34:36 +00:00
|
|
|
var $this = $(this);
|
2010-12-19 03:53:03 +00:00
|
|
|
|
2010-12-18 21:34:36 +00:00
|
|
|
if($this.val() === attrPh)
|
2010-12-19 03:53:03 +00:00
|
|
|
$this.val('').removeClass('placeholder');
|
|
|
|
|
2010-12-18 21:34:36 +00:00
|
|
|
}).bind('blur', function() {
|
2010-12-19 03:53:03 +00:00
|
|
|
|
2010-12-18 21:34:36 +00:00
|
|
|
var $this = $(this);
|
2010-12-19 03:53:03 +00:00
|
|
|
|
2010-12-18 21:34:36 +00:00
|
|
|
if($this.val() === '')
|
2010-12-19 03:53:03 +00:00
|
|
|
$this.val(attrPh).addClass('placeholder');
|
|
|
|
|
2010-12-18 21:34:36 +00:00
|
|
|
});
|
2010-12-19 03:53:03 +00:00
|
|
|
|
2010-12-18 21:34:36 +00:00
|
|
|
}
|
2010-12-19 03:53:03 +00:00
|
|
|
|
2010-12-18 21:34:36 +00:00
|
|
|
});
|
2010-12-19 03:53:03 +00:00
|
|
|
|
2010-12-18 21:34:36 +00:00
|
|
|
};
|
2010-12-19 03:53:03 +00:00
|
|
|
|
2010-12-18 21:34:36 +00:00
|
|
|
})(jQuery);
|
|
|
|
|
|
|
|
jQuery(function($){
|
|
|
|
$(document).ready(function(){
|
|
|
|
if (!Modernizr.input.placeholder) { $("input[placeholder], textarea[placeholder]").replaceholder() }
|
|
|
|
})
|
2010-12-19 03:53:03 +00:00
|
|
|
})
|