2014-09-26 22:43:54 +02:00
|
|
|
/**
|
|
|
|
_ _ _
|
|
|
|
| |__ ___ ___ | |_ ___| |_ _ __ __ ___ __
|
|
|
|
| '_ \ / _ \ / _ \| __/ __| __| '__/ _` \ \/ /
|
|
|
|
| |_) | (_) | (_) | |_\__ | |_| | | (_| |> <
|
|
|
|
|_.__/ \___/ \___/ \__|___/\__|_| \__,_/_/\_\.js
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2014-09-29 09:44:29 +02:00
|
|
|
if(searx.autocompleter) {
|
|
|
|
searx.searchResults = new Bloodhound({
|
|
|
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
|
|
|
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
|
|
|
remote: '/autocompleter?q=%QUERY'
|
|
|
|
});
|
|
|
|
searx.searchResults.initialize();
|
|
|
|
}
|
|
|
|
|
2014-09-26 22:43:54 +02:00
|
|
|
$(document).ready(function(){
|
|
|
|
$('.btn-toggle .btn').click(function() {
|
|
|
|
var btnClass = 'btn-' + $(this).data('btn-class');
|
|
|
|
var btnLabelDefault = $(this).data('btn-label-default');
|
|
|
|
var btnLabelToggled = $(this).data('btn-label-toggled');
|
2014-09-27 10:23:05 +02:00
|
|
|
if(btnLabelToggled != '') {
|
|
|
|
if($(this).hasClass('btn-default')) {
|
2014-09-26 22:43:54 +02:00
|
|
|
|
|
|
|
var html = $(this).html().replace(btnLabelDefault, btnLabelToggled);
|
2014-09-27 10:23:05 +02:00
|
|
|
} else {
|
2014-09-26 22:43:54 +02:00
|
|
|
var html = $(this).html().replace(btnLabelToggled, btnLabelDefault);
|
|
|
|
}
|
|
|
|
$(this).html(html);
|
|
|
|
}
|
|
|
|
$(this).toggleClass(btnClass);
|
|
|
|
$(this).toggleClass('btn-default');
|
|
|
|
});
|
2014-09-27 10:23:05 +02:00
|
|
|
|
|
|
|
$('.btn-collapse').click(function() {
|
|
|
|
var btnTextCollapsed = $(this).data('btn-text-collapsed');
|
|
|
|
var btnTextNotCollapsed = $(this).data('btn-text-not-collapsed');
|
|
|
|
|
|
|
|
if(btnTextCollapsed != '' && btnTextNotCollapsed != '') {
|
|
|
|
if($(this).hasClass('collapsed')) {
|
|
|
|
var html = $(this).html().replace(btnTextCollapsed, btnTextNotCollapsed);
|
|
|
|
} else {
|
|
|
|
var html = $(this).html().replace(btnTextNotCollapsed, btnTextCollapsed);
|
|
|
|
}
|
|
|
|
$(this).html(html);
|
|
|
|
}
|
|
|
|
});
|
2014-09-27 15:46:57 +02:00
|
|
|
|
|
|
|
$(".select-all-on-click").click(function () {
|
|
|
|
$(this).select();
|
|
|
|
});
|
2014-09-29 09:44:29 +02:00
|
|
|
|
|
|
|
if(searx.autocompleter) {
|
|
|
|
$('#q').typeahead(null, {
|
|
|
|
name: 'search-results',
|
|
|
|
displayKey: function(result) {
|
|
|
|
return result;
|
|
|
|
},
|
|
|
|
source: searx.searchResults.ttAdapter()
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|