summaryrefslogtreecommitdiff
path: root/modules/tag
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-07-24 14:18:15 -0700
committerTim Almdal <tnalmdal@shaw.ca>2009-07-24 14:18:15 -0700
commit078c77a62b623322956457bfd7bfbdaf56203b00 (patch)
tree941a39067f101b4773a642572f24575ffc43db3e /modules/tag
parentfa1d32e6466d8c6ffe77d163e2da9c71688a3c61 (diff)
Add tag autocomplete to the album and photo edit pop up dialogs.
This required putting a wrapper view around the forms and passing this view as the parameter to the item_edit_form event. The view contains a $script variable that the modules can add script to be included in the form html when rendered as part of the ajax response.
Diffstat (limited to 'modules/tag')
-rw-r--r--modules/tag/helpers/tag_event.php10
-rw-r--r--modules/tag/js/tag.js2
2 files changed, 9 insertions, 3 deletions
diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php
index e1ab1b73..58034900 100644
--- a/modules/tag/helpers/tag_event.php
+++ b/modules/tag/helpers/tag_event.php
@@ -64,9 +64,15 @@ class tag_event_Core {
tag::compact();
}
- static function item_edit_form($item, $form) {
+ static function item_edit_form($item, $view) {
+ $url = url::site("tags/autocomplete");
+ $view->script[] = "$('#gEditFormContainer form').ready(function() {
+ $('#gEditFormContainer form input[id=tags]').autocomplete(
+ '$url', {max: 30, formatResult: formatTagAutoCompleteResult}
+ );
+ });";
$tag_value = implode("; ", tag::item_tags($item));
- $form->edit_item->input("tags")->label(t("Tags (separate by , or ;)"))
+ $view->form->edit_item->input("tags")->label(t("Tags (separate by , or ;)"))
->value($tag_value);
}
diff --git a/modules/tag/js/tag.js b/modules/tag/js/tag.js
index 282da1ea..bbf44166 100644
--- a/modules/tag/js/tag.js
+++ b/modules/tag/js/tag.js
@@ -68,7 +68,7 @@ function editInPlace(element) {
}
function formatTagAutoCompleteResult(row) {
- var text = $("#gAddTagForm input:text").val();
+ var text = $(".ac_loading").val();
if (/[\s,;]/.test(text)) {
for (var i= text.length - 1; i >= 0; i--) {
var chr = text.charAt(i);