mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-04-23 14:09:20 -04:00
Partial implementation of ticket #80. Provide auto complete and suggestions on the tag add form in the tag sidebar block. Updated the xss golden file as well. Still to do figure out how toget it into the edit popup dialog
This commit is contained in:
@@ -442,8 +442,8 @@ modules/tag/views/admin_tags.html.php 50 DIRTY $tag->id
|
||||
modules/tag/views/admin_tags.html.php 50 $tag->name
|
||||
modules/tag/views/admin_tags.html.php 51 DIRTY $tag->count
|
||||
modules/tag/views/admin_tags.html.php 52 DIRTY $tag->id
|
||||
modules/tag/views/tag_block.html.php 3 DIRTY $cloud
|
||||
modules/tag/views/tag_block.html.php 5 DIRTY $form
|
||||
modules/tag/views/tag_block.html.php 13 DIRTY $cloud
|
||||
modules/tag/views/tag_block.html.php 15 DIRTY $form
|
||||
modules/tag/views/tag_cloud.html.php 4 DIRTY $tag->count
|
||||
modules/tag/views/tag_cloud.html.php 4 DIRTY $max_count
|
||||
modules/tag/views/tag_cloud.html.php 5 DIRTY $tag->count
|
||||
|
||||
@@ -78,4 +78,21 @@ class Tags_Controller extends REST_Controller {
|
||||
|
||||
return tag::get_add_form($item);
|
||||
}
|
||||
|
||||
public function autocomplete() {
|
||||
$tags = array();
|
||||
$tag_parts = preg_split("#[,\s;]+# ", $this->input->get("q"));
|
||||
$limit = $this->input->get("limit");
|
||||
$tag_part = end($tag_parts);
|
||||
$tag_list = ORM::factory("tag")
|
||||
->like("name", "{$tag_part}%", false)
|
||||
->orderby("name", "ASC")
|
||||
->limit($limit)
|
||||
->find_all();
|
||||
foreach ($tag_list as $tag) {
|
||||
$tags[] = $tag->name;
|
||||
}
|
||||
|
||||
print implode("\n", $tags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ class tag_Core {
|
||||
($item->is_photo() ? t("Add tag to photo") : t("Add tag to movie"));
|
||||
|
||||
$group = $form->group("add_tag")->label("Add Tag");
|
||||
$group->input("name")->label($label)->rules("required|length[1,64]");
|
||||
$group->input("name")->label($label)->rules("required");
|
||||
$group->hidden("item_id")->value($item->id);
|
||||
$group->submit("")->value(t("Add Tag"));
|
||||
return $form;
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
*/
|
||||
class tag_theme_Core {
|
||||
static function head($theme) {
|
||||
$theme->css("jquery.autocomplete.css");
|
||||
$theme->script("jquery.autocomplete.js");
|
||||
$theme->script("tag.js");
|
||||
}
|
||||
|
||||
|
||||
@@ -66,3 +66,18 @@ function editInPlace(element) {
|
||||
};
|
||||
ajaxify_editInPlaceForm();
|
||||
}
|
||||
|
||||
function formatTagAutoCompleteResult(row) {
|
||||
var text = $("#gAddTagForm input:text").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];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<script>
|
||||
$("#gAddTagForm").ready(function() {
|
||||
var url = $("#gTagCloud").attr("title") + "/autocomplete";
|
||||
$("#gAddTagForm input:text").autocomplete(
|
||||
url, {
|
||||
max: 30,
|
||||
formatResult: formatTagAutoCompleteResult}
|
||||
);
|
||||
});
|
||||
</script>
|
||||
<div id="gTagCloud" title="<?= url::site("tags") ?>">
|
||||
<?= $cloud ?>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user