/// class PD.Web.UI.BoxedDialog
/// using PD.Web.UI.MessageDialog

PD.Web.UI.BoxedDialog =
PD.Web.UI.MessageDialog.extend({

    //================================
    // FIELDS
    //================================

    _items: null,

    //================================
    // PROPERTIES
    //================================

    get_items: function () {
        return this._items;
    },
    
    //================================
    // EVENT HANDLERS
    //================================

    onInit: function (e) {
        this._super(e);
        this._items = [];

        if (_.isArray(this.get_options().items)) {
            this._items = this.get_options().items;
        }

    },
        
    //================================
    // PRIVATE METHODS
    //================================

    _setText: function () {

        var hasItemsTag = this.get_message().indexOf("{{items}}") > 0;
        var markup = this._getListMarkup();

        if (hasItemsTag) {
            this.get_textNode().append(this.get_message().replace("{{items}}", markup));
        }
        else {
            
            this.get_textNode().append(markup);
        }

        this.get

        this.get_node().addClass("-pd-msg-dialog-boxed");
        this.get_textNode().addClass("-pd-msg-dialog-boxed-text");

    },

    _getListMarkup: function () {

        var result = "";

        _.each(this.get_items(), function (value, index) {
            result += "<div>" + value + "</div>";
        });
        
        return "<div class='-pd-msg-dialog-boxed-box is-fixed'>" + result + "</div>";

    }

});

//================================
// STATIC METHODS
//================================

PD.Web.UI.BoxedDialog.show = function (options) {
    return new PD.Web.UI.BoxedDialog(options);
};

PD.Web.UI.BoxedDialog.warn = function (options) {
    return PD.Web.UI.MessageDialog.warn(options, PD.Web.UI.BoxedDialog);
};

PD.Web.UI.BoxedDialog.info = function (options) {
    return PD.Web.UI.MessageDialog.info(options, PD.Web.UI.BoxedDialog);
};

PD.Web.UI.BoxedDialog.error = function (options) {
    return PD.Web.UI.MessageDialog.error(options, PD.Web.UI.BoxedDialog);
};

PD.Web.UI.BoxedDialog.success = function (options) {
    return PD.Web.UI.MessageDialog.success(options, PD.Web.UI.BoxedDialog);
};