Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 31 additions & 37 deletions app/public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,42 +24,36 @@ $('.documentation table').addClass('table table-striped table-bordered');

var quickSearchData = null;

var $quickSearchTypeahead = $('#quick-search-typeahead>input');
$quickSearchTypeahead.typeahead({
source: function (query, process) {
if (quickSearchData) {
process(quickSearchData.names);
} else {
var url = $quickSearchTypeahead.attr('data-action');

$.get(url, {}, function (data) {
quickSearchData = JSON.parse(data);
process(quickSearchData.names);
var $quickSearchTypeahead = $('#quick-search-typeahead').find('>input');
$quickSearchTypeahead.on("focus", function () {
var url = $quickSearchTypeahead.attr('data-action');
$.get(url, {}, function (quickSearchData) {
$quickSearchTypeahead.typeahead({
source: quickSearchData.names,
items: 'all',
updater: function (item) {
// get text to display in quick search box
var displayText = item;
console.log(item);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably want to remove the console.log

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I removed it in a163bae and forgot to also do so here.

But keep in mind that this function doesn't exist any more with the full text search in #200 as I am using a maintained fork of twitter bootstrap there, because it's more user friendly (results can be selected with the arrow keys)


var trailingEmLoc = displayText.indexOf('<em>');
if (trailingEmLoc !== -1) {
displayText = displayText.substring(0, trailingEmLoc);
}

// Track the search
_paq.push(['trackSiteSearch', displayText, false, false]);

// get URL to go to
var itemIndex = quickSearchData.names.indexOf(item);
if (itemIndex !== -1) {
window.location.href = quickSearchData.urls[itemIndex];
}

// return display text
return $.trim(displayText);
}
});
}
},
items: -1,
updater: function (item) {
// get text to display in quick search box
var displayText = item;

var trailingEmLoc = displayText.indexOf('<em>');
if (trailingEmLoc != -1) {
displayText = displayText.substring(0, trailingEmLoc);
}

// Track the search
_paq.push(['trackSiteSearch', displayText, false, false]);

// get URL to go to
var itemIndex = quickSearchData.names.indexOf(item);
if (itemIndex != -1) {
window.location.href = quickSearchData.urls[itemIndex];
}

// return display text
return $.trim(displayText);
}
});

});
});
});
Loading