From 62c373dea7f3fce72c895e5cb814f716a97c56de Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Sat, 9 Apr 2016 00:06:25 +0200 Subject: Recherche sur le message d'accueil --- static/saclay/css/styles.css | 29 +++++++++++++++++ static/saclay/js/interface.js | 2 ++ static/saclay/js/search.js | 48 +++++++++++++++++++++++++++ templates/chimere/base.html | 1 + templates/chimere/blocks/welcome.html | 61 ++++++++++++----------------------- templates/chimere/main_map.html | 2 +- 6 files changed, 102 insertions(+), 41 deletions(-) create mode 100755 static/saclay/js/search.js diff --git a/static/saclay/css/styles.css b/static/saclay/css/styles.css index 6046bb2..5847c3c 100644 --- a/static/saclay/css/styles.css +++ b/static/saclay/css/styles.css @@ -452,6 +452,7 @@ a#ui-active-menuitem.ui-state-hover{ width: 281px; } +#haystack-search-page, #haystack-search{ width:35px; height:28px; @@ -463,6 +464,19 @@ a#ui-active-menuitem.ui-state-hover{ vertical-align:top; } +#haystack-search-page .action-label, +#haystack-search .action-label{ + display: none; +} + +#id_welcome_search{ + height: 20px; +} + +.welcome-dialog p.welcome-search{ + padding: 10px 0 20px 0; +} + #search-listing img{ vertical-align:middle; } @@ -2118,3 +2132,18 @@ select#id_categories{ color:#d38fac; } +#welcome h3, #welcome h4, +#welcome{ + font-family: 'Numans', sans-serif; + text-align: center; + color: #999; + font-weight: 300; +} + +#welcome h3{ + font-size: 50px; +} + +#welcome h4{ + font-size: 30px; +} diff --git a/static/saclay/js/interface.js b/static/saclay/js/interface.js index e004ce4..ebfa527 100644 --- a/static/saclay/js/interface.js +++ b/static/saclay/js/interface.js @@ -162,6 +162,8 @@ $(function(){ $('input[name="transport"]').change(change_routing_transport); $('input[name="speed"]').change(change_routing_speed); $('#id_speed').change(change_routing_speed); + + $('#haystack-search-page').click(welcome_search); }); function change_routing_speed(){ 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; + } +}); + diff --git a/templates/chimere/base.html b/templates/chimere/base.html index 375feda..5f88092 100644 --- a/templates/chimere/base.html +++ b/templates/chimere/base.html @@ -1,6 +1,7 @@ {% extends "base.html" %} {% load chimere_tags i18n %} {% block extra_head %} + diff --git a/templates/chimere/blocks/welcome.html b/templates/chimere/blocks/welcome.html index 8d7add2..66f3011 100644 --- a/templates/chimere/blocks/welcome.html +++ b/templates/chimere/blocks/welcome.html @@ -6,7 +6,7 @@ $(function(){ $('#welcome div.media-player').jmeEmbedControls(); $('#welcome video').each(function(index){$(this).pause()}); $('#welcome audio').each(function(index){$(this).pause()}); - $("#welcome").dialog({width:826, height:410, dialogClass:'welcome-dialog' + $("#welcome").dialog({width:550, height:300, dialogClass:'welcome-dialog' {% if not display %}, autoOpen:false{% endif %}, open: function () { $("#welcome_content").scrollTop(0); } }); @@ -14,47 +14,28 @@ $(function(){ // -->