Showing
3 changed files
with
14 additions
and
3 deletions
@@ -9,14 +9,21 @@ var $searchBox = $('.search-box'), | @@ -9,14 +9,21 @@ var $searchBox = $('.search-box'), | ||
9 | $indexSearch = $('.index-search'), | 9 | $indexSearch = $('.index-search'), |
10 | $indexLogo = $('.index-logo'); | 10 | $indexLogo = $('.index-logo'); |
11 | 11 | ||
12 | -var $search = $searchBox.children('input'), | ||
13 | - $cancelSearch = $indexSearch.children('.no-search'); | 12 | +var $search = $searchBox.children('input[type="text"]'), |
13 | + $cancelSearch = $indexSearch.children('.no-search'), | ||
14 | + $searchIcon = $searchBox.children('.search-icon'); | ||
14 | 15 | ||
15 | require('../common'); | 16 | require('../common'); |
16 | 17 | ||
17 | $search.on('focus', function() { | 18 | $search.on('focus', function() { |
18 | $indexSearch.addClass('action'); | 19 | $indexSearch.addClass('action'); |
19 | $indexLogo.addClass('action'); | 20 | $indexLogo.addClass('action'); |
21 | +}).on('input', function() { | ||
22 | + if ($search.val() === '') { | ||
23 | + $searchIcon.addClass('empty'); | ||
24 | + } else { | ||
25 | + $searchIcon.removeClass('empty'); | ||
26 | + } | ||
20 | }); | 27 | }); |
21 | 28 | ||
22 | $cancelSearch.on('touchstart', function() { | 29 | $cancelSearch.on('touchstart', function() { |
@@ -81,9 +81,13 @@ | @@ -81,9 +81,13 @@ | ||
81 | } | 81 | } |
82 | .search-icon { | 82 | .search-icon { |
83 | right: 10rem / $pxConvertRem; | 83 | right: 10rem / $pxConvertRem; |
84 | + color: #000; | ||
85 | + | ||
86 | + &.empty { | ||
84 | color: #e6e6e6; | 87 | color: #e6e6e6; |
85 | } | 88 | } |
86 | } | 89 | } |
90 | + } | ||
87 | 91 | ||
88 | .no-search { | 92 | .no-search { |
89 | display: none; | 93 | display: none; |
@@ -9,7 +9,7 @@ | @@ -9,7 +9,7 @@ | ||
9 | <input type="hidden" name="from" value="search"> | 9 | <input type="hidden" name="from" value="search"> |
10 | <input type="text" name="query" placeholder="搜索" autocomplete="off"> | 10 | <input type="text" name="query" placeholder="搜索" autocomplete="off"> |
11 | <span class="iconfont clear-text"></span> | 11 | <span class="iconfont clear-text"></span> |
12 | - <span class="iconfont search-icon"></span> | 12 | + <span class="iconfont search-icon empty"></span> |
13 | </div> | 13 | </div> |
14 | </form> | 14 | </form> |
15 | </div> | 15 | </div> |
-
Please register or login to post a comment