diff --git a/public/javascripts/application.js b/public/javascripts/application.js index c368626..34cc445 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -694,3 +694,82 @@ jQuery(function() { target: "#ajax-form-message-area" }) }); + +/** +* @author Remy Sharp +* @url http://remysharp.com/2007/01/25/jquery-tutorial-text-box-hints/ +*/ + +(function ($) { + +$.fn.hint = function (blurClass) { + if (!blurClass) { + blurClass = 'blur'; + } + + return this.each(function () { + // get jQuery version of 'this' + var $input = $(this), + + // capture the rest of the variable to allow for reuse + title = $input.attr('title'), + $form = $(this.form), + $win = $(window); + + function remove() { + if ($input.val() === title && $input.hasClass(blurClass)) { + $input.val('').removeClass(blurClass); + } + } + + // only apply logic if the element has the attribute + if (title) { + // on blur, set value to title attr if text is blank + $input.blur(function () { + if (this.value === '') { + $input.val(title).addClass(blurClass); + } + }).focus(remove).blur(); // now change all inputs to title + + // clear the pre-defined text when form is submitted + $form.submit(remove); + $win.unload(remove); // handles Firefox's autocomplete + } + }); +}; + +})(jQuery); + +var altBeautify = jQuery('
') + .append('') + .append('') + .append(''); +var altTarget; +jQuery(document).ready(function () { + jQuery('body').append(altBeautify); +}); + +function altTimeout() { + if (!altTarget) + return; + altBeautify.css('top', jQuery(altTarget).offset().top + jQuery(altTarget).height()); + altBeautify.css('left', jQuery(altTarget).offset().left); + altBeautify.find('.alt-beautify-content').html(jQuery(altTarget).attr('alt-beautify')); + altBeautify.show(); +} + +jQuery('a[title]').live('mouseover', function (e) { + alt = jQuery(this).attr('title'); + if (alt != '') { + jQuery(this).attr('alt-beautify', alt); + jQuery(this).attr('title', ''); + } + + altTarget = this; + setTimeout("altTimeout()", 300); +}); +jQuery('a[title]').live('mouseout', function (e) { + altTarget = null; + altBeautify.hide(); +}); + -- libgit2 0.21.2