fixes #547
This commit is contained in:
30
app/assets/javascripts/artists.js
Normal file
30
app/assets/javascripts/artists.js
Normal file
@@ -0,0 +1,30 @@
|
||||
(function() {
|
||||
Danbooru.Artist = {};
|
||||
|
||||
Danbooru.Artist.initialize_all = function() {
|
||||
if ($("#c-artists").length) {
|
||||
Danbooru.Artist.initialize_check_name_link();
|
||||
}
|
||||
}
|
||||
|
||||
Danbooru.Artist.initialize_check_name_link = function() {
|
||||
$("#check-name-link").click(function(e) {
|
||||
var artist_name = $("#artist_name").val();
|
||||
$.get("/artists.json?name=" + artist_name,
|
||||
function(data) {
|
||||
if (data.length) {
|
||||
$("#check-name-result").html("Taken")
|
||||
} else {
|
||||
$("#check-name-result").html("OK")
|
||||
}
|
||||
}
|
||||
);
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
Danbooru.Artist.initialize_all();
|
||||
});
|
||||
@@ -25,7 +25,7 @@ class ArtistsController < ApplicationController
|
||||
end
|
||||
|
||||
def index
|
||||
@artists = Artist.search(params[:search]).order("id desc").paginate(params[:page])
|
||||
@artists = Artist.search(params[:search] || params).order("id desc").paginate(params[:page])
|
||||
respond_with(@artists) do |format|
|
||||
format.xml do
|
||||
render :xml => @artists.to_xml(:include => [:urls])
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<%= simple_form_for(@artist) do |f| %>
|
||||
<%= f.input :name %>
|
||||
<div class="input">
|
||||
<label for="artist_name">Name</label>
|
||||
<%= text_field "artist", "name" %>
|
||||
[<%= link_to "check", "#", :id => "check-name-link" %>]
|
||||
<span id="check-name-result"></span>
|
||||
</div>
|
||||
<%= f.input :other_names_comma, :hint => "Separate with commas", :as => :text, :label => "Other names" %>
|
||||
<%= f.input :group_name %>
|
||||
<%= f.input :url_string, :label => "URLs", :as => :text, :input_html => {:size => "50x5"} %>
|
||||
|
||||
Reference in New Issue
Block a user