Adding Horizontal Tab nagigation on Autoroute Patterns Localization settings.

Fixing Token Picker CSS (vertical position).
This commit is contained in:
Skrypt
2015-04-28 13:49:48 -04:00
parent e508385dcb
commit d2fc47eb2d
8 changed files with 83 additions and 32 deletions

View File

@@ -71,6 +71,7 @@
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Scripts\autoroute-browser.js" />
<Content Include="Styles\orchard-autoroute-settings.css" /> <Content Include="Styles\orchard-autoroute-settings.css" />
<Content Include="Web.config" /> <Content Include="Web.config" />
<Content Include="Scripts\Web.config" /> <Content Include="Scripts\Web.config" />

View File

@@ -5,6 +5,7 @@ namespace Orchard.Autoroute {
public void BuildManifests(ResourceManifestBuilder builder) { public void BuildManifests(ResourceManifestBuilder builder) {
var manifest = builder.Add(); var manifest = builder.Add();
manifest.DefineStyle("AutorouteSettings").SetUrl("orchard-autoroute-settings.css"); manifest.DefineStyle("AutorouteSettings").SetUrl("orchard-autoroute-settings.css");
manifest.DefineScript("AutorouteBrowser").SetUrl("autoroute-browser.js").SetDependencies("jQuery");
} }
} }
} }

View File

@@ -0,0 +1,26 @@
(function ($) {
var AutorouteCultureBrowser = function (culture) {
var self = this;
this.culture = culture;
this.initialize = function () {
self.culture.find(".autoroute-cultures").on("click", "a.culture", function (e) {
var categoryLink = $(this);
var href = categoryLink.attr("href");
self.culture.find(".autoroute-cultures li").removeClass("selected");
categoryLink.closest("li").addClass("selected");
self.culture.find(".items").hide();
self.culture.find(href).show();
e.preventDefault();
});
self.culture.find(".autoroute-cultures a").first().click();
}
};
$(function () {
var browser = new AutorouteCultureBrowser($("#main"));
browser.initialize();
});
})(jQuery);

View File

@@ -26,7 +26,7 @@ namespace Orchard.Autoroute.Settings {
public bool AllowCustomPattern { get; set; } public bool AllowCustomPattern { get; set; }
public bool AutomaticAdjustmentOnEdit { get; set; } public bool AutomaticAdjustmentOnEdit { get; set; }
public bool? IsDefault { get; set; } public bool? IsDefault { get; set; }
public IEnumerable<string> SiteCultures { get; set; } public List<string> SiteCultures { get; set; }
public string DefaultSiteCulture { get; set; } public string DefaultSiteCulture { get; set; }
/// <summary> /// <summary>

View File

@@ -29,7 +29,7 @@ namespace Orchard.Autoroute.Settings {
var settings = definition.Settings.GetModel<AutorouteSettings>(); var settings = definition.Settings.GetModel<AutorouteSettings>();
//get cultures //get cultures
settings.SiteCultures = _cultureManager.ListCultures(); settings.SiteCultures = _cultureManager.ListCultures().ToList();
//get default site culture //get default site culture
settings.DefaultSiteCulture = _cultureManager.GetSiteCulture(); settings.DefaultSiteCulture = _cultureManager.GetSiteCulture();
@@ -81,7 +81,7 @@ namespace Orchard.Autoroute.Settings {
}; };
//get cultures //get cultures
settings.SiteCultures = _cultureManager.ListCultures(); settings.SiteCultures = _cultureManager.ListCultures().ToList();
if (updateModel.TryUpdateModel(settings, "AutorouteSettings", null, null)) { if (updateModel.TryUpdateModel(settings, "AutorouteSettings", null, null)) {
// remove empty patterns // remove empty patterns

View File

@@ -18,6 +18,10 @@
text-align: right; text-align: right;
} }
.autoroute-settings-patterns tr td input { .autoroute-settings-patterns, .autoroute-settings-patterns tr td input {
width: 100%; width: 100%;
} }
.autoroute-settings-patterns td, .autoroute-settings-patterns th {
padding:10px;
}

View File

@@ -2,6 +2,7 @@
@using Orchard.Utility.Extensions; @using Orchard.Utility.Extensions;
@{ @{
Script.Require("AutorouteBrowser");
Style.Require("AutorouteSettings"); Style.Require("AutorouteSettings");
int patternCount = 0; int patternCount = 0;
int patternCultureCount = 0; int patternCultureCount = 0;
@@ -21,31 +22,49 @@
<span class="hint">@T("This option will cause the Url to automatically be regenerated when you edit existing content and publish it again, otherwise it will always keep the old route, or you have to perform bulk update in the Autoroute admin.")</span> <span class="hint">@T("This option will cause the Url to automatically be regenerated when you edit existing content and publish it again, otherwise it will always keep the old route, or you have to perform bulk update in the Autoroute admin.")</span>
</div> </div>
</fieldset> </fieldset>
@foreach (var culture in Model.SiteCultures) { <fieldset>
<fieldset> <h4>@T("Patterns") :</h4>
<label>@T("Patterns") @culture :</label> </fieldset>
<table class="items autoroute-settings-patterns"> <fieldset>
<tr> <div id="local-navigation">
<th class="autoroute-settings-default">@T("Default")</th> <ul class="autoroute-cultures localmenu group">
<th class="autoroute-settings-name">@T("Name")<span class="hint">@T("Name of the pattern")</span></th> @{
<th class="autoroute-settings-pat">@T("Pattern")<span class="hint">@T("The definition of the pattern")</span></th> int i = 0;
<th class="autoroute-settings-desc">@T("Description")<span class="hint">@T("The description of the pattern, displayed in the editor")</span></th>
<th class="autoroute-settings-actions">&nbsp;</th>
</tr>
@for (int index = 0; index < Model.Patterns.Where(x => x.Culture == culture).Count(); index++) {
<tr>
<td>@Html.RadioButtonFor(m => m.DefaultPatterns[cultureCount].Culture, culture + "|" + patternCultureCount, patternCultureCount.ToString() == Model.DefaultPatterns[cultureCount].PatternIndex ? new { @checked = "checked" } : null)</td>
<td>@Html.TextBoxFor(m => m.Patterns[patternCount].Name, new { @class = "text" })</td>
<td>@Html.TextBoxFor(m => m.Patterns[patternCount].Pattern, new { @class = "tokenized text" })</td>
<td>@Html.TextBoxFor(m => m.Patterns[patternCount].Description, new { @class = "text" })</td>
<td>@Html.HiddenFor(m => m.Patterns[patternCount].Culture)&nbsp;</td>
</tr>
if (Model.Patterns[patternCount].Name != null) { patternCultureCount++; } else { patternCultureCount = 0; }
patternCount++;
} }
<tr></tr> @foreach (var culture in Model.SiteCultures) {
</table> var cssClass = i == 0 ? "selected first" : i == Model.SiteCultures.Count - 1 ? "last" : "middle";
</fieldset> <li class="@cssClass"><a class="culture" href="#cat-@culture">@culture</a></li>
cultureCount++; i++;
} }
@Display.TokenHint() </ul>
</div>
<div id="content">
@foreach (var culture in Model.SiteCultures) {
<fieldset id="cat-@culture" class="items" style="@(cultureCount == 0 ? "display:block;" : "display:none;" )">
<table class="autoroute-settings-patterns">
<tr>
<th class="autoroute-settings-default">@T("Default")</th>
<th class="autoroute-settings-name">@T("Name")<span class="hint">@T("Name of the pattern")</span></th>
<th class="autoroute-settings-pat">@T("Pattern")<span class="hint">@T("The definition of the pattern")</span></th>
<th class="autoroute-settings-desc">@T("Description")<span class="hint">@T("The description of the pattern, displayed in the editor")</span></th>
<th class="autoroute-settings-actions">&nbsp;</th>
</tr>
@for (int index = 0; index < Model.Patterns.Where(x => x.Culture == culture).Count(); index++) {
<tr>
<td>@Html.RadioButtonFor(m => m.DefaultPatterns[cultureCount].Culture, culture + "|" + patternCultureCount, patternCultureCount.ToString() == Model.DefaultPatterns[cultureCount].PatternIndex ? new { @checked = "checked" } : null)</td>
<td>@Html.TextBoxFor(m => m.Patterns[patternCount].Name, new { @class = "text" })</td>
<td>@Html.TextBoxFor(m => m.Patterns[patternCount].Pattern, new { @class = "tokenized text" })</td>
<td>@Html.TextBoxFor(m => m.Patterns[patternCount].Description, new { @class = "text" })</td>
<td>@Html.HiddenFor(m => m.Patterns[patternCount].Culture)&nbsp;</td>
</tr>
if (Model.Patterns[patternCount].Name != null) { patternCultureCount++; } else { patternCultureCount = 0; }
patternCount++;
}
<tr></tr>
</table>
</fieldset>
cultureCount++;
}
</div>
</fieldset>
@Display.TokenHint()

View File

@@ -8,7 +8,7 @@
cursor: pointer; cursor: pointer;
padding-right:8px; padding-right:8px;
margin-top:10px; margin-top:0.15em;
right:100%; right:100%;
} }