discourse/app/assets/javascripts/admin/components/site-text-summary.js.es6

38 lines
855 B
Plaintext
Raw Normal View History

import Component from "@ember/component";
import { on } from "discourse-common/utils/decorators";
export default Component.extend({
2018-06-15 23:03:24 +08:00
classNames: ["site-text"],
classNameBindings: ["siteText.overridden"],
2018-06-15 23:03:24 +08:00
@on("didInsertElement")
highlightTerm() {
const term = this._searchTerm();
if (term) {
$(
this.element.querySelector(".site-text-id, .site-text-value")
).highlight(term, {
2018-06-15 23:03:24 +08:00
className: "text-highlight"
});
}
$(this.element.querySelector(".site-text-value")).ellipsis();
},
click() {
this.editAction(this.siteText);
},
_searchTerm() {
const regex = this.searchRegex;
const siteText = this.siteText;
if (regex && siteText) {
const matches = siteText.value.match(new RegExp(regex, "i"));
if (matches) return matches[0];
}
return this.term;
}
});