Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

One Searchbox #814

Merged
merged 12 commits into from
Nov 28, 2016
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function testAjaxStatus()
$session = $this->getMinkSession();
$session->visit($this->getVuFindUrl() . '/Search/Home');
$page = $session->getPage();
$this->findCss($page, '.searchForm [name="lookfor"]')
$this->findCss($page, '#searchForm_lookfor')
->setValue('id:testsample1');
$this->findCss($page, '.btn.btn-primary')->click();
$this->snooze();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected function performSearch($query, $page = false)
$session = $this->getMinkSession();
$session->visit($this->getVuFindUrl() . '/Search/Home');
$page = $session->getPage();
$this->findCss($page, '.searchForm [name="lookfor"]')->setValue($query);
$this->findCss($page, '#searchForm_lookfor')->setValue($query);
$this->findCss($page, '.btn.btn-primary')->click();
$this->snooze();
return $page;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function testCombinedSearchResults()
$session = $this->getMinkSession();
$session->visit($this->getVuFindUrl() . '/Combined');
$page = $session->getPage();
$this->findCss($page, '.searchForm [name="lookfor"]')
$this->findCss($page, '#searchForm_lookfor')
->setValue('id:"testsample1" OR id:"theplus+andtheminus-"');
$this->findCss($page, '.btn.btn-primary')->click();
$this->snooze();
Expand All @@ -127,7 +127,7 @@ public function testCombinedSearchResultsAllAjax()
$session = $this->getMinkSession();
$session->visit($this->getVuFindUrl() . '/Combined');
$page = $session->getPage();
$this->findCss($page, '.searchForm [name="lookfor"]')
$this->findCss($page, '#searchForm_lookfor')
->setValue('id:"testsample1" OR id:"theplus+andtheminus-"');
$this->findCss($page, '.btn.btn-primary')->click();
$this->snooze();
Expand All @@ -149,7 +149,7 @@ public function testCombinedSearchResultsMixedAjax()
$session = $this->getMinkSession();
$session->visit($this->getVuFindUrl() . '/Combined');
$page = $session->getPage();
$this->findCss($page, '.searchForm [name="lookfor"]')
$this->findCss($page, '#searchForm_lookfor')
->setValue('id:"testsample1" OR id:"theplus+andtheminus-"');
$this->findCss($page, '.btn.btn-primary')->click();
$this->snooze();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected function gotoSearch()
$session = $this->getMinkSession();
$session->visit($this->getVuFindUrl() . '/Search/Home');
$page = $session->getPage();
$this->findCss($page, '.searchForm [name="lookfor"]')->setValue('Dewey');
$this->findCss($page, '#searchForm_lookfor')->setValue('Dewey');
$this->findCss($page, '.btn.btn-primary')->click();
return $page;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public function testLinkInSearchResults()
$session = $this->getMinkSession();
$session->visit($this->getVuFindUrl() . '/Search/Home');
$page = $session->getPage();
$this->findCss($page, '.searchForm [name="lookfor"]')
$this->findCss($page, '#searchForm_lookfor')
->setValue('id:testsample1');
$this->findCss($page, '.btn.btn-primary')->click();

Expand Down Expand Up @@ -182,7 +182,7 @@ public function testLinkInSearchResultsWithAutoloading()
$session = $this->getMinkSession();
$session->visit($this->getVuFindUrl() . '/Search/Home');
$page = $session->getPage();
$this->findCss($page, '.searchForm [name="lookfor"]')
$this->findCss($page, '#searchForm_lookfor')
->setValue('id:testsample1');
$this->findCss($page, '.btn.btn-primary')->click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected function gotoSearch()
$session = $this->getMinkSession();
$session->visit($this->getVuFindUrl() . '/Search/Home');
$page = $session->getPage();
$this->findCss($page, '.searchForm [name="lookfor"]')
$this->findCss($page, '#searchForm_lookfor')
->setValue('id:testdeweybrowse');
$this->findCss($page, '.btn.btn-primary')->click();
$this->snooze();
Expand Down Expand Up @@ -192,7 +192,7 @@ protected function localStorageDance()
// Search for anything else
$session->visit($this->getVuFindUrl() . '/Search/Home');
$page = $session->getPage();
$this->findCss($page, '.searchForm [name="lookfor"]')
$this->findCss($page, '#searchForm_lookfor')
->setValue('anything else');
$this->findCss($page, '.btn.btn-primary')->click();
// Come back
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected function gotoRecord()
$session = $this->getMinkSession();
$session->visit($this->getVuFindUrl() . '/Search/Home');
$page = $session->getPage();
$this->findCss($page, '.searchForm [name="lookfor"]')->setValue('Dewey');
$this->findCss($page, '#searchForm_lookfor')->setValue('Dewey');
$this->findCss($page, '.btn.btn-primary')->click();
$this->findCss($page, '.result a.title')->click();
return $page;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function performSearch($query)
$session = $this->getMinkSession();
$session->visit($this->getVuFindUrl() . '/Search/Home');
$page = $session->getPage();
$this->findCss($page, '.searchForm [name="lookfor"]')->setValue($query);
$this->findCss($page, '#searchForm_lookfor')->setValue($query);
$this->findCss($page, '.btn.btn-primary')->click();
$this->snooze();
return $page;
Expand Down
2 changes: 1 addition & 1 deletion themes/bootprint3/css/compiled.css

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions themes/bootprint3/less/bootprint.less
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ header .fa.fa-bars { font-size: 21px; }
header .navbar {
border-radius: 5px 5px 0 0;
padding: 0 10px;
.searchForm { display: none !important; }
&.search {
border-radius: 0;
padding-bottom: 4px;
}
.navbar-brand {
height: 65px;
width: 170px;
Expand All @@ -138,10 +141,6 @@ header .navbar {
.navbar-right { margin: 0; }
}
}
header .searchbox {
background: linear-gradient(to bottom, #FFF, #EEE);
display: block !important;
}
header .searchbox .tab-content { border: 0; }
header .searchbox .tab-content .navbar-text { margin: 5px 10px 5px 0; }
@media (max-width: 767px) {
Expand Down
2 changes: 1 addition & 1 deletion themes/bootprint3/less/search.less
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/* --- Search form --- */
.searchForm_lookfor,
.searchForm_type { border-color: @brand-primary; }
[name=searchForm] {
.searchForm {
margin: 6px 8px 8px;
padding: 0;

Expand Down
9 changes: 4 additions & 5 deletions themes/bootprint3/scss/bootprint.scss
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ header .fa.fa-bars { font-size: 21px; }
header .navbar {
border-radius: 5px 5px 0 0;
padding: 0 10px;
.searchForm { display: none !important; }
&.search {
border-radius: 0;
padding-bottom: 4px;
}
.navbar-brand {
height: 65px;
width: 170px;
Expand All @@ -137,10 +140,6 @@ header .navbar {
.navbar-right { margin: 0; }
}
}
header .searchbox {
background: linear-gradient(to bottom, #FFF, #EEE);
display: block !important;
}
header .searchbox .tab-content { border: 0; }
header .searchbox .tab-content .navbar-text { margin: 5px 10px 5px 0; }
@media (max-width: 767px) {
Expand Down
2 changes: 1 addition & 1 deletion themes/bootprint3/scss/search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/* --- Search form --- */
.searchForm_lookfor,
.searchForm_type { border-color: $brand-primary; }
[name=searchForm] {
.searchForm {
margin: 6px 8px 8px;
padding: 0;

Expand Down
2 changes: 1 addition & 1 deletion themes/bootstrap3/css/compiled.css

Large diffs are not rendered by default.

73 changes: 35 additions & 38 deletions themes/bootstrap3/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,54 +205,51 @@ function setupOffcanvas() {

function setupAutocomplete() {
// Search autocomplete
$('.autocomplete').each(function autocompleteSetup(i, op) {
$(op).autocomplete({
maxResults: 10,
loadingString: VuFind.translate('loading') + '...',
handler: function vufindACHandler(input, cb) {
var query = input.val();
var searcher = extractClassParams(input);
var hiddenFilters = [];
$(input).closest('.searchForm').find('input[name="hiddenFilters[]"]').each(function hiddenFiltersEach() {
hiddenFilters.push($(this).val());
});
$.fn.autocomplete.ajax({
url: VuFind.path + '/AJAX/JSON',
data: {
q: query,
method: 'getACSuggestions',
searcher: searcher.searcher,
type: searcher.type ? searcher.type : $(input).closest('.searchForm').find('.searchForm_type').val(),
hiddenFilters: hiddenFilters
},
dataType: 'json',
success: function autocompleteJSON(json) {
if (json.data.length > 0) {
var datums = [];
for (var j = 0; j < json.data.length; j++) {
datums.push(json.data[j]);
}
cb(datums);
} else {
cb([]);
$('#searchForm_lookfor').autocomplete({
maxResults: 10,
loadingString: VuFind.translate('loading') + '...',
handler: function vufindACHandler(input, cb) {
var query = input.val();
var searcher = extractClassParams(input);
var hiddenFilters = [];
$('#searchForm').find('input[name="hiddenFilters[]"]').each(function hiddenFiltersEach() {
hiddenFilters.push($(this).val());
});
$.fn.autocomplete.ajax({
url: VuFind.path + '/AJAX/JSON',
data: {
q: query,
method: 'getACSuggestions',
searcher: searcher.searcher,
type: searcher.type ? searcher.type : $('#searchForm_type').val(),
hiddenFilters: hiddenFilters
},
dataType: 'json',
success: function autocompleteJSON(json) {
if (json.data.length > 0) {
var datums = [];
for (var j = 0; j < json.data.length; j++) {
datums.push(json.data[j]);
}
cb(datums);
} else {
cb([]);
}
});
}
});
}
});
}
});
// Update autocomplete on type change
$('.searchForm_type').change(function searchTypeChange() {
var $lookfor = $(this).closest('.searchForm').find('.searchForm_lookfor[name]');
$lookfor.autocomplete('clear cache');
$('#searchForm_type').change(function searchTypeChange() {
$('#searchForm_lookfor').autocomplete('clear cache');
});
}

/**
* Handle arrow keys to jump to next record
*/
function keyboardShortcuts() {
var $searchform = $('.searchForm_lookfor');
var $searchform = $('#searchForm_lookfor');
if ($('.pager').length > 0) {
$(window).keydown(function shortcutKeyDown(e) {
if (!$searchform.is(':focus')) {
Expand Down Expand Up @@ -390,7 +387,7 @@ $(document).ready(function commonDocReady() {
if (sessionStorage.getItem('vufind_retain_filters')) {
var state = (sessionStorage.getItem('vufind_retain_filters') === 'true');
$('.searchFormKeepFilters').prop('checked', state);
$('.applied-filter').prop('checked', state);
$('#applied-filter').prop('checked', state);
}

setupIeSupport();
Expand Down
5 changes: 0 additions & 5 deletions themes/bootstrap3/less/bootstrap.less
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ img {max-width: 100%;}
}
.tab-content {padding: 4px;}

@media (max-width: 991px) {
header .container.navbar {margin-bottom: 0;}
.searchForm {margin-top: 0;}
}
@media (min-width: 768px) {
h2 {
font-size: 23px;
Expand All @@ -64,7 +60,6 @@ img {max-width: 100%;}
@media (max-width: 767px) {
h2 { font-size: 20px; }
h3 { font-size: 16px; }
.searchForm {padding-top: 0;}
}

/* --- Form Errors --- */
Expand Down
7 changes: 7 additions & 0 deletions themes/bootstrap3/less/components/search.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
@thumbnail-width-medium: 100px;
@thumbnail-width-large: 160px;

.searchForm {
margin: 0;
padding: 0;
}

header .container.navbar { margin-bottom: 0; }

.bulkActionButtons label {display: inline-block;}
.bulkActionButtons label input {margin-top: 2px;}
.grid { @media (max-width: 767px) {min-height: 250px;} }
Expand Down
5 changes: 0 additions & 5 deletions themes/bootstrap3/scss/bootstrap.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ img {max-width: 100%;}
}
.tab-content {padding: 4px;}

@media (max-width: 991px) {
header .container.navbar {margin-bottom: 0;}
.searchForm {margin-top: 0;}
}
@media (min-width: 768px) {
h2 {
font-size: 23px;
Expand All @@ -65,7 +61,6 @@ img {max-width: 100%;}
@media (max-width: 767px) {
h2 { font-size: 20px; }
h3 { font-size: 16px; }
.searchForm {padding-top: 0;}
}

/* --- Form Errors --- */
Expand Down
7 changes: 7 additions & 0 deletions themes/bootstrap3/scss/components/search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ $thumbnail-width-small: 60px !default;
$thumbnail-width-medium: 100px !default;
$thumbnail-width-large: 160px !default;

.searchForm {
margin: 0;
padding: 0;
}

header .container.navbar { margin-bottom: 0; }

.bulkActionButtons label {display: inline-block;}
.bulkActionButtons label input {margin-top: 2px;}
.grid { @media (max-width: 767px) {min-height: 250px;} }
Expand Down
Loading