mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 15:05:46 +01:00
search fix, moved topic search to topic.js
This commit is contained in:
@@ -406,12 +406,6 @@ app.cacheBuster = null;
|
|||||||
searchButton.show();
|
searchButton.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareSearch() {
|
|
||||||
searchFields.removeClass('hide').show();
|
|
||||||
searchButton.hide();
|
|
||||||
searchInput.focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
searchButton.on('click', function(e) {
|
searchButton.on('click', function(e) {
|
||||||
if (!config.loggedIn && !config.allowGuestSearching) {
|
if (!config.loggedIn && !config.allowGuestSearching) {
|
||||||
app.alert({
|
app.alert({
|
||||||
@@ -423,43 +417,26 @@ app.cacheBuster = null;
|
|||||||
}
|
}
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
prepareSearch();
|
app.prepareSearch();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
require(['search', 'mousetrap'], function(search, Mousetrap) {
|
$('#search-form').on('submit', function () {
|
||||||
$('#search-form').on('submit', function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
var input = $(this).find('input');
|
var input = $(this).find('input');
|
||||||
|
require(['search'], function(search) {
|
||||||
search.query({term: input.val()}, function() {
|
search.query({term: input.val()}, function() {
|
||||||
input.val('');
|
input.val('');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$('.topic-search')
|
app.prepareSearch = function() {
|
||||||
.on('click', '.prev', function() {
|
$("#search-fields").removeClass('hide').show();
|
||||||
search.topicDOM.prev();
|
$("#search-button").hide();
|
||||||
})
|
$('#search-fields input').focus();
|
||||||
.on('click', '.next', function() {
|
};
|
||||||
search.topicDOM.next();
|
|
||||||
});
|
|
||||||
|
|
||||||
Mousetrap.bind('ctrl+f', function(e) {
|
|
||||||
if (config.topicSearchEnabled) {
|
|
||||||
// If in topic, open search window and populate, otherwise regular behaviour
|
|
||||||
var match = ajaxify.currentPage.match(/^topic\/([\d]+)/),
|
|
||||||
tid;
|
|
||||||
if (match) {
|
|
||||||
e.preventDefault();
|
|
||||||
tid = match[1];
|
|
||||||
searchInput.val('in:topic-' + tid + ' ');
|
|
||||||
prepareSearch();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleStatusChange() {
|
function handleStatusChange() {
|
||||||
$('#user-control-list .user-status').off('click').on('click', function(e) {
|
$('#user-control-list .user-status').off('click').on('click', function(e) {
|
||||||
|
|||||||
@@ -64,8 +64,36 @@ define('forum/topic', [
|
|||||||
browsing.onUpdateUsersInRoom(data);
|
browsing.onUpdateUsersInRoom(data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleTopicSearch();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function handleTopicSearch() {
|
||||||
|
require(['search', 'mousetrap'], function(search, Mousetrap) {
|
||||||
|
$('.topic-search')
|
||||||
|
.on('click', '.prev', function() {
|
||||||
|
search.topicDOM.prev();
|
||||||
|
})
|
||||||
|
.on('click', '.next', function() {
|
||||||
|
search.topicDOM.next();
|
||||||
|
});
|
||||||
|
|
||||||
|
Mousetrap.bind('ctrl+f', function(e) {
|
||||||
|
if (config.topicSearchEnabled) {
|
||||||
|
// If in topic, open search window and populate, otherwise regular behaviour
|
||||||
|
var match = ajaxify.currentPage.match(/^topic\/([\d]+)/),
|
||||||
|
tid;
|
||||||
|
if (match) {
|
||||||
|
e.preventDefault();
|
||||||
|
tid = match[1];
|
||||||
|
$('#search-fields input').val('in:topic-' + tid + ' ');
|
||||||
|
app.prepareSearch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Topic.toTop = function() {
|
Topic.toTop = function() {
|
||||||
navigator.scrollTop(0);
|
navigator.scrollTop(0);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user