diff options
author | Chad Kieffer <ckieffer@gmail.com> | 2009-10-18 10:32:08 -0600 |
---|---|---|
committer | Chad Kieffer <ckieffer@gmail.com> | 2009-10-18 10:32:08 -0600 |
commit | c9ccc2461880de141c37c3c7a7df3b26530ce806 (patch) | |
tree | a719cc2ba974e8a020c07a92a8a7de24fb31c0f4 /lib/gallery.common.js | |
parent | 08a22f4a39a1dad4b63f1303aa9cb3e758a784f3 (diff) |
Moved the short_form init function to gallery.common and made it jQuery plugin. Dropped gallery.form.js. Applied short forms to server_add and tag admin pages. Added tag.css to admin views. Added .g-wide {}.
Diffstat (limited to 'lib/gallery.common.js')
-rw-r--r-- | lib/gallery.common.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/gallery.common.js b/lib/gallery.common.js index 5721c779..7c52fef0 100644 --- a/lib/gallery.common.js +++ b/lib/gallery.common.js @@ -172,4 +172,40 @@ }; }; + // Initialize a short form. Short forms may contain only one text input. + $.fn.gallery_short_form = function() { + return this.each(function(i){ + var label = $(this).find("label:first"); + var input = $(this).find("input[type=text]:first"); + var button = $(this).find("input[type=submit]"); + + $(".g-short-form").addClass("ui-helper-clearfix"); + $(".g-short-form input[type=text]").addClass("ui-corner-left"); + $(".g-short-form input[type=submit]").addClass("ui-state-default ui-corner-right"); + + // Set the input value equal to label text + if (input.val() == "") { + input.val(label.html()); + button.enable(false); + } + + // Attach event listeners to the input + input.bind("focus", function(e) { + // Empty input value if it equals it's label + if ($(this).val() == label.html()) { + $(this).val(""); + } + button.enable(true); + }); + + input.bind("blur", function(e){ + // Reset the input value if it's empty + if ($(this).val() == "") { + $(this).val(label.html()); + button.enable(false); + } + }); + }); + }; + })(jQuery); |