From 5dcdcb1c99d89fcbc6e0886131bf11eb1b352519 Mon Sep 17 00:00:00 2001 From: Acris Liu Date: Mon, 20 Feb 2017 13:42:18 +0800 Subject: [PATCH 1/4] fixed: layout conflict between local search and algoia search --- layout/_scripts/third-party/localsearch.swig | 4 +- .../third-party/algolia-search.styl | 35 ++++ .../components/third-party/localsearch.styl | 193 ++++++++---------- source/js/src/algolia-search.js | 4 +- 4 files changed, 128 insertions(+), 108 deletions(-) diff --git a/layout/_scripts/third-party/localsearch.swig b/layout/_scripts/third-party/localsearch.swig index a1a3dac91..688002500 100644 --- a/layout/_scripts/third-party/localsearch.swig +++ b/layout/_scripts/third-party/localsearch.swig @@ -11,7 +11,7 @@ // monitor main search box; function proceedsearch() { - $("body").append('
').css('overflow', 'hidden'); + $("body").append('
').css('overflow', 'hidden'); $('.popup').toggle(); } // search function; @@ -115,7 +115,7 @@ $('.popup-btn-close').click(function(e){ $('.popup').hide(); - $(".popoverlay").remove(); + $(".local-search-pop-overlay").remove(); $('body').css('overflow', ''); }); $('.popup').click(function(e){ diff --git a/source/css/_common/components/third-party/algolia-search.styl b/source/css/_common/components/third-party/algolia-search.styl index 6a0a7c968..e2e98280d 100644 --- a/source/css/_common/components/third-party/algolia-search.styl +++ b/source/css/_common/components/third-party/algolia-search.styl @@ -1,8 +1,43 @@ +.algolia-pop-overlay + position: fixed + width: 100% + height: 100% + top: 0 + left: 0 + z-index: 2080 + background-color: rgba(0, 0, 0, 0.3) + .algolia-popup overflow: hidden padding: 0 + display: none + position: fixed + top: 10% + left: 50% + width: 700px + height: 80% + margin-left: -350px + background: #fff + color: #333 + z-index: 9999 + border-radius: 5px + +mobile() + padding: 0 + top: 0 + left: 0 + margin: 0 + width: 100% + height: 100% + border-radius: 0 .popup-btn-close + position: absolute + right: 14px + color: #4EBD79 + font-size: 14px + font-weight: bold + text-transform: uppercase + cursor: pointer padding-left: 15px border-left: 1px solid #eee top: 10px diff --git a/source/css/_common/components/third-party/localsearch.styl b/source/css/_common/components/third-party/localsearch.styl index eca4e3af3..a253a2ccd 100644 --- a/source/css/_common/components/third-party/localsearch.styl +++ b/source/css/_common/components/third-party/localsearch.styl @@ -1,117 +1,102 @@ -ul.search-result-list { - padding: 0; - margin: 0 5px; -} +.local-search-pop-overlay + position: fixed + width: 100% + height: 100% + top: 0 + left: 0 + z-index: 2080 + background-color: rgba(0, 0, 0, 0.3) -p.search-result { - border-bottom: 1px dashed #ccc; - padding: 5px 0; -} +.local-search-popup + display: none + position: fixed + top: 10% + left: 50% + margin-left: -350px + width: 700px + height: 80% + padding: 0 + background: #fff + color: #333 + z-index: 9999 + border-radius: 5px + +mobile() + padding: 0 + top: 0 + left: 0 + margin: 0 + width: 100% + height: 100% + border-radius: 0 -a.search-result-title { - font-weight: bold; - font-size: 16px; -} + ul.search-result-list + padding: 0 + margin: 0 5px -.search-keyword { - border-bottom: 1px dashed #f00; - font-size: 14px; - font-weight: bold; - color: #f00; -} + p.search-result + border-bottom: 1px dashed #ccc + padding: 5px 0 -.local-search-header { - padding: 5px; - height: 36px; - background: #f5f5f5; - border-top-left-radius: 5px; - border-top-right-radius: 5px; -} + a.search-result-title + font-weight: bold + font-size: 16px -#local-search-result { - overflow: auto; - position: relative; - padding: 5px 25px; - height: calc(100% - 55px); -} + .search-keyword + border-bottom: 1px dashed #f00 + font-size: 14px + font-weight: bold + color: #f00 -.popup { - display: none; - position: fixed; - top: 10%; - left: 50%; - margin-left: -350px; - width: 700px; - height: 80%; - padding: 0; - background: #fff; - color: #333; - z-index: 9999; - border-radius: 5px; - +mobile() { - padding: 0; - top: 0; - left: 0; - margin: 0; - width: 100%; - height: 100%; - border-radius: 0px; - } -} + .local-search-header + padding: 5px + height: 36px + background: #f5f5f5 + border-top-left-radius: 5px + border-top-right-radius: 5px -.popoverlay { - position: fixed; - width: 100%; - height: 100%; - top: 0px; - left: 0px; - z-index: 2080; - background-color: rgba(0, 0, 0, 0.3); -} + #local-search-result + overflow: auto + position: relative + padding: 5px 25px + height: calc(100% - 55px) -.local-search-input-wrapper { - display: inline-block; - width: calc(100% - 60px); - height: 36px; - line-height: 36px; - padding: 0 5px; -} + .local-search-input-wrapper + display: inline-block + width: calc(100% - 60px) + height: 36px + line-height: 36px + padding: 0 5px -.local-search-input-wrapper input { - padding: 8px 0; - height: 20px; - display: block; - width: 100%; - outline: none; - border: none; - background: transparent; - vertical-align: middle; -} + .local-search-input-wrapper input + padding: 8px 0 + height: 20px + display: block + width: 100% + outline: none + border: none + background: transparent + vertical-align: middle -.search-icon, .popup-btn-close { - display: inline-block; - font-size: 18px; - color: #999; - height: 36px; - width: 18px; -} + .search-icon, .popup-btn-close + display: inline-block + font-size: 18px + color: #999 + height: 36px + width: 18px -.search-icon { - float: left; -} + .search-icon + float: left -.popup-btn-close { - border-left: 1px solid #eee; - float: right; - cursor: pointer; - padding-left: 10px; -} + .popup-btn-close + border-left: 1px solid #eee + float: right + cursor: pointer + padding-left: 10px -#no-result { - position: absolute; - left: 50%; - top: 50%; - -webkit-transform: translate(-50%, -50%); - transform: translate(-50%, -50%); - color: #ccc; -} + #no-result + position: absolute + left: 50% + top: 50% + -webkit-transform: translate(-50%, -50%) + transform: translate(-50%, -50%) + color: #ccc diff --git a/source/js/src/algolia-search.js b/source/js/src/algolia-search.js index b79ccabca..34f097a6f 100644 --- a/source/js/src/algolia-search.js +++ b/source/js/src/algolia-search.js @@ -99,14 +99,14 @@ $(document).ready(function () { $('.popup-trigger').on('click', function(e) { e.stopPropagation(); - $('body').append('
').css('overflow', 'hidden'); + $('body').append('
').css('overflow', 'hidden'); $('.popup').toggle(); $('#algolia-search-input').find('input').focus(); }); $('.popup-btn-close').click(function(){ $('.popup').hide(); - $('.popoverlay').remove(); + $('.algolia-pop-overlay').remove(); $('body').css('overflow', ''); }); From 6d7db9e8d0d3358dcdbda25cb84403e0dd205783 Mon Sep 17 00:00:00 2001 From: Acris Liu Date: Mon, 20 Feb 2017 14:03:22 +0800 Subject: [PATCH 2/4] add: local search enable switch --- _config.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/_config.yml b/_config.yml index 41555700f..be269fbad 100755 --- a/_config.yml +++ b/_config.yml @@ -217,7 +217,7 @@ post_meta: created_at: true updated_at: false categories: true - + # Post wordcount display settings # Dependies: https://github.com/willin/hexo-wordcount post_wordcount: @@ -392,7 +392,7 @@ busuanzi_count: # tencent_analytics: # Tencent MTA ID -# tencent_mta: +# tencent_mta: # Enable baidu push so that the blog will push the url to baidu automatically which is very helpful for SEO @@ -425,7 +425,9 @@ algolia_search: hits_empty: "We didn't find any results for the search: ${query}" hits_stats: "${hits} results found in ${time} ms" - +# Local search +local_search: + enable: false #! --------------------------------------------------------------- #! DO NOT EDIT THE FOLLOWING SETTINGS From 9b9f9e7b082846d7aaa70f20140cb9ebdefcbfec Mon Sep 17 00:00:00 2001 From: Acris Liu Date: Mon, 20 Feb 2017 14:03:36 +0800 Subject: [PATCH 3/4] fixed: script conflict between local search and algoia search --- layout/_partials/search.swig | 2 +- layout/_scripts/third-party/localsearch.swig | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/layout/_partials/search.swig b/layout/_partials/search.swig index 186466f52..0c5c1a6be 100644 --- a/layout/_partials/search.swig +++ b/layout/_partials/search.swig @@ -4,6 +4,6 @@ {% include 'search/swiftype.swig' %} {% elseif theme.tinysou_Key %} {% include 'search/tinysou.swig' %} -{% elseif config.search.path %} +{% elseif theme.local_search.enable %} {% include 'search/localsearch.swig' %} {% endif %} diff --git a/layout/_scripts/third-party/localsearch.swig b/layout/_scripts/third-party/localsearch.swig index 688002500..f768baaf2 100644 --- a/layout/_scripts/third-party/localsearch.swig +++ b/layout/_scripts/third-party/localsearch.swig @@ -1,4 +1,4 @@ -{% if config.search.path %} +{% if theme.local_search.enable %}