mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-22 03:37:25 +08:00
Some work on letting modules be responsible for their own piece of the menu (wrt menu item icons & style)
--HG-- branch : dev
This commit is contained in:
@@ -8,8 +8,11 @@ namespace Orchard.Core.Dashboard {
|
||||
public string MenuName { get { return "admin"; } }
|
||||
|
||||
public void GetNavigation(NavigationBuilder builder) {
|
||||
builder.Add(T("Dashboard"), "-5",
|
||||
menu => menu.Add(T("Orchard"), "-5", item => item.Action("Index", "Admin", new { area = "Dashboard" })
|
||||
builder.AddImageSet("dashboard.menu")
|
||||
.Add(T("Dashboard"), "-5",
|
||||
menu => menu.Add(T("Orchard"), "-5",
|
||||
item => item
|
||||
.Action("Index", "Admin", new { area = "Dashboard" })
|
||||
.Permission(StandardPermissions.AccessAdminPanel)));
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +0,0 @@
|
||||
#menu .menu-admin .section-dashboard h3 a {
|
||||
background-image:url(images/menu-dashboard.png);
|
||||
background-position:0 5px;
|
||||
}
|
||||
#menu .menu-admin .section-dashboard h3 a:hover {
|
||||
background-position:0 -16px;
|
||||
}
|
7
src/Orchard.Web/Core/Dashboard/styles/dashboard.menu.css
Normal file
7
src/Orchard.Web/Core/Dashboard/styles/dashboard.menu.css
Normal file
@@ -0,0 +1,7 @@
|
||||
.navicon-dashboard {
|
||||
background-image:url(images/dashboard.menu.png) !important;
|
||||
background-position:0 2px !important;
|
||||
}
|
||||
.navicon-dashboard:hover {
|
||||
background-position:0 -30px !important;
|
||||
}
|
@@ -9,7 +9,8 @@ namespace Orchard.Core.Navigation {
|
||||
public void GetNavigation(NavigationBuilder builder) {
|
||||
//todo: - add new menu? and list menus? ...and remove hard-coded menu name here
|
||||
builder.Add(T("Navigation"), "8",
|
||||
menu => menu.Add(T("Main Menu"), "0", item => item.Action("Index", "Admin", new { area = "Navigation" })
|
||||
menu => menu
|
||||
.Add(T("Main Menu"), "0", item => item.Action("Index", "Admin", new { area = "Navigation" })
|
||||
.Permission(Permissions.ManageMainMenu)));
|
||||
}
|
||||
}
|
||||
|
@@ -239,6 +239,8 @@
|
||||
<Content Include="Contents\Views\Admin\Create.cshtml" />
|
||||
<Content Include="Contents\Views\Admin\Edit.cshtml" />
|
||||
<Content Include="Contents\Views\Admin\List.cshtml" />
|
||||
<Content Include="Dashboard\styles\dashboard.menu.css" />
|
||||
<Content Include="Dashboard\styles\images\dashboard.menu.png" />
|
||||
<Content Include="Feeds\Views\Feed.cshtml" />
|
||||
<Content Include="Contents\Views\Parts.Contents.Publish.cshtml" />
|
||||
<Content Include="Contents\Views\Parts.Contents.Publish.SummaryAdmin.cshtml" />
|
||||
@@ -378,6 +380,9 @@
|
||||
<ItemGroup>
|
||||
<Content Include="Shapes\Views\LocalMenuItem.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Dashboard\styles\Web.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
13
src/Orchard.Web/Modules/Orchard.Pages/AdminMenu.cs
Normal file
13
src/Orchard.Web/Modules/Orchard.Pages/AdminMenu.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Orchard.Localization;
|
||||
using Orchard.UI.Navigation;
|
||||
|
||||
namespace Orchard.Core.Dashboard {
|
||||
public class AdminMenu : INavigationProvider {
|
||||
public Localizer T { get; set; }
|
||||
public string MenuName { get { return "admin"; } }
|
||||
|
||||
public void GetNavigation(NavigationBuilder builder) {
|
||||
builder.AddImageSet("page.menu");
|
||||
}
|
||||
}
|
||||
}
|
@@ -37,6 +37,7 @@
|
||||
<Reference Include="System.Web" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AdminMenu.cs" />
|
||||
<Compile Include="Migrations.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
@@ -54,8 +55,13 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Styles\page.menu.css" />
|
||||
<Content Include="Styles\images\page.menu.png" />
|
||||
<Content Include="web.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Styles\Web.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
<ProjectExtensions>
|
||||
|
21
src/Orchard.Web/Modules/Orchard.Pages/Styles/Web.config
Normal file
21
src/Orchard.Web/Modules/Orchard.Pages/Styles/Web.config
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="webpages:Enabled" value="false" />
|
||||
</appSettings>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<!-- iis6 - for any request in this location, return via managed static file handler -->
|
||||
<add path="*" verb="*" type="System.Web.StaticFileHandler" />
|
||||
</httpHandlers>
|
||||
</system.web>
|
||||
<system.webServer>
|
||||
<handlers accessPolicy="Script,Read">
|
||||
<!--
|
||||
iis7 - for any request to a file exists on disk, return it via native http module.
|
||||
accessPolicy 'Script' is to allow for a managed 404 page.
|
||||
-->
|
||||
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
</configuration>
|
@@ -0,0 +1,7 @@
|
||||
.navicon-dashboard {
|
||||
background-image:url(images/dashboard.menu.png) !important;
|
||||
background-position:0 2px !important;
|
||||
}
|
||||
.navicon-dashboard:hover {
|
||||
background-position:0 -30px !important;
|
||||
}
|
@@ -343,19 +343,20 @@ form.link button:hover {
|
||||
padding:0 0 0 10px;
|
||||
}
|
||||
#menu .menu-admin li h3 a {
|
||||
background:url(images/menu-all.png) no-repeat 0 5px;
|
||||
background:url(images/menu-all.png) no-repeat 0 4px;
|
||||
padding:0 0 0 16px;
|
||||
}
|
||||
#menu .menu-admin li h3 a:hover {
|
||||
background-position:0 -17px;
|
||||
color:#fff;
|
||||
}
|
||||
/* todo: (heskew) pull out into the appropriate modules somehow when this is baked */
|
||||
/* todo: (heskew) pull out into the appropriate modules somehow when this is baked * /
|
||||
#menu .menu-admin .section-dashboard h3 a { background-position:0 -36px; }
|
||||
#menu .menu-admin .section-dashboard h3 a:hover { background-position:0 -56px; }
|
||||
/* todo: need to get the "New" sub items */
|
||||
/* todo: need to get the "New" sub items * /
|
||||
#menu .menu-admin .section-content h3 a { background-position:0 -247px; }
|
||||
#menu .menu-admin .section-content h3 a:hover { background-position:0 -268px; }
|
||||
/* todo: need an icon for "Blogs" */
|
||||
/* todo: need an icon for "Blogs" * /
|
||||
#menu .menu-admin .section-comments h3 a { background-position:0 -539px; }
|
||||
#menu .menu-admin .section-comments h3 a:hover { background-position:0 -559px; }
|
||||
#menu .menu-admin .section-lists h3 a { background-position:0 -289px; }
|
||||
@@ -374,7 +375,7 @@ form.link button:hover {
|
||||
#menu .menu-admin .section-themes h3 a:hover { background-position:0 -518px; }
|
||||
#menu .menu-admin .section-users h3 a { background-position:0 -619px; }
|
||||
#menu .menu-admin .section-users h3 a:hover { background-position:0 -640px; }
|
||||
|
||||
*/
|
||||
#menu .menu-admin li h3 a, #menu .menu-admin li h3 span {
|
||||
line-height:16px;
|
||||
color:#aec3ce;
|
||||
|
@@ -5,6 +5,10 @@
|
||||
Script.Include("admin.js");
|
||||
IEnumerable<dynamic> firstLevelMenuItems = Model;
|
||||
|
||||
foreach (var imageSet in Model.ImageSets) {
|
||||
RegisterImageSet(imageSet, Model.MenuName /* style */, 16 /* bounding box */);
|
||||
}
|
||||
|
||||
Model.Attributes.Add("role", "navigation");
|
||||
var tag = Tag(Model, "ul");
|
||||
}
|
||||
@@ -14,11 +18,28 @@
|
||||
|
||||
string sectionHeaderText = firstLevelMenuItem.Text;
|
||||
var firstOfTheSecond = secondLevelMenuItems.FirstOrDefault();
|
||||
var sectionHeaderMarkup = firstLevelMenuItem.RouteValues != null || HasText(firstLevelMenuItem.Url)
|
||||
? Html.Link(sectionHeaderText, (string)firstLevelMenuItem.Href)
|
||||
: firstOfTheSecond != null && firstLevelMenuItem.LinkToFirstChild
|
||||
? Html.Link(sectionHeaderText, (string)firstOfTheSecond.Href)
|
||||
: new HtmlString(string.Format("<span>{0}</span>", Html.Encode(sectionHeaderText)));
|
||||
|
||||
var imageClassName = "navicon-" + sectionHeaderText.TextHint.HtmlClassify();
|
||||
var imageId = HasText(firstLevelMenuItem.ImageId)
|
||||
? "navicon-" + firstLevelMenuItem.ImageId
|
||||
: null;
|
||||
|
||||
IHtmlString sectionHeaderMarkup;
|
||||
if (firstLevelMenuItem.RouteValues != null || HasText(firstLevelMenuItem.Url)) {
|
||||
sectionHeaderMarkup = HasText(imageId)
|
||||
? Html.Link(sectionHeaderText, (string)firstLevelMenuItem.Href, new { @class = imageClassName, id = imageId })
|
||||
: Html.Link(sectionHeaderText, (string)firstLevelMenuItem.Href, new { @class = imageClassName });
|
||||
}
|
||||
else if (firstOfTheSecond != null && firstLevelMenuItem.LinkToFirstChild && (firstOfTheSecond.RouteValues != null || HasText(firstOfTheSecond.Url))) {
|
||||
sectionHeaderMarkup = HasText(imageId)
|
||||
? Html.Link(sectionHeaderText, (string)firstOfTheSecond.Href, new { @class = imageClassName, id = imageId })
|
||||
: Html.Link(sectionHeaderText, (string)firstOfTheSecond.Href, new { @class = imageClassName });
|
||||
}
|
||||
else {
|
||||
sectionHeaderMarkup = HasText(imageId)
|
||||
? new HtmlString(string.Format(@"<span class=""{1}"" id=""{2}"">{0}</span>", Html.Encode(sectionHeaderText), Html.Encode(imageClassName), Html.Encode(imageId)))
|
||||
: new HtmlString(string.Format(@"<span class=""{1}"">{0}</span>", Html.Encode(sectionHeaderText), Html.Encode(imageClassName)));
|
||||
}
|
||||
|
||||
if (firstLevelMenuItem == firstLevelMenuItems.First()) {
|
||||
firstLevelMenuItem.Classes.Add("first");
|
||||
@@ -26,12 +47,11 @@
|
||||
if (firstLevelMenuItem == firstLevelMenuItems.Last()) {
|
||||
firstLevelMenuItem.Classes.Add("last");
|
||||
}
|
||||
|
||||
if (firstLevelMenuItem.Selected) {
|
||||
firstLevelMenuItem.Classes.Add("selected");
|
||||
}
|
||||
|
||||
firstLevelMenuItem.Classes.Add("section-" + sectionHeaderText.HtmlClassify());
|
||||
firstLevelMenuItem.Classes.Add("section-" + sectionHeaderText.TextHint.HtmlClassify());
|
||||
var firstLevelTag = Tag(firstLevelMenuItem, "li");
|
||||
@firstLevelTag.StartElement
|
||||
<h3>@sectionHeaderMarkup</h3>
|
||||
@@ -39,7 +59,7 @@
|
||||
<ul class="menuItems">
|
||||
@foreach (var secondLevelMenuItem in secondLevelMenuItems.Where(menuItem => !menuItem.LocalNav)) {
|
||||
if (secondLevelMenuItem.Selected) {
|
||||
secondLevelMenuItem.Classes.Add("selected");
|
||||
secondLevelMenuItem.Classes.Add("selected");
|
||||
}
|
||||
var secondLevelTag = Tag(secondLevelMenuItem, "li");
|
||||
@secondLevelTag.StartElement
|
||||
|
Reference in New Issue
Block a user