mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
CSS classes can now be specified for widgets, fixes #5387
This commit is contained in:
@@ -59,6 +59,16 @@ namespace Orchard.Widgets.Drivers {
|
||||
}
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(widgetPart.CssClasses)) {
|
||||
var classNames = widgetPart.CssClasses.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
for (var i = 0; i < classNames.Length; i++) {
|
||||
classNames[i] = classNames[i].Trim().HtmlClassify();
|
||||
}
|
||||
|
||||
widgetPart.CssClasses = String.Join(" ", classNames);
|
||||
}
|
||||
|
||||
_widgetsService.MakeRoomForWidgetPosition(widgetPart);
|
||||
|
||||
return Editor(widgetPart, shapeHelper);
|
||||
|
||||
@@ -76,5 +76,13 @@ namespace Orchard.Widgets.Models {
|
||||
/// </summary>
|
||||
[HiddenInput(DisplayValue = false)]
|
||||
public IEnumerable<LayerPart> AvailableLayers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Css classes for the widget.
|
||||
/// </summary>
|
||||
public string CssClasses {
|
||||
get { return this.Retrieve(x => x.CssClasses); }
|
||||
set { this.Store(x => x.CssClasses, value); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,11 @@ namespace Orchard.Widgets {
|
||||
displaying.ShapeMetadata.Alternates.Add("Widget__Name__" + widgetPart.Name);
|
||||
}
|
||||
|
||||
// Adding other css classes to the widget.
|
||||
if (!String.IsNullOrWhiteSpace(widgetPart.CssClasses)) {
|
||||
widget.Classes.Add(widgetPart.CssClasses);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -27,3 +27,8 @@
|
||||
@Html.TextBoxFor(widget => widget.Name, new { @class = "text" })
|
||||
<span class="hint">@T("The technical name of the Widget, used for css class and alternates.")</span>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
@Html.LabelFor(widget => widget.CssClasses, T("Css classes"))
|
||||
@Html.TextBoxFor(widget => widget.CssClasses, new { @class = "text medium" })
|
||||
<span class="hint">@T("Add custom css classes for the widget separated by spaces.")</span>
|
||||
</fieldset>
|
||||
|
||||
Reference in New Issue
Block a user