void WriteTabs(IEnumerable <TabItem> lst) { foreach (TabItem ti in lst) { if (String.IsNullOrEmpty(ti.Text)) { continue; } if (ti.Roles.Count > 0 && !ti.Roles.Contains(m_userRole)) { continue; } bool fHideChildren = false; if (TabItemBound != null) { TabBoundEventArgs tbe = new TabBoundEventArgs(ti); TabItemBound(this, tbe); if (tbe.Cancel) { continue; } fHideChildren = tbe.SuppressChildren; } if (ti.ID == SelectedItem) { m_tw.AddAttribute(HtmlTextWriterAttribute.Class, "current"); } m_tw.RenderBeginTag(HtmlTextWriterTag.Li); m_tw.AddAttribute(HtmlTextWriterAttribute.Href, ResolveUrl(ti.Link)); m_tw.AddAttribute(HtmlTextWriterAttribute.Id, "tabID" + ti.ID.ToString()); m_tw.AddAttribute(HtmlTextWriterAttribute.Class, "topTab"); m_tw.RenderBeginTag(HtmlTextWriterTag.A); m_tw.InnerWriter.Write(ti.Text); m_tw.RenderEndTag(); // Anchor tag if (this.MenuStyle == HoverStyle.HoverPop && ti.Children != null && ti.Children.Count() > 0 && !fHideChildren) { m_tw.RenderBeginTag(HtmlTextWriterTag.Ul); WriteTabs(ti.Children); m_tw.RenderEndTag(); // ul tag. } m_tw.RenderEndTag(); // li tag } }
void WriteTabs(IEnumerable <TabItem> lst, int level = 0) { // Issue #392: // Hack for Android touch devices: since there's no hover on a touch device, you have to tap it. // On iOS, the first tap is the "hover" and a 2nd tap is the actual click. // But on Android, the first tap does both, which makes selecting from a menu hard. // So an android, we'll set the top-level menu URL to "#" and have it return false in on-click to prevent a navigation. bool fAndroidHack = (level == 0 && NeedsAndroidHack); foreach (TabItem ti in lst) { if (String.IsNullOrEmpty(ti.Text)) { continue; } if (ti.Roles.Count > 0 && !ti.Roles.Contains(m_userRole)) { continue; } bool fHideChildren = false; if (TabItemBound != null) { TabBoundEventArgs tbe = new TabBoundEventArgs(ti); TabItemBound(this, tbe); if (tbe.Cancel) { continue; } fHideChildren = tbe.SuppressChildren; } if (ti.ID == SelectedItem) { m_tw.AddAttribute(HtmlTextWriterAttribute.Class, "current"); } m_tw.RenderBeginTag(HtmlTextWriterTag.Li); if (fAndroidHack) { m_tw.AddAttribute(HtmlTextWriterAttribute.Onclick, "return false;"); } m_tw.AddAttribute(HtmlTextWriterAttribute.Href, fAndroidHack ? "#" : ResolveUrl(ti.Link)); m_tw.AddAttribute(HtmlTextWriterAttribute.Id, "tabID" + ti.ID.ToString()); m_tw.AddAttribute(HtmlTextWriterAttribute.Class, "topTab"); m_tw.RenderBeginTag(HtmlTextWriterTag.A); m_tw.InnerWriter.Write(ti.Text); m_tw.RenderEndTag(); // Anchor tag if (this.MenuStyle == HoverStyle.HoverPop && ti.Children != null && ti.Children.Count() > 0 && !fHideChildren) { m_tw.RenderBeginTag(HtmlTextWriterTag.Ul); WriteTabs(ti.Children, level + 1); m_tw.RenderEndTag(); // ul tag. } m_tw.RenderEndTag(); // li tag } }