loading.js 850 Bytes
/**
 * Loading mask
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/29
 */

var $ = require('jquery');

var $page = $('.yoho-page');

var $loading,
    hasInit = false;

/** modify by liangzhifeng at 2015.11.2 */

// 初始化
function init($container) {
    hasInit = true;
    if ($container === undefined) {
        $container = $page;
    }
    var html = '<div class="loading-mask hide"><div class="loading"></div></div>';

    $container.append(html);

    $loading = $container.children('.loading-mask');
}

//显示loading
function showLoadingMask() {
    if (!hasInit) {
        init();
        hasInit = true;
    }
    $loading.removeClass('hide');
}

//隐藏loading
function hideLoadingMask() {
    $loading.addClass('hide');
}

exports.init = init;
exports.showLoadingMask = showLoadingMask;
exports.hideLoadingMask = hideLoadingMask;