Blame view

public/js/plugin/modal.alert.js 681 Bytes
陈轩 authored
1 2 3 4 5 6
/* eslint-disable vars-on-top */
/**
 *  jquery alert 基于 jquery modal;
 *  @author xuan.chen@yoho.com
 */
'use strict';
lijing authored
7
let Modal = require('./modal');
陈轩 authored
8 9

$.yAlert = function(config) {
lijing authored
10
    let DEFAULT = {
11 12 13
        okText: '确定'
    };
陈轩 authored
14 15 16 17
    if (typeof config === 'string') {
        config = {content: config};
    }
18 19
    config = $.extend({}, DEFAULT, config);
lijing authored
20 21 22 23
    let t = require('common/modal.alert.hbs');
    let element = t(config);
    let $element = $(element).appendTo('body');
    let modal = new Modal($element);
陈轩 authored
24 25 26 27 28

    $element.one('hiden.yoho.modal', function() {
        $element.remove();
    });
    modal.show();
陈轩 authored
29 30

    return $element;
陈轩 authored
31 32 33
};

module.exports = alert;