1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
/*jslint white: true, onevar: true, browser: true, undef: true, nomen: true, plusplus: true, bitwise: true, regexp: true, strict: true, newcap: true, immed: true */
"use strict";
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, embed, x, event;
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) {
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;
}
// check for the IdentitySelector event handler is there.
if (document.addEventListener) {
event = document.createEvent("Events");
event.initEvent("IdentitySelectorAvailable", true, true);
top.dispatchEvent(event);
if (top.IdentitySelectorAvailable === true) {
return true;
}
}
}
return false;
},
activate: function (selectorId, hiddenFieldName) {
var selector, hiddenField;
selector = document.getElementById(selectorId);
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;
},
hideStatic: function (divName) {
var div = document.getElementById(divName);
if (div) {
div.style.visibility = 'hidden';
}
},
showStatic: function (divName) {
var div = document.getElementById(divName);
if (div) {
div.style.visibility = 'visible';
}
},
hideDynamic: function (divName) {
var div = document.getElementById(divName);
if (div) {
div.style.display = 'none';
}
},
showDynamic: function (divName) {
var div = document.getElementById(divName);
if (div) {
div.style.display = '';
}
},
checkDynamic: function (controlDiv, unsupportedDiv) {
if (this.isSupported()) {
this.showDynamic(controlDiv);
if (unsupportedDiv) {
this.hideDynamic(unsupportedDiv);
}
} else {
this.hideDynamic(controlDiv);
if (unsupportedDiv) {
this.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);
}
}
}
};
|