discourse/app/assets/javascripts/admin/components/site-text-summary.js.es6
Joffrey JAFFEUX f9648de897
DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808)
Co-Authored-By: Bianca Nenciu <nbianca@users.noreply.github.com>
Co-Authored-By: David Taylor <david@taylorhq.com>
2019-01-10 11:06:01 +01:00

35 lines
770 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.$(".site-text-id, .site-text-value").highlight(term, {
className: "text-highlight"
});
}
this.$(".site-text-value").ellipsis();
},
click() {
this.send("edit");
},
_searchTerm() {
const regex = this.get("searchRegex");
const siteText = this.get("siteText");
if (regex && siteText) {
const matches = siteText.value.match(new RegExp(regex, "i"));
if (matches) return matches[0];
}
return this.get("term");
}
});