improved ui for saved searches #2523

This commit is contained in:
r888888888
2015-11-17 17:36:22 -08:00
parent ac617544b8
commit 156165a86f
5 changed files with 68 additions and 16 deletions

View File

@@ -524,23 +524,47 @@
}
Danbooru.Post.initialize_saved_searches = function() {
$("#saved_search_category").autocomplete({
minLength: 1,
source: function(req, resp) {
$.ajax({
url: "/saved_searches/categories.json",
method: "get",
success: function(data) {
resp($.map(data, function(saved_search) {
return {
label: saved_search.category,
value: saved_search.category
};
}));
}
})
}
});
$("#save-search-dialog").dialog({
width: 500,
modal: true,
autoOpen: false,
buttons: {
"Submit": function() {
$("#save-search-dialog form").submit();
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
$("#save-search").click(function() {
if (Danbooru.meta("disable-categorized-saved-searches") === "false") {
var input = window.prompt("Category for this saved search (optional):");
if (input !== null) {
$.post(
"/saved_searches.js",
{
"tags": $("#tags").attr("value"),
"category": input
}
);
}
$("#save-search-dialog").dialog("open");
} else {
$.post(
"/saved_searches.js",
{
"tags": $("#tags").attr("value")
"saved_search_tags": $("#tags").attr("value")
}
);
}