Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
67 changes: 30 additions & 37 deletions app/public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,42 +24,35 @@ $('.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;

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