Skip to content

Commit

Permalink
Set a default noMatchTemplate and update example.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Humphreys committed Mar 6, 2020
1 parent 0aef59a commit 189bf57
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions dist/tribute.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ class Tribute {
return (
noMatchTemplate ||
function() {
return "";
return "<li>No Match Found!</li>";
}.bind(this)
);
})(noMatchTemplate),
Expand Down Expand Up @@ -1445,7 +1445,7 @@ class Tribute {
}

static defaultSelectTemplate(item) {
if (typeof item === "undefined") return null;
if (typeof item === "undefined") return "@" + this.current.mentionText;
if (this.range.isContentEditable(this.current.element)) {
return (
'<span class="tribute-mention">' +
Expand Down
4 changes: 2 additions & 2 deletions dist/tribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@
}

return noMatchTemplate || function () {
return "";
return "<li>No Match Found!</li>";
}.bind(_this);
}(noMatchTemplate),
// column to search against in the object
Expand Down Expand Up @@ -1815,7 +1815,7 @@
}], [{
key: "defaultSelectTemplate",
value: function defaultSelectTemplate(item) {
if (typeof item === "undefined") return null;
if (typeof item === "undefined") return "@" + this.current.mentionText;

if (this.range.isContentEditable(this.current.element)) {
return '<span class="tribute-mention">' + (this.current.collection.trigger + item.original[this.current.collection.fillAttr]) + "</span>";
Expand Down
2 changes: 1 addition & 1 deletion dist/tribute.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/tribute.min.js.map

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ <h5>Tribute on traditional form elements!</h5>
}

return "@" + item.original.value;
}
},
requireLeadingSpace: false
});

tribute.attach(document.getElementById("test"));
Expand Down Expand Up @@ -270,9 +271,11 @@ <h5>Tribute on traditional form elements!</h5>
console.log("Matched item:", e.detail.item);
});

var noMatchRunOnce = false;
document
.getElementById("test")
.addEventListener("tribute-no-match", function(e) {
if (noMatchRunOnce) return;
var values = [
{
key: "Cheese Tacos",
Expand All @@ -281,6 +284,7 @@ <h5>Tribute on traditional form elements!</h5>
}
];
tribute.appendCurrent(values);
noMatchRunOnce = true;
});

var activateLink = document.getElementById("activateInput");
Expand Down
4 changes: 2 additions & 2 deletions example/tribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@
}

return noMatchTemplate || function () {
return "";
return "<li>No Match Found!</li>";
}.bind(_this);
}(noMatchTemplate),
// column to search against in the object
Expand Down Expand Up @@ -1815,7 +1815,7 @@
}], [{
key: "defaultSelectTemplate",
value: function defaultSelectTemplate(item) {
if (typeof item === "undefined") return null;
if (typeof item === "undefined") return "@" + this.current.mentionText;

if (this.range.isContentEditable(this.current.element)) {
return '<span class="tribute-mention">' + (this.current.collection.trigger + item.original[this.current.collection.fillAttr]) + "</span>";
Expand Down
4 changes: 2 additions & 2 deletions src/Tribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Tribute {
return (
noMatchTemplate ||
function() {
return "";
return "<li>No Match Found!</li>";
}.bind(this)
);
})(noMatchTemplate),
Expand Down Expand Up @@ -166,7 +166,7 @@ class Tribute {
}

static defaultSelectTemplate(item) {
if (typeof item === "undefined") return null;
if (typeof item === "undefined") return "@" + this.current.mentionText;
if (this.range.isContentEditable(this.current.element)) {
return (
'<span class="tribute-mention">' +
Expand Down

0 comments on commit 189bf57

Please sign in to comment.