From b0f915754f33d873b424e5ebe64c0eab34b3c679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sun, 27 May 2018 23:29:39 +0300 Subject: [PATCH] Created AbpAutoFocusTagHelper. --- .../TagHelpers/Utils/AbpAutoFocusTagHelper.cs | 19 +++++++++++++++++++ .../{If => Utils}/AbpIfTagHelper.cs | 2 +- .../bootstrap/dom-event-handlers.js | 4 +++- 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Utils/AbpAutoFocusTagHelper.cs rename src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/{If => Utils}/AbpIfTagHelper.cs (87%) diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Utils/AbpAutoFocusTagHelper.cs b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Utils/AbpAutoFocusTagHelper.cs new file mode 100644 index 0000000000..c48d73e1fa --- /dev/null +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Utils/AbpAutoFocusTagHelper.cs @@ -0,0 +1,19 @@ +using Microsoft.AspNetCore.Razor.TagHelpers; + +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Utils +{ + [HtmlTargetElement(Attributes = "abp-auto-focus")] + public class AbpAutoFocusTagHelper : AbpTagHelper + { + [HtmlAttributeName("abp-auto-focus")] + public bool AutoFocus { get; set; } + + public override void Process(TagHelperContext context, TagHelperOutput output) + { + if (AutoFocus) + { + output.Attributes.Add("data-auto-focus", "true"); + } + } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/If/AbpIfTagHelper.cs b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Utils/AbpIfTagHelper.cs similarity index 87% rename from src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/If/AbpIfTagHelper.cs rename to src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Utils/AbpIfTagHelper.cs index 9533c07eba..05214857a0 100644 --- a/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/If/AbpIfTagHelper.cs +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Utils/AbpIfTagHelper.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.If +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Utils { [HtmlTargetElement(Attributes = "abp-if")] public class AbpIfTagHelper : AbpTagHelper diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore.mvc.ui.theme.shared/bootstrap/dom-event-handlers.js b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore.mvc.ui.theme.shared/bootstrap/dom-event-handlers.js index 1da78f4ede..cf19c05135 100644 --- a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore.mvc.ui.theme.shared/bootstrap/dom-event-handlers.js +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore.mvc.ui.theme.shared/bootstrap/dom-event-handlers.js @@ -72,6 +72,8 @@ }); $(function () { + enableFormFeatures($('form')); + $('[data-toggle="tooltip"]').tooltip({ container: 'body' }); @@ -80,7 +82,7 @@ container: 'body' }); - enableFormFeatures($('form')); + $('[data-auto-focus="true"]').first().findWithSelf('input').focus(); }); })(jQuery); \ No newline at end of file