/**
 * Main site search
 */
define([
    'jquery', 'dataset/typeahead', 'reuse/typeahead', 'organization/typeahead', 'typeahead'
], function($, datasets, reuses, organizations) {
    'use strict';

    var SEARCH_FOCUS_CLASS = 'col-sm-7 col-lg-8',
        SEARCH_UNFOCUS_CLASS = 'col-sm-2 col-lg-3';

    // Expandable main search bar
    $('#main-search')
        .focusin(function() {
            $('.collapse-on-search').addClass('hide');
            $(this).closest('.navbar-nav')
                .removeClass(SEARCH_UNFOCUS_CLASS)
                .addClass(SEARCH_FOCUS_CLASS);
        })
        .focusout(function() {
            $(this).closest('.navbar-nav')
                .removeClass(SEARCH_FOCUS_CLASS)
                .addClass(SEARCH_UNFOCUS_CLASS);
            $('.collapse-on-search').removeClass('hide');
        })
    ;

    // Typeahead
    $('#main-search')
        .typeahead({highlight: true}, organizations, datasets, reuses)
        .on('typeahead:selected', function(e, data, dataset) {
            switch (dataset) {
                case 'datasets':
                    window.location = '/datasets/' + data.slug;
                    break;
                case 'reuses':
                    window.location = '/reuses/' + data.slug;
                    break;
                case 'organizations':
                    window.location = '/organizations/' + data.slug;
                    break;
            }
        });

});

@@ -1005,437 +1005,78 @@
 data
-set) %7B%0A            switch (dataset) %7B%0A                case 'datasets':%0A                    window.location = '/datasets/' + data.slug;%0A                    break;%0A                case 'reuses':%0A                    window.location = '/reuses/' + data.slug;%0A                    break;%0A                case 'organizations':%0A                    window.location = '/organizations/' + data.slug;%0A                    break;%0A            %7D
+type) %7B%0A            window.location = '/' + datatype + '/' + data.slug
 %0A   

Simplify typeahead search js