BUGFIX: limit hijacking of search for places that have infinite lists of stuff.
This commit is contained in:
parent
daa5b1f77d
commit
66b6d6c4dd
|
@ -48,8 +48,8 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({
|
||||||
'`': 'nextSection',
|
'`': 'nextSection',
|
||||||
'~': 'prevSection',
|
'~': 'prevSection',
|
||||||
'/': 'showSearch',
|
'/': 'showSearch',
|
||||||
'ctrl+f': 'showSearch',
|
'ctrl+f': 'showBuiltinSearch',
|
||||||
'command+f': 'showSearch',
|
'command+f': 'showBuiltinSearch',
|
||||||
'?': 'showHelpModal', // open keyboard shortcut help
|
'?': 'showHelpModal', // open keyboard shortcut help
|
||||||
'q': 'quoteReply'
|
'q': 'quoteReply'
|
||||||
},
|
},
|
||||||
|
@ -103,6 +103,30 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({
|
||||||
this._changeSection(-1);
|
this._changeSection(-1);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
showBuiltinSearch: function() {
|
||||||
|
var routeName = _.map(Discourse.Router.router.currentHandlerInfos, "name").join("_");
|
||||||
|
var blacklist = [
|
||||||
|
/^application_discovery_discovery.categories/
|
||||||
|
];
|
||||||
|
|
||||||
|
var whitelist = [
|
||||||
|
/^application_topic_/,
|
||||||
|
/^application_discovery_discovery/,
|
||||||
|
/^application_user_userActivity/
|
||||||
|
];
|
||||||
|
|
||||||
|
var check = function(regex){return routeName.match(regex);};
|
||||||
|
|
||||||
|
var whitelisted = _.any(whitelist, check);
|
||||||
|
var blacklisted = _.any(blacklist, check);
|
||||||
|
|
||||||
|
if(whitelisted && !blacklisted){
|
||||||
|
return this.showSearch();
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
showSearch: function() {
|
showSearch: function() {
|
||||||
$('#search-button').click();
|
$('#search-button').click();
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue