help-common.js 1.58 KB
/**
 * [帮助中心 常见问题弹框]
 * @author: wsl(shuiling.wang@yoho.cn)
 * @date: 2016/12/02
 */

var problemTpl = require('../../hbs/help/problem-box.hbs');

// 问题弹窗操作
var problemBox = function() {
    var $problemBox;

    $('.help-page').append(problemTpl());
    $problemBox = $('.problem-box');

    $problemBox.css({lineHeight: $(window).height() + 'px'});

    $('.problem a').on('click', function() {
        var ask = $(this).data('ask') || '';
        var answer = $(this).data('answer') || '';

        $problemBox.find('.a-area').html(ask);
        $problemBox.find('.q-area').html(answer);
        $problemBox.show();

        $('body').css({overflow: 'hidden'});
    });

    $('.problem-box .close, .problem-box .mark').on('click', function() {
        $problemBox.hide();
        $('body').css({overflow: 'auto'});
    });
};

var $subsets = $('.subsets');

/**
 * 目录切换
 */
$subsets.click(function() {
    var $this = $(this);
    var className = $this.attr('class').split(' ')[1];
    var parentId = 'parentId-' + className.split('-')[1];
    var $child = $this.parent().find('.' + parentId);// 当前子分类

    if ($this.hasClass('open')) {
        $child.hide();
        $this.removeClass('open').children('.icon').removeClass('minus').addClass('plus');
    } else {
        $('.smll-category').hide();
        $('.subsets').children('.icon').removeClass('minus').addClass('plus');
        $child.show();
        $subsets.removeClass('open');
        $this.addClass('open').children('.icon').removeClass('plus').addClass('minus');
    }
});

module.exports = problemBox;