diff options
Diffstat (limited to 'src')
4 files changed, 42 insertions, 17 deletions
diff --git a/src/DotNetOpenAuth/DotNetOpenAuth.csproj b/src/DotNetOpenAuth/DotNetOpenAuth.csproj index 8aacd1b..bf2e26c 100644 --- a/src/DotNetOpenAuth/DotNetOpenAuth.csproj +++ b/src/DotNetOpenAuth/DotNetOpenAuth.csproj @@ -186,6 +186,12 @@ http://opensource.org/licenses/ms-pl.html <HintPath>..\..\lib\System.Web.Abstractions.dll</HintPath> <RequiredTargetFramework>3.5</RequiredTargetFramework> </Reference> + <Reference Include="System.Web.Extensions"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Web.Extensions.Design"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> <Reference Include="System.Web.Mobile" /> <Reference Include="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdAjaxTextBox.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdAjaxTextBox.cs index d293cad..2c8d947 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdAjaxTextBox.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdAjaxTextBox.cs @@ -825,7 +825,6 @@ loader.insert();"; // Call into the .js file with initialization information. StringBuilder startupScript = new StringBuilder(); - startupScript.AppendLine("<script language='javascript'>"); startupScript.AppendFormat("var box = document.getElementsByName('{0}')[0];{1}", this.Name, Environment.NewLine); startupScript.AppendFormat( CultureInfo.InvariantCulture, @@ -854,10 +853,7 @@ loader.insert();"; Page.ClientScript.GetPostBackEventReference(this, null), Environment.NewLine); - startupScript.AppendLine("</script>"); - - Page.ClientScript.RegisterStartupScript(this.GetType(), "ajaxstartup", startupScript.ToString()); - + ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxstartup", startupScript.ToString(), true); if (this.HookFormSubmit) { string htmlFormat = @" var openidbox = document.getElementsByName('{0}')[0]; diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdAjaxTextBox.js b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdAjaxTextBox.js index 1941175..4806ea4 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdAjaxTextBox.js +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdAjaxTextBox.js @@ -376,7 +376,7 @@ function initAjaxOpenId(box, openid_logo_url, dotnetopenid_logo_url, spinner_url if (identifier == box.value) { box.dnoi_internal.setVisualCue('discovering'); } - }); + }, box); window.dnoa_internal.addDiscoverySuccess(function(identifier, discoveryResult, state) { if (identifier == box.value && (box.dnoi_internal.state == 'discovering' || !box.dnoi_internal.state)) { @@ -401,20 +401,20 @@ function initAjaxOpenId(box, openid_logo_url, dotnetopenid_logo_url, spinner_url if (discoveryResult.error) { box.title = discoveryResult.error; } } } - }); + }, box); window.dnoa_internal.addDiscoveryFailed(function(identifier, message) { if (identifier == box.value) { box.dnoi_internal.setVisualCue('failed'); if (message) { box.title = message; } } - }); + }, box); window.dnoa_internal.addAuthStarted(function(discoveryResult, serviceEndpoint, state) { if (discoveryResult.userSuppliedIdentifier == box.value) { box.dnoi_internal.setVisualCue('discovering'); } - }); + }, box); window.dnoa_internal.addAuthSuccess(function(discoveryResult, serviceEndpoint, extensionResponses, state) { if (discoveryResult.userSuppliedIdentifier == box.value) { @@ -459,7 +459,7 @@ function initAjaxOpenId(box, openid_logo_url, dotnetopenid_logo_url, spinner_url box.dnoi_internal.postback(discoveryResult, serviceEndpoint, extensionResponses, state); } } - }); + }, box); window.dnoa_internal.addAuthFailed(function(discoveryResult, serviceEndpoint, state) { if (discoveryResult.userSuppliedIdentifier == box.value) { @@ -468,7 +468,7 @@ function initAjaxOpenId(box, openid_logo_url, dotnetopenid_logo_url, spinner_url box.dnoi_internal.displayLoginButton(discoveryResult); } } - }); + }, box); window.dnoa_internal.addAuthCleared(function(discoveryResult, serviceEndpoint) { if (discoveryResult.userSuppliedIdentifier == box.value) { @@ -482,7 +482,11 @@ function initAjaxOpenId(box, openid_logo_url, dotnetopenid_logo_url, spinner_url box.timeout); } } - }); + }, box); + + /***************************************** + * Flow + *****************************************/ box.dnoi_internal.displayLoginButton = function(discoveryResult) { trace('No asynchronous authentication attempt is in progress. Display setup view.'); @@ -497,10 +501,6 @@ function initAjaxOpenId(box, openid_logo_url, dotnetopenid_logo_url, spinner_url box.dnoi_internal.setVisualCue('setup', null, null, providers); }; - /***************************************** - * Flow - *****************************************/ - /// <summary>Called to initiate discovery on some identifier.</summary> box.dnoi_internal.performDiscovery = function() { box.dnoi_internal.authenticationIFrames.closeFrames(); diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingPartyAjaxControlBase.js b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingPartyAjaxControlBase.js index 26d1252..4975812 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingPartyAjaxControlBase.js +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingPartyAjaxControlBase.js @@ -42,8 +42,31 @@ window.dnoa_internal.argsToString = function() { }; window.dnoa_internal.registerEvent = function(name) { + var filterOnApplicability = function(fn, domElement) { + /// <summary>Wraps a given function with a check so that the function only executes when a given element is still in the DOM.</summary> + return function() { + var args = Array.prototype.slice.call(arguments); + if (!domElement) { + // no element used as a basis of applicability indicates we always fire this callback. + fn.apply(null, args); + } else { + var elements = document.getElementsByTagName(domElement.tagName); + var isElementInDom = false; + for (var i = 0; i < elements.length; i++) { + if (elements[i] === domElement) { + isElementInDom = true; + break; + } + } + if (isElementInDom) { + fn.apply(null, args); + } + } + } + }; + window.dnoa_internal[name + 'Listeners'] = []; - window.dnoa_internal['add' + name] = function(fn) { window.dnoa_internal[name + 'Listeners'].push(fn); }; + window.dnoa_internal['add' + name] = function(fn, whileDomElementApplicable) { window.dnoa_internal[name + 'Listeners'].push(filterOnApplicability(fn, whileDomElementApplicable)); }; window.dnoa_internal['remove' + name] = function(fn) { window.dnoa_internal[name + 'Listeners'].remove(fn); }; window.dnoa_internal['fire' + name] = function() { var args = Array.prototype.slice.call(arguments); |