Blame view

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

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

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

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

module.exports = alert;