seajs.use(['mobi/zepto/1.1.3/zepto', 'mobi/panel/1.0.0/panel', 'mobi/mo/1.0.0/mo'],function($, Panel, LegoMobi){

    $(function(){

        //返回顶部按钮
        LegoMobi.initScrollTop();

        //返回键
        // $(".m-menu__back").on("click", function(){
        //     history.back();
        // });
        
        //顶部导航栏切换
        $(".m-header").on("touchstart", ".m-menu--toggle", function(){
            $(this).toggleClass('cur');
            var _nav = $('.m-header__nav');
            if(!_nav.hasClass('nav-toggle')){
                _nav.show();
                setTimeout(function(){
                    _nav.addClass('nav-toggle');
                },20);
            }else{
                _nav.removeClass('nav-toggle');
                setTimeout(function(){
                    _nav.hide();
                },300);
            }
        });

        //频道展开
        $(".m-channel__list--hd").on("click", function(){
            $(this).parents(".m-channel__list").toggleClass('list-expand');
        });

        //展开登录面板
        var PanelInstance = $(".m-infoPanel").Panel({
            targetContent : $(".wrapper"),
            displayMode : 'overlay'
        });

        //打开Panel
        $(".m-menu__personal").on('click',function(){
            $(".m-infoPanel--mask").show();
            PanelInstance.open();

            setTimeout(function(){
                //禁用屏幕滚动
                $(window).on("touchmove", function(e){
                    e.preventDefault();
                });
            },0)
        });

        //关闭Panel
        $(".m-infoPanel--mask, .m-panel--close").on('click', function(){
            PanelInstance.close();
            setTimeout(function(){
                $(".m-infoPanel--mask").hide();
                
                //取消禁用屏幕滚动
                $(window).off("touchmove");
            },0);
        });

    });
});