Пример #1
0
        protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            base.CreateChildControls();

            try
            {
                if (System.Web.HttpContext.Current == null)
                {
                    writer.WriteLine("Number of child controls : " + this.Controls.Count);
                }
                writer.WriteLine("<div id=\"" + this.ClientID + "\" class=\"panel\" style=\"height:" + this.Height.Value + "px;width:" + this.Width.Value + "px;\">");
                writer.WriteLine("<div class=\"boxhead\">");
                writer.WriteLine("<h2 id=\"" + this.ClientID + "Label\">" + this.Text + "</h2>");
                writer.WriteLine("</div>");
                writer.WriteLine("<div class=\"boxbody\">");

                if (this.hasMenu)
                {
                    writer.WriteLine("<div id='" + this.ClientID + "_menubackground' class=\"menubar_panel\">");
                    _menu.RenderControl(writer);
                    writer.WriteLine("</div>");
                }

                int upHeight = (int)this.Height.Value - 46;
                int upWidth  = (int)this.Width.Value - 5;

                if (this.hasMenu)
                {
                    upHeight = upHeight - 34;
                }

                writer.WriteLine("<div id=\"" + this.ClientID + "_content\" class=\"content\" style=\"width: auto; height:" + (upHeight) + "px;\">");

                string styleString = "";

                foreach (string key in this.Style.Keys)
                {
                    styleString += key + ":" + this.Style[key] + ";";
                }

                writer.WriteLine("<div class=\"innerContent\" id=\"" + this.ClientID + "_innerContent\" style='" + styleString + "'>");
                foreach (Control c in this.Controls)
                {
                    if (!(c.ID == _menu.ID))
                    {
                        c.RenderControl(writer);
                    }
                }

                writer.WriteLine("</div>");
                writer.WriteLine("</div>");
                writer.WriteLine("</div>");
                writer.WriteLine("<div class=\"boxfooter\"><div class=\"statusBar\"><h2>" + this.StatusBarText + "</h2></div></div>");
                writer.WriteLine("</div>");

                /*
                 * if(_autoResize)
                 *  writer.WriteLine("<script type=\"text/javascript\">jQuery(document).ready(function(){ resizePanel('" + this.ClientID + "', " + this.hasMenu.ToString().ToLower() + ");});</script>");
                 */
            }
            catch (Exception ex)
            {
                this.Page.Trace.Warn("Error rendering umbracopanel control" + ex.ToString());
            }
        }
Пример #2
0
        protected override void Render(HtmlTextWriter writer)
        {
            EnsureChildControls();

            var jsEventCode = new StringBuilder();


            if (CodeMirrorEnabled == false)
            {
                CodeTextBox.RenderControl(writer);
                jsEventCode.Append(RenderBasicEditor());
            }
            else
            {
                writer.WriteBeginTag("div");
                writer.WriteAttribute("id", this.ClientID);
                writer.WriteAttribute("class", "umb-editor umb-codeeditor " + this.CssClass);
                this.ControlStyle.AddAttributesToRender(writer);
                writer.Write(HtmlTextWriter.TagRightChar);
                Menu.RenderControl(writer);

                writer.WriteBeginTag("div");
                writer.WriteAttribute("class", "code-container");
                this.ControlStyle.AddAttributesToRender(writer);
                writer.Write(HtmlTextWriter.TagRightChar);
                CodeTextBox.RenderControl(writer);
                writer.WriteEndTag("div");
                writer.WriteEndTag("div");

                jsEventCode.Append(RenderCodeEditor());
            }

            jsEventCode.Append(@"   
					//TODO: for now this is a global var, need to refactor all this so that is using proper js standards
					//with correct objects, and proper accessors to these objects.
					var UmbEditor;                 
                    $(document).ready(function () {
                        //create the editor
                       UmbEditor = new Umbraco.Controls.CodeEditor.UmbracoEditor(" + (CodeMirrorEnabled == false).ToString().ToLower() + @", '" + ClientID + @"');");

            if (this.AutoResize)
            {
                if (CodeMirrorEnabled)
                {
                    //reduce the width if using code mirror because of the line numbers
                    OffSetX += 20;
                    OffSetY += 50;
                }

                //add the resize code
                jsEventCode.Append(@"
                        var m_textEditor = jQuery('#" + ClientID + @"');
                   
                       //with codemirror adding divs for line numbers, we need to target a different element
                       m_textEditor = m_textEditor.find('iframe').length > 0 ? m_textEditor.children('div').get(0) : m_textEditor.get(0);
                   
                       jQuery(window).resize(function(){  resizeTextArea(m_textEditor, " + OffSetX + "," + OffSetY + @"); });
                       jQuery(document).ready(function(){  resizeTextArea(m_textEditor, " + OffSetX + "," + OffSetY + @"); });");
            }

            jsEventCode.Append(@"                       
                    });");

            writer.WriteLine(@"<script type=""text/javascript"">{0}</script>", jsEventCode);
        }