diff --git a/public/src/forum/admin/footer.js b/public/src/forum/admin/footer.js index d2a33e3110..a2dcbe6c70 100644 --- a/public/src/forum/admin/footer.js +++ b/public/src/forum/admin/footer.js @@ -101,12 +101,25 @@ define('forum/admin/footer', ['forum/admin/settings'], function(Settings) { function setupACPSearch() { var menu = $('#acp-search .dropdown-menu'), - routes = []; + routes = [], + firstResult = null; $('#acp-search input').on('keyup', function() { $('#acp-search .dropdown').addClass('open'); }); + $('#acp-search').parents('form').on('submit', function(ev) { + var href = firstResult ? firstResult : RELATIVE_PATH + '/search/' + $(this).find('input').val(); + ajaxify.go(href.replace(/^\//, '')); + + setTimeout(function() { + $('#acp-search .dropdown').removeClass('open'); + }, 150); + + ev.preventDefault(); + return false; + }); + $('.sidebar-nav a').each(function(idx, link) { routes.push($(link).attr('href')); }); @@ -120,6 +133,8 @@ define('forum/admin/footer', ['forum/admin/settings'], function(Settings) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); } + firstResult = null; + if (value.length >= 3) { for (var file in acpIndex) { if (acpIndex.hasOwnProperty(file)) { @@ -141,6 +156,7 @@ define('forum/admin/footer', ['forum/admin/settings'], function(Settings) { title = title.join(' > '); href = RELATIVE_PATH + href; + firstResult = firstResult ? firstResult : href; if ($.inArray(href, routes) !== -1) { menuItems.append('
...' + description + '...