diff options
author | Valérie-Emma Leroux <emma@iggdrasil.net> | 2016-09-19 13:45:34 +0200 |
---|---|---|
committer | Valérie-Emma Leroux <emma@iggdrasil.net> | 2016-09-19 13:45:34 +0200 |
commit | 501530b36bd2bfde0f9d6f29f69fba868272f7a3 (patch) | |
tree | fbb82d0b2906b50de4eb65aba9f61dfdab8f0225 /static/saclay/js/search.js | |
parent | 996fda6af4b0ad431e32187dc2ad59a49f66b089 (diff) | |
parent | 0b4867c720c9a2dc49996ed1a45580138a749caa (diff) | |
download | Chimère - projet Saclay-501530b36bd2bfde0f9d6f29f69fba868272f7a3.tar.bz2 Chimère - projet Saclay-501530b36bd2bfde0f9d6f29f69fba868272f7a3.zip |
Merge branch 'saclay-v2.2' of git.iggdrasil.net:/srv/git/chimere_saclay into saclay-v2.2
Diffstat (limited to 'static/saclay/js/search.js')
-rwxr-xr-x | static/saclay/js/search.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/static/saclay/js/search.js b/static/saclay/js/search.js new file mode 100755 index 0000000..27e9a3a --- /dev/null +++ b/static/saclay/js/search.js @@ -0,0 +1,48 @@ +function load_search_box(){ + if (!search_url) return; + $.ajax({url: search_url}).done(function( data ) { + $("#search-box").html(data); + }); +} + +function haystack_search(evt, page){ + search_result = new Array(); + $('#categories').find('#ul_categories > li > input').attr("checked", false); + if (!$('#id_q').val()){ + $('.ac-results').remove(); + $('#search-result').html('').show('slow'); + return false; + } + + var c_url = search_url + "?q=" + $('#id_q').val(); + if (page){ + c_url += '&page=' + page; + } + $.get(c_url).done(function( data ) { + $('.ac-results').remove(); + $('#search-result').html(data).show('slow'); + }); + return false; +} + +function welcome_search(){ + if ($("#welcome").is(":visible") && $("#id_welcome_search").val()) { + $("#id_q").val($("#id_welcome_search").val()); + $("#action-search").click(); + $('#welcome').dialog('close'); + $("#haystack-search").click(); + return true; + } +} + +// disable enter +$(window).keydown(function(event){ + if (event.keyCode == 13) { + event.preventDefault(); + if (!welcome_search()){ + $("#haystack-search").click(); + } + return false; + } +}); + |