diff options
-rw-r--r-- | modules/tag/controllers/tags.php | 2 | ||||
-rw-r--r-- | modules/tag/helpers/tag_event.php | 6 | ||||
-rw-r--r-- | modules/tag/js/tag.js | 15 | ||||
-rw-r--r-- | modules/tag/views/tag_block.html.php | 4 |
4 files changed, 9 insertions, 18 deletions
diff --git a/modules/tag/controllers/tags.php b/modules/tag/controllers/tags.php index 69178925..c993e374 100644 --- a/modules/tag/controllers/tags.php +++ b/modules/tag/controllers/tags.php @@ -81,7 +81,7 @@ class Tags_Controller extends REST_Controller { public function autocomplete() { $tags = array(); - $tag_parts = preg_split("#[,\s]+# ", $this->input->get("q")); + $tag_parts = preg_split("#,#", $this->input->get("q")); $limit = $this->input->get("limit"); $tag_part = end($tag_parts); $tag_list = ORM::factory("tag") diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php index 7becf36f..0cb49ffa 100644 --- a/modules/tag/helpers/tag_event.php +++ b/modules/tag/helpers/tag_event.php @@ -68,7 +68,11 @@ class tag_event_Core { $url = url::site("tags/autocomplete"); $view->script[] = "$('#gEditFormContainer form').ready(function() { $('#gEditFormContainer form input[id=tags]').autocomplete( - '$url', {max: 30, formatResult: formatTagAutoCompleteResult} + '$url', + {max: 30, + multiple: true, + multipleSeparator: ',', + cacheLength: 1} ); });"; $tag_value = implode(", ", tag::item_tags($item)); diff --git a/modules/tag/js/tag.js b/modules/tag/js/tag.js index bbf44166..a5aaa3f8 100644 --- a/modules/tag/js/tag.js +++ b/modules/tag/js/tag.js @@ -66,18 +66,3 @@ function editInPlace(element) { }; ajaxify_editInPlaceForm(); } - -function formatTagAutoCompleteResult(row) { - var text = $(".ac_loading").val(); - if (/[\s,;]/.test(text)) { - for (var i= text.length - 1; i >= 0; i--) { - var chr = text.charAt(i); - if (chr == " " || chr == "," || chr == ";") { - break; - } - } - return text.substr(0, i + 1) + row[0]; - } else { - return row[0]; - } -} diff --git a/modules/tag/views/tag_block.html.php b/modules/tag/views/tag_block.html.php index 233eb361..59a4ef88 100644 --- a/modules/tag/views/tag_block.html.php +++ b/modules/tag/views/tag_block.html.php @@ -5,7 +5,9 @@ $("#gAddTagForm input:text").autocomplete( url, { max: 30, - formatResult: formatTagAutoCompleteResult} + multiple: true, + multipleSeparator: ',', + cacheLength: 1} ); }); </script> |