|
|
|
@ -16,6 +16,11 @@
|
|
|
|
|
cb(matches);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
function get_path(){
|
|
|
|
|
var jsFileLocation = $('script[src*=edit_books]').attr('src'); // the js file path
|
|
|
|
|
jsFileLocation = jsFileLocation.replace('/static/js/edit_books.js', ''); // the js folder path
|
|
|
|
|
return jsFileLocation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var authors = new Bloodhound({
|
|
|
|
|
name: 'authors',
|
|
|
|
@ -24,7 +29,7 @@
|
|
|
|
|
},
|
|
|
|
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
|
|
|
|
remote: {
|
|
|
|
|
url: '/get_authors_json?q=%QUERY'
|
|
|
|
|
url: get_path()+'/get_authors_json?q=%QUERY'
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -68,7 +73,7 @@
|
|
|
|
|
return [query];
|
|
|
|
|
},
|
|
|
|
|
remote: {
|
|
|
|
|
url: '/get_series_json?q=',
|
|
|
|
|
url: get_path()+'/get_series_json?q=',
|
|
|
|
|
replace: function(url, query) {
|
|
|
|
|
url_query = url+encodeURIComponent(query);
|
|
|
|
|
return url_query;
|
|
|
|
@ -99,7 +104,7 @@
|
|
|
|
|
return tokens
|
|
|
|
|
},
|
|
|
|
|
remote: {
|
|
|
|
|
url: '/get_tags_json?q=%QUERY'
|
|
|
|
|
url: get_path()+'/get_tags_json?q=%QUERY'
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -141,7 +146,7 @@
|
|
|
|
|
return [query];
|
|
|
|
|
},
|
|
|
|
|
remote: {
|
|
|
|
|
url: '/get_languages_json?q=',
|
|
|
|
|
url: get_path()+'/get_languages_json?q=',
|
|
|
|
|
replace: function(url, query) {
|
|
|
|
|
url_query = url+encodeURIComponent(query);
|
|
|
|
|
return url_query;
|
|
|
|
@ -177,3 +182,19 @@
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('form').on('change input typeahead:selected', function(data){
|
|
|
|
|
form = $('form').serialize();
|
|
|
|
|
$.getJSON( get_path()+"/get_matching_tags", form, function( data ) {
|
|
|
|
|
$('.tags_click').each(function() {
|
|
|
|
|
if ($.inArray(parseInt($(this).children('input').first().val(), 10), data.tags) == -1 ) {
|
|
|
|
|
if (!($(this).hasClass('active'))) {
|
|
|
|
|
$(this).addClass('disabled');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$(this).removeClass('disabled');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|