modal.alert.js
681 Bytes
/* eslint-disable vars-on-top */
/**
* jquery alert 基于 jquery modal;
* @author xuan.chen@yoho.com
*/
'use strict';
var Modal = require('./modal');
$.yAlert = function(config) {
var DEFAULT = {
okText: '确定'
};
if (typeof config === 'string') {
config = {content: config};
}
config = $.extend({}, DEFAULT, config);
var t = require('common/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();
return $element;
};
module.exports = alert;