Merge branch 'jquery-1.10'

This commit is contained in:
r888888888
2013-06-18 18:38:28 -07:00
14 changed files with 469 additions and 311 deletions

View File

@@ -1,10 +1,8 @@
//= require jquery-1.7.1.min.js
//= require jquery-ui-1.8.12.custom.min.js
//= require jquery-1.10.1.min.js
//= require jquery-ui-1.10.3.min.js
//= require jquery.hotkeys.js
//= require jquery.timeout.js
//= require typeahead.min.js
//= require rails.js
//= require common.js
//= require_self
//= require_tree .

View File

@@ -6,19 +6,30 @@
Danbooru.Artist.initialize_check_name_link();
if (Danbooru.meta("enable-auto-complete") === "true") {
Danbooru.Artist.initialize_typeahead();
Danbooru.Artist.initialize_auto_complete();
}
}
}
Danbooru.Artist.initialize_typeahead = function() {
$("#quick_search_name").typeahead({
name: "artists",
remote: "/artists.json?search[name]=*%QUERY*",
limit: 10,
valueKey: "name",
template: function(context) {
return "<p>" + context.name.replace(/_/g, " ") + "</p>";
Danbooru.Artist.initialize_auto_complete = function() {
$("#quick_search_name").autocomplete({
source: function(req, resp) {
$.ajax({
url: "/artists.json",
data: {
"search[name]": "*" + req.term + "*"
},
method: "get",
minLength: 2,
success: function(data) {
resp($.map(data, function(tag) {
return {
label: tag.name,
value: tag.name
};
}));
}
});
}
});
}

View File

@@ -14,13 +14,25 @@
Danbooru.Pool.initialize_add_to_pool_link = function() {
$("#add-to-pool-dialog").dialog({autoOpen: false});
$("#c-pool-elements #a-new input[type=text]").typeahead({
name: "pools",
remote: "/pools.json?search[is_active]=true&search[name_matches]=%QUERY",
limit: 10,
valueKey: "name",
template: function(context) {
return "<p>" + context.name.replace(/_/g, " ") + "</p>";
$("#c-pool-elements #a-new input[type=text]").autocomplete({
source: function(req, resp) {
$.ajax({
url: "/pools.json",
data: {
"search[is_active]": "true"
"search[name_matches]": req.term
},
method: "get",
minLength: 2,
success: function(data) {
resp($.map(data, function(tag) {
return {
label: tag.name.replace(/_/g, " "),
value: tag.name
};
}));
}
});
}
});

View File

@@ -6,7 +6,7 @@
Danbooru.Post.initialize_all = function() {
this.initialize_post_previews();
if (Danbooru.meta("enable-tag-autocomplete") === "true") {
if (Danbooru.meta("enable-auto-complete") === "true") {
this.initialize_tag_autocomplete();
}
@@ -36,13 +36,36 @@
}
Danbooru.Post.initialize_tag_autocomplete = function() {
$("#tags").typeahead({
name: "tags",
remote: "/tags.json?search[order]=count&search[name_matches]=%QUERY*",
limit: 10,
valueKey: "name",
template: function(context) {
return "<p class=\"category-" + context.category + "\"><a>" + context.name + "</a></p>";
$("#tags,#post_tag_string,#upload_tag_string").autocomplete({
focus: function() {
return false;
},
select: function(event, ui) {
var terms = this.value.match(/\S+/g);
terms.pop();
terms.push(ui.item.value);
this.value = terms.join(" ") + " ";
return false;
},
source: function(req, resp) {
var term = req.term.match(/\S+/g).pop();
$.ajax({
url: "/tags.json",
data: {
"search[order]": "count",
"search[name_matches]": term + "*"
},
method: "get",
minLength: 2,
success: function(data) {
resp($.map(data, function(tag) {
return {
label: tag.name,
value: tag.name
};
}));
}
});
}
});
}

View File

@@ -3,17 +3,32 @@
Danbooru.WikiPage.initialize_all = function() {
if ($("#c-wiki-pages").length) {
if (Danbooru.meta("enable-tag-autocomplete") === "true") {
$("#quick_search_title,#wiki_page_title").typeahead({
name: "wiki_pages",
remote: "/wiki_pages.json?search[title]=*%QUERY*",
limit: 10,
valueKey: "title",
template: function(context) {
return "<p>" + context.title.replace(/_/g, " ") + "</p>";
}
});
}
this.initialize_typeahead();
}
}
Danbooru.WikiPage.initialize_typeahead = function() {
if (Danbooru.meta("enable-auto-complete") === "true") {
$("#quick_search_title,#wiki_page_title").autocomplete({
source: function(req, resp) {
$.ajax({
url: "/wiki_pages.json",
data: {
"search[title]": "*" + req.term + "*"
},
method: "get",
minLength: 2,
success: function(data) {
resp($.map(data, function(tag) {
return {
label: tag.title.replace(/_/g, " "),
value: tag.title
};
}));
}
});
}
});
}
}
})();