modal.alert.js
563 Bytes
/* eslint-disable vars-on-top */
/**
* jquery alert 基于 jquery modal;
* @author xuan.chen@yoho.com
*/
'use strict';
var Modal = require('./modal');
$.yAlert = function(config) {
if (typeof config === 'string') {
config = {content: config};
}
var t = require('template/modal.alert.hbs');
var element = t(config);
var $element = $(element).appendTo('body');
var modal = new Modal($element);
$element.one('hiden.yoho.modal', function() {
$element.remove();
});
modal.show();
};
module.exports = alert;