/// <summary>
        /// The add mobile navigation node.
        /// </summary>
        /// <param name="htmlHelper">
        /// The html helper.
        /// </param>
        /// <param name="node">
        /// The node.
        /// </param>
        /// <param name="dataTheme">
        /// The data theme.
        /// </param>
        /// <param name="dataContentTheme">
        /// The data content theme.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public static string AddMobileNavigationNode(
            HtmlHelper htmlHelper, NavigationNode node, string dataTheme, string dataContentTheme)
        {
            var nodeOutput = new StringBuilder();

            if (node.Children.Count > 0)
            {
                nodeOutput.Append(
                    string.Format(
                        "<div data-role=\"collapsible\" data-theme=\"{0}\" data-content-theme=\"{1}\">",
                        dataTheme,
                        dataContentTheme));
            }

            if (node.Children.Count == 0)
            {
                nodeOutput.Append(
                    htmlHelper.ActionLink(
                        node.Name, node.Action, node.Controller, null, new { data_role = "button", rel = "external" }));
            }
            else
            {
                nodeOutput.Append(AddMobileSubMenu(htmlHelper, node.Children));
            }

            if (node.Children.Count > 0)
            {
                nodeOutput.Append("</div>");
            }

            return nodeOutput.ToString();
        }
Beispiel #2
0
 /// <summary>
 /// The add recursive.
 /// </summary>
 /// <param name="navigationNodes">
 /// The navigation nodes.
 /// </param>
 /// <param name="toAdd">
 /// The to add.
 /// </param>
 private void AddRecursive(IList<NavigationNode> navigationNodes, NavigationNode toAdd)
 {
     if (navigationNodes.Contains(toAdd))
     {
         foreach (NavigationNode node in toAdd.Children)
         {
             this.AddRecursive(navigationNodes.Single(x => x.Name == toAdd.Name).Children, node);
         }
     }
     else
     {
         navigationNodes.Add(toAdd);
     }
 }
Beispiel #3
0
 /// <summary>
 /// The add internal.
 /// </summary>
 /// <param name="path">
 /// The path.
 /// </param>
 private void AddInternal(NavigationNode path)
 {
     this.AddRecursive(this.NavigationNodes, path);
 }
        /// <summary>
        /// The equals.
        /// </summary>
        /// <param name="other">
        /// The other.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public virtual bool Equals(NavigationNode other)
        {
            if (this.Name == other.Name)
            {
                return true;
            }

            return false;
        }
        /// <summary>
        /// The add navigation node.
        /// </summary>
        /// <param name="htmlHelper">
        /// The html helper.
        /// </param>
        /// <param name="node">
        /// The node.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public static string AddNavigationNode(HtmlHelper htmlHelper, NavigationNode node)
        {
            var nodeOutput = new StringBuilder();

            if (node.Children.Count == 0)
            {
                nodeOutput.Append("<li>");
            }
            else
            {
                nodeOutput.Append("<li class=\"dropdown\">");
            }

            if (node.Children.Count == 0)
            {
                if (node.HasMvcUrl)
                {
                    nodeOutput.Append(
                        string.IsNullOrEmpty(node.Icon)
                            ? string.Format(
                                @"<a href=""{0}"">{1}</a>",
                                UrlHelper.GenerateUrl(
                                    null,
                                    node.Action,
                                    node.Controller,
                                    null,
                                    null,
                                    null,
                                    null,
                                    htmlHelper.RouteCollection,
                                    htmlHelper.ViewContext.RequestContext,
                                    true),
                                node.Name)
                            : string.Format(
                                @"<a href=""{0}""><i class=""{1}""></i> <span>{2}</span></a>",
                                UrlHelper.GenerateUrl(
                                    null,
                                    node.Action,
                                    node.Controller,
                                    null,
                                    null,
                                    null,
                                    null,
                                    htmlHelper.RouteCollection,
                                    htmlHelper.ViewContext.RequestContext,
                                    true),
                                node.Icon,
                                node.Name));
                }
                else if (node.HasLegacyUrl)
                {
                    nodeOutput.Append(
                        string.IsNullOrEmpty(node.Icon)
                            ? string.Format(@"<a href=""{0}"">{1}</a>", node.LegacyUrl, node.Name)
                            : string.Format(
                                @"<a href=""/{0}""><i class=""{1}""></i> <span>{2}</span></a>",
                                node.LegacyUrl,
                                node.Icon,
                                node.Name));
                }
            }
            else
            {
                nodeOutput.Append(
                    string.Format(
                        @"<a href=""#"" class=""dropdown-toggle"" data-toggle=""dropdown""><i class=""{0}""></i> <span>{1}</span> <b class=""caret""></b></a>",
                        node.Icon,
                        node.Name));
                nodeOutput.Append(AddSubMenu(htmlHelper, node.Children));
            }

            nodeOutput.Append("</li>");

            return nodeOutput.ToString();
        }