From db5438ab1a599147c3d50ada88584be02b272cf3 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Fri, 10 Jun 2016 20:34:25 +0200 Subject: [PATCH] frio: improvements in search behavior - search value woll be added to nav search input - focus on nav search input as main search - save search button appears in the second navbar if search is available - search heading appears in the second navbar - provide a mobile search by pressing the search icon - dirfind: heading distinguish between people and form search - some js fixes in theme.js --- mod/dirfind.php | 4 +- view/theme/frio/css/style.css | 17 ++++++++ view/theme/frio/js/theme.js | 54 ++++++++++++++++++++----- view/theme/frio/templates/nav.tpl | 13 +++++- view/theme/frio/templates/searchbox.tpl | 10 ++++- 5 files changed, 85 insertions(+), 13 deletions(-) diff --git a/mod/dirfind.php b/mod/dirfind.php index f193a5c45c..44f70d641e 100644 --- a/mod/dirfind.php +++ b/mod/dirfind.php @@ -33,6 +33,7 @@ function dirfind_content(&$a, $prefix = "") { if(strpos($search,'@') === 0) { $search = substr($search,1); + $header = sprintf( t('People Search - %s'), $search); if ((valid_email($search) AND validate_email($search)) OR (substr(normalise_link($search), 0, 7) == "http://")) { $user_data = probe_url($search); @@ -43,6 +44,7 @@ function dirfind_content(&$a, $prefix = "") { if(strpos($search,'!') === 0) { $search = substr($search,1); $community = true; + $header = sprintf( t('Forum Search - %s'), $search); } $o = ''; @@ -227,7 +229,7 @@ function dirfind_content(&$a, $prefix = "") { $tpl = get_markup_template('viewcontact_template.tpl'); $o .= replace_macros($tpl,array( - 'title' => sprintf( t('People Search - %s'), $search), + 'title' => $header, '$contacts' => $entries, '$paginate' => paginate($a), )); diff --git a/view/theme/frio/css/style.css b/view/theme/frio/css/style.css index 0ecb56441d..49d78e1314 100644 --- a/view/theme/frio/css/style.css +++ b/view/theme/frio/css/style.css @@ -581,6 +581,9 @@ nav.navbar a { margin: 0px; padding: 10px 15px; } +#search-mobile .navbar-form { + margin: 0; +} #topbar-first #search-box .form-search { height: 25px; font-size: 13px; @@ -1531,6 +1534,11 @@ img.acpopup-img { /*margin-left: -15px;*/ padding: 0; } +#tabmenu .search-heading { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} ul.tabs { list-style: none; height: 100%; @@ -1661,6 +1669,15 @@ ul.dropdown-menu li:hover { color: $link_color; font-size: 20px; } +.search-content-wrapper > #search-header-wrapper { + display: none; +} +.search-content-wrapper > .section-title-wrapper { + display: none; +} +#navbar-button > #search-save-form > #search-save { + margin-top: 3px; +} /* Section-Content-Wrapper */ #search-header-wrapper { padding: 15px; diff --git a/view/theme/frio/js/theme.js b/view/theme/frio/js/theme.js index 9be1b9456e..28221dcd0d 100644 --- a/view/theme/frio/js/theme.js +++ b/view/theme/frio/js/theme.js @@ -40,7 +40,7 @@ $(document).ready(function(){ $(".field.select > select, .field.custom > select").addClass("form-control"); // move the tabbar to the second nav bar - if( $("ul.tabbar")) { + if( $("ul.tabbar").length ) { $("ul.tabbar").appendTo("#topbar-second > .container > #tabmenu"); } @@ -50,7 +50,7 @@ $(document).ready(function(){ // to the friendica logo (the mask is in nav.tpl at the botom). To make it work we need to apply the // correct url. The only way which comes to my mind was to do this with js // So we apply the correct url (with the link to the id of the mask) after the page is loaded. - if($("#logo-img")) { + if($("#logo-img").length ) { var pageurl = "url('" + window.location.href + "#logo-mask')"; $("#logo-img").css({"mask": pageurl}); } @@ -66,7 +66,7 @@ $(document).ready(function(){ }); // add Jot botton to the scecond navbar - if( $("section #jotOpen")) { + if( $("section #jotOpen").length ) { $("section #jotOpen").appendTo("#topbar-second > .container > #navbar-button"); if( $("#jot-popup").is(":hidden")) $("#topbar-second > .container > #navbar-button #jotOpen").hide(); } @@ -94,13 +94,6 @@ $(document).ready(function(){ }); } }); - - // add search-heading to the scecond navbar - if( $(".search-heading")) { - $(".search-heading").appendTo("#topbar-second > .container > #tabmenu"); - } - - //$('ul.flex-nav').flexMenu(); @@ -120,6 +113,47 @@ $(document).ready(function(){ // initialize the bootstrap-select $('.selectpicker').selectpicker(); + // add search-heading to the seccond navbar + if( $(".search-heading").length) { + $(".search-heading").appendTo("#topbar-second > .container > #tabmenu"); + } + + // add search results heading to the second navbar + // and insert the search value to the top nav search input + if( $(".search-content-wrapper").length ) { + // get the text of the heading (we catch the plain text because we don't + // want to have a h4 heading in the navbar + var searchText = $(".section-title-wrapper > h2").text(); + // insert the plain text in a