diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/DotNetOpenAuth/InfoCard/InfoCardSelector.cs | 6 | ||||
-rw-r--r-- | src/DotNetOpenAuth/InfoCard/SupportingScript.js | 206 |
2 files changed, 106 insertions, 106 deletions
diff --git a/src/DotNetOpenAuth/InfoCard/InfoCardSelector.cs b/src/DotNetOpenAuth/InfoCard/InfoCardSelector.cs index c85e45d..949c12b 100644 --- a/src/DotNetOpenAuth/InfoCard/InfoCardSelector.cs +++ b/src/DotNetOpenAuth/InfoCard/InfoCardSelector.cs @@ -553,7 +553,7 @@ namespace DotNetOpenAuth.InfoCard { // generate the onclick script for the image string invokeScript = string.Format( CultureInfo.InvariantCulture, - @"if (ActivateSelector('{0}', '{1}')) {{ {2} }}", + @"if (document.infoCard.activate('{0}', '{1}')) {{ {2} }}", this.SelectorObjectId, this.HiddenFieldName, postback); @@ -662,13 +662,13 @@ namespace DotNetOpenAuth.InfoCard { this.Page.ClientScript.RegisterStartupScript( typeof(InfoCardSelector), "SelectorSupportingScript_" + this.ClientID, - string.Format(CultureInfo.InvariantCulture, "CheckStatic('{0}', '{1}');", this.infoCardSupportedPanel.ClientID, this.infoCardNotSupportedPanel.ClientID), + string.Format(CultureInfo.InvariantCulture, "document.infoCard.checkStatic('{0}', '{1}');", this.infoCardSupportedPanel.ClientID, this.infoCardNotSupportedPanel.ClientID), true); } else if (RenderMode == RenderMode.Dynamic) { this.Page.ClientScript.RegisterStartupScript( typeof(InfoCardSelector), "SelectorSupportingScript_" + this.ClientID, - string.Format(CultureInfo.InvariantCulture, "CheckDynamic('{0}', '{1}');", this.infoCardSupportedPanel.ClientID, this.infoCardNotSupportedPanel.ClientID), + string.Format(CultureInfo.InvariantCulture, "document.infoCard.checkDynamic('{0}', '{1}');", this.infoCardSupportedPanel.ClientID, this.infoCardNotSupportedPanel.ClientID), true); } } diff --git a/src/DotNetOpenAuth/InfoCard/SupportingScript.js b/src/DotNetOpenAuth/InfoCard/SupportingScript.js index d867dc7..ce4b02d 100644 --- a/src/DotNetOpenAuth/InfoCard/SupportingScript.js +++ b/src/DotNetOpenAuth/InfoCard/SupportingScript.js @@ -1,122 +1,122 @@ -function AreCardsSupported() { - /// <summary> - /// Determines if information cards are supported by the - /// browser. - /// </summary> - /// <returns> - /// true-if the browser supports information cards. - ///</returns> +document.infoCard = { + isSupported: function() { + /// <summary> + /// Determines if information cards are supported by the + /// browser. + /// </summary> + /// <returns> + /// true-if the browser supports information cards. + ///</returns> - var IEVer = -1; - if (navigator.appName == 'Microsoft Internet Explorer') { - if (new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})").exec(navigator.userAgent) != null) { - IEVer = parseFloat(RegExp.$1); + var IEVer = -1; + if (navigator.appName == 'Microsoft Internet Explorer') { + if (new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})").exec(navigator.userAgent) != null) { + IEVer = parseFloat(RegExp.$1); + } } - } - // Look for IE 7+. - if (IEVer >= 7) { - var embed = document.createElement("object"); - embed.type = "application/x-informationcard"; - return !(embed.issuerPolicy === undefined) && embed.isInstalled; - } - - // not IE (any version) - if (IEVer < 0 && navigator.mimeTypes && navigator.mimeTypes.length) { - // check to see if there is a mimeType handler. - x = navigator.mimeTypes['application/x-informationcard']; - if (x && x.enabledPlugin) { - return true; + // Look for IE 7+. + if (IEVer >= 7) { + var embed = document.createElement("object"); + embed.type = "application/x-informationcard"; + return !(embed.issuerPolicy === undefined) && embed.isInstalled; } - // check for the IdentitySelector event handler is there. - if (document.addEventListener) { - var event = document.createEvent("Events"); - event.initEvent("IdentitySelectorAvailable", true, true); - top.dispatchEvent(event); - - if (top.IdentitySelectorAvailable == true) { + // not IE (any version) + if (IEVer < 0 && navigator.mimeTypes && navigator.mimeTypes.length) { + // check to see if there is a mimeType handler. + x = navigator.mimeTypes['application/x-informationcard']; + if (x && x.enabledPlugin) { return true; } - } - } - - return false; -} -function ActivateSelector(selectorId, hiddenFieldName) { - var selector = document.getElementById(selectorId); - var hiddenField = document.getElementsByName(hiddenFieldName)[0]; - try { - hiddenField.value = selector.value; - } catch (e) { - // Selector was canceled - return false; - } - if (hiddenField.value == 'undefined') { // really the string, not === undefined - // We're dealing with a bad FireFox selector plugin. - // Just add the control to the form by setting its name property and submit to activate. - selector.name = hiddenFieldName; - hiddenField.parentNode.removeChild(hiddenField); - return true; - } - return true; -}; + // check for the IdentitySelector event handler is there. + if (document.addEventListener) { + var event = document.createEvent("Events"); + event.initEvent("IdentitySelectorAvailable", true, true); + top.dispatchEvent(event); -function HideStatic(divName) { - var div = document.getElementById(divName); - if (div) { - div.style.visibility = 'hidden'; - } -} + if (top.IdentitySelectorAvailable == true) { + return true; + } + } + } + + return false; + }, -function ShowStatic(divName) { - var div = document.getElementById(divName); - if (div) { - div.style.visibility = 'visible'; - } -} + activate: function(selectorId, hiddenFieldName) { + var selector = document.getElementById(selectorId); + var hiddenField = document.getElementsByName(hiddenFieldName)[0]; + try { + hiddenField.value = selector.value; + } catch (e) { + // Selector was canceled + return false; + } + if (hiddenField.value == 'undefined') { // really the string, not === undefined + // We're dealing with a bad FireFox selector plugin. + // Just add the control to the form by setting its name property and submit to activate. + selector.name = hiddenFieldName; + hiddenField.parentNode.removeChild(hiddenField); + return true; + } + return true; + }, -function HideDynamic(divName) { - var div = document.getElementById(divName); - if (div) { - div.style.display = 'none'; - } -} + hideStatic: function (divName) { + var div = document.getElementById(divName); + if (div) { + div.style.visibility = 'hidden'; + } + }, -function ShowDynamic(divName) { - var div = document.getElementById(divName); - if (div) { - div.style.display = ''; - } -} + showStatic: function(divName) { + var div = document.getElementById(divName); + if (div) { + div.style.visibility = 'visible'; + } + }, -function CheckDynamic(controlDiv, unsupportedDiv) { - if (AreCardsSupported()) { - ShowDynamic(controlDiv); - if (unsupportedDiv != '') { - HideDynamic(unsupportedDiv); + hideDynamic: function (divName) { + var div = document.getElementById(divName); + if (div) { + div.style.display = 'none'; } - } - else { - HideDynamic(controlDiv); - if (unsupportedDiv != '') { - ShowDynamic(unsupportedDiv); + }, + + showDynamic: function (divName) { + var div = document.getElementById(divName); + if (div) { + div.style.display = ''; } - } -} + }, -function CheckStatic(controlDiv, unsupportedDiv) { - if (AreCardsSupported()) { - ShowStatic(controlDiv); - if (unsupportedDiv != '') { - HideStatic(unsupportedDiv); + checkDynamic: function (controlDiv, unsupportedDiv) { + if (this.isSupported()) { + this.showDynamic(controlDiv); + if (unsupportedDiv != '') { + this.hideDynamic(unsupportedDiv); + } + } else { + this.hideDynamic(controlDiv); + if (unsupportedDiv != '') { + this.showDynamic(unsupportedDiv); + } } - } - else { - HideStatic(controlDiv); - if (unsupportedDiv != '') { - ShowDynamic(unsupportedDiv); + }, + + checkStatic: function(controlDiv, unsupportedDiv) { + if (this.isSupported()) { + this.showStatic(controlDiv); + if (unsupportedDiv != '') { + this.hideStatic(unsupportedDiv); + } + } else { + this.hideStatic(controlDiv); + if (unsupportedDiv != '') { + this.showDynamic(unsupportedDiv); + } } } -}
\ No newline at end of file +}; |