public void ConfigureAccordion(Accordion ac) { ac .Rendering .SetPrettyRender(true) .Finish() .Options .SetCollapsible(this.collapsible) .SetDisabled(this.disabled) .SetAnimated(this.animated) .SetEvent(this.evt) .SetAutoHeight(this.autoHeight) .SetClearStyle(this.clearStyle) .SetFillSpace(this.fillSpace) .SetIcons(this.headerIconClass, this.headerSelectedIconClass) .SetNavigation(this.navigation) .SetNavigationFilter(this.navigationFilter) .Finish() .Panels .Add("My Panel 1", (this.activePanel == 0) ) .Add("My Panel 2", (this.activePanel == 1) ) .Add("My Panel 3", (this.activePanel == 2) ) ; if (this.showEvents) { ac.Events .SetCreateEvent("return createEvent(event, ui);") .SetChangeEvent("return changeEvent(event, ui);") .SetChangeStartEvent("return changeStartEvent(event, ui);") ; } if (!this.prettyRender) ac.Rendering.Compress(); if (this.renderCSS) ac.Rendering.ShowCSS(); }
public void ConfigureAccordion(Accordion ac) { ac .Rendering .SetPrettyRender(true) .Finish() .Options .SetCollapsible(this.collapsible) .SetDisabled(this.disabled) .SetAnimate(this.animate) .SetEvent(this.evt) .SetHeightStyle(this.heightStyle) .SetIcons(this.headerIconClass, this.activeHeaderIconClass) .Finish() .Panels .Add("My Panel 1", (this.activePanel == 0) ) .Add("My Panel 2", (this.activePanel == 1) ) .Add("My Panel 3", (this.activePanel == 2) ) ; if (this.showEvents) { ac.Events .SetCreateEvent("return createEvent(event, ui);") .SetActivateEvent("return activateEvent(event, ui);") .SetBeforeActivateEvent("return beforeActivateEvent(event, ui);") ; } if (!this.prettyRender) ac.Rendering.Compress(); if (this.renderCSS) ac.Rendering.ShowCSS(); }
internal static void ForceRender(Accordion acc) { using (acc.RenderContainer()) { for (int n=0; n < acc.Panels.ToList().Count(); n++) { using (acc.Panels.RenderNextPane()) { } // pane } // for } // container }
internal static Accordion SetupSimpleAccordionObject(TextWriter writer) { // nothing special, just create a simple dummy accordion helper as a starting point // (saves having the same code everywhere!) Accordion acc = new Accordion(writer, "myAccordion"); // leave the options to the calling test to set // define the test panels acc.Panels .Add("Pane #1") .Add("Pane #2") .Add("Pane #3") ; return acc; }
public string JavaScriptCode(Accordion ac) { return ac.GetStartUpScript(); }
public string CSharpCode(Accordion ac) { jStringBuilder sb = new jStringBuilder(true/*includeWhitespace*/, 0); sb.AppendTabsLineIf("<%"); sb.AppendTabsFormatLineIf("var ac = Html.CreateAccordion(\"{0}\")", ac.ID); string optionsCode = OptionsCSharpCode(); string showEventsCode = ShowEventsCSharpCode(); string renderCode = base.RenderCSharpCode(); sb.IncIndent(); if (optionsCode.Length > 0) { sb.AppendTabsLineIf(".Options"); sb.IncIndent(); sb.Append(optionsCode); sb.DecIndent(); sb.AppendTabsLineIf(".Finish()"); } if (showEventsCode.Length > 0) { sb.AppendTabsLineIf(".Events"); sb.IncIndent(); sb.Append(showEventsCode); sb.DecIndent(); sb.AppendTabsLineIf(".Finish()"); } if (renderCode.Length > 0) sb.Append(renderCode); sb.DecIndent(); sb.IncIndent(); sb.AppendTabsLineIf(".Panels"); sb.IncIndent(); sb.AppendTabsFormatLineIf(".Add(\"My Panel 1\"{0})", (this.activePanel == 0 ? ", true" : "") ); sb.AppendTabsFormatLineIf(".Add(\"My Panel 2\"{0})", (this.activePanel == 1 ? ", true" : "") ); sb.AppendTabsFormatLineIf(".Add(\"My Panel 3\"{0})", (this.activePanel == 2 ? ", true" : "") ); sb.DecIndent(); sb.AppendTabsLineIf(".Finish()"); sb.DecIndent(); sb.AppendTabsLineIf(";"); sb.AppendTabsLineIf("%>"); sb.AppendLineIf(); sb.AppendTabsLineIf("<%using (ac.RenderContainer()) {%>"); sb.IncIndent(); sb.AppendTabsLineIf("<%using (ac.Panels.RenderNextPane()) {%>"); sb.AppendTabsLineIf("\t<p>Proin ...</p>"); sb.AppendTabsLineIf("<%}%>"); sb.AppendTabsLineIf("<%using (ac.Panels.RenderNextPane()) {%>"); sb.AppendTabsLineIf("\t<p>Morbi ...</p>"); sb.AppendTabsLineIf("<%}%>"); sb.AppendTabsLineIf("<%using (ac.Panels.RenderNextPane()) {%>"); sb.AppendTabsLineIf("\t<p>Mauris ...</p>"); sb.AppendTabsLineIf("<%}%>"); sb.DecIndent(); sb.AppendTabsLineIf("<%}%>"); return sb.ToString(); }
public void Accordion_Can_Override_Container_HTML_And_Header_HTML_And_Content_HTML_Tags() { // Arrange var resp = new MockWriter(); var ac = new Accordion(resp, "myAccordion") .Rendering .Compress() .Finish() .Options .SetContainerTag("dl") .SetHeadingTag("dt") .SetContentTag("dd") .Finish() .Panels .Add("Panel #1") .Configure() .Header .Hyperlink .SetTitle("some external webpage") .SetURL("http://toepoke.co.uk") .Finish() .Finish() .Finish() .Add("Panel #2") .Add("Panel #3") .Finish() ; // Act TestHelper.ForceRender(ac); string html = resp.Output.ToString(); // Assert Assert.IsTrue(html.Contains("<dl id=\"myAccordion\"")); Assert.IsTrue(html.Contains("<dt><a href=\"http://toepoke.co.uk\">some external webpage</a>")); Assert.IsTrue(html.Contains("<dd></dd>")); // heading tag in the HTML should also change Assert.IsTrue(html.Contains("$(document).ready( function() {$(\"#myAccordion\").accordion({heading: \"dt\"});});")); }
public void Ensure_Invisible_Accordion_Panel_Is_Not_Rendered() { // Arrange var resp = new MockWriter(); var accordion = new Accordion(resp, "myAccordion") .Rendering .Compress() .SetRenderCSS(true) .Finish() .Panels .Add("Panel #1") .Add("Panel #2") .Configure() .SetVisibility(false) .Finish() .Add("Panel #3") .Finish() ; // only testing raw output TestHelper.ForceRender(accordion); // Act string html = resp.Output.ToString(); // Assert Assert.IsTrue (html.Contains("<div id=\"myAccordion\" class=\"ui-accordion ui-widget ui-helper-reset ui-accordion-icons\"")); Assert.IsTrue (html.Contains("<h3 class=\"ui-accordion-header ui-helper-reset ui-state-default ui-state-active ui-corner-top\">Panel #1</h3>")); Assert.IsFalse(html.Contains("<h3 class=\"ui-accordion-header ui-helper-reset ui-state-default ui-corner-all\">Panel #2</h3>")); Assert.IsTrue (html.Contains("<h3 class=\"ui-accordion-header ui-helper-reset ui-state-default ui-corner-all\">Panel #3</h3>")); }
public void Accordion_Can_Override_Container_HTML_And_Header_HTML_And_Content_HTML_Tags() { // Arrange var resp = new MockWriter(); var ac = new Accordion(resp, "myAccordion") .Rendering .Compress() .Finish() .Options .SetContainerTag("dl") .SetHeadingTag("dt") .SetContentTag("dd") .Finish() .Panels .Add("Panel #1") .Add("Panel #2") .Add("Panel #3") .Finish() ; // Act TestHelper.ForceRender(ac); string html = resp.Output.ToString(); // Assert Assert.IsTrue(html.Contains("<dl id=\"myAccordion\"")); Assert.IsTrue(html.Contains("<dt>Panel #1</dt>")); Assert.IsTrue(html.Contains("<dd></dd>")); // heading tag in the HTML should also change Assert.IsTrue(html.Contains("$(document).ready( function() {$(\"#myAccordion\").accordion({heading: \"dt\"});});")); }
public void Accordion_Header_With_Custom_Attribute_CSS_Delivers_Correct_CSS_Classes() { // Arrange var resp = new MockWriter(); Accordion acc = new Accordion(resp, "myAccordion") .Panels .Add("Pane #1") .Configure() .Header .WithStyle("font-size", "xx-large") .Finish() .Finish() .Add("Pane #2") .Add("Pane #3") .Finish() ; // only testing raw output TestHelper.ForceRender(acc); // Act string html = resp.Output.ToString(); // Assert Assert.IsTrue(html.Contains("<h3 style=\"font-size:xx-large\">")); }
public void Accordion_Can_Set_ID_On_Panel() { // Arrange var resp = new MockWriter(); var accordion = new Accordion(resp, "myAccordion") .Rendering .Compress() .SetRenderCSS(true) .Finish() .Panels .Add("<a href=\"http://blog.toepoke.co.uk\" id=\"blog-link-id\">blog</a>") .Configure() .Header .WithID("blog-header-id") .Finish() .Finish() .Add("Panel #2") .Finish() ; // only testing raw output TestHelper.ForceRender(accordion); // Act string html = resp.Output.ToString(); // Assert Assert.IsTrue(html.Contains("<div id=\"myAccordion\" class=\"ui-accordion ui-widget ui-helper-reset ui-accordion-icons\"")); Assert.IsTrue(html.Contains("<h3 id=\"blog-header-id\" class=\"ui-accordion-header ui-helper-reset ui-state-default ui-state-active ui-corner-top\"")); Assert.IsTrue(html.Contains("<a href=\"http://blog.toepoke.co.uk\" id=\"blog-link-id\">blog</a>")); }
/// <summary> /// Constructor /// </summary> /// <param name="accordion">Accordion object to configure rendering options for</param> public Rendering(Accordion accordion) : base() { this.Accordion = accordion; }
public string JavaScriptCode(Accordion ac) { ac.Rendering.SetPrettyRender(true); return ac.GetStartUpScript(); }
/// <summary> /// Detailed constructor /// </summary> /// <param name="writer">HttpResponse object to render the accordion onto</param> /// <param name="owner">Accordions object the panel belongs to</param> /// <param name="title">Title to appear in the accordion panel</param> /// <param name="isActive">Flags whether this panel is the active one</param> public Panel(TextWriter writer, Accordion owner, string title, bool isActive) { this.OnAccordion = owner; this.Header = new Header(this); this._Writer = writer; this.Title = title; this.IsActive = isActive; }
/// <summary> /// Constructor /// </summary> /// <param name="accordion">Accordion object to be configured</param> public Options(Accordion accordion) : base() { this.Accordion = accordion; this.Reset(); }
/// <summary> /// Creates an accordion control from the given HTML helper object (which can then /// be configured and rendered). /// </summary> /// <param name="page">WebForms page to render the control onto</param> /// <param name="id">ID to give to the accordion (must be unique on the page)</param> /// <param name="headingTag">Heading tag to use for the accordion panels (defaults to H3)</param> /// <returns>Created accoridon control</returns> public static Accordion CreateAccordion(this System.Web.UI.Page page, string id, string headingTag) { TextWriter writer = page.Response.Output; Accordion newAccordion = new Accordion(writer, id, headingTag); return newAccordion; }
/// <summary> /// Creates an accordion control from the given HTML helper object (which can then /// be configured and rendered). /// </summary> /// <param name="html">Html helper (used to get the HttpResponse object to render onto)</param> /// <param name="id">ID to give to the accordion (must be unique on the page)</param> /// <param name="headingTag">Heading tag to use for the accordion panels (defaults to H3)</param> /// <returns>Created accoridon control</returns> public static Accordion CreateAccordion(this HtmlHelper html, string id, string headingTag) { TextWriter writer = html.ViewContext.Writer; Accordion newAccordion = new Accordion(writer, id, headingTag); return newAccordion; }
/// <summary> /// Constructor /// </summary> /// <param name="accordion">Accordion object the panels are related to.</param> public Panels(Accordion accordion) : base() { this.Accordion = accordion; this._Panels = new List<Panel>(); }
/// <summary> /// Constructor /// </summary> /// <param name="ac">Accordion object to call</param> public Methods(Accordion ac) : base(ac) { }
/// <summary> /// Constructor /// </summary> /// <param name="accordion">Accordion object to configure events for</param> public Events(Accordion accordion) : base() { this.Accordion = accordion; this.Reset(); }