discourse/app/assets/javascripts/admin/components/site-text-summary.js.es6
Joffrey JAFFEUX b3eb67976d
DEV: Upgrades to Ember 3.10 (#7871)
Co-Authored-By: majakomel <maja.komel@gmail.com>
2019-07-16 12:45:15 +02:00

37 lines
824 B
JavaScript

import { on } from "ember-addons/ember-computed-decorators";
export default Ember.Component.extend({
classNames: ["site-text"],
classNameBindings: ["siteText.overridden"],
@on("didInsertElement")
highlightTerm() {
const term = this._searchTerm();
if (term) {
$(
this.element.querySelector(".site-text-id, .site-text-value")
).highlight(term, {
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;
}
});