Move search box to header. Add search results to breadcrumbs when you search
This commit is contained in:
@@ -98,8 +98,6 @@
|
||||
'keyup .forum-nav-browse-filter-input': 'filterTopics',
|
||||
'click .forum-nav-browse-menu-wrapper': 'ignoreClick',
|
||||
'click .forum-nav-browse-title': 'selectTopicHandler',
|
||||
'keydown .forum-nav-search-input': 'performSearch',
|
||||
'click .fa-search': 'performSearch',
|
||||
'change .forum-nav-sort-control': 'sortThreads',
|
||||
'click .forum-nav-thread-link': 'threadSelected',
|
||||
'click .forum-nav-load-more-link': 'loadMorePages',
|
||||
@@ -591,7 +589,6 @@
|
||||
DiscussionThreadListView.prototype.selectTopic = function($target) {
|
||||
var allItems, discussionIds, $item;
|
||||
this.hideBrowseMenu();
|
||||
this.clearSearch();
|
||||
$item = $target.closest('.forum-nav-browse-menu-item');
|
||||
|
||||
this.setCurrentTopicDisplay(this.getPathText($item));
|
||||
@@ -666,22 +663,15 @@
|
||||
return this.retrieveFirstPage(event);
|
||||
};
|
||||
|
||||
DiscussionThreadListView.prototype.performSearch = function(event) {
|
||||
/*
|
||||
event.which 13 represent the Enter button
|
||||
*/
|
||||
|
||||
var text;
|
||||
if (event.which === 13 || event.type === 'click') {
|
||||
event.preventDefault();
|
||||
this.hideBrowseMenu();
|
||||
this.setCurrentTopicDisplay(gettext('Search Results'));
|
||||
text = this.$('.forum-nav-search-input').val();
|
||||
this.searchFor(text);
|
||||
}
|
||||
DiscussionThreadListView.prototype.performSearch = function($searchInput) {
|
||||
this.hideBrowseMenu();
|
||||
this.setCurrentTopicDisplay(gettext('Search Results'));
|
||||
// trigger this event so the breadcrumbs can update as well
|
||||
this.trigger('search:initiated');
|
||||
this.searchFor($searchInput.val(), $searchInput);
|
||||
};
|
||||
|
||||
DiscussionThreadListView.prototype.searchFor = function(text) {
|
||||
DiscussionThreadListView.prototype.searchFor = function(text, $searchInput) {
|
||||
var url, self = this;
|
||||
this.clearSearchAlerts();
|
||||
this.clearFilters();
|
||||
@@ -696,7 +686,7 @@
|
||||
*/
|
||||
|
||||
return DiscussionUtil.safeAjax({
|
||||
$elem: this.$('.forum-nav-search-input'),
|
||||
$elem: $searchInput,
|
||||
data: {
|
||||
text: text
|
||||
},
|
||||
@@ -790,12 +780,6 @@
|
||||
});
|
||||
};
|
||||
|
||||
DiscussionThreadListView.prototype.clearSearch = function() {
|
||||
this.$('.forum-nav-search-input').val('');
|
||||
this.current_search = '';
|
||||
return this.clearSearchAlerts();
|
||||
};
|
||||
|
||||
DiscussionThreadListView.prototype.clearFilters = function() {
|
||||
this.$('.forum-nav-filter-main-control').val('all');
|
||||
return this.$('.forum-nav-filter-cohort-control').val('all');
|
||||
|
||||
@@ -374,24 +374,6 @@
|
||||
});
|
||||
});
|
||||
|
||||
describe('Search events', function() {
|
||||
it('perform search when enter pressed inside search textfield', function() {
|
||||
setupAjax();
|
||||
spyOn(this.view, 'searchFor');
|
||||
this.view.$el.find('.forum-nav-search-input').trigger($.Event('keydown', {
|
||||
which: 13
|
||||
}));
|
||||
return expect(this.view.searchFor).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('perform search when search icon is clicked', function() {
|
||||
setupAjax();
|
||||
spyOn(this.view, 'searchFor');
|
||||
this.view.$el.find('.fa-search').click();
|
||||
return expect(this.view.searchFor).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('username search', function() {
|
||||
var setAjaxResults;
|
||||
|
||||
@@ -582,14 +564,6 @@
|
||||
return expectBrowseMenuVisible(false);
|
||||
});
|
||||
|
||||
it('should hide when a search is executed', function() {
|
||||
setupAjax();
|
||||
$('.forum-nav-search-input').trigger($.Event('keydown', {
|
||||
which: 13
|
||||
}));
|
||||
return expectBrowseMenuVisible(false);
|
||||
});
|
||||
|
||||
it('should hide when a category is clicked', function() {
|
||||
$('.forum-nav-browse-title')[0].click();
|
||||
return expectBrowseMenuVisible(false);
|
||||
@@ -636,13 +610,6 @@
|
||||
describe('selecting an item', function() {
|
||||
var testSelectionRequest;
|
||||
|
||||
it('should clear the search box', function() {
|
||||
setupAjax();
|
||||
$('.forum-nav-search-input').val('foobar');
|
||||
$('.forum-nav-browse-menu-following .forum-nav-browse-title').click();
|
||||
return expect($('.forum-nav-search-input').val()).toEqual('');
|
||||
});
|
||||
|
||||
it('should change the button text', function() {
|
||||
setupAjax();
|
||||
$('.forum-nav-browse-menu-following .forum-nav-browse-title').click();
|
||||
|
||||
@@ -678,7 +678,7 @@ class DiscussionTabHomePage(CoursePage, DiscussionPageMixin):
|
||||
return self.q(css=".discussion-body section.home-header").present
|
||||
|
||||
def perform_search(self, text="dummy"):
|
||||
self.q(css=".forum-nav-search-input").fill(text + chr(10))
|
||||
self.q(css=".search-input").fill(text + chr(10))
|
||||
EmptyPromise(
|
||||
self.is_ajax_finished,
|
||||
"waiting for server to return result"
|
||||
|
||||
@@ -267,6 +267,14 @@ class DiscussionNavigationTest(BaseDiscussionTestCase):
|
||||
self.thread_page.q(css=".breadcrumbs .nav-item")[0].click()
|
||||
self.assertEqual(len(self.thread_page.q(css=".breadcrumbs .nav-item")), 1)
|
||||
|
||||
def test_breadcrumbs_clear_search(self):
|
||||
self.thread_page.q(css=".search-input").fill("search text")
|
||||
self.thread_page.q(css=".search-btn").click()
|
||||
|
||||
# Verify that clicking the first breadcrumb clears your search
|
||||
self.thread_page.q(css=".breadcrumbs .nav-item")[0].click()
|
||||
self.assertEqual(self.thread_page.q(css=".search-input").text[0], "")
|
||||
|
||||
|
||||
@attr(shard=2)
|
||||
class DiscussionTabSingleThreadTest(BaseDiscussionTestCase, DiscussionResponsePaginationTestMixin):
|
||||
|
||||
Reference in New Issue
Block a user