UX: Only intercept Cmd-F/Ctrl-F for search on a topic when not all posts
are available in the DOM.
This commit is contained in:
parent
504d61de94
commit
a09ff29dd9
|
@ -116,25 +116,19 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({
|
||||||
},
|
},
|
||||||
|
|
||||||
showBuiltinSearch: function() {
|
showBuiltinSearch: function() {
|
||||||
var routeName = _.map(Discourse.Router.router.currentHandlerInfos, "name").join("_");
|
var currentPath = this.container.lookup('controller:application').get('currentPath'),
|
||||||
var blacklist = [
|
blacklist = [ /^discovery\.categories/ ],
|
||||||
/^application_discovery_discovery.categories/
|
whitelist = [ /^topic\./ ],
|
||||||
];
|
check = function(regex) { return !!currentPath.match(regex); },
|
||||||
|
showSearch = whitelist.any(check) && !blacklist.any(check);
|
||||||
|
|
||||||
var whitelist = [
|
// If we're viewing a topic, only intercept search if there are cloaked posts
|
||||||
/^application_topic_/
|
if (showSearch && currentPath.match(/^topic\./)) {
|
||||||
];
|
showSearch = $('.cooked').length < this.container.lookup('controller:topic').get('postStream.stream.length');
|
||||||
|
|
||||||
var check = function(regex){return routeName.match(regex);};
|
|
||||||
|
|
||||||
var whitelisted = _.any(whitelist, check);
|
|
||||||
var blacklisted = _.any(blacklist, check);
|
|
||||||
|
|
||||||
if(whitelisted && !blacklisted){
|
|
||||||
return this.showSearch(true);
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return showSearch ? this.showSearch(true) : true;
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleProgress: function() {
|
toggleProgress: function() {
|
||||||
|
|
Loading…
Reference in New Issue