rdialog.js 1.65 KB
/**
 * 弹框 dialog 改版
 * @author: gxh<xuhui.ge@yoho.cn>
 * @date: 2016/01/06
 */
var $ = require('yoho-jquery'),
    Dialog = require('../plugins/dialog').Dialog;

function RDialog(opts) {
    var option = $.extend(true, {}, {
        className: 'r-dialog',
        closeIcon: true
    }, opts);

    option.content = '<div class="dialog-content">' + option.content + '</div>';
    option.btns.name = '';

    Dialog.call(this, option);
}

RDialog.prototype = new Dialog({
    inherit: true
});
RDialog.prototype.constructor = RDialog;

function RConfirm(content, ok, cancel) {
    var rd = new RDialog({
        content: content,
        btns: [{
            id: 'confirm-btn-ok',
            btnClass: ['alert-sure'],
            name: '确定',
            cb: function() {
                rd.close();
                (typeof ok === 'function') && ok();
            }
        }, {
            id: 'confirm-btn-cencel',
            btnClass: ['btn-cancel'],
            name: '取消',
            cb: function() {
                rd.close();
            }
        }]
    });

    rd.show();
}

RConfirm.prototype = new Dialog({
    inherit: true
});

RConfirm.prototype.constructor = RConfirm;
exports.RConfirm = RConfirm;

function RAlert(content, title) {
    var that = this;
    var rd = new RDialog({
        content: content,
        title: title || '提示',
        btns: [{
            btnClass: ['alert-sure'],
            name: '确定',
            cb: function() {
                that.close();
            }
        }]
    });

    rd.show();
}
RAlert.prototype = new Dialog({
    inherit: true
});

RAlert.prototype.constructor = RAlert;
exports.RAlert = RAlert;