Adding some helpful focus the form functionality for logon and setup

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-03-09 00:55:56 -08:00
parent 262fc83dbf
commit 4a0b3f8468
6 changed files with 21 additions and 7 deletions

View File

@@ -1,8 +1,15 @@
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();
},
toggleWhatYouControl: function() {
var _controller = $(this);
var _controllees = $("[data-controllerid=" + _controller.attr("id") + "]");
if (_controller.is(":checked")) {
var _this = $(this);
var _controllees = $("[data-controllerid=" + _this.attr("id") + "]");
if (_this.is(":checked")) {
$(_controllees.slideDown(200)[0]).find("input").focus();
} else {
_controllees.slideUp(200);

View File

@@ -88,6 +88,7 @@
</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

@@ -0,0 +1 @@
$("#SiteName").closest("form").helpfullyFocus();

View File

@@ -24,4 +24,5 @@
<%=Html.AntiForgeryTokenOrchard()%>
<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

@@ -1,9 +1,7 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BodyEditorViewModel>" %>
<%@ Import Namespace="Orchard.Core.Common.ViewModels"%>
<% Html.RegisterScript("tiny_mce.js"); %>
<%=Html.TextArea("Text", Model.Text, 25, 80, new { @class = "html" }) %>
<%
<%=Html.TextArea("Text", Model.Text, 25, 80, new { @class = "html" }) %><%
using (this.Capture("end-of-page-scripts")) {%>
<script type="text/javascript">
tinyMCE.init({

View File

@@ -1,4 +1,7 @@
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<BaseViewModel>" %>
<%@ Import Namespace="Orchard.UI.Resources"%>
<%@ Import Namespace="System.IO"%>
<%@ Import Namespace="Orchard.Mvc.ViewEngines"%>
<%@ Import Namespace="Orchard.Mvc.ViewModels" %>
<%@ Import Namespace="Orchard.Mvc.Html" %>
<% //todo: (heskew) this should really be using the IResourceManager if it's to be a theme especially for the jquery dep (w/out needing to copy into this theme...)
@@ -8,6 +11,9 @@
var basejs = ResolveUrl("~/Core/Themes/Scripts/base.js");
Model.Zones.AddAction("content:after", html =>
html.ViewContext.Writer.Write(@"<script type=""text/javascript"" src=""" + basejs + @"""></script>"));
var setupjs = ResolveUrl("~/Modules/Orchard.Setup/Scripts/setup.js");
Model.Zones.AddAction("content:after", html =>
html.ViewContext.Writer.Write(@"<script type=""text/javascript"" src=""" + setupjs + @"""></script>"));
var siteCss = ResolveUrl("../Styles/site.css");
Model.Zones.AddAction("head:styles", html =>
html.ViewContext.Writer.Write(@"<link rel=""stylesheet"" type=""text/css"" href=""" + siteCss + @"""/>"));