/// class PD.Manage.Modules.MaintenanceMode

PD.Manage.Modules.MaintenanceMode =
PD.Manage.Module.extend({

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

    _grid: null,
    
    //===================================
    // EVENT HANDLERS
    //===================================

    onInit: function (e) {
        this._status_init();
        this._users_init();
        this._message_init();
    },

    prepare: function () {

        var that = this;

        PD.ajax({
            url: PD.Path.resolve("~/Manage/Maintenance/Index"),
            success: function (data) {
                that.data("maintenanceSettings", data);
                that.ready();
            },
            error: function (e) {
                that.error();
                e.errorHandled = true;
            }
        });

    },

    //===================================
    // PROTECTED METHODS
    //===================================

    template: function (e) {
        return [
            "<div class='-pd-maintenance-mode'>",
            "</div>"
        ];
    },

    focus: function () {
        this._super();
    },

    //===================================
    // PRIVATE METHODS
    //===================================

    _status_init: function () {

        var control = new PD.Manage.Modules.Maintenance.MaintenanceStatus(this.data("maintenanceSettings"));

        this.get_children().add(control);

    },

    _users_init: function () {

        var control = new PD.Manage.Modules.Maintenance.MaintenanceUsers(this.data("maintenanceSettings"));

        this.get_children().add(control);

    },

    _message_init: function () {

        var control = new PD.Manage.Modules.Maintenance.MaintenanceMessage(this.data("maintenanceSettings"));

        this.get_children().add(control);

    }
    
});