modal.alert.js 681 Bytes
/* eslint-disable vars-on-top */
/**
 *  jquery alert 基于 jquery modal;
 *  @author xuan.chen@yoho.com
 */
'use strict';
let Modal = require('./modal');

$.yAlert = function(config) {
    let DEFAULT = {
        okText: '确定'
    };

    if (typeof config === 'string') {
        config = {content: config};
    }

    config = $.extend({}, DEFAULT, config);

    let t = require('common/modal.alert.hbs');
    let element = t(config);
    let $element = $(element).appendTo('body');
    let modal = new Modal($element);

    $element.one('hiden.yoho.modal', function() {
        $element.remove();
    });
    modal.show();

    return $element;
};

module.exports = alert;