Browse Source

JS cleanup.

pull/342/head
Pēteris Caune 5 years ago
parent
commit
6147451851
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
2 changed files with 10 additions and 12 deletions
  1. +9
    -6
      static/js/checks.js
  2. +1
    -6
      static/js/details.js

+ 9
- 6
static/js/checks.js View File

@ -7,7 +7,10 @@ $(function () {
$("#update-name-form").attr("action", url);
$("#update-name-input").val(this.dataset.name);
var tagsSelectize = document.getElementById("update-tags-input").selectize;
tagsSelectize.setValue(this.dataset.tags.split(" "));
$("#update-desc-input").val(this.dataset.desc);
$('#update-name-modal').modal("show");
$("#update-name-input").focus();
@ -234,6 +237,10 @@ $(function () {
});
// Configure Selectize for entering tags
function divToOption() {
return {value: this.textContent};
}
$("#update-tags-input").selectize({
create: true,
createOnBlur: true,
@ -241,12 +248,8 @@ $(function () {
labelField: "value",
searchField: ["value"],
hideSelected: true,
highlight: false
});
var tagsSelectize = document.getElementById("update-tags-input").selectize;
$("#my-checks-tags div").each(function(idx, el) {
tagsSelectize.addOption({value: el.textContent});
highlight: false,
options: $("#my-checks-tags div").map(divToOption).get()
});
});

+ 1
- 6
static/js/details.js View File

@ -7,12 +7,7 @@ $(function () {
});
// Configure Selectize for entering tags
var options = [];
var allTags = $("#update-tags-input").data("all-tags").split(" ");
for (var i=0, tag; tag = allTags[i]; i++) {
options.push({value: tag});
}
$("#update-tags-input").selectize({
create: true,
createOnBlur: true,
@ -21,7 +16,7 @@ $(function () {
searchField: ["value"],
hideSelected: true,
highlight: false,
options: options
options: allTags.map(function(tag) { return {value: tag} })
});
$("#new-check-alert a").click(function() {


Loading…
Cancel
Save