summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Staudacher <andy.st@gmail.com>2009-09-15 22:05:02 -0700
committerAndy Staudacher <andy.st@gmail.com>2009-09-15 22:05:02 -0700
commit7ba93e264512a8a29213f680723e34007b737935 (patch)
tree4ee309149d874fe6e79293255e6f0833c46bc556
parentdc3d45e7607acce91253e44c29998b8797131f93 (diff)
parentffccfb9e634de527261dca8e46ac4053806ec87b (diff)
Merge commit 'upstream/master'
-rw-r--r--lib/gallery.form.js48
-rw-r--r--modules/server_add/controllers/admin_server_add.php13
-rw-r--r--themes/default/js/ui.init.js7
3 files changed, 33 insertions, 35 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);
}
});
}
diff --git a/modules/server_add/controllers/admin_server_add.php b/modules/server_add/controllers/admin_server_add.php
index fac2aa44..7cd82d60 100644
--- a/modules/server_add/controllers/admin_server_add.php
+++ b/modules/server_add/controllers/admin_server_add.php
@@ -34,15 +34,17 @@ class Admin_Server_Add_Controller extends Admin_Controller {
$form = $this->_get_admin_form();
$paths = unserialize(module::get_var("server_add", "authorized_paths", "a:0:{}"));
if ($form->validate()) {
- if (is_readable($form->add_path->path->value)) {
+ if (is_link($form->add_path->path->value)) {
+ $form->add_path->path->add_error("is_symlink", 1);
+ } else if (! is_readable($form->add_path->path->value)) {
+ $form->add_path->path->add_error("not_readable", 1);
+ } else {
$path = $form->add_path->path->value;
$paths[$path] = 1;
module::set_var("server_add", "authorized_paths", serialize($paths));
message::success(t("Added path %path", array("path" => $path)));
server_add::check_config($paths);
url::redirect("admin/server_add");
- } else {
- $form->add_path->path->add_error("not_readable", 1);
}
}
@@ -84,9 +86,10 @@ class Admin_Server_Add_Controller extends Admin_Controller {
array("id" => "gServerAddAdminForm"));
$add_path = $form->group("add_path");
$add_path->input("path")->label(t("Path"))->rules("required")
- ->error_messages("not_readable", t("This directory is not readable by the webserver"));
+ ->error_messages("not_readable", t("This directory is not readable by the webserver"))
+ ->error_messages("is_symlink", t("Symbolic links are not allowed"));
$add_path->submit("add")->value(t("Add Path"));
return $form;
}
-} \ No newline at end of file
+}
diff --git a/themes/default/js/ui.init.js b/themes/default/js/ui.init.js
index 949933e9..93dfb275 100644
--- a/themes/default/js/ui.init.js
+++ b/themes/default/js/ui.init.js
@@ -2,7 +2,7 @@
* Initialize jQuery UI and Gallery Plugin elements
*/
-var shortForms = new Array(
+var short_forms = new Array(
"#gQuickSearchForm",
"#gAddTagForm",
"#gSearchForm"
@@ -36,7 +36,10 @@ $(document).ready(function() {
}
// Initialize short forms
- handleShortFormEvent(shortForms);
+ for (var i in short_forms) {
+ short_form_init(short_forms[i]);
+ $(short_forms[i]).addClass("gShortForm");
+ }
$(".gShortForm input[type=text]").addClass("ui-corner-left");
$(".gShortForm input[type=submit]").addClass("ui-state-default ui-corner-right");