order by latest and views filters
sane wrapping for large text in excerpt
This commit is contained in:
parent
0768a3b2e9
commit
b593a8db92
|
@ -26,7 +26,19 @@ var controllerOpts = {
|
|||
|
||||
changeSort: function(sortBy) {
|
||||
if (this.get('isSearch')) {
|
||||
// TODO we should amend search string here
|
||||
var term = this.get('searchTerm');
|
||||
var order;
|
||||
|
||||
if (sortBy === 'activity') { order = 'latest'; }
|
||||
if (sortBy === 'views') { order = 'views'; }
|
||||
|
||||
if (order && term.indexOf("order:" + order) === -1) {
|
||||
term = term.replace(/order:[a-z]+/, '');
|
||||
term = term.trim() + " order:" + order;
|
||||
this.set('model.params.q', term);
|
||||
this.get('model').refreshSort();
|
||||
}
|
||||
|
||||
} else {
|
||||
if (sortBy === this.get('order')) {
|
||||
this.toggleProperty('ascending');
|
||||
|
|
|
@ -139,10 +139,15 @@ export default Discourse.View.extend(StringBuffer, {
|
|||
const self = this;
|
||||
if (term) {
|
||||
var terms = term.split(/\s+/);
|
||||
// .main-link a is omitted cause a bit clowny
|
||||
var excerpt = self.$('.topic-excerpt');
|
||||
// some sane wrapping
|
||||
excerpt.text(excerpt.text().replace(/\S{40,}/g, function(match){
|
||||
return match.replace(/(\S)/g, "$1\u200B");
|
||||
}));
|
||||
|
||||
terms.forEach(function(word) {
|
||||
// .main-link a is omitted cause a bit clowny
|
||||
self.$('.topic-excerpt')
|
||||
.highlight(word, {element: 'b', className: 'search-highlight'});
|
||||
excerpt.highlight(word, {element: 'b', className: 'search-highlight'});
|
||||
});
|
||||
}
|
||||
}.on('didInsertElement')
|
||||
|
|
Loading…
Reference in New Issue