Skip to content

Commit fafb6b0

Browse files
committed
Added data type and data size properties.
Added data type and data size properties (API v2 only).
1 parent 7996358 commit fafb6b0

File tree

14 files changed

+215
-16
lines changed

14 files changed

+215
-16
lines changed

samples/RecaptchaMVCSample/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@
3636
//
3737
// You can specify all the values or you can default the Revision and Build Numbers
3838
// by using the '*' as shown below:
39-
[assembly: AssemblyVersion("2.0.0.0")]
40-
[assembly: AssemblyFileVersion("2.0.0.0")]
39+
[assembly: AssemblyVersion("2.1.0.0")]
40+
[assembly: AssemblyFileVersion("2.1.0.0")]

samples/RecaptchaWebFormSample/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@
3636
//
3737
// You can specify all the values or you can default the Revision and Build Numbers
3838
// by using the '*' as shown below:
39-
[assembly: AssemblyVersion("2.0.0.0")]
40-
[assembly: AssemblyFileVersion("2.0.0.0")]
39+
[assembly: AssemblyVersion("2.1.0.0")]
40+
[assembly: AssemblyFileVersion("2.1.0.0")]

src/Recaptcha.Web.4.0/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@
3737
// You can specify all the values or you can default the Build and Revision Numbers
3838
// by using the '*' as shown below:
3939
// [assembly: AssemblyVersion("1.0.*")]
40-
[assembly: AssemblyVersion("2.0.0.0")]
41-
[assembly: AssemblyFileVersion("2.0.0.0")]
40+
[assembly: AssemblyVersion("2.1.0.0")]
41+
[assembly: AssemblyFileVersion("2.1.0.0")]

src/Recaptcha.Web.4.0/Recaptcha.Web.4.0.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@
9292
<Compile Include="..\Recaptcha.Web\Recaptcha2VerificationResult.cs">
9393
<Link>Recaptcha2VerificationResult.cs</Link>
9494
</Compile>
95+
<Compile Include="..\Recaptcha.Web\RecaptchaDataSize.cs">
96+
<Link>RecaptchaDataSize.cs</Link>
97+
</Compile>
98+
<Compile Include="..\Recaptcha.Web\RecaptchaDataType.cs">
99+
<Link>RecaptchaDataType.cs</Link>
100+
</Compile>
95101
<Compile Include="..\Recaptcha.Web\RecaptchaHtmlHelper.cs">
96102
<Link>RecaptchaHtmlHelper.cs</Link>
97103
</Compile>

src/Recaptcha.Web.4.5.1/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@
3737
// You can specify all the values or you can default the Build and Revision Numbers
3838
// by using the '*' as shown below:
3939
// [assembly: AssemblyVersion("1.0.*")]
40-
[assembly: AssemblyVersion("2.0.0.0")]
41-
[assembly: AssemblyFileVersion("2.0.0.0")]
40+
[assembly: AssemblyVersion("2.1.0.0")]
41+
[assembly: AssemblyFileVersion("2.1.0.0")]

src/Recaptcha.Web.4.5.1/Recaptcha.Web.4.5.1.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@
9696
<Compile Include="..\Recaptcha.Web\Recaptcha2VerificationResult.cs">
9797
<Link>Recaptcha2VerificationResult.cs</Link>
9898
</Compile>
99+
<Compile Include="..\Recaptcha.Web\RecaptchaDataSize.cs">
100+
<Link>RecaptchaDataSize.cs</Link>
101+
</Compile>
102+
<Compile Include="..\Recaptcha.Web\RecaptchaDataType.cs">
103+
<Link>RecaptchaDataType.cs</Link>
104+
</Compile>
99105
<Compile Include="..\Recaptcha.Web\RecaptchaHtmlHelper.cs">
100106
<Link>RecaptchaHtmlHelper.cs</Link>
101107
</Compile>

src/Recaptcha.Web/Mvc/RecaptchaMvcExtensions.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public static class RecaptchaMvcExtensions
3131
/// <param name="theme">Sets the theme of recaptcha.</param>
3232
/// <param name="language">Sets the language of recaptcha. If no language is specified, the language of the current UI culture will be used.</param>
3333
/// <param name="tabIndex">Sets the tab index of recaptcha.</param>
34+
/// <param name="dataType">Sets the data type of recaptcha.</param>
35+
/// <param name="dataSize">Sets the size of recaptcha.</param>
3436
/// <param name="useSsl">Sets the value to the UseSsl property.</param>
3537
/// <param name="apiVersion">Determines the version of the reCAPTCHA API.</param>
3638
/// <returns>Returns an instance of the IHtmlString type.</returns>
@@ -40,6 +42,8 @@ public static IHtmlString Recaptcha(
4042
RecaptchaTheme theme = RecaptchaTheme.Red,
4143
string language = null,
4244
int tabIndex = 0,
45+
RecaptchaDataType? dataType = null,
46+
RecaptchaDataSize? dataSize = null,
4347
SslBehavior useSsl = SslBehavior.SameAsRequestUrl,
4448
string apiVersion = "{recaptchaApiVersion}")
4549
{
@@ -53,7 +57,7 @@ public static IHtmlString Recaptcha(
5357
}
5458
else
5559
{
56-
rHtmlHelper = new Recaptcha2HtmlHelper(publicKey, theme, language, tabIndex, useSsl);
60+
rHtmlHelper = new Recaptcha2HtmlHelper(publicKey, theme, language, tabIndex, dataType, dataSize, useSsl);
5761
}
5862

5963
var writer = new HtmlTextWriter(new StringWriter());

src/Recaptcha.Web/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@
3737
// You can specify all the values or you can default the Build and Revision Numbers
3838
// by using the '*' as shown below:
3939
// [assembly: AssemblyVersion("1.0.*")]
40-
[assembly: AssemblyVersion("2.0.0.0")]
41-
[assembly: AssemblyFileVersion("2.0.0.0")]
40+
[assembly: AssemblyVersion("2.1.0.0")]
41+
[assembly: AssemblyFileVersion("2.1.0.0")]

src/Recaptcha.Web/Recaptcha.Web.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@
9292
<Compile Include="Mvc\RecaptchaMvcExtensions.cs" />
9393
<Compile Include="Recaptcha2HtmlHelper.cs" />
9494
<Compile Include="Recaptcha2VerificationResult.cs" />
95+
<Compile Include="RecaptchaDataSize.cs" />
96+
<Compile Include="RecaptchaDataType.cs" />
9597
<Compile Include="RecaptchaHtmlHelper.cs" />
9698
<Compile Include="RecaptchaHtmlHelperBase.cs" />
9799
<Compile Include="RecaptchaKeyHelper.cs" />

src/Recaptcha.Web/Recaptcha2HtmlHelper.cs

Lines changed: 86 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@ public class Recaptcha2HtmlHelper : RecaptchaHtmlHelperBase
2020
{
2121
#region Constructors
2222

23+
/// <summary>
2324
/// Creates an instance of the <see cref="Recaptcha2HtmlHelper"/> class.
2425
/// </summary>
2526
/// <param name="publicKey">Sets the public key to be part of the recaptcha HTML.</param>
2627
public Recaptcha2HtmlHelper(string publicKey)
2728
: base(publicKey)
28-
{ }
29+
{
30+
DataType = null;
31+
DataSize = null;
32+
}
2933

3034
/// <summary>
3135
/// Creates an instance of the <see cref="Recaptcha2HtmlHelper"/> class.
@@ -36,7 +40,10 @@ public Recaptcha2HtmlHelper(string publicKey)
3640
/// <param name="tabIndex">Sets the tab index of the recaptcha HTML.</param>
3741
public Recaptcha2HtmlHelper(string publicKey, RecaptchaTheme theme, string language, int tabIndex)
3842
: base(publicKey, theme, language, tabIndex)
39-
{ }
43+
{
44+
DataType = null;
45+
DataSize = null;
46+
}
4047

4148
/// <summary>
4249
/// Creates an instance of the <see cref="Recaptcha2HtmlHelper"/> class.
@@ -48,10 +55,52 @@ public Recaptcha2HtmlHelper(string publicKey, RecaptchaTheme theme, string langu
4855
/// <param name="useSsl">Determines whether to use SSL in reCAPTCHA API URLs.</param>
4956
public Recaptcha2HtmlHelper(string publicKey, RecaptchaTheme theme, string language, int tabIndex, SslBehavior useSsl)
5057
: base(publicKey, theme, language, tabIndex, useSsl)
51-
{ }
58+
{
59+
DataType = null;
60+
DataSize = null;
61+
}
62+
63+
/// <summary>
64+
/// Creates an instance of the <see cref="Recaptcha2HtmlHelper"/> class.
65+
/// </summary>
66+
/// <param name="publicKey">Sets the public key of the recaptcha HTML.</param>
67+
/// <param name="theme">Sets the theme of the recaptcha HTML.</param>
68+
/// <param name="language">Sets the language of the recaptcha HTML.</param>
69+
/// <param name="tabIndex">Sets the tab index of the recaptcha HTML.</param>
70+
/// <param name="dataType">Sets the type of the recaptcha HTML.</param>
71+
/// <param name="dataSize">Sets the size for the recpatcha HTML.</param>
72+
/// <param name="useSsl">Determines whether to use SSL in reCAPTCHA API URLs.</param>
73+
public Recaptcha2HtmlHelper(string publicKey, RecaptchaTheme theme, string language, int tabIndex, RecaptchaDataType? dataType, RecaptchaDataSize? dataSize, SslBehavior useSsl)
74+
: base(publicKey, theme, language, tabIndex, useSsl)
75+
{
76+
DataType = dataType;
77+
DataSize = dataSize;
78+
}
5279

5380
#endregion Constructors
5481

82+
#region Properties
83+
84+
/// <summary>
85+
/// Gets or sets the size of the reCAPTCHA control.
86+
/// </summary>
87+
public RecaptchaDataSize? DataSize
88+
{
89+
get;
90+
set;
91+
}
92+
93+
/// <summary>
94+
/// Gets or sets they type of the reCAPTCHA control.
95+
/// </summary>
96+
public RecaptchaDataType? DataType
97+
{
98+
get;
99+
set;
100+
}
101+
102+
#endregion Properties
103+
55104
#region Public Methods
56105

57106
/// <summary>
@@ -111,6 +160,40 @@ public override string ToString()
111160
sb.Append(string.Format(" data-tabindex=\"{0}\"", TabIndex));
112161
}
113162

163+
if (DataSize != null)
164+
{
165+
string dataSize = null;
166+
167+
switch(DataSize)
168+
{
169+
case RecaptchaDataSize.Compact:
170+
dataSize = "compact";
171+
break;
172+
default:
173+
dataSize = "normal";
174+
break;
175+
}
176+
177+
sb.Append(string.Format(" data-size=\"{0}\"", dataSize));
178+
}
179+
180+
if (DataType != null)
181+
{
182+
string dataType = null;
183+
184+
switch (DataType)
185+
{
186+
case RecaptchaDataType.Audio:
187+
dataType = "audio";
188+
break;
189+
default:
190+
dataType = "image";
191+
break;
192+
}
193+
194+
sb.Append(string.Format(" data-type=\"{0}\"", dataType));
195+
}
196+
114197
sb.Append("></div>");
115198

116199
return sb.ToString();

0 commit comments

Comments
 (0)