Making the admin menu collapsible once again

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-10-18 17:05:29 -07:00
parent ac6baea828
commit e85de1b884
3 changed files with 37 additions and 39 deletions

View File

@@ -1,33 +0,0 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<%--//todo: get the settings from the cookie to class-ify parts of the menu that should be closed on load--%>
<%--<ul id="navigation" role="navigation">
<%if (Model.Menu != null) {
foreach (var menuSection in Model.Menu) {
// todo: (heskew) need some help(er)
var firstSectionItem = menuSection.Items.FirstOrDefault();
var sectionHeaderMarkup = firstSectionItem != null
? Html.ActionLink(menuSection.Text, (string)firstSectionItem.RouteValues["action"], firstSectionItem.RouteValues).ToHtmlString()
: string.Format("<span>{0}</span>", Html.Encode(menuSection.Text));
var classification = "";
if (menuSection == Model.Menu.First())
classification = "first ";
if (menuSection == Model.Menu.Last())
classification += "last ";
%>
<li<%=!string.IsNullOrEmpty(classification) ? string.Format(" class=\"{0}\"", classification.TrimEnd()) : "" %>><h3><%=sectionHeaderMarkup %></h3><ul class="menuItems"><%foreach (var menuItem in menuSection.Items) { %>
<li><%: Html.ActionLink(menuItem.Text, (string)menuItem.RouteValues["action"], menuItem.RouteValues)%></li>
<%} %></ul></li>
<%
}
}%>
</ul>
<% using (this.Capture("end-of-page-scripts")) { %>
<script type="text/javascript">
(function ($) {
$("#navigation h3").expandoControl(function(controller) { return controller.next(); }, { key: "N42", path: "<%:ResolveUrl("~/") %>" });
})(jQuery);
</script>
<% } %>--%>

View File

@@ -1,14 +1,44 @@
<ul id="navigation">
@using System.Web.Routing;
@{
Script.Require("jQuery");
Script.Include("admin.js");
IEnumerable<dynamic> firstLevelMenuItems = Model;
}
<ul id="navigation" role="navigation">
@foreach(var firstLevelMenuItem in Model) {
<li>
<h3><a href="#">@firstLevelMenuItem.Text</a></h3>
IEnumerable<dynamic> secondLevelMenuItems = firstLevelMenuItem;
var firstOfTheSecond = secondLevelMenuItems.FirstOrDefault();
var sectionHeaderMarkup = firstOfTheSecond != null
? Html.ActionLink((string)firstLevelMenuItem.Text, (string)firstOfTheSecond.RouteValues["action"], (RouteValueDictionary)firstOfTheSecond.RouteValues)
: new HtmlString(string.Format("<span>{0}</span>", Html.Encode(firstLevelMenuItem.Text)));
if (firstLevelMenuItem == firstLevelMenuItems.First()) {
firstLevelMenuItem.Classes.Add("first");
}
if (firstLevelMenuItem == firstLevelMenuItems.Last()) {
firstLevelMenuItem.Classes.Add("last");
}
var firstLevelTag = Tag(firstLevelMenuItem, "li");
@firstLevelTag.StartElement
<h3>@sectionHeaderMarkup</h3>
<ul class="menuItems">
@foreach(var secondLevelMenuItem in firstLevelMenuItem) {
@foreach(var secondLevelMenuItem in secondLevelMenuItems) {
<li>
<a href="@secondLevelMenuItem.Href">@secondLevelMenuItem.Text</a>
</li>
}
</ul>
</li>
@firstLevelTag.EndElement
}
</ul>
</ul>
@using(Script.Foot()) {
<script type="text/javascript">
//<![CDATA[
(function ($) {
$("#navigation h3").expandoControl(function(controller) { return controller.next(); }, { key: "N42", path: "@Url.Content("~/")" });
})(jQuery);
//]]>
</script>
}

View File

@@ -68,6 +68,7 @@
<SubType>Designer</SubType>
</Content>
<Content Include="TheThemeMachine\Views\User.cshtml" />
<None Include="TheAdmin\Views\Menu.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="TheAdmin\Styles\images\icons.png" />