summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdAjaxTextBox.cs4
-rw-r--r--src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.cs21
-rw-r--r--src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.js64
3 files changed, 58 insertions, 31 deletions
diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdAjaxTextBox.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdAjaxTextBox.cs
index 4249834..f646599 100644
--- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdAjaxTextBox.cs
+++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdAjaxTextBox.cs
@@ -704,6 +704,10 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
protected override void OnPreRender(EventArgs e) {
base.OnPreRender(e);
+ if (!this.Visible) {
+ return;
+ }
+
if (this.DownloadYahooUILibrary) {
// Although we'll add the <script> tag to download the YAHOO component,
// a download failure may have occurred, so protect ourselves from a
diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.cs
index 9980ea2..e93383d 100644
--- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.cs
+++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.cs
@@ -182,6 +182,14 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
}
/// <summary>
+ /// Gets a value indicating whether some button in the selector will want
+ /// to display the <see cref="OpenIdAjaxTextBox"/> control.
+ /// </summary>
+ protected virtual bool OpenIdTextBoxVisible {
+ get { return this.Buttons.OfType<SelectorOpenIdButton>().Any(); }
+ }
+
+ /// <summary>
/// Releases unmanaged and - optionally - managed resources
/// </summary>
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
@@ -272,6 +280,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Postback", script, true);
this.PreloadDiscovery(this.Buttons.OfType<SelectorProviderButton>().Select(op => op.OPIdentifier).Where(id => id != null));
+ this.textBox.Visible = this.OpenIdTextBoxVisible;
}
/// <summary>
@@ -308,13 +317,15 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
writer.RenderEndTag(); // </ul>
- writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none");
- writer.AddAttribute(HtmlTextWriterAttribute.Id, "OpenIDForm");
- writer.RenderBeginTag(HtmlTextWriterTag.Div);
+ if (this.textBox.Visible) {
+ writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none");
+ writer.AddAttribute(HtmlTextWriterAttribute.Id, "OpenIDForm");
+ writer.RenderBeginTag(HtmlTextWriterTag.Div);
- this.textBox.RenderControl(writer);
+ this.textBox.RenderControl(writer);
- writer.RenderEndTag(); // </div>
+ writer.RenderEndTag(); // </div>
+ }
this.positiveAssertionField.RenderControl(writer);
}
diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.js b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.js
index 6271952..c58e06e 100644
--- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.js
+++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.js
@@ -10,7 +10,7 @@ $(function() {
var hint = $.cookie('openid_identifier') || '';
var ajaxbox = document.getElementsByName('openid_identifier')[0];
- if (hint != 'infocard') {
+ if (ajaxbox && hint != 'infocard') {
ajaxbox.setValue(hint);
}
@@ -31,12 +31,18 @@ $(function() {
}
});
if (!matchFound) {
- $('#OpenIDButton')
- .removeClass('grayedOut')
- .addClass('focused');
- $('#OpenIDForm').show('slow', function() {
- ajaxbox.focus();
- });
+ if (ajaxbox) {
+ $('#OpenIDButton')
+ .removeClass('grayedOut')
+ .addClass('focused');
+ $('#OpenIDForm').show('slow', function() {
+ ajaxbox.focus();
+ });
+ } else {
+ // No OP button matched the last identifier, and there is no text box,
+ // so just un-gray all buttons.
+ ops.removeClass('grayedOut');
+ }
}
}
@@ -65,13 +71,15 @@ $(function() {
}
});
- ajaxbox.onStateChanged = function(state) {
- if (state == "authenticated") {
- showLoginSuccess('OpenIDButton', true);
- } else {
- showLoginSuccess('OpenIDButton', false); // hide checkmark
- }
- };
+ if (ajaxbox) {
+ ajaxbox.onStateChanged = function(state) {
+ if (state == "authenticated") {
+ showLoginSuccess('OpenIDButton', true);
+ } else {
+ showLoginSuccess('OpenIDButton', false); // hide checkmark
+ }
+ };
+ }
function checkidSetup(identifier, timerBased) {
var openid = new window.OpenIdIdentifier(identifier);
@@ -88,8 +96,10 @@ $(function() {
window.postLoginAssertion(respondingEndpoint.response.toString(), window.parent.location.href);
}
- // take over how the text box does postbacks.
- ajaxbox.dnoi_internal.postback = doLogin;
+ if (ajaxbox) {
+ // take over how the text box does postbacks.
+ ajaxbox.dnoi_internal.postback = doLogin;
+ }
// This FrameManager will be used for background logins for the OP buttons
// and the last used identifier. It is NOT the frame manager used by the
@@ -138,7 +148,7 @@ $(function() {
// Don't immediately login if the user clicked OpenID and he can't see the identifier box.
if ($(this)[0].id != 'OpenIDButton') {
relevantUserSuppliedIdentifier = $(this)[0].id;
- } else if ($('#OpenIDForm').is(':visible')) {
+ } else if (ajaxbox && $('#OpenIDForm').is(':visible')) {
relevantUserSuppliedIdentifier = ajaxbox.value;
}
@@ -157,16 +167,18 @@ $(function() {
$('img', this)[0].click();
}
});
- $('#OpenIDButton').click(function() {
- // Be careful to only try to select the text box once it is available.
- if ($('#OpenIDForm').is(':hidden')) {
- $('#OpenIDForm').show('slow', function() {
+ if (ajaxbox) {
+ $('#OpenIDButton').click(function() {
+ // Be careful to only try to select the text box once it is available.
+ if ($('#OpenIDForm').is(':hidden')) {
+ $('#OpenIDForm').show('slow', function() {
+ ajaxbox.focus();
+ });
+ } else {
ajaxbox.focus();
- });
- } else {
- ajaxbox.focus();
- }
- });
+ }
+ });
+ }
// Make popup window close on escape (the dialog style is already taken care of)
$(document).keydown(function(e) {