From 71554b020fce18e05c5eff3c47ff360632718a82 Mon Sep 17 00:00:00 2001 From: Nikolai Kristiansen Date: Mon, 28 Jul 2014 22:06:20 +0200 Subject: [PATCH] Search fixes, adds groups and memberstatus --- wp-content/themes/aktiv2014/app/scripts/main.js | 17 ++++++++++++----- .../themes/aktiv2014/dist/scripts/main.js | 2 +- wp-content/themes/aktiv2014/header.php | 2 ++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/wp-content/themes/aktiv2014/app/scripts/main.js b/wp-content/themes/aktiv2014/app/scripts/main.js index be053a6..af4793b 100644 --- a/wp-content/themes/aktiv2014/app/scripts/main.js +++ b/wp-content/themes/aktiv2014/app/scripts/main.js @@ -82,8 +82,14 @@ jQuery(document).ready(function() { /* Search */ $('.search-field').focus(); - var header_template = ''; - $('.search-field').on('keyup', _.debounce(function(e) { + var header_template = '
NavnBrukernavnEpostTelefon
'; + $('.search-field').on('keyup keypress', function(e) { + // No + if (e.keyCode === 10 || e.keyCode === 13) { + e.preventDefault(); + } + }); + $('.search-field').on('keyup keypress', _.debounce(function(e) { if(e.target.value.length > 2) { $.getJSON(user_search_endpoint, {q: e.target.value}, function(data) { if(data.meta.num_results === 0) { @@ -91,8 +97,9 @@ jQuery(document).ready(function() { $('.search-results .meta').html(''); return; } + //console.log(data); var list = '<% _.each(results, function(u) { %>' + - ' <% }); %>
NavnBrukernavnEpostTelefonMedlemGrupper
<%= u.firstname %> <%= u.lastname %><%= u.username %><%= u.email %><%= u.number %>
'; + '<%= u.firstname %> <%= u.lastname %><%= u.username %><%= u.email %><%= u.number %><% if(u.is_member != 0) { %>Ja<% } else { %>Nei<% } %><%= u.groups %> <% }); %>'; var html = header_template + _.template(list, data); $('.search-result-list').html(html); @@ -100,9 +107,9 @@ jQuery(document).ready(function() { $('.search-results .meta').html(_.template(search_meta, data)); }); } else { - console.log('too short'); + $('.search-result-list').html('Skriv minst 3 tegn.'); + $('.search-results .meta').html(''); } }, 300)); - }); diff --git a/wp-content/themes/aktiv2014/dist/scripts/main.js b/wp-content/themes/aktiv2014/dist/scripts/main.js index 195ca02..dd74a05 100644 --- a/wp-content/themes/aktiv2014/dist/scripts/main.js +++ b/wp-content/themes/aktiv2014/dist/scripts/main.js @@ -1 +1 @@ -"use strict";function format_posts(t){var e="",n=0;if(0===t.length)return"";for(e+='ArrangementStedTid',n=0;n',e+=''+r.title+"",e+=''+r.custom_fields._neuf_events_venue+"",e+=''+moment.unix(r.custom_fields._neuf_events_starttime).utc().format("DD. MMMM YYYY, HH.mm")+""}return e}var program_endpoint="https://studentersamfundet.no/api/events/get_upcoming/",inside_url="https://inside.studentersamfundet.no",user_search_endpoint=inside_url+"/api/user.php",query_params={count:10},entrypoint=".program-list";jQuery(document).ready(function(){moment.lang("nb");var t=jQuery;t.getJSON(program_endpoint+"?callback=?",query_params,function(e){if(e&&e.events){var n=format_posts(e.events);t(entrypoint).html(n)}}),t("#menu .menu-toggle").on("click",function(e){e.preventDefault();var n=t("#menu .main-menu, #menu .user-menu-wrap");n.toggleClass("visible")}),t("#menu a.profile-badge").on("click",function(e){e.preventDefault();var n=t("#menu .user-menu");n.toggleClass("visible")}),t("[data-toggle-introduction]").on("click",function(){t(this).parent().fadeOut(600),t.cookie("introduction-dismissed","1")}),"1"!==t.cookie("introduction-dismissed")&&(t(".introduction").show(),t(".introduction").addClass("fadein")),t(".search-field").focus();var e="";t(".search-field").on("keyup",_.debounce(function(n){n.target.value.length>2?t.getJSON(user_search_endpoint,{q:n.target.value},function(n){if(0===n.meta.num_results)return t(".search-result-list").html("Ingen treff."),void t(".search-results .meta").html("");var r='<% _.each(results, function(u) { %> <% }); %>
NavnBrukernavnEpostTelefon
<%= u.firstname %> <%= u.lastname %><%= u.username %><%= u.email %><%= u.number %>
',a=e+_.template(r,n);t(".search-result-list").html(a);var s="Antall treff: <%= meta.num_results %>";t(".search-results .meta").html(_.template(s,n))}):console.log("too short")},300))}); \ No newline at end of file +"use strict";function format_posts(t){var e="",n=0;if(0===t.length)return"";for(e+='ArrangementStedTid',n=0;n',e+=''+r.title+"",e+=''+r.custom_fields._neuf_events_venue+"",e+=''+moment.unix(r.custom_fields._neuf_events_starttime).utc().format("DD. MMMM YYYY, HH.mm")+""}return e}var program_endpoint="https://studentersamfundet.no/api/events/get_upcoming/",inside_url="https://inside.studentersamfundet.no",user_search_endpoint=inside_url+"/api/user.php",query_params={count:10},entrypoint=".program-list";jQuery(document).ready(function(){moment.lang("nb");var t=jQuery;t.getJSON(program_endpoint+"?callback=?",query_params,function(e){if(e&&e.events){var n=format_posts(e.events);t(entrypoint).html(n)}}),t("#menu .menu-toggle").on("click",function(e){e.preventDefault();var n=t("#menu .main-menu, #menu .user-menu-wrap");n.toggleClass("visible")}),t("#menu a.profile-badge").on("click",function(e){e.preventDefault();var n=t("#menu .user-menu");n.toggleClass("visible")}),t("[data-toggle-introduction]").on("click",function(){t(this).parent().fadeOut(600),t.cookie("introduction-dismissed","1")}),"1"!==t.cookie("introduction-dismissed")&&(t(".introduction").show(),t(".introduction").addClass("fadein")),t(".search-field").focus();var e="";t(".search-field").on("keyup keypress",function(t){(10===t.keyCode||13===t.keyCode)&&t.preventDefault()}),t(".search-field").on("keyup keypress",_.debounce(function(n){n.target.value.length>2?t.getJSON(user_search_endpoint,{q:n.target.value},function(n){if(0===n.meta.num_results)return t(".search-result-list").html("Ingen treff."),void t(".search-results .meta").html("");var r='<% _.each(results, function(u) { %> <% }); %>
NavnBrukernavnEpostTelefonMedlemGrupper
<%= u.firstname %> <%= u.lastname %><%= u.username %><%= u.email %><%= u.number %><% if(u.is_member != 0) { %>Ja<% } else { %>Nei<% } %><%= u.groups %>
',s=e+_.template(r,n);t(".search-result-list").html(s);var a="Antall treff: <%= meta.num_results %>";t(".search-results .meta").html(_.template(a,n))}):(t(".search-result-list").html("Skriv minst 3 tegn."),t(".search-results .meta").html(""))},300))}); \ No newline at end of file diff --git a/wp-content/themes/aktiv2014/header.php b/wp-content/themes/aktiv2014/header.php index 1910325..1704d22 100644 --- a/wp-content/themes/aktiv2014/header.php +++ b/wp-content/themes/aktiv2014/header.php @@ -14,6 +14,8 @@ + +