Authored by ccbikai

频道选择顶部搜索

@@ -4,15 +4,13 @@ @@ -4,15 +4,13 @@
4 * @date: 2015/10/28 4 * @date: 2015/10/28
5 */ 5 */
6 var $ = require('jquery'); 6 var $ = require('jquery');
7 -  
8 var $searchBox = $('.search-box'), 7 var $searchBox = $('.search-box'),
9 $indexSearch = $('.index-search'), 8 $indexSearch = $('.index-search'),
10 $indexLogo = $('.index-logo'); 9 $indexLogo = $('.index-logo');
11 10
12 -$searchBox.find('input').on('focus', function () { 11 +$searchBox.find('input').on('focus', function() {
13 $indexLogo.css({ 12 $indexLogo.css({
14 - width: 0,  
15 - display: 'none' 13 + width: 0
16 }); 14 });
17 $searchBox.css({ 15 $searchBox.css({
18 width: '12.8rem' 16 width: '12.8rem'
@@ -21,10 +19,9 @@ $searchBox.find('input').on('focus', function () { @@ -21,10 +19,9 @@ $searchBox.find('input').on('focus', function () {
21 width: '15.5rem' 19 width: '15.5rem'
22 }); 20 });
23 $('.clear-text, .no-search').show(); 21 $('.clear-text, .no-search').show();
24 -}).on('blur', function () { 22 +}).on('blur', function() {
25 $indexLogo.css({ 23 $indexLogo.css({
26 - width: '5.4rem',  
27 - display: 'block' 24 + width: '5.4rem'
28 }); 25 });
29 $searchBox.css({ 26 $searchBox.css({
30 width: '8.8rem' 27 width: '8.8rem'
@@ -34,11 +31,10 @@ $searchBox.find('input').on('focus', function () { @@ -34,11 +31,10 @@ $searchBox.find('input').on('focus', function () {
34 }); 31 });
35 $('.clear-text, .no-search').hide(); 32 $('.clear-text, .no-search').hide();
36 }); 33 });
37 -  
38 -$searchBox.find('.clear-text').click(function () { 34 +$searchBox.find('.clear-text').click(function() {
39 $searchBox.find('input').val('').trigger('focus'); 35 $searchBox.find('input').val('').trigger('focus');
40 }); 36 });
41 -  
42 -$searchBox.find('.search-icon').click(function () { 37 +$searchBox.find('.search-icon').click(function() {
43 $indexSearch.submit(); 38 $indexSearch.submit();
44 -});  
  39 +});
  40 +
@@ -13,11 +13,18 @@ @@ -13,11 +13,18 @@
13 font-size: 50rem / $pxConvertRem; 13 font-size: 50rem / $pxConvertRem;
14 width: 216rem / $pxConvertRem; 14 width: 216rem / $pxConvertRem;
15 color: #343434; 15 color: #343434;
  16 + overflow: hidden;
  17 + transition: width 400ms;
16 } 18 }
17 19
18 .index-search { 20 .index-search {
19 - float: right; 21 + position: absolute;
  22 + top: 0;
  23 + right: 0;
20 width: 384rem / $pxConvertRem; 24 width: 384rem / $pxConvertRem;
  25 + height: 112rem / $pxConvertRem;
  26 + overflow: hidden;
  27 + transition: width 400ms;
21 .search-box { 28 .search-box {
22 float: left; 29 float: left;
23 position: relative; 30 position: relative;