diff options
-rw-r--r-- | lib/gallery.common.js | 26 | ||||
-rw-r--r-- | modules/server_add/controllers/admin_server_add.php | 6 | ||||
-rw-r--r-- | modules/server_add/views/admin_server_add.html.php | 5 | ||||
-rw-r--r-- | modules/tag/helpers/tag_event.php | 2 |
4 files changed, 19 insertions, 20 deletions
diff --git a/lib/gallery.common.js b/lib/gallery.common.js index 95988573..548aa29a 100644 --- a/lib/gallery.common.js +++ b/lib/gallery.common.js @@ -229,11 +229,11 @@ source: function(request, response) { var split = function(val) { return val.split(/,\s*/); - } + }; var extract_last = function(term) { return split(term).pop(); - } + }; var ajax_options = { dataType: "json", @@ -241,15 +241,17 @@ success: function(data) { response(data); }, + data: { + term: request.term + }, + dataFilter: function(data, dataType) { + // Drop the <meta> tag + return data.substring(data.indexOf("\n") + 1); + } }; - if (options.multiple) { - + if ("multiple" in options) { $.extend(ajax_options, { - dataFilter: function(data, dataType) { - // Drop the <meta> tag - return data.substring(data.indexOf("\n") + 1); - }, data: { term: extract_last(request.term) } @@ -258,12 +260,12 @@ $.ajax(ajax_options, response); } - } + }; - if (options.multiple) { + if ("multiple" in options) { var split = function(val) { return val.split(/,\s*/); - } + }; $.extend(autocomplete_options, { focus: function(event, ui) { var terms = split(this.value); @@ -280,7 +282,7 @@ this.value = terms.join(", "); return false; } - }) + }); } $(this).autocomplete(autocomplete_options); diff --git a/modules/server_add/controllers/admin_server_add.php b/modules/server_add/controllers/admin_server_add.php index ba2b9b3f..4e522702 100644 --- a/modules/server_add/controllers/admin_server_add.php +++ b/modules/server_add/controllers/admin_server_add.php @@ -73,14 +73,14 @@ class Admin_Server_Add_Controller extends Admin_Controller { public function autocomplete() { $directories = array(); - $path_prefix = Input::instance()->get("q"); + $path_prefix = Input::instance()->get("term"); foreach (glob("{$path_prefix}*") as $file) { if (is_dir($file) && !is_link($file)) { - $directories[] = html::clean($file); + $directories[] = (string)html::clean($file); } } - ajax::response(implode("\n", $directories)); + ajax::response(json_encode($directories)); } private function _get_admin_form() { diff --git a/modules/server_add/views/admin_server_add.html.php b/modules/server_add/views/admin_server_add.html.php index f59e327f..b2421c7c 100644 --- a/modules/server_add/views/admin_server_add.html.php +++ b/modules/server_add/views/admin_server_add.html.php @@ -6,10 +6,7 @@ $("document").ready(function() { $("#g-path").gallery_autocomplete( "<?= url::site("__ARGS__") ?>".replace("__ARGS__", "admin/server_add/autocomplete"), - { - max: 256, - loadingClass: "g-loading-small", - }); + {multiple: true}); }); </script> diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php index 79d6e0bc..08d5d53a 100644 --- a/modules/tag/helpers/tag_event.php +++ b/modules/tag/helpers/tag_event.php @@ -124,7 +124,7 @@ class tag_event_Core { ->text("$('input[name=tags]') .gallery_autocomplete( '$autocomplete_url', - {max: 30, multiple: true, multipleSeparator: ',', cacheLength: 1} + {multiple: true} ); $('input[name=tags]') .change(function (event) { |