view.js 1.04 KB
import {
    View
} from 'js/yoho-mvc';

class TabView extends View {
    constructor() {
        super('.tab');
        this.end = false;
        this.on('touchend touchcancel', 'span', this.tabClick.bind(this));
    }

    tabClick(e) {
        let $this = $(e.currentTarget);

        if (!$this.hasClass('active')) {
            let $index = $this.index();

            $this.addClass('active').siblings('span').removeClass('active');
            $('.tab-item:eq(' + $index + ')').removeClass('hide').siblings('.tab-item').addClass('hide');
            window.rePosFooter();
        }
    }
}

class GetContent extends View {
    constructor() {
        super('.grade-new-c');

        // srcoll to load more
        $(window).scroll(() => {
            window.requestAnimationFrame(this.scrollHandler.bind(this));
        });
    }

    scrollHandler() {
        if (($(window).scrollTop() + $(window).height() >= $(document).height()) && $('.ul-detail').length > 0) {
            this.emit('search');
        }
    }
}

export {
    TabView,
    GetContent
};