<%@ 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 editor, contentArea, contentWrap, initialHeight;

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

            var lastChild = $(contentArea.lastChild, editor.document);
            var endHeight = lastChild.offset().top + lastChild.height() + 45;

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

</asp:Content>
