summaryrefslogtreecommitdiff
path: root/lib/gallery.form.js
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-09-21 21:29:13 -0700
committerBharat Mediratta <bharat@menalto.com>2009-09-21 21:29:13 -0700
commite5a78d39ec49332054cbc1a398d7c110e1d9191c (patch)
treec2acb4731a381b7a1b28fa5ed505a76adb23a3ef /lib/gallery.form.js
parent529ded3388673036314eefd5bfb1cfc0b76f7f9e (diff)
parent33690a32bcf132e5ab470ff77ba23c073ac26271 (diff)
Merge branch 'master' of git@github.com:gallery/gallery3 into bharat_dev
Conflicts: modules/gallery/controllers/albums.php
Diffstat (limited to 'lib/gallery.form.js')
-rw-r--r--lib/gallery.form.js48
1 files changed, 20 insertions, 28 deletions
diff --git a/lib/gallery.form.js b/lib/gallery.form.js
index e69be326..77ce3b7d 100644
--- a/lib/gallery.form.js
+++ b/lib/gallery.form.js
@@ -1,42 +1,34 @@
/**
- * Handle initialization of all short forms
- *
- * @param shortForms array Array of short form IDs
- */
-function handleShortFormEvent(shortForms) {
- for (var i in shortForms) {
- shortFormInit(shortForms[i]);
- }
-}
-
-/**
* Initialize a short form. Short forms may contain only one text input.
*
- * @param formID string The form's ID, including #
+ * @param form_id string The form's CSS id
*/
-function shortFormInit(formID) {
- $(formID).addClass("gShortForm");
-
- // Get the input ID and it's label text
- var labelValue = $(formID + " label:first").html();
- var inputID = "#" + $(formID + " input[type=text]:first").attr("id");
+function short_form_init(form_id) {
+ var form = $(form_id);
+ var label = form.find("label:first");
+ var input = form.find("input[type=text]:first");
+ var button = form.find("input[type=submit]");
// Set the input value equal to label text
- if ($(inputID).val() == "") {
- $(inputID).val(labelValue);
+ if (input.val() == "") {
+ input.val(label.html());
+ button.enable(false);
}
// Attach event listeners to the input
- $(inputID).bind("focus blur", function(e){
- var eLabelVal = $(this).siblings("label").html();
- var eInputVal = $(this).val();
-
+ input.bind("focus", function(e) {
// Empty input value if it equals it's label
- if (eLabelVal == eInputVal) {
- $(this).val("");
+ if ($(this).val() == label.html()) {
+ $(this).val("");
+ }
+ button.enable(true);
+ });
+
+ input.bind("blur", function(e){
// Reset the input value if it's empty
- } else if ($(this).val() == "") {
- $(this).val(eLabelVal);
+ if ($(this).val() == "") {
+ $(this).val(label.html());
+ button.enable(false);
}
});
}