channel.js 1.11 KB
/**
 * 频道选择页面顶部搜索
 * @author: bikai<kai.bi@yoho.cn>
 * @date: 2015/10/28
 */
var $ = require('jquery');

var $searchBox = $('.search-box'),
    $indexSearch = $('.index-search'),
    $indexLogo = $('.index-logo');

require('../common');

function showBigSearch() {
    $indexLogo.css({
        opacity: 0
    });
    $searchBox.css({
        width: '12.8rem'
    });
    $indexSearch.css({
        width: '15.5rem'
    });
    $('.clear-text, .no-search').show();
}

function hideBigSearch() {
    $indexLogo.css({
        opacity: 1
    });
    $searchBox.css({
        width: '8.8rem'
    });
    $indexSearch.css({
        width: '9.6rem'
    });
    $('.clear-text, .no-search').hide();
}

$searchBox.find('input').on('focus', function() {
    showBigSearch();
});

$searchBox.find('.clear-text').on('touchend', function() {
    $searchBox.find('input').val('');
});
$searchBox.find('.search-icon').on('touchend', function() {
    $indexSearch.submit();
});

$('.no-search').on('touchend', function() {
    $searchBox.find('input').val('');
    hideBigSearch();
});

window.rePosFooter && window.rePosFooter();