From 5fd5852a68a16dfefde0f9ea4abac22ba5fb996d Mon Sep 17 00:00:00 2001 From: hartvig Date: Tue, 24 Aug 2010 07:57:38 +0000 Subject: [PATCH] Implements 28647, cache panel sizes [TFS Changeset #76338] --- components/umbraco.controls/Panel.cs | 109 +++++++--- .../umbraco/masterpages/umbracoPage.Master | 2 + .../umbracoPage.Master.designer.cs | 9 + umbraco/presentation/umbraco/umbraco.aspx | 205 ++++++++++-------- .../umbraco_client/Panel/javascript.js | 4 + 5 files changed, 199 insertions(+), 130 deletions(-) diff --git a/components/umbraco.controls/Panel.cs b/components/umbraco.controls/Panel.cs index d28db359a1..8001445d02 100644 --- a/components/umbraco.controls/Panel.cs +++ b/components/umbraco.controls/Panel.cs @@ -9,30 +9,54 @@ using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using ClientDependency.Core; +using umbraco.BusinessLogic; -namespace umbraco.uicontrols { +namespace umbraco.uicontrols +{ - [ClientDependency(ClientDependencyType.Javascript, "panel/javascript.js", "UmbracoClient")] - [ClientDependency(ClientDependencyType.Css, "panel/style.css", "UmbracoClient")] - public class UmbracoPanel : System.Web.UI.WebControls.Panel { + [ClientDependency(ClientDependencyType.Javascript, "panel/javascript.js", "UmbracoClient")] + [ClientDependency(ClientDependencyType.Css, "panel/style.css", "UmbracoClient")] + public class UmbracoPanel : System.Web.UI.WebControls.Panel + { private ScrollingMenu _menu = new ScrollingMenu(); - public UmbracoPanel() { + public UmbracoPanel() + { } - protected override void OnInit(EventArgs e) { + protected override void OnInit(EventArgs e) + { + // We can grab the cached window size from cookie values + if (AutoResize) + { + if (!String.IsNullOrEmpty(StateHelper.GetCookieValue("umbPanel_pWidth"))) + { + int pWidth = 0; + int pHeight = 0; + if (int.TryParse(StateHelper.GetCookieValue("umbPanel_pWidth"), out pWidth)) + { + Width = Unit.Pixel(pWidth); + } + if (int.TryParse(StateHelper.GetCookieValue("umbPanel_pHeight"), out pHeight)) + { + Height = Unit.Pixel(pHeight); + } + } + } + setupMenu(); } - protected override void OnLoad(System.EventArgs EventArguments) { + protected override void OnLoad(System.EventArgs EventArguments) + { _menu.Visible = hasMenu; - if(_autoResize) + if (_autoResize) this.Page.ClientScript.RegisterStartupScript(this.GetType(), "PanelEvents", "jQuery(document).ready(function() {jQuery(window).load(function(){ resizePanel('" + this.ClientID + "', " + this.hasMenu.ToString().ToLower() + ",true); }) });", true); - //this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "PanelEvents", ""); + //this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "PanelEvents", ""); } private bool _hasMenu = false; @@ -40,19 +64,24 @@ namespace umbraco.uicontrols { private string _text; private bool _autoResize = true; - public bool hasMenu { + public bool hasMenu + { get { return _hasMenu; } set { _hasMenu = value; } } - public bool AutoResize { + public bool AutoResize + { get { return _autoResize; } set { _autoResize = value; } } - public string Text { - get { - if (_text == "") { + public string Text + { + get + { + if (_text == "") + { _text = " "; } return _text; @@ -61,29 +90,35 @@ namespace umbraco.uicontrols { set { _text = value; } } - public string StatusBarText { + public string StatusBarText + { get { return _StatusBarText; } set { _StatusBarText = value; } } - public ScrollingMenu Menu { + public ScrollingMenu Menu + { get { return _menu; } } - internal void setupMenu() { - _menu.ID = this.ID + "_menu"; - if (this.Width.Value < 20) - this.Width = Unit.Pixel(24); - _menu.Width = (int)Unit.Pixel((int)this.Width.Value - 20).Value; - this.Controls.Add(_menu); + internal void setupMenu() + { + _menu.ID = this.ID + "_menu"; + if (this.Width.Value < 20) + this.Width = Unit.Pixel(24); + _menu.Width = (int)Unit.Pixel((int)this.Width.Value - 20).Value; + this.Controls.Add(_menu); } - - protected override void Render(System.Web.UI.HtmlTextWriter writer) { + + protected override void Render(System.Web.UI.HtmlTextWriter writer) + { base.CreateChildControls(); - - try { - if (System.Web.HttpContext.Current == null) { + + try + { + if (System.Web.HttpContext.Current == null) + { writer.WriteLine("Number of child controls : " + this.Controls.Count); } writer.WriteLine("
"); @@ -91,8 +126,9 @@ namespace umbraco.uicontrols { writer.WriteLine("

" + this.Text + "

"); writer.WriteLine("
"); writer.WriteLine("
"); - - if (this.hasMenu) { + + if (this.hasMenu) + { writer.WriteLine("
"); _menu.RenderControl(writer); writer.WriteLine("
"); @@ -103,18 +139,21 @@ namespace umbraco.uicontrols { if (this.hasMenu) upHeight = upHeight - 34; - + writer.WriteLine("
"); string styleString = ""; - foreach (string key in this.Style.Keys) { + foreach (string key in this.Style.Keys) + { styleString += key + ":" + this.Style[key] + ";"; } writer.WriteLine("
"); - foreach (Control c in this.Controls) { - if (!(c.ID == _menu.ID)) { + foreach (Control c in this.Controls) + { + if (!(c.ID == _menu.ID)) + { c.RenderControl(writer); } } @@ -130,7 +169,9 @@ namespace umbraco.uicontrols { writer.WriteLine(""); */ - } catch (Exception ex) { + } + catch (Exception ex) + { this.Page.Trace.Warn("Error rendering umbracopanel control" + ex.ToString()); } } diff --git a/umbraco/presentation/umbraco/masterpages/umbracoPage.Master b/umbraco/presentation/umbraco/masterpages/umbracoPage.Master index 95257dffe5..66197796df 100644 --- a/umbraco/presentation/umbraco/masterpages/umbracoPage.Master +++ b/umbraco/presentation/umbraco/masterpages/umbracoPage.Master @@ -17,6 +17,8 @@ Priority="0" /> + protected global::ClientDependency.Core.Controls.JsInclude JsInclude8; + /// + /// JsInclude9 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude9; + /// /// JsInclude4 control. /// diff --git a/umbraco/presentation/umbraco/umbraco.aspx b/umbraco/presentation/umbraco/umbraco.aspx index 6e55e505f7..17a2725fcf 100644 --- a/umbraco/presentation/umbraco/umbraco.aspx +++ b/umbraco/presentation/umbraco/umbraco.aspx @@ -1,114 +1,128 @@ <%@ Page Trace="false" Language="c#" CodeBehind="umbraco.aspx.cs" AutoEventWireup="True" - Inherits="umbraco.cms.presentation._umbraco" %> + Inherits="umbraco.cms.presentation._umbraco" %> <%@ Register Src="controls/Tree/TreeControl.ascx" TagName="TreeControl" TagPrefix="umbraco" %> <%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %> <%@ Register TagPrefix="uc1" TagName="quickSearch" Src="Search/QuickSearch.ascx" %> <%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %> - - - Umbraco CMS - <%=Request.Url.Host.ToLower().Replace("www.", "") %> - - - - - - - - - - - - - - - - - - - - - + Umbraco CMS - + <%=Request.Url.Host.ToLower().Replace("www.", "") %> + + + + + + + + + + + + + + + + + + + - - - -
- - - - - - - - - - - -
-
-
-
- -
- -
- -
-
-
- - - -
-
-
-   -
-
- - - - -
    - -
-
-
-
- - -
-
- +
+ + + + + + + + + + + +
+
+
+
+ +
+ +
+ +
+
+
+ + + +
+
+
+ +   +
+
+ + + + +
    + +
+
+
+
+ + +
+
- - -
-
- -
-
× -
-
- + +
+
+
+
+
+ × +
+ +
+
- diff --git a/umbraco/presentation/umbraco_client/Panel/javascript.js b/umbraco/presentation/umbraco_client/Panel/javascript.js index 8a72f77eba..9413d58234 100644 --- a/umbraco/presentation/umbraco_client/Panel/javascript.js +++ b/umbraco/presentation/umbraco_client/Panel/javascript.js @@ -43,4 +43,8 @@ function resizePanelTo(PanelName, hasMenu, pWidth, pHeight) { jQuery("#" + PanelName + "_menu_slh").width(scrollwidth); jQuery("#" + PanelName + "_menubackground").width(panelWidth - 2); } + + // set cookies + jQuery.cookie('umbPanel_pWidth', pWidth); + jQuery.cookie('umbPanel_pHeight', pHeight); }