<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="indexTitle" ContentPlaceHolderID="TitleContent" runat="server">
    Home Page
</asp:Content>

<asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server">

    <%= Html.Telerik().Editor()
            .Name("Editor")
            .Value("<ul><li>One Tree Hill</li><li>Two And a Half Men</li><li>Three Days Grace</li></ul>")
            .ClientEvents(events => events
                .OnSelectionChange("onSelectionChange")
            )
    %>

    <script type="text/javascript">
        var contentArea, contentWrap, initialHeight;

        function onSelectionChange(e) {
            if (!contentWrap) {
                var editor = $('#Editor');
                contentWrap = editor.find('.t-content')[0];
                contentArea = contentWrap.contentWindow.document.body;
                initialHeight = $(contentWrap).height();
            }

            var endHeight;

            if ($.browser.msie) {
                if ($.browser.version < 8)
                    endHeight = contentArea.scrollHeight + 45;
                else
                    endHeight = contentArea.scrollHeight - 1;
            } else
                endHeight = contentArea.offsetHeight + 45;

            $(contentWrap).height(Math.max(initialHeight, endHeight));
        }
    </script>

</asp:Content>
