--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2012-09-28 18:01:56 -07:00
@@ -28,16 +28,16 @@
: null; : null;
IHtmlString sectionHeaderMarkup; IHtmlString sectionHeaderMarkup;
if (firstLevelMenuItem.RouteValues != null || HasText(firstLevelMenuItem.Url)) { if (firstOfTheSecond != null && firstLevelMenuItem.LinkToFirstChild && (firstOfTheSecond.RouteValues != null || HasText(firstOfTheSecond.Url))) {
sectionHeaderMarkup = HasText(itemId)
? Html.Link(sectionHeaderText, (string)firstLevelMenuItem.Href, new { @class = itemClassName, id = itemId })
: Html.Link(sectionHeaderText, (string)firstLevelMenuItem.Href, new { @class = itemClassName });
}
else if (firstOfTheSecond != null && firstLevelMenuItem.LinkToFirstChild && (firstOfTheSecond.RouteValues != null || HasText(firstOfTheSecond.Url))) {
sectionHeaderMarkup = HasText(itemId) sectionHeaderMarkup = HasText(itemId)
? Html.Link(sectionHeaderText, (string)firstOfTheSecond.Href, new { @class = itemClassName, id = itemId }) ? Html.Link(sectionHeaderText, (string)firstOfTheSecond.Href, new { @class = itemClassName, id = itemId })
: Html.Link(sectionHeaderText, (string)firstOfTheSecond.Href, new { @class = itemClassName }); : Html.Link(sectionHeaderText, (string)firstOfTheSecond.Href, new { @class = itemClassName });
} }
else if (firstLevelMenuItem.RouteValues != null || HasText(firstLevelMenuItem.Url)) {
sectionHeaderMarkup = HasText(itemId)
? Html.Link(sectionHeaderText, (string)firstLevelMenuItem.Href, new { @class = itemClassName, id = itemId })
: Html.Link(sectionHeaderText, (string)firstLevelMenuItem.Href, new { @class = itemClassName });
}
else { else {
// if the header isn't linked and there are no children there's no reason for this item in the menu other than to look pretty // if the header isn't linked and there are no children there's no reason for this item in the menu other than to look pretty
if (secondLevelMenuItems.Count() == 0) { if (secondLevelMenuItems.Count() == 0) {
@@ -70,6 +70,8 @@
<ul class="menuItems"> <ul class="menuItems">
@foreach (var secondLevelMenuItem in secondLevelMenuItems.Where(menuItem => !menuItem.LocalNav)) { @foreach (var secondLevelMenuItem in secondLevelMenuItems.Where(menuItem => !menuItem.LocalNav)) {
string secondLevelTextHint = secondLevelMenuItem.Text.TextHint; string secondLevelTextHint = secondLevelMenuItem.Text.TextHint;
var firstOfTheThird = ((IEnumerable<dynamic>)secondLevelMenuItem).FirstOrDefault();
var secondLevelItemClassName = HasText(secondLevelTextHint) var secondLevelItemClassName = HasText(secondLevelTextHint)
? "subnavicon-" + secondLevelTextHint.HtmlClassify() ? "subnavicon-" + secondLevelTextHint.HtmlClassify()
: "subnavicon"; : "subnavicon";
@@ -82,12 +84,16 @@
} }
var secondLevelTag = Tag(secondLevelMenuItem, "li"); var secondLevelTag = Tag(secondLevelMenuItem, "li");
var secondLevelUrl = secondLevelMenuItem.Href;
if (firstOfTheThird != null && secondLevelMenuItem.LinkToFirstChild && (firstOfTheThird.RouteValues != null || HasText(firstOfTheThird.Url))) {
secondLevelUrl = firstOfTheThird.Href;
}
@secondLevelTag.StartElement @secondLevelTag.StartElement
if (HasText(secondLevelItemId)) { if (HasText(secondLevelItemId)) {
<a href="@secondLevelMenuItem.Href" class="@secondLevelItemClassName" id="@secondLevelItemId">@secondLevelMenuItem.Text</a> <a href="@secondLevelUrl" class="@secondLevelItemClassName" id="@secondLevelItemId">@secondLevelMenuItem.Text</a>
} }
else { else {
<a href="@secondLevelMenuItem.Href" class="@secondLevelItemClassName">@secondLevelMenuItem.Text</a> <a href="@secondLevelUrl" class="@secondLevelItemClassName">@secondLevelMenuItem.Text</a>
} }
@secondLevelTag.EndElement @secondLevelTag.EndElement
} }