/** * 封装flavr,方便使用 */ var Flavr = function() { //动画数组 var animates = ["tada", "swing", "shake", "rubberBand", "bounce", "pulse"]; //获取随机动画 function getAnimate() { return animates[Math.floor(Math.random() * animates.length)]; } var fr = { /** * 弹窗信息 * @param {String} 信息内容 */ alert: function(msg) { new $.flavr({ buttons: { OK: { text: 'OK', style: 'default', addClass: null, action: null } }, animateEntrance: getAnimate(), content: msg }); }, /** * 提示信息 * @param {String} 信息内容 */ msg: function(msg) { new $.flavr({ modal: false, autoclose: true, timeout: 2000, buttons: {}, animateEntrance: getAnimate(), content: msg }); }, /** * 确认信息 * @param {String} 信息内容 * @param {Function} 确认回调函数 * @param {Function} 取消回调函数 */ confirm: function(msg, okBack, cancelBack) { new $.flavr({ dialog: 'confirm', buttons: { OK: { text: '确认', style: 'danger', addClass: null, action: okBack }, CANCEL: { text: '取消', addClass: null, action: cancelBack } }, animateEntrance: getAnimate(), content: msg }); } } return fr; } var flavr = new Flavr(); flavr.alert("Flavr Alert"); flavr.msg("Flavr Msg"); flavr.confirm("确定删除吗?", function() { flavr.msg("删除成功"); });回复
把按钮内容变成中文实例,我是参考多个按钮demo改出来的
new $.flavr({ content: 'How old are you?', dialog: 'prompt', prompt: { placeholder: 'Enter something' }, buttons: { danger: { text: '确定', style: 'danger', action: function() { alert('Mission failed!'); return false; } }, cancel: { text: '取消', style: 'default' } }, });回复