Beispiel #1
0
		public void ConfigureTabs(Tabs tabs) {
			tabs
				.Rendering
					.SetPrettyRender(true)
				.Finish()
				.Options
					.SetCollapsible(this.collapsible)
					.SetDisabled(this.disabled)
					.SetEffect(this.fx)
					.SetEvent(this.evt)
					.Finish()
				.Panes
					.Add("tab1", "Tab #1", (this.selectedTab == 0) )
					.Add("tab2", "Tab #2", (this.selectedTab == 1) )
					.Add("tab3", "Tab #3", (this.selectedTab == 2) )
				.Finish()
			;

			if (this.showEvents) {
				tabs.Events
					.SetCreateEvent("return createEvent(event, ui);")
					.SetSelectEvent("return selectEvent(event, ui);")
					.SetLoadEvent("return loadEvent(event, ui);")
					.SetShowEvent("return showEvent(event, ui);")
					.SetAddEvent("return addEvent(event, ui);")
					.SetRemoveEvent("return removeEvent(event, ui);")
					.SetEnableEvent("return enableEvent(event, ui);")
					.SetDisableEvent("return disableEvent(event, ui);")
				;
			}
			if (!this.prettyRender)
				tabs.Rendering.Compress();
			if (this.renderCSS)
				tabs.Rendering.ShowCSS();
		}
Beispiel #2
0
#pragma warning restore 1591

		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="tabs">Tabs to configure options of</param>
		public Options(Tabs tabs)
		 : base()
		{
			this.Tabs = tabs;
			this.ShowAnimation = new AnimationOptions(this, "show");
			this.HideAnimation = new AnimationOptions(this, "hide");
			this.Evt = DEFAULT_EVENT;
			this.Collapsible = false;			
			this.DisabledArray = new List<int>();
		}
Beispiel #3
0
#pragma warning restore 1591

		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="tabs">Tabs to configure options of</param>
		public Options(Tabs tabs)
		 : base()
		{
			this.Tabs = tabs;
			this.Cookie = new CookieOptions(this);
			this.Fx = "";
			this.Evt = DEFAULT_EVENT;
			this.Collapsible = false;			
			this.DisabledArray = new List<int>();
		}
Beispiel #4
0
		public void ConfigureTabs(Tabs tabs) {
			tabs
				.Panes
					.Add("step1", "About you")
					.Add("step2", "Your game")
					.Add("finish", "Finish")
				.Finish()
				.Rendering
					.SetAutoScript(false)
					.SetTabDepth(1)
				.Finish();
		}
Beispiel #5
0
		public void ConfigureTabs(Tabs tabs) {
			tabs
				.Rendering
					.SetPrettyRender(true)
				.Finish()
				.Options
					.SetCollapsible(this.collapsible)
					.SetDisabled(this.disabled)
					.ShowAnimation
						.SetEffect(this.showEffect)
						.SetDuration(this.showDuration)
					.Finish()
					.HideAnimation
						.SetEffect(this.hideEffect)
						.SetDuration(this.hideDuration)
					.Finish()
				.Finish()
				.Panes
					.Add("tab1", "Tab #1", (this.selectedTab == 0) )
					.Add("tab2", "Tab #2", (this.selectedTab == 1) )
					.Add("tab3", "Tab #3", (this.selectedTab == 2) )
				.Finish()
			;

			if (this.showEvents) {
				tabs.Events
					.SetCreateEvent("return createEvent(event, ui);")
					.SetBeforeActivateEvent("return beforeActivateEvent(event, ui);")
					.SetLoadEvent("return loadEvent(event, ui);")
					.SetActivateEvent("return activateEvent(event, ui);")
					.SetBeforeLoadEvent("return beforeLoadEvent(event, ui);")
				;
			}
			if (!this.prettyRender)
				tabs.Rendering.Compress();
			if (this.renderCSS)
				tabs.Rendering.ShowCSS();
		}
Beispiel #6
0
		public void Ensure_Title_Of_Tab_Can_Be_Changed_After_Tab_Is_Created()
		{
			// Arrange
			var resp = new MockWriter();
			Tabs tabs = new Tabs(resp, "myTabs")
				.Panes
					.Add("tab1", "Tab #1")
					.Add("tab2", "Tab #2")
					.Add("tab3", "Tab #3")
						.Configure()
							// Test we can change the title from the detault if we wish
							.SetTitle("Changed Title")
							.Finish()
					.Finish()
				.Rendering
					.Compress()
				.Finish()
			;

			TestHelper.ForceRender(tabs);
			
			// Act - Force output we'd see on the web page
			string html = resp.Output.ToString();

			// Assert
			// 2 content panels (2nd is no longer rendered)
			Assert.IsTrue (html.Contains("<a href=\"#tab1\" title=\"Tab #1\">Tab #1</a>") );
			Assert.IsTrue (html.Contains("<a href=\"#tab2\" title=\"Tab #2\">Tab #2</a>") );
			Assert.IsTrue (html.Contains("<a href=\"#tab3\" title=\"Changed Title\">Changed Title</a>") );
		}
Beispiel #7
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="tabs">Tabs object to set rendering options of</param>
		public Rendering(Tabs tabs)
		 : base()
		{
			this.Tabs = tabs;
		}
Beispiel #8
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="tabs">Tabs object the panels belong to</param>
		public Panes(Tabs tabs)
		 : base()
		{
			this.Tabs = tabs;
			this._Panes = new Dictionary<string,Pane>();
		}
Beispiel #9
0
		public void Ensure_Invisible_Tab_Is_Not_Rendered()
		{
			// Arrange
			var resp = new MockWriter();
			Tabs tabs = new Tabs(resp, "myTabs")
				.Panes
					.Add("tab1", "Tab #1")
					.Add("tab2", "Tab #2")
						.Configure()
							// Mark the middle one as a non-render
							.SetVisibility(false)
							.Finish()							
					.Add("tab3", "Tab #3")
					.Finish()
				.Rendering
					.Compress()
				.Finish()
			;

			TestHelper.ForceRender(tabs);
			
			// Act - Force output we'd see on the web page
			string html = resp.Output.ToString();

			// Assert
			// 2 content panels (2nd is no longer rendered)
			Assert.IsTrue (html.Contains("<div id=\"tab1\"></div>") );
			Assert.IsFalse(html.Contains("<div id=\"tab2\"></div>") );
			Assert.IsTrue (html.Contains("<div id=\"tab3\"></div>") );
		}
Beispiel #10
0
		internal static void ForceRender(Tabs tabs)
		{
			using (tabs.RenderHeader()) {
				for (var tbNdx=0; tbNdx < tabs.Panes.ToDictionary().Count(); tbNdx++)
					using (tabs.Panes.RenderNextPane()) {}
			}
		}
Beispiel #11
0
		public void RenderNextPane_Throws_Exception_When_Tabs_Are_Added_Dynamically()
		{
			// Arrange
			var resp = new MockWriter();
			Tabs tabs = new Tabs(resp, "myTabs");

			// define the test tabs
			tabs
				.AsDynamic()
				.Panes
				.Add("http://someurl.com/tab1", "Tab 1")
				.Add("http://someurl.com/tab2", "Tab 2")
				.Add("http://someurl.com/tab3", "Tab 3")
			;

			// only testing raw output
			tabs
				.Rendering
					.SetAutoScript(false)
					.Compress()
			;

			// This should throw a wobbler
			TestHelper.ForceRender(tabs);

			Assert.Fail("NotSupportedException should have been thrown.");
		}
Beispiel #12
0
		public string CSharpCode(Tabs tabs) {
			jStringBuilder sb = new jStringBuilder(true/*includeWhitespace*/, 0);

			sb.AppendTabsLineIf("<%");
			sb.AppendTabsFormatLineIf("var tabs = Html.CreateTabs(\"{0}\")", tabs.ID);

			string optionsCode = OptionsCSharpCode();
			string showEventsCode = ShowEventsCSharpCode();
			string renderCode = base.RenderCSharpCode();
			bool showOptions = (optionsCode.Length > 0 || showEventsCode.Length > 0 || renderCode.Length > 0);

			if (showOptions) {
				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(".Panes");
			sb.IncIndent();
			sb.AppendTabsFormatLineIf(".Add(\"tab1\", \"Tab #1\"{0})", (this.selectedTab == 0 ? ", true" : "") );
			sb.AppendTabsFormatLineIf(".Add(\"tab2\", \"Tab #2\"{0})", (this.selectedTab == 1 ? ", true" : "") );
			sb.AppendTabsFormatLineIf(".Add(\"tab3\", \"Tab #3\"{0})", (this.selectedTab == 2 ? ", true" : "") );
			sb.DecIndent();
			sb.AppendTabsLineIf(".Finish();");
			sb.DecIndent();
			sb.AppendTabsLineIf("%>");

			sb.AppendLineIf();
			sb.AppendTabsLineIf("<%using (tabs.RenderHeader()) {%>");
			sb.IncIndent();
			sb.AppendTabsLineIf("<%using (tabs.Panes.RenderNextPane()) {%>");
			sb.AppendTabsLineIf("\t<p>Proin ...</p>");
			sb.AppendTabsLineIf("<%}%>");
			sb.AppendTabsLineIf("<%using (tabs.Panes.RenderNextPane()) {%>");
			sb.AppendTabsLineIf("\t<p>Morbi ...</p>");
			sb.AppendTabsLineIf("<%}%>");
			sb.AppendTabsLineIf("<%using (tabs.Panes.RenderNextPane()) {%>");
			sb.AppendTabsLineIf("\t<p>Mauris ...</p>");
			sb.AppendTabsLineIf("<%}%>");
			sb.DecIndent();
			sb.AppendTabsLineIf("<%}%>");
			
			return sb.ToString();
		}
Beispiel #13
0
		internal static Tabs SetupSimpleTabObject(TextWriter writer) 
		{
			// nothing special, just create a simple dummy tab helper as a starting point 
			// (saves having the same code everywhere!)
			Tabs ts = new Tabs(writer, "myTabs");

			// define the test tabs
			ts.Panes
				.Add("tab1", "Tab 1")
				.Add("tab2", "Tab 2")
				.Add("tab3", "Tab 3")
			;

			return ts;
		}
Beispiel #14
0
		public void Pretty_Dynamic_Tabs_Script_Renders_Correctly()
		{
			// Arrange
			var resp = new MockWriter();
			Tabs tabs = new Tabs(resp, "myTabs");

			// define the test tabs
			tabs
				.AsDynamic()
				.Panes
				.Add("http://someurl.com/tab1", "Tab 1")
				.Add("http://someurl.com/tab2", "Tab 2")
				.Add("http://someurl.com/tab3", "Tab 3")
			;

			// only testing raw output
			tabs
				.Rendering
					.SetAutoScript(false)
					.SetPrettyRender(true)
			;

			using (tabs.RenderHeader()) {
			}

			// Act - Force output we'd see on the web page
			string html = resp.Output.ToString();

			// Assert
			string expected = 
				"<div id=\"myTabs\">" + Environment.NewLine +
				"	<ul>" + Environment.NewLine + 
				"		<li>" + Environment.NewLine +
				"			<a href=\"http://someurl.com/tab1\"><span>Tab 1</span></a>" + Environment.NewLine +
				"		</li>" + Environment.NewLine +
				"		<li>" + Environment.NewLine +
				"			<a href=\"http://someurl.com/tab2\"><span>Tab 2</span></a>" + Environment.NewLine +
				"		</li>" + Environment.NewLine +
				"		<li>" + Environment.NewLine +
				"			<a href=\"http://someurl.com/tab3\"><span>Tab 3</span></a>" + Environment.NewLine +
				"		</li>" + Environment.NewLine +
				"	</ul>" + Environment.NewLine +
				"</div>" + Environment.NewLine;

			Assert.AreEqual(expected, html);
		}
Beispiel #15
0
		public string JavaScriptCode(Tabs tabs) {
			tabs.Rendering.SetPrettyRender(true);
			return tabs.GetStartUpScript();
		}
Beispiel #16
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="tabs">Tabs object to call</param>
		public Methods(Tabs tabs) : base(tabs)
		{
		}		
Beispiel #17
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="tabs">Tabs object to configure events for</param>
		public Events(Tabs tabs)
		 : base()
		{
			this.Tabs = tabs;
		}
Beispiel #18
0
		public string JavaScriptCode(Tabs tabs) {
			return tabs.GetStartUpScript();
		}
Beispiel #19
0
		/// <summary>
		/// Creates a Tabs control that can be configured and later rendered on the page.
		/// </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>
		/// <returns>Created Tabs control</returns>
		public static Tabs CreateTabs(this HtmlHelper html, string id) {
			TextWriter writer = html.ViewContext.Writer;
			Tabs newTabs = new Tabs(writer, id);

			return newTabs;
		}
Beispiel #20
0
		/// <summary>
		/// Creates a Tabs control that can be configured and later rendered on the page.
		/// </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>
		/// <returns>Created Tabs control</returns>
		public static Tabs CreateTabs(this System.Web.UI.Page page, string id) {
			TextWriter writer = page.Response.Output;
			Tabs newTabs = new Tabs(writer, id);

			return newTabs;
		}