-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add target attribute to Menu #15636
base: main
Are you sure you want to change the base?
Add target attribute to Menu #15636
Changes from 9 commits
71c1e5d
318ad74
2d92263
3dfac16
c6355eb
62d6e4f
e58edad
7a89f86
25ce926
23a836e
a497ad1
dd5bfe4
498aad4
d7ecf0f
75fdb01
2f0fbc1
38f4d4e
e8470f7
2e797f2
82b6b26
a437d48
e2183f9
2fb58bd
020fade
8bfdaee
7449dbd
d3dcafe
8bd2c45
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,14 @@ | |
</div> | ||
</div> | ||
|
||
<div class="@Orchard.GetWrapperClasses()"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Select |
||
<label asp-for="Target" class="@Orchard.GetLabelClasses()">@T["Target"]</label> | ||
<div class="@Orchard.GetEndClasses()"> | ||
<input asp-for="Target" class="form-control" /> | ||
<span class="hint">@T["The target attribute of the A tag, see more:"] <a class="seedoc" target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target">target</a></span> | ||
</div> | ||
</div> | ||
|
||
<div class="@Orchard.GetWrapperClasses()"> | ||
<label asp-for="Html" class="@Orchard.GetLabelClasses()">@T["Html"]</label> | ||
<div class="@Orchard.GetEndClasses()"> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,11 @@ | |
<input asp-for="Url" class="form-control" /> | ||
</div> | ||
</div> | ||
|
||
<div class="@Orchard.GetWrapperClasses()"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Select |
||
<label asp-for="Target" class="@Orchard.GetLabelClasses()">@T["Target"]</label> | ||
<div class="@Orchard.GetEndClasses()"> | ||
<input asp-for="Target" class="form-control" /> | ||
<span class="hint">@T["The target attribute of the A tag, see more:"] <a class="seedoc" target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target">target</a></span> | ||
</div> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,12 @@ | |
} | ||
|
||
tag.Attributes["href"] = url; | ||
|
||
if (!string.IsNullOrEmpty(htmlMenuItemPart.Target)) | ||
{ | ||
tag.Attributes["target"] = htmlMenuItemPart.Target; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Validate the value to make sure only valid values can be provided There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is really not necessary, since the target attribute is freely definable, e.g. target="order_details" , and when the user clicks on a link it will always refresh the existing window as much as possible, instead of always opening a new one. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target |
||
} | ||
|
||
tag.InnerHtml.AppendHtml(Html.Raw(htmlMenuItemPart.Html)); | ||
} | ||
@tag |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<a href="@(Model.Href ?? "#")">@Model.Text</a> | ||
<a href="@(Model.Href ?? "#")" @(!string.IsNullOrEmpty(Model.Target) ? $"target=\"" + Model.Target + "\"" : string.Empty)>@Model.Text</a> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
{% assign link = Model.ContentItem.Content.HtmlMenuItemPart %} | ||
<a class="nav-link" href="{{ link.Url | href }}">{{ link.Html | raw }}</a> | ||
<a class="nav-link" href="{{ link.Url | href }}"{% if link.Target %} target="{{link.Target}}" {% endif %}>{{ link.Html | raw }}</a> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{% assign link = Model.ContentItem.Content.LinkMenuItemPart %} | ||
<a class="nav-link" href="{{ link.Url | href }}" | ||
<a class="nav-link" href="{{ link.Url | href }}"{% if link.Target %} target="{{link.Target}}" {% endif %} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same |
||
{% if link.Url contains "#" %} | ||
data-bs-target="{{ link.Url | split: '/' | last }}" | ||
{% endif %}> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,5 @@ | |
{% if Model.HasItems %} | ||
<a href="{{ link.Url | href }}" class="nav-link px-lg-3 py-3 py-lg-4 dropdown-toggle" data-bs-toggle="dropdown">{{ link.Html | raw }}<b class="caret"></b></a> | ||
{% else %} | ||
<a class="nav-link px-lg-3 py-3 py-lg-4" href="{{ link.Url | href }}">{{ link.Html | raw }}</a> | ||
<a class="nav-link px-lg-3 py-3 py-lg-4" href="{{ link.Url | href }}"{% if link.Target %} target="{{link.Target}}" {% endif %}>{{ link.Html | raw }}</a> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same. With line at the end of the file |
||
{% endif %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,5 @@ | |
{% if Model.HasItems %} | ||
<a href="{{ link.Url | href }}" class="nav-link px-lg-3 py-3 py-lg-4 dropdown-toggle" data-bs-toggle="dropdown">{{ Model.ContentItem.DisplayText }}<b class="caret"></b></a> | ||
{% else %} | ||
<a class="nav-link px-lg-3 py-3 py-lg-4" href="{{ link.Url | href }}">{{ Model.ContentItem.DisplayText }}</a> | ||
<a class="nav-link px-lg-3 py-3 py-lg-4" href="{{ link.Url | href }}"{% if link.Target %} target="{{link.Target}}" {% endif %}>{{ Model.ContentItem.DisplayText }}</a> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same |
||
{% endif %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Select menu instead of of a text box. The options can be
Value: Text
_blank: Opens the linked document in a new window or tab
_self Opens: the linked document in the same frame as it was clicked (this is default)
_parent: Opens the linked document in the parent frame
_top: Opens the linked document in the full body of the window
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This restricts users from using named window, such as those with a target attribute set to
MyWorkflow
, so clicking on any link if whose target isMyWorkflow
will always use the same windowNot sure if OC has a text box similar to
autocomplete
, we can set the above options you mentioned as autocomplete options, while allowing the user to enter any custom contentThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like to create UI where anyone can use not just developers. Drop down menu will provide better user experience for the common use. What if we do a menu with "Other" options. When other is selected, we can show an input to provider the custom value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about this ?
https://getbootstrap.com/docs/5.3/forms/form-control/#datalists