BUGFIX: limit hijacking of search for places that have infinite lists of stuff.

This commit is contained in:
Sam 2014-06-05 10:23:42 +10:00
parent daa5b1f77d
commit 66b6d6c4dd
1 changed files with 26 additions and 2 deletions

View File

@ -48,8 +48,8 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({
'`': 'nextSection',
'~': 'prevSection',
'/': 'showSearch',
'ctrl+f': 'showSearch',
'command+f': 'showSearch',
'ctrl+f': 'showBuiltinSearch',
'command+f': 'showBuiltinSearch',
'?': 'showHelpModal', // open keyboard shortcut help
'q': 'quoteReply'
},
@ -103,6 +103,30 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({
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() {
$('#search-button').click();
return false;