mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Enabling the ENTER key to quickly navigate to the content type or part if results were found based on the filter.
If no results were found and hitting ENTER, the input is used as a suggested name for the content type or part to create. If no results were found and clicking the primary button, the input is used as a suggested name for the content type or part to create.
This commit is contained in:
@@ -60,11 +60,11 @@ namespace Orchard.ContentTypes.Controllers {
|
||||
});
|
||||
}
|
||||
|
||||
public ActionResult Create() {
|
||||
public ActionResult Create(string suggestion) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.EditContentTypes, T("Not allowed to create a content type.")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
return View(new CreateTypeViewModel());
|
||||
return View(new CreateTypeViewModel { DisplayName = suggestion, Name = suggestion.ToSafeName() });
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("Create")]
|
||||
@@ -375,11 +375,11 @@ namespace Orchard.ContentTypes.Controllers {
|
||||
});
|
||||
}
|
||||
|
||||
public ActionResult CreatePart() {
|
||||
public ActionResult CreatePart(string suggestion) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.EditContentTypes, T("Not allowed to create a content part.")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
return View(new CreatePartViewModel());
|
||||
return View(new CreatePartViewModel { Name = suggestion.ToSafeName() });
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("CreatePart")]
|
||||
|
||||
@@ -1,16 +1,40 @@
|
||||
(function($) {
|
||||
$(function() {
|
||||
$("#search-box").focus().on("keyup", function() {
|
||||
var text = $(this).val().toLowerCase();
|
||||
$("#search-box").focus().on("keyup", function (e) {
|
||||
var text = $(this).val();
|
||||
|
||||
if (e.keyCode == 13) {
|
||||
var visibleRows = $("[data-record-text]:visible");
|
||||
if (visibleRows.length > 0) {
|
||||
var editLink = $("a", visibleRows[0]);
|
||||
location.href = editLink.attr("href");
|
||||
} else {
|
||||
var primaryButton = $("#layout-main .manage .primaryAction");
|
||||
location.href = primaryButton.attr("href") + "?suggestion=" + text;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (text == "") {
|
||||
$("[data-record-text]").show();
|
||||
} else {
|
||||
var lowerCaseText = text.toLowerCase();
|
||||
$("[data-record-text]").each(function() {
|
||||
var recordText = $(this).data("record-text").toLowerCase();
|
||||
$(this).toggle(recordText.indexOf(text) >= 0);
|
||||
$(this).toggle(recordText.indexOf(lowerCaseText) >= 0);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$("#layout-main .manage .primaryAction").on("click", function(e) {
|
||||
var suggestion = $("#search-box").val();
|
||||
|
||||
if (suggestion.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
location.href = $(this).attr("href") + "?suggestion=" + suggestion;
|
||||
e.preventDefault();
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
||||
Reference in New Issue
Block a user