Comma Seperated Tags List Walker Feature
Commit adds support of adding a list with commas to the tag field.
This commit is contained in:
parent
e8cfad9241
commit
b0013d5d2c
1 changed files with 20 additions and 7 deletions
|
@ -807,18 +807,31 @@
|
|||
?>
|
||||
</select>
|
||||
<script>
|
||||
let addToTagList = function (value) {
|
||||
// trim
|
||||
value = value.replace(/^\s+|\s+$/g,"");
|
||||
|
||||
if ($("#tags option[value='" + value + "']").length > 0) {
|
||||
$("#tags option[value='" + value + "']").prop('selected', true);
|
||||
} else {
|
||||
$('#tags').prepend($('<option>', {
|
||||
value: value,
|
||||
text: value,
|
||||
selected: true
|
||||
}));
|
||||
}
|
||||
};
|
||||
$(document).ready(function() {
|
||||
$('#addTag').keypress(function(e) {
|
||||
if (e.which == 13) {
|
||||
var value = $(this).val();
|
||||
if ($("#tags option[value='" + value + "']").length > 0) {
|
||||
$("#tags option[value='" + value + "']").prop('selected', true);
|
||||
// Split input?
|
||||
if (value.indexOf(',') > -1) {
|
||||
value.split(',').forEach( function(s) {
|
||||
addToTagList(s);
|
||||
});
|
||||
} else {
|
||||
$('#tags').prepend($('<option>', {
|
||||
value: $(this).val(),
|
||||
text: $(this).val(),
|
||||
selected: true
|
||||
}));
|
||||
addToTagList(value);
|
||||
}
|
||||
$(this).val('');
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue