Making use of the autofocus attribute

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-05-12 15:52:36 -07:00
parent f6c170679e
commit bed6afb98b
7 changed files with 27 additions and 19 deletions

View File

@@ -22,8 +22,9 @@
} %>
<%=Html.ActionLink(T("Edit").ToString(), "edit", new {tenantName = tenant.Name, area = "Orchard.MultiTenancy"}) %><%
if (!string.Equals(tenant.Name, "default", StringComparison.OrdinalIgnoreCase)) { //todo: (heskew) base this off the view model so logic on what can be removed and have its state changed stays in the controller
%><%=_Encoded(" | ")%>
<%=Html.ActionLink(T("Remove").ToString(), "delete", new {tenantName = tenant.Name, area = "Orchard.MultiTenancy"}) %><%
%><%--
delete not implemented! <%=_Encoded(" | ")%>
<%=Html.ActionLink(T("Remove").ToString(), "delete", new {tenantName = tenant.Name, area = "Orchard.MultiTenancy"}) %>--%><%
} %>
</div>
</div>

View File

@@ -97,7 +97,6 @@
</ItemGroup>
<ItemGroup>
<Content Include="Module.txt" />
<Content Include="Scripts\setup.js" />
<Content Include="Views\Web.config" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

View File

@@ -1,5 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<SetupViewModel>" %>
<%@ Import Namespace="Orchard.Mvc.Html"%>
<%@ Import Namespace="Orchard.Setup.ViewModels"%>
<h1><%=Html.TitleForPage(_Encoded("Get Started").ToHtmlString())%></h1>
<%
@@ -9,7 +8,7 @@ using (Html.BeginFormAntiForgeryPost()) { %>
<fieldset class="site">
<div>
<label for="SiteName"><%=_Encoded("What is the name of your site?") %></label>
<%=Html.EditorFor(svm => svm.SiteName) %>
<%=Html.TextBoxFor(svm => svm.SiteName, new { autofocus = "autofocus" })%>
</div>
<div>
<label for="AdminUsername"><%=_Encoded("Choose a user name:") %></label>

View File

@@ -3,9 +3,17 @@ jQuery.fn.extend({
helpfullyFocus: function() {
var _this = $(this);
var firstError = _this.find(".input-validation-error").first();
return firstError.size() === 1
? firstError.focus()
: _this.find("input:text").first().focus();
// try to focus the first error on the page
if (firstError.size() === 1) {
return firstError.focus();
}
// or, give it up to the browser to autofocus
if ('autofocus' in document.createElement('input')) {
return;
}
// otherwise, make the autofocus attribute work
var autofocus = _this.find(":input[autofocus=autofocus]").first();
return autofocus.focus();
},
toggleWhatYouControl: function() {
var _this = $(this);
@@ -53,3 +61,7 @@ jQuery.fn.extend({
$("body").append(_this);
});
})();
// a little better autofocus
$(function() {
$("body").helpfullyFocus();
});

View File

@@ -8,8 +8,8 @@ using (Html.BeginFormAntiForgeryPost(Url.Action("LogOn", new {ReturnUrl = Reques
<fieldset>
<legend><%=_Encoded("Account Information")%></legend>
<div>
<label for="username"><%=_Encoded("Username or Email:")%></label>
<%= Html.TextBox("userNameOrEmail")%>
<label for="userNameOrEmail"><%=_Encoded("Username or Email:")%></label>
<%= Html.TextBox("userNameOrEmail", "", new { autofocus = "autofocus" })%>
<%= Html.ValidationMessage("userNameOrEmail")%>
</div>
<div>
@@ -22,5 +22,4 @@ using (Html.BeginFormAntiForgeryPost(Url.Action("LogOn", new {ReturnUrl = Reques
</div>
<input type="submit" value="<%=_Encoded("Log On") %>" />
</fieldset><%
} %><%
using (this.Capture("end-of-page-scripts")) { %><script type="text/javascript">$("#username").closest("form").helpfullyFocus();</script><% } %>
} %>

View File

@@ -10,7 +10,7 @@ using (Html.BeginFormAntiForgeryPost(Url.Action("LogOn", new {ReturnUrl = Reques
<legend><%=_Encoded("Account Information")%></legend>
<div class="group">
<label for="username"><%=_Encoded("Username:")%></label>
<%= Html.TextBox("username")%>
<%= Html.TextBox("username", "", new { autofocus = "autofocus" })%>
<%= Html.ValidationMessage("username")%>
</div>
<div class="group">
@@ -23,5 +23,4 @@ using (Html.BeginFormAntiForgeryPost(Url.Action("LogOn", new {ReturnUrl = Reques
</div>
<input type="submit" value="<%=_Encoded("Log On") %>" />
</fieldset><%
} %><%
using (this.Capture("end-of-page-scripts")) { %><script type="text/javascript">$("#username").closest("form").helpfullyFocus();</script><% } %>
} %>

View File

@@ -10,7 +10,7 @@ using (Html.BeginFormAntiForgeryPost(Url.Action("LogOn", new {ReturnUrl = Reques
<legend><%=_Encoded("Account Information")%></legend>
<div class="group">
<label for="username"><%=_Encoded("Username:")%></label>
<%= Html.TextBox("username")%>
<%= Html.TextBox("username", "", new { autofocus = "autofocus" })%>
<%= Html.ValidationMessage("username")%>
</div>
<div class="group">
@@ -23,5 +23,4 @@ using (Html.BeginFormAntiForgeryPost(Url.Action("LogOn", new {ReturnUrl = Reques
</div>
<input type="submit" value="<%=_Encoded("Log On") %>" />
</fieldset><%
} %><%
using (this.Capture("end-of-page-scripts")) { %><script type="text/javascript">$("#username").closest("form").helpfullyFocus();</script><% } %>
} %>