rdialog.js 1.76 KB
/**
 * 弹框 dialog 改版
 * @author: gxh<xuhui.ge@yoho.cn>
 * @date: 2016/01/06
 */
var $ = require('yoho-jquery'),
    Dialog = require('../common/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, okName, cancelName) {
    var rd = new RDialog({
        content: content,
        btns: [{
            id: 'confirm-btn-ok',
            btnClass: ['alert-sure'],
            name: okName || '确定',
            cb: function() {
                rd.close();
                (typeof ok === 'function') && ok();
            }
        }, {
            id: 'confirm-btn-cencel',
            btnClass: ['btn-cancel'],
            name: cancelName || '取消',
            cb: function() {
                rd.close();
                (typeof cancel === 'function') && cancel();
            }
        }]
    });

    rd.show();
}

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

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

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

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

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