show 'better author and tags editing; partly copied from https://bitbucket.org/SpeedProg/calibreserver
parent
a9801371b6
commit
7d148c0a74
@ -0,0 +1,189 @@
|
||||
/*
|
||||
* typehead.js-bootstrap3.less
|
||||
* @version 0.2.3
|
||||
* https://github.com/hyspace/typeahead.js-bootstrap3.less
|
||||
*
|
||||
* Licensed under the MIT license:
|
||||
* http://www.opensource.org/licenses/MIT
|
||||
*/
|
||||
.has-warning .twitter-typeahead .tt-input,
|
||||
.has-warning .twitter-typeahead .tt-hint {
|
||||
border-color: #8a6d3b;
|
||||
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
||||
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
||||
}
|
||||
.has-warning .twitter-typeahead .tt-input:focus,
|
||||
.has-warning .twitter-typeahead .tt-hint:focus {
|
||||
border-color: #66512c;
|
||||
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #c0a16b;
|
||||
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #c0a16b;
|
||||
}
|
||||
.has-error .twitter-typeahead .tt-input,
|
||||
.has-error .twitter-typeahead .tt-hint {
|
||||
border-color: #a94442;
|
||||
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
||||
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
||||
}
|
||||
.has-error .twitter-typeahead .tt-input:focus,
|
||||
.has-error .twitter-typeahead .tt-hint:focus {
|
||||
border-color: #843534;
|
||||
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #ce8483;
|
||||
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #ce8483;
|
||||
}
|
||||
.has-success .twitter-typeahead .tt-input,
|
||||
.has-success .twitter-typeahead .tt-hint {
|
||||
border-color: #3c763d;
|
||||
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
||||
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
||||
}
|
||||
.has-success .twitter-typeahead .tt-input:focus,
|
||||
.has-success .twitter-typeahead .tt-hint:focus {
|
||||
border-color: #2b542c;
|
||||
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #67b168;
|
||||
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #67b168;
|
||||
}
|
||||
.input-group .twitter-typeahead:first-child .tt-input,
|
||||
.input-group .twitter-typeahead:first-child .tt-hint {
|
||||
border-bottom-left-radius: 4px;
|
||||
border-top-left-radius: 4px;
|
||||
}
|
||||
.input-group .twitter-typeahead:last-child .tt-input,
|
||||
.input-group .twitter-typeahead:last-child .tt-hint {
|
||||
border-bottom-right-radius: 4px;
|
||||
border-top-right-radius: 4px;
|
||||
}
|
||||
.input-group.input-group-sm .twitter-typeahead .tt-input,
|
||||
.input-group.input-group-sm .twitter-typeahead .tt-hint {
|
||||
height: 30px;
|
||||
padding: 5px 10px;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
border-radius: 3px;
|
||||
}
|
||||
select.input-group.input-group-sm .twitter-typeahead .tt-input,
|
||||
select.input-group.input-group-sm .twitter-typeahead .tt-hint {
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
}
|
||||
textarea.input-group.input-group-sm .twitter-typeahead .tt-input,
|
||||
textarea.input-group.input-group-sm .twitter-typeahead .tt-hint,
|
||||
select[multiple].input-group.input-group-sm .twitter-typeahead .tt-input,
|
||||
select[multiple].input-group.input-group-sm .twitter-typeahead .tt-hint {
|
||||
height: auto;
|
||||
}
|
||||
.input-group.input-group-sm .twitter-typeahead:not(:first-child):not(:last-child) .tt-input,
|
||||
.input-group.input-group-sm .twitter-typeahead:not(:first-child):not(:last-child) .tt-hint {
|
||||
border-radius: 0;
|
||||
}
|
||||
.input-group.input-group-sm .twitter-typeahead:first-child .tt-input,
|
||||
.input-group.input-group-sm .twitter-typeahead:first-child .tt-hint {
|
||||
border-bottom-left-radius: 3px;
|
||||
border-top-left-radius: 3px;
|
||||
border-bottom-right-radius: 0;
|
||||
border-top-right-radius: 0;
|
||||
}
|
||||
.input-group.input-group-sm .twitter-typeahead:last-child .tt-input,
|
||||
.input-group.input-group-sm .twitter-typeahead:last-child .tt-hint {
|
||||
border-bottom-left-radius: 0;
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-right-radius: 3px;
|
||||
border-top-right-radius: 3px;
|
||||
}
|
||||
.input-group.input-group-lg .twitter-typeahead .tt-input,
|
||||
.input-group.input-group-lg .twitter-typeahead .tt-hint {
|
||||
height: 46px;
|
||||
padding: 10px 16px;
|
||||
font-size: 18px;
|
||||
line-height: 1.33;
|
||||
border-radius: 6px;
|
||||
}
|
||||
select.input-group.input-group-lg .twitter-typeahead .tt-input,
|
||||
select.input-group.input-group-lg .twitter-typeahead .tt-hint {
|
||||
height: 46px;
|
||||
line-height: 46px;
|
||||
}
|
||||
textarea.input-group.input-group-lg .twitter-typeahead .tt-input,
|
||||
textarea.input-group.input-group-lg .twitter-typeahead .tt-hint,
|
||||
select[multiple].input-group.input-group-lg .twitter-typeahead .tt-input,
|
||||
select[multiple].input-group.input-group-lg .twitter-typeahead .tt-hint {
|
||||
height: auto;
|
||||
}
|
||||
.input-group.input-group-lg .twitter-typeahead:not(:first-child):not(:last-child) .tt-input,
|
||||
.input-group.input-group-lg .twitter-typeahead:not(:first-child):not(:last-child) .tt-hint {
|
||||
border-radius: 0;
|
||||
}
|
||||
.input-group.input-group-lg .twitter-typeahead:first-child .tt-input,
|
||||
.input-group.input-group-lg .twitter-typeahead:first-child .tt-hint {
|
||||
border-bottom-left-radius: 6px;
|
||||
border-top-left-radius: 6px;
|
||||
border-bottom-right-radius: 0;
|
||||
border-top-right-radius: 0;
|
||||
}
|
||||
.input-group.input-group-lg .twitter-typeahead:last-child .tt-input,
|
||||
.input-group.input-group-lg .twitter-typeahead:last-child .tt-hint {
|
||||
border-bottom-left-radius: 0;
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-right-radius: 6px;
|
||||
border-top-right-radius: 6px;
|
||||
}
|
||||
.twitter-typeahead {
|
||||
width: 100%;
|
||||
}
|
||||
.input-group .twitter-typeahead {
|
||||
display: table-cell !important;
|
||||
float: left;
|
||||
}
|
||||
.twitter-typeahead .tt-hint {
|
||||
color: #999999;
|
||||
}
|
||||
.twitter-typeahead .tt-input {
|
||||
z-index: 2;
|
||||
}
|
||||
.twitter-typeahead .tt-input[disabled],
|
||||
.twitter-typeahead .tt-input[readonly],
|
||||
fieldset[disabled] .twitter-typeahead .tt-input {
|
||||
cursor: not-allowed;
|
||||
background-color: #eeeeee !important;
|
||||
}
|
||||
.tt-dropdown-menu {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
left: 0;
|
||||
z-index: 1000;
|
||||
min-width: 160px;
|
||||
width: 100%;
|
||||
padding: 5px 0;
|
||||
margin: 2px 0 0;
|
||||
list-style: none;
|
||||
font-size: 14px;
|
||||
background-color: #ffffff;
|
||||
border: 1px solid #cccccc;
|
||||
border: 1px solid rgba(0, 0, 0, 0.15);
|
||||
border-radius: 4px;
|
||||
-webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
|
||||
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
|
||||
background-clip: padding-box;
|
||||
*border-right-width: 2px;
|
||||
*border-bottom-width: 2px;
|
||||
}
|
||||
.tt-dropdown-menu .tt-suggestion {
|
||||
display: block;
|
||||
padding: 3px 20px;
|
||||
clear: both;
|
||||
font-weight: normal;
|
||||
line-height: 1.42857143;
|
||||
color: #333333;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.tt-dropdown-menu .tt-suggestion.tt-cursor {
|
||||
text-decoration: none;
|
||||
outline: 0;
|
||||
background-color: #f5f5f5;
|
||||
color: #262626;
|
||||
}
|
||||
.tt-dropdown-menu .tt-suggestion.tt-cursor a {
|
||||
color: #262626;
|
||||
}
|
||||
.tt-dropdown-menu .tt-suggestion p {
|
||||
margin: 0;
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
/**
|
||||
* Created by SpeedProg on 05.04.2015.
|
||||
*/
|
||||
|
||||
/*
|
||||
Takes a prefix, query typeahead callback, Bloodhound typeahead adapter
|
||||
and returns the completions it gets from the bloodhound engine prefixed.
|
||||
*/
|
||||
function prefixed_source(prefix, query, cb, bh_adapter) {
|
||||
bh_adapter(query, function(retArray){
|
||||
var matches = [];
|
||||
for (var i = 0; i < retArray.length; i++) {
|
||||
var obj = {name : prefix + retArray[i].name};
|
||||
matches.push(obj);
|
||||
}
|
||||
cb(matches);
|
||||
});
|
||||
}
|
||||
|
||||
var authors = new Bloodhound({
|
||||
name: 'authors',
|
||||
datumTokenizer: function(datum) {
|
||||
return [datum.name];
|
||||
},
|
||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||
remote: {
|
||||
url: '/get_authors_json?q=%QUERY'
|
||||
}
|
||||
});
|
||||
|
||||
function authors_source(query, cb) {
|
||||
var bh_adapter = authors.ttAdapter();
|
||||
|
||||
var tokens = query.split("&");
|
||||
var current_author = tokens[tokens.length-1].trim();
|
||||
|
||||
tokens.splice(tokens.length-1, 1); // remove last element
|
||||
var prefix = "";
|
||||
for (var i = 0; i < tokens.length; i++) {
|
||||
var author = tokens[i].trim();
|
||||
prefix += author + " & ";
|
||||
}
|
||||
|
||||
prefixed_source(prefix, current_author, cb, bh_adapter);
|
||||
}
|
||||
|
||||
|
||||
|
||||
var promise = authors.initialize();
|
||||
promise.done(function(){
|
||||
$("#bookAuthor").typeahead(
|
||||
{
|
||||
highlight: true, minLength: 1,
|
||||
hint: true
|
||||
}, {
|
||||
name: 'authors', displayKey: 'name',
|
||||
source: authors_source
|
||||
}
|
||||
)
|
||||
});
|
||||
|
||||
var series = new Bloodhound({
|
||||
name: 'series',
|
||||
datumTokenizer: function(datum) {
|
||||
return [datum.name];
|
||||
},
|
||||
queryTokenizer: function(query) {
|
||||
return [query];
|
||||
},
|
||||
remote: {
|
||||
url: '/get_series_json?q=',
|
||||
replace: function(url, query) {
|
||||
url_query = url+encodeURIComponent(query);
|
||||
return url_query;
|
||||
}
|
||||
}
|
||||
});
|
||||
var promise = series.initialize();
|
||||
promise.done(function(){
|
||||
$("#series").typeahead(
|
||||
{
|
||||
highlight: true, minLength: 0,
|
||||
hint: true
|
||||
}, {
|
||||
name: 'series', displayKey: 'name',
|
||||
source: series.ttAdapter()
|
||||
}
|
||||
)
|
||||
});
|
||||
|
||||
var tags = new Bloodhound({
|
||||
name: 'tags',
|
||||
datumTokenizer: function(datum) {
|
||||
return [datum.name];
|
||||
},
|
||||
queryTokenizer: function(query) {
|
||||
tokens = query.split(",");
|
||||
tokens = [tokens[tokens.length-1].trim()];
|
||||
return tokens
|
||||
},
|
||||
remote: {
|
||||
url: '/get_tags_json?q=%QUERY'
|
||||
}
|
||||
});
|
||||
|
||||
function tag_source(query, cb) {
|
||||
var bh_adapter = tags.ttAdapter();
|
||||
|
||||
var tokens = query.split(",");
|
||||
var current_tag = tokens[tokens.length-1].trim();
|
||||
|
||||
tokens.splice(tokens.length-1, 1); // remove last element
|
||||
var prefix = "";
|
||||
for (var i = 0; i < tokens.length; i++) {
|
||||
var tag = tokens[i].trim();
|
||||
prefix += tag + ", ";
|
||||
}
|
||||
|
||||
prefixed_source(prefix, current_tag, cb, bh_adapter);
|
||||
}
|
||||
|
||||
var promise = tags.initialize();
|
||||
promise.done(function(){
|
||||
$("#tags").typeahead(
|
||||
{
|
||||
highlight: true, minLength: 0,
|
||||
hint: true
|
||||
}, {
|
||||
name: 'tags', displayKey: 'name',
|
||||
source: tag_source
|
||||
}
|
||||
)
|
||||
});
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue