diff --git a/doc-src/assets/javascripts/placeholder.js b/doc-src/assets/javascripts/placeholder.js new file mode 100644 index 00000000..7081fb74 --- /dev/null +++ b/doc-src/assets/javascripts/placeholder.js @@ -0,0 +1,51 @@ +(function($) { + + $.fn.replaceholder = function(options) { + + var $placeholder; + + (this.length > 0) ? $this = $(this) : $this = $('input[placeholder]'); + return $this.each(function() { + + settings = jQuery.extend({ + focusColor: '#000', + blurColor: '#aaa' + }, options); + + var $placeholder = $(this); + + if ($placeholder.length > 0) { + + var attrPh = $placeholder.attr('placeholder'); + + $placeholder.attr('value', attrPh); + $placeholder.css('color',settings.blurColor) + .bind('focus', function() { + + var $this = $(this); + + if($this.val() === attrPh) + $this.val('').css('color',settings.focusColor); + + }).bind('blur', function() { + + var $this = $(this); + + if($this.val() === '') + $this.val(attrPh).css('color',settings.blurColor); + + }); + + } + + }); + + }; + +})(jQuery); + +jQuery(function($){ + $(document).ready(function(){ + if (!Modernizr.input.placeholder) { $("input[placeholder], textarea[placeholder]").replaceholder() } + }) +}) \ No newline at end of file diff --git a/doc-src/layouts/partials/js-core.haml b/doc-src/layouts/partials/js-core.haml index b7c3d547..3db68129 100644 --- a/doc-src/layouts/partials/js-core.haml +++ b/doc-src/layouts/partials/js-core.haml @@ -1,5 +1,6 @@ %script(src="/javascripts/modernizr-1.6.min.js" type="text/javascript") %script(src="/javascripts/jquery-1.3.2.min.js" type="text/javascript") %script(src="/javascripts/jquery.cookie.js" type="text/javascript") +%script(src="/javascripts/placeholder.js" type="text/javascript" deferred) %script(src="/javascripts/site.js" type="text/javascript") %script(src="/javascripts/fixups.js" type="text/javascript" deferred)