function sendSearchQuery() { pattern = $('#addons-search-box').val(); url = 'http://addons.prestashop.com/en/search.php?search_query='+pattern+'&utm_source=back-office&utm_medium=recherche-theme&utm_campaign=back-office-EN'; window.open(url, '_blank'); } function goToProduct(url) { window.open(url+'&utm_source=back-office&utm_medium=themes-push&utm_campaign=back-office-EN', '_blank'); } $(document).ready(function() { var onSearch = false; var ajaxSearch = false; var timeouts = []; $('#addons-search-box')[0].selectionStart = $('#addons-search-box')[0].selectionEnd = $('#addons-search-box').val().length; $('#addons-search-btn').click(function(e) { if ($("#addons-search-box").val() && !onSearch) { sendSearchQuery(); e.preventDefault(); } }); $("#addons-search-box").live('blur', function() { setTimeout(function(){ $("#addons-search-results").remove() }, 200); }); $(".addons-style-view-product").live('click', function() { goToProduct($(this).find('p').html()) }); $("#addons-search-form").submit( function() { if ($("#addons-search-box").val() && !onSearch) return true; return false; }); $("#addons-search-box").keypress(function(e) { code = (e.keyCode ? e.keyCode : e.which); if (code === 13 && $("#addons-search-box").val() && !onSearch) { sendSearchQuery(); e.preventDefault(); } }); $("#addons-search-box").click(function() {onSearch=false;}); $("#addons-search-box").keyup( function(event) { if (event.which === 40 || event.which === 38) return false; if ($(this).val().length < 3) { $("#addons-search-results").remove(); return false; } $("#query").css('background', 'transparent url("https://medias2.prestastore.com/img/loader.gif") no-repeat right center'); $("#addons-search-results").remove(); if (ajaxSearch) ajaxSearch.abort(); for (i=0; i' + '
' + '' + value.cname + '' + '
(' + value.count + ' results)' + '

' + value.link_rewrite + '?search_query=' + $("#addons-search-box").val() + '

' + '
'; } else { html += '
  • ' + '
    ' + '' + '
    ' + '' + value.name + '' + '
    ' + value.cname + '

    ' + value.product_link + '

    ' + '
  • '; } if (index != (json.length -1)) html += '
  • '; }); html += ''; } if (json.length > 0) $("#addons-search-box").after(html); $("#addons-search-results").show(); } }); }, 500); timeouts.push(timeout_ref); }); });