﻿/// <reference name="MicrosoftAjax.js"/>

Type.registerNamespace("OS.Web");

OS.Web.HtmlArea = function(element) {
    OS.Web.HtmlArea.initializeBase(this, [element]);

    this._element = element;
    this._btnEdit = null;
    this._pnlContent = null;
    this._key = null;
}

OS.Web.HtmlArea.prototype = {
    initialize: function() {
        OS.Web.HtmlArea.callBaseMethod(this, 'initialize');

        $addHandler(this._element, "mouseover", Function.createDelegate(this, this.ShowEditButton));
        $addHandler(this._element, "mouseout", Function.createDelegate(this, this.HideEditButton));
        $addHandler(this._btnEdit, "click", Function.createDelegate(this, this.EditContent));
    },

    dispose: function() {
        //Add custom dispose actions here
        OS.Web.HtmlArea.callBaseMethod(this, 'dispose');
    },

    EditContent: function() {
        ShowPageModalDialog(Resources.Content,
            SITE_BASE_URL + "Modules/Core/IFrames/IHtmlAreaEditor.aspx?key=" + this._key, 685, 520,
            Function.createDelegate(this, this.OnContentChanged));
    },

    OnContentChanged: function(e, data) {
        if (e == OS.Web.DialogResult.Ok) {
            this._pnlContent.innerHTML = data;
        }
    },

    ShowEditButton: function() {
        Sys.UI.DomElement.addCssClass(this._btnEdit, "HtmlAreaEditButtonActive");
    },

    HideEditButton: function() {
        Sys.UI.DomElement.removeCssClass(this._btnEdit, "HtmlAreaEditButtonActive");
    },

    get_BtnEdit: function() {
        return this._btnEdit;
    },
    set_BtnEdit: function(value) {
        this._btnEdit = value;
    },

    get_PnlContent: function() {
        return this._pnlContent;
    },
    set_PnlContent: function(value) {
        this._pnlContent = value;
    },

    get_Key: function() {
        return this._key;
    },
    set_Key: function(value) {
        this._key = value;
    }
}
OS.Web.HtmlArea.registerClass('OS.Web.HtmlArea', Sys.UI.Control);

if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();




