Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Web/Web/UI/Controls
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv28796
Modified Files:
Head.cs
Log Message:
fixed SPRNET-723 (made Head control adhere to standards)
Index: Head.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Web/Web/UI/Controls/Head.cs,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Head.cs 24 Jul 2007 14:32:58 -0000 1.7
--- Head.cs 28 Nov 2007 23:26:19 -0000 1.8
***************
*** 48,51 ****
--- 48,65 ----
public class Head : Control
{
+ private string _defaultStyleType = "text/css";
+
+ /// <summary>
+ /// Gets or sets the default mimetype for the <style> element's 'type' attribute
+ /// </summary>
+ /// <remarks>
+ /// Defaults to "text/css"
+ /// </remarks>
+ public string DefaultStyleType
+ {
+ get { return _defaultStyleType; }
+ set { _defaultStyleType = value; }
+ }
+
/// <summary>
/// Gets a reference to the <see cref="T:Spring.Web.UI.Page"/> instance that contains the
***************
*** 71,74 ****
--- 85,89 ----
bool hasIntrinsicHead = (this.Page.Header != null);
#endif
+ // don't render begin/end element if we are nested within an ASP.NET <head> control
if (!hasIntrinsicHead)
{
***************
*** 91,99 ****
if (Page.Styles.Count > 0)
{
writer.RenderBeginTag(HtmlTextWriterTag.Style);
!
foreach (DictionaryEntry style in Page.Styles)
{
! writer.WriteLine(style.Key + " { " + style.Value + "}");
}
writer.RenderEndTag();
--- 106,115 ----
if (Page.Styles.Count > 0)
{
+ writer.AddAttribute(HtmlTextWriterAttribute.Type, _defaultStyleType);
writer.RenderBeginTag(HtmlTextWriterTag.Style);
!
foreach (DictionaryEntry style in Page.Styles)
{
! writer.WriteLine(style.Key + " { " + style.Value + " }");
}
writer.RenderEndTag();
***************
*** 104,113 ****
{
foreach (DictionaryEntry file in Page.StyleFiles)
! {
! writer.AddAttribute("rel", "stylesheet");
writer.AddAttribute(HtmlTextWriterAttribute.Type, "text/css");
writer.AddAttribute(HtmlTextWriterAttribute.Href, WebUtils.CreateAbsolutePath(Page.CssRoot, (string)file.Value));
!
! writer.RenderBeginTag(HtmlTextWriterTag.Link);
writer.RenderEndTag();
}
--- 120,129 ----
{
foreach (DictionaryEntry file in Page.StyleFiles)
! {
! writer.AddAttribute("rel", "stylesheet");
writer.AddAttribute(HtmlTextWriterAttribute.Type, "text/css");
writer.AddAttribute(HtmlTextWriterAttribute.Href, WebUtils.CreateAbsolutePath(Page.CssRoot, (string)file.Value));
!
! writer.RenderBeginTag(HtmlTextWriterTag.Link);
writer.RenderEndTag();
}
***************
*** 119,125 ****
{
object script = scriptEntry.Value;
! if (script is ScriptBlock)
{
! RenderScriptBlock(writer, script as ScriptBlock);
}
else if (script is ScriptFile)
--- 135,141 ----
{
object script = scriptEntry.Value;
! if (script is ScriptEvent)
{
! RenderScriptEvent(writer, script as ScriptEvent);
}
else if (script is ScriptFile)
***************
*** 127,133 ****
RenderScriptFile(writer, script as ScriptFile);
}
! else if (script is ScriptEvent)
{
! RenderScriptEvent(writer, script as ScriptEvent);
}
}
--- 143,149 ----
RenderScriptFile(writer, script as ScriptFile);
}
! else if (script is ScriptBlock)
{
! RenderScriptBlock(writer, script as ScriptBlock);
}
}
***************
*** 136,142 ****
private void RenderScriptBlock(HtmlTextWriter writer, ScriptBlock script)
{
! writer.AddAttribute("language", script.Language);
!
! writer.RenderBeginTag(HtmlTextWriterTag.Script);
writer.WriteLine(script.Script);
writer.RenderEndTag();
--- 152,157 ----
private void RenderScriptBlock(HtmlTextWriter writer, ScriptBlock script)
{
! RenderCommonScriptAttributes(writer, script);
! writer.RenderBeginTag(HtmlTextWriterTag.Script);
writer.WriteLine(script.Script);
writer.RenderEndTag();
***************
*** 145,152 ****
private void RenderScriptFile(HtmlTextWriter writer, ScriptFile script)
{
! writer.AddAttribute("language", script.Language);
! writer.AddAttribute(HtmlTextWriterAttribute.Src, WebUtils.CreateAbsolutePath(Page.ScriptsRoot, script.FileName));
!
! writer.RenderBeginTag(HtmlTextWriterTag.Script);
writer.RenderEndTag();
}
--- 160,167 ----
private void RenderScriptFile(HtmlTextWriter writer, ScriptFile script)
{
! RenderCommonScriptAttributes(writer, script);
! writer.AddAttribute(HtmlTextWriterAttribute.Src, WebUtils.CreateAbsolutePath(Page.ScriptsRoot, script.FileName));
!
! writer.RenderBeginTag(HtmlTextWriterTag.Script);
writer.RenderEndTag();
}
***************
*** 154,165 ****
private void RenderScriptEvent(HtmlTextWriter writer, ScriptEvent script)
{
! writer.AddAttribute("language", script.Language);
! writer.AddAttribute(HtmlTextWriterAttribute.For, script.Element);
writer.AddAttribute("event", script.EventName);
!
! writer.RenderBeginTag(HtmlTextWriterTag.Script);
writer.WriteLine(script.Script);
writer.RenderEndTag();
}
}
}
\ No newline at end of file
--- 169,189 ----
private void RenderScriptEvent(HtmlTextWriter writer, ScriptEvent script)
{
! RenderCommonScriptAttributes(writer, script);
! writer.AddAttribute(HtmlTextWriterAttribute.For, script.Element);
writer.AddAttribute("event", script.EventName);
!
! writer.RenderBeginTag(HtmlTextWriterTag.Script);
writer.WriteLine(script.Script);
writer.RenderEndTag();
}
+
+ private void RenderCommonScriptAttributes(HtmlTextWriter writer, Script script)
+ {
+ if (StringUtils.HasLength(script.Language))
+ {
+ writer.AddAttribute("language", script.Language);
+ }
+ writer.AddAttribute("type", script.Type.ToString());
+ }
}
}
\ No newline at end of file
|