admin_module 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/Gemfile +2 -0
- data/README.md +7 -0
- data/admin_module.gemspec +3 -1
- data/{bin → exe}/admin_module +0 -0
- data/lib/admin_module.rb +9 -0
- data/lib/admin_module/command/config.rb +20 -0
- data/lib/admin_module/command/gdl.rb +15 -0
- data/lib/admin_module/guideline.rb +8 -0
- data/lib/admin_module/page_factory.rb +43 -2
- data/lib/admin_module/pages.rb +38 -81
- data/lib/admin_module/pages/guideline_page.rb +54 -1
- data/lib/admin_module/pages/guideline_page_400.rb +87 -0
- data/lib/admin_module/pages/guideline_version_page.rb +9 -5
- data/lib/admin_module/pages/guidelines_page.rb +40 -34
- data/lib/admin_module/pages/guidelines_page_400.rb +65 -0
- data/lib/admin_module/pages/guidelines_version_all_page.rb +79 -72
- data/lib/admin_module/pages/guidelines_version_all_page_400.rb +122 -0
- data/lib/admin_module/pages/login_page.rb +2 -2
- data/lib/admin_module/pages/login_page_400.rb +73 -0
- data/lib/admin_module/version.rb +1 -1
- data/spec/data/config/no_ams_version.admin_module +11 -0
- data/spec/data/html/guideline-400.html +2713 -0
- data/spec/data/html/guideline-400_files/BindChildren.js +852 -0
- data/spec/data/html/guideline-400_files/CVlogo.jpg +0 -0
- data/spec/data/html/guideline-400_files/Guideline.js +301 -0
- data/spec/data/html/guideline-400_files/OptimalOutcome.png +0 -0
- data/spec/data/html/guideline-400_files/WebResource(1).axd +561 -0
- data/spec/data/html/guideline-400_files/WebResource.axd +548 -0
- data/spec/data/html/guideline-400_files/styles.css +444 -0
- data/spec/data/html/guideline-400_files/styles2.css +115 -0
- data/spec/data/html/guideline-400_files/tab.css +50 -0
- data/spec/data/html/guideline-400_files/tabpane.js +297 -0
- data/spec/data/html/guideline.html +1809 -0
- data/spec/data/html/guideline_files/BindChildren.js +799 -0
- data/spec/data/html/guideline_files/Guideline.js +300 -0
- data/spec/data/html/guideline_files/LeftMenu.html +0 -0
- data/spec/data/html/guideline_files/MainFrame.html +18 -0
- data/spec/data/html/guideline_files/ScriptResource.axd +3725 -0
- data/spec/data/html/guideline_files/Stylesheet.css +1545 -0
- data/spec/data/html/guideline_files/WebResource(1).axd +0 -0
- data/spec/data/html/guideline_files/WebResource(2).axd +566 -0
- data/spec/data/html/guideline_files/WebResource(3).axd +219 -0
- data/spec/data/html/guideline_files/WebResource.axd +696 -0
- data/spec/data/html/guideline_files/framebar.html +0 -0
- data/spec/data/html/guideline_files/guideline.html +0 -0
- data/spec/data/html/guideline_files/home.png +0 -0
- data/spec/data/html/guideline_files/jquery-ui.css +578 -0
- data/spec/data/html/guideline_files/jquery.js +7 -0
- data/spec/data/html/guideline_files/slidebar.gif +29 -0
- data/spec/data/html/guideline_files/tab.css +49 -0
- data/spec/data/html/guideline_files/tabpane.js +297 -0
- data/spec/data/html/guidelines-400.html +368 -0
- data/spec/data/html/guidelines-400_files/CVlogo.jpg +0 -0
- data/spec/data/html/guidelines-400_files/EditListSearchHelper.js +141 -0
- data/spec/data/html/guidelines-400_files/OptimalOutcome.png +0 -0
- data/spec/data/html/guidelines-400_files/WebResource(1).axd +561 -0
- data/spec/data/html/guidelines-400_files/WebResource.axd +548 -0
- data/spec/data/html/guidelines-400_files/menu.css +29 -0
- data/spec/data/html/guidelines-400_files/menu.js +48 -0
- data/spec/data/html/guidelines-400_files/shadow.gif +0 -0
- data/spec/data/html/guidelines-400_files/styles.css +444 -0
- data/spec/data/html/guidelines-400_files/styles2.css +115 -0
- data/spec/data/html/guidelines.html +217 -0
- data/spec/data/html/guidelines_files/EditListSearchHelper.js +123 -0
- data/spec/data/html/guidelines_files/ScriptResource.axd +3725 -0
- data/spec/data/html/guidelines_files/Stylesheet.css +1545 -0
- data/spec/data/html/guidelines_files/jquery-ui.css +578 -0
- data/spec/data/html/login.aspx.html +293 -0
- data/spec/data/html/login.aspx_files/ScriptResource.axd +3332 -0
- data/spec/data/html/login.aspx_files/Stylesheet.css +1545 -0
- data/spec/data/html/login.aspx_files/jquery-ui.css +578 -0
- data/spec/data/html/login.aspx_files/jquery.js +7 -0
- data/spec/data/html/login400.aspx.html +191 -0
- data/spec/data/html/login400.aspx_files/WebResource(1).axd +561 -0
- data/spec/data/html/login400.aspx_files/WebResource.axd +548 -0
- data/spec/data/html/login400.aspx_files/styles.css +444 -0
- data/spec/data/html/version_all_guidelines-400.html +702 -0
- data/spec/data/html/version_all_guidelines-400_files/CVlogo.jpg +0 -0
- data/spec/data/html/version_all_guidelines-400_files/Calendar.js +521 -0
- data/spec/data/html/version_all_guidelines-400_files/OptimalOutcome.png +0 -0
- data/spec/data/html/version_all_guidelines-400_files/TwoSelects.js +300 -0
- data/spec/data/html/version_all_guidelines-400_files/menu.css +29 -0
- data/spec/data/html/version_all_guidelines-400_files/menu.js +48 -0
- data/spec/data/html/version_all_guidelines-400_files/shadow.gif +0 -0
- data/spec/data/html/version_all_guidelines-400_files/styles(1).css +134 -0
- data/spec/data/html/version_all_guidelines-400_files/styles.css +444 -0
- data/spec/data/html/version_all_guidelines-400_files/styles2.css +115 -0
- data/spec/data/html/version_all_guidelines.html +560 -0
- data/spec/data/html/version_all_guidelines_files/Calendar.js +521 -0
- data/spec/data/html/version_all_guidelines_files/ScriptResource.axd +3725 -0
- data/spec/data/html/version_all_guidelines_files/Stylesheet.css +1545 -0
- data/spec/data/html/version_all_guidelines_files/TwoSelects.js +304 -0
- data/spec/data/html/version_all_guidelines_files/jquery-ui.css +578 -0
- data/spec/lib/admin_module/command/config_spec.rb +27 -0
- data/spec/lib/admin_module/command/gdl_spec.rb +31 -0
- data/spec/lib/admin_module/configuration_spec.rb +47 -0
- data/spec/lib/admin_module/guideline_spec.rb +26 -0
- data/spec/lib/admin_module/page_factory_spec.rb +72 -0
- data/spec/lib/admin_module/pages/guideline_page_400_spec.rb +51 -0
- data/spec/lib/admin_module/pages/guideline_page_spec.rb +50 -0
- data/spec/lib/admin_module/pages/guidelines_page_400_spec.rb +92 -0
- data/spec/lib/admin_module/pages/guidelines_page_spec.rb +91 -0
- data/spec/lib/admin_module/pages/guidelines_version_all_page_400_spec.rb +102 -0
- data/spec/lib/admin_module/pages/guidelines_version_all_page_spec.rb +105 -0
- data/spec/lib/admin_module/pages/login_page_400_spec.rb +42 -0
- data/spec/lib/admin_module/pages/login_page_spec.rb +33 -0
- data/spec/support/html_spec.rb +26 -0
- data/spec/support/mocks.rb +23 -0
- metadata +191 -5
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
function TreeView_HoverNode(data, node) {
|
|
2
|
+
if (!data) {
|
|
3
|
+
return;
|
|
4
|
+
}
|
|
5
|
+
node.hoverClass = data.hoverClass;
|
|
6
|
+
WebForm_AppendToClassName(node, data.hoverClass);
|
|
7
|
+
if (__nonMSDOMBrowser) {
|
|
8
|
+
node = node.childNodes[node.childNodes.length - 1];
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
node = node.children[node.children.length - 1];
|
|
12
|
+
}
|
|
13
|
+
node.hoverHyperLinkClass = data.hoverHyperLinkClass;
|
|
14
|
+
WebForm_AppendToClassName(node, data.hoverHyperLinkClass);
|
|
15
|
+
}
|
|
16
|
+
function TreeView_GetNodeText(node) {
|
|
17
|
+
var trNode = WebForm_GetParentByTagName(node, "TR");
|
|
18
|
+
var outerNodes;
|
|
19
|
+
if (trNode.childNodes[trNode.childNodes.length - 1].getElementsByTagName) {
|
|
20
|
+
outerNodes = trNode.childNodes[trNode.childNodes.length - 1].getElementsByTagName("A");
|
|
21
|
+
if (!outerNodes || outerNodes.length == 0) {
|
|
22
|
+
outerNodes = trNode.childNodes[trNode.childNodes.length - 1].getElementsByTagName("SPAN");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
var textNode = (outerNodes && outerNodes.length > 0) ?
|
|
26
|
+
outerNodes[0].childNodes[0] :
|
|
27
|
+
trNode.childNodes[trNode.childNodes.length - 1].childNodes[0];
|
|
28
|
+
return (textNode && textNode.nodeValue) ? textNode.nodeValue : "";
|
|
29
|
+
}
|
|
30
|
+
function TreeView_PopulateNode(data, index, node, selectNode, selectImageNode, lineType, text, path, databound, datapath, parentIsLast) {
|
|
31
|
+
if (!data) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
var context = new Object();
|
|
35
|
+
context.data = data;
|
|
36
|
+
context.node = node;
|
|
37
|
+
context.selectNode = selectNode;
|
|
38
|
+
context.selectImageNode = selectImageNode;
|
|
39
|
+
context.lineType = lineType;
|
|
40
|
+
context.index = index;
|
|
41
|
+
context.isChecked = "f";
|
|
42
|
+
var tr = WebForm_GetParentByTagName(node, "TR");
|
|
43
|
+
if (tr) {
|
|
44
|
+
var checkbox = tr.getElementsByTagName("INPUT");
|
|
45
|
+
if (checkbox && (checkbox.length > 0)) {
|
|
46
|
+
for (var i = 0; i < checkbox.length; i++) {
|
|
47
|
+
if (checkbox[i].type.toLowerCase() == "checkbox") {
|
|
48
|
+
if (checkbox[i].checked) {
|
|
49
|
+
context.isChecked = "t";
|
|
50
|
+
}
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
var param = index + "|" + data.lastIndex + "|" + databound + context.isChecked + parentIsLast + "|" +
|
|
57
|
+
text.length + "|" + text + datapath.length + "|" + datapath + path;
|
|
58
|
+
TreeView_PopulateNodeDoCallBack(context, param);
|
|
59
|
+
}
|
|
60
|
+
function TreeView_ProcessNodeData(result, context) {
|
|
61
|
+
var treeNode = context.node;
|
|
62
|
+
if (result.length > 0) {
|
|
63
|
+
var ci = result.indexOf("|", 0);
|
|
64
|
+
context.data.lastIndex = result.substring(0, ci);
|
|
65
|
+
ci = result.indexOf("|", ci + 1);
|
|
66
|
+
var newExpandState = result.substring(context.data.lastIndex.length + 1, ci);
|
|
67
|
+
context.data.expandState.value += newExpandState;
|
|
68
|
+
var chunk = result.substr(ci + 1);
|
|
69
|
+
var newChildren, table;
|
|
70
|
+
if (__nonMSDOMBrowser) {
|
|
71
|
+
var newDiv = document.createElement("div");
|
|
72
|
+
newDiv.innerHTML = chunk;
|
|
73
|
+
table = WebForm_GetParentByTagName(treeNode, "TABLE");
|
|
74
|
+
newChildren = null;
|
|
75
|
+
if ((typeof(table.nextSibling) == "undefined") || (table.nextSibling == null)) {
|
|
76
|
+
table.parentNode.insertBefore(newDiv.firstChild, table.nextSibling);
|
|
77
|
+
newChildren = table.previousSibling;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
table = table.nextSibling;
|
|
81
|
+
table.parentNode.insertBefore(newDiv.firstChild, table);
|
|
82
|
+
newChildren = table.previousSibling;
|
|
83
|
+
}
|
|
84
|
+
newChildren = document.getElementById(treeNode.id + "Nodes");
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
table = WebForm_GetParentByTagName(treeNode, "TABLE");
|
|
88
|
+
table.insertAdjacentHTML("afterEnd", chunk);
|
|
89
|
+
newChildren = document.all[treeNode.id + "Nodes"];
|
|
90
|
+
}
|
|
91
|
+
if ((typeof(newChildren) != "undefined") && (newChildren != null)) {
|
|
92
|
+
TreeView_ToggleNode(context.data, context.index, treeNode, context.lineType, newChildren);
|
|
93
|
+
treeNode.href = document.getElementById ?
|
|
94
|
+
"javascript:TreeView_ToggleNode(" + context.data.name + "," + context.index + ",document.getElementById('" + treeNode.id + "'),'" + context.lineType + "',document.getElementById('" + newChildren.id + "'))" :
|
|
95
|
+
"javascript:TreeView_ToggleNode(" + context.data.name + "," + context.index + "," + treeNode.id + ",'" + context.lineType + "'," + newChildren.id + ")";
|
|
96
|
+
if ((typeof(context.selectNode) != "undefined") && (context.selectNode != null) && context.selectNode.href &&
|
|
97
|
+
(context.selectNode.href.indexOf("javascript:TreeView_PopulateNode", 0) == 0)) {
|
|
98
|
+
context.selectNode.href = treeNode.href;
|
|
99
|
+
}
|
|
100
|
+
if ((typeof(context.selectImageNode) != "undefined") && (context.selectImageNode != null) && context.selectNode.href &&
|
|
101
|
+
(context.selectImageNode.href.indexOf("javascript:TreeView_PopulateNode", 0) == 0)) {
|
|
102
|
+
context.selectImageNode.href = treeNode.href;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
context.data.populateLog.value += context.index + ",";
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
var img = treeNode.childNodes ? treeNode.childNodes[0] : treeNode.children[0];
|
|
109
|
+
if ((typeof(img) != "undefined") && (img != null)) {
|
|
110
|
+
var lineType = context.lineType;
|
|
111
|
+
if (lineType == "l") {
|
|
112
|
+
img.src = context.data.images[13];
|
|
113
|
+
}
|
|
114
|
+
else if (lineType == "t") {
|
|
115
|
+
img.src = context.data.images[10];
|
|
116
|
+
}
|
|
117
|
+
else if (lineType == "-") {
|
|
118
|
+
img.src = context.data.images[16];
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
img.src = context.data.images[3];
|
|
122
|
+
}
|
|
123
|
+
var pe;
|
|
124
|
+
if (__nonMSDOMBrowser) {
|
|
125
|
+
pe = treeNode.parentNode;
|
|
126
|
+
pe.insertBefore(img, treeNode);
|
|
127
|
+
pe.removeChild(treeNode);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
pe = treeNode.parentElement;
|
|
131
|
+
treeNode.style.visibility="hidden";
|
|
132
|
+
treeNode.style.display="none";
|
|
133
|
+
pe.insertAdjacentElement("afterBegin", img);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function TreeView_SelectNode(data, node, nodeId) {
|
|
139
|
+
if (!data) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if ((typeof(data.selectedClass) != "undefined") && (data.selectedClass != null)) {
|
|
143
|
+
var id = data.selectedNodeID.value;
|
|
144
|
+
if (id.length > 0) {
|
|
145
|
+
var selectedNode = document.getElementById(id);
|
|
146
|
+
if ((typeof(selectedNode) != "undefined") && (selectedNode != null)) {
|
|
147
|
+
WebForm_RemoveClassName(selectedNode, data.selectedHyperLinkClass);
|
|
148
|
+
selectedNode = WebForm_GetParentByTagName(selectedNode, "TD");
|
|
149
|
+
WebForm_RemoveClassName(selectedNode, data.selectedClass);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
WebForm_AppendToClassName(node, data.selectedHyperLinkClass);
|
|
153
|
+
node = WebForm_GetParentByTagName(node, "TD");
|
|
154
|
+
WebForm_AppendToClassName(node, data.selectedClass)
|
|
155
|
+
}
|
|
156
|
+
data.selectedNodeID.value = nodeId;
|
|
157
|
+
}
|
|
158
|
+
function TreeView_ToggleNode(data, index, node, lineType, children) {
|
|
159
|
+
if (!data) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
var img = node.childNodes[0];
|
|
163
|
+
var newExpandState;
|
|
164
|
+
try {
|
|
165
|
+
if (children.style.display == "none") {
|
|
166
|
+
children.style.display = "block";
|
|
167
|
+
newExpandState = "e";
|
|
168
|
+
if ((typeof(img) != "undefined") && (img != null)) {
|
|
169
|
+
if (lineType == "l") {
|
|
170
|
+
img.src = data.images[15];
|
|
171
|
+
}
|
|
172
|
+
else if (lineType == "t") {
|
|
173
|
+
img.src = data.images[12];
|
|
174
|
+
}
|
|
175
|
+
else if (lineType == "-") {
|
|
176
|
+
img.src = data.images[18];
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
img.src = data.images[5];
|
|
180
|
+
}
|
|
181
|
+
img.alt = data.collapseToolTip.replace(/\{0\}/, TreeView_GetNodeText(node));
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
children.style.display = "none";
|
|
186
|
+
newExpandState = "c";
|
|
187
|
+
if ((typeof(img) != "undefined") && (img != null)) {
|
|
188
|
+
if (lineType == "l") {
|
|
189
|
+
img.src = data.images[14];
|
|
190
|
+
}
|
|
191
|
+
else if (lineType == "t") {
|
|
192
|
+
img.src = data.images[11];
|
|
193
|
+
}
|
|
194
|
+
else if (lineType == "-") {
|
|
195
|
+
img.src = data.images[17];
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
img.src = data.images[4];
|
|
199
|
+
}
|
|
200
|
+
img.alt = data.expandToolTip.replace(/\{0\}/, TreeView_GetNodeText(node));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
catch(e) {}
|
|
205
|
+
data.expandState.value = data.expandState.value.substring(0, index) + newExpandState + data.expandState.value.slice(index + 1);
|
|
206
|
+
}
|
|
207
|
+
function TreeView_UnhoverNode(node) {
|
|
208
|
+
if (!node.hoverClass) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
WebForm_RemoveClassName(node, node.hoverClass);
|
|
212
|
+
if (__nonMSDOMBrowser) {
|
|
213
|
+
node = node.childNodes[node.childNodes.length - 1];
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
node = node.children[node.children.length - 1];
|
|
217
|
+
}
|
|
218
|
+
WebForm_RemoveClassName(node, node.hoverHyperLinkClass);
|
|
219
|
+
}
|
|
@@ -0,0 +1,696 @@
|
|
|
1
|
+
if (!window.Sys) { window.Sys = {}; }
|
|
2
|
+
if (!Sys.WebForms) { Sys.WebForms = {}; }
|
|
3
|
+
Sys.WebForms.Menu = function(options) {
|
|
4
|
+
this.items = [];
|
|
5
|
+
this.depth = options.depth || 1;
|
|
6
|
+
this.parentMenuItem = options.parentMenuItem;
|
|
7
|
+
this.element = Sys.WebForms.Menu._domHelper.getElement(options.element);
|
|
8
|
+
if (this.element.tagName === 'DIV') {
|
|
9
|
+
var containerElement = this.element;
|
|
10
|
+
this.element = Sys.WebForms.Menu._domHelper.firstChild(containerElement);
|
|
11
|
+
this.element.tabIndex = options.tabIndex || 0;
|
|
12
|
+
options.element = containerElement;
|
|
13
|
+
options.menu = this;
|
|
14
|
+
this.container = new Sys.WebForms._MenuContainer(options);
|
|
15
|
+
Sys.WebForms.Menu._domHelper.setFloat(this.element, this.container.rightToLeft ? "right" : "left");
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
this.container = options.container;
|
|
19
|
+
this.keyMap = options.keyMap;
|
|
20
|
+
}
|
|
21
|
+
Sys.WebForms.Menu._elementObjectMapper.map(this.element, this);
|
|
22
|
+
if (this.parentMenuItem && this.parentMenuItem.parentMenu) {
|
|
23
|
+
this.parentMenu = this.parentMenuItem.parentMenu;
|
|
24
|
+
this.rootMenu = this.parentMenu.rootMenu;
|
|
25
|
+
if (!this.element.id) {
|
|
26
|
+
this.element.id = (this.container.element.id || 'menu') + ':submenu:' + Sys.WebForms.Menu._elementObjectMapper._computedId;
|
|
27
|
+
}
|
|
28
|
+
if (this.depth > this.container.staticDisplayLevels) {
|
|
29
|
+
this.displayMode = "dynamic";
|
|
30
|
+
this.element.style.display = "none";
|
|
31
|
+
this.element.style.position = "absolute";
|
|
32
|
+
if (this.rootMenu && this.container.orientation === 'horizontal' && this.parentMenu.isStatic()) {
|
|
33
|
+
this.element.style.top = "100%";
|
|
34
|
+
if (this.container.rightToLeft) {
|
|
35
|
+
this.element.style.right = "0px";
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
this.element.style.left = "0px";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
this.element.style.top = "0px";
|
|
43
|
+
if (this.container.rightToLeft) {
|
|
44
|
+
this.element.style.right = "100%";
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
this.element.style.left = "100%";
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (this.container.rightToLeft) {
|
|
51
|
+
this.keyMap = Sys.WebForms.Menu._keyboardMapping.verticalRtl;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
this.keyMap = Sys.WebForms.Menu._keyboardMapping.vertical;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this.displayMode = "static";
|
|
59
|
+
this.element.style.display = "block";
|
|
60
|
+
if (this.container.orientation === 'horizontal') {
|
|
61
|
+
Sys.WebForms.Menu._domHelper.setFloat(this.element, this.container.rightToLeft ? "right" : "left");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
Sys.WebForms.Menu._domHelper.appendCssClass(this.element, this.displayMode);
|
|
66
|
+
var children = this.element.childNodes;
|
|
67
|
+
var count = children.length;
|
|
68
|
+
for (var i = 0; i < count; i++) {
|
|
69
|
+
var node = children[i];
|
|
70
|
+
if (node.nodeType !== 1) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
var topLevelMenuItem = null;
|
|
74
|
+
if (this.parentMenuItem) {
|
|
75
|
+
topLevelMenuItem = this.parentMenuItem.topLevelMenuItem;
|
|
76
|
+
}
|
|
77
|
+
var menuItem = new Sys.WebForms.MenuItem(this, node, topLevelMenuItem);
|
|
78
|
+
var previousMenuItem = this.items[this.items.length - 1];
|
|
79
|
+
if (previousMenuItem) {
|
|
80
|
+
menuItem.previousSibling = previousMenuItem;
|
|
81
|
+
previousMenuItem.nextSibling = menuItem;
|
|
82
|
+
}
|
|
83
|
+
this.items[this.items.length] = menuItem;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
Sys.WebForms.Menu.prototype = {
|
|
87
|
+
blur: function() { if (this.container) this.container.blur(); },
|
|
88
|
+
collapse: function() {
|
|
89
|
+
this.each(function(menuItem) {
|
|
90
|
+
menuItem.hover(false);
|
|
91
|
+
menuItem.blur();
|
|
92
|
+
var childMenu = menuItem.childMenu;
|
|
93
|
+
if (childMenu) {
|
|
94
|
+
childMenu.collapse();
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
this.hide();
|
|
98
|
+
},
|
|
99
|
+
doDispose: function() { this.each(function(item) { item.doDispose(); }); },
|
|
100
|
+
each: function(fn) {
|
|
101
|
+
var count = this.items.length;
|
|
102
|
+
for (var i = 0; i < count; i++) {
|
|
103
|
+
fn(this.items[i]);
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
firstChild: function() { return this.items[0]; },
|
|
107
|
+
focus: function() { if (this.container) this.container.focus(); },
|
|
108
|
+
get_displayed: function() { return this.element.style.display !== 'none'; },
|
|
109
|
+
get_focused: function() {
|
|
110
|
+
if (this.container) {
|
|
111
|
+
return this.container.focused;
|
|
112
|
+
}
|
|
113
|
+
return false;
|
|
114
|
+
},
|
|
115
|
+
handleKeyPress: function(keyCode) {
|
|
116
|
+
if (this.keyMap.contains(keyCode)) {
|
|
117
|
+
if (this.container.focusedMenuItem) {
|
|
118
|
+
this.container.focusedMenuItem.navigate(keyCode);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
var firstChild = this.firstChild();
|
|
122
|
+
if (firstChild) {
|
|
123
|
+
this.container.navigateTo(firstChild);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
hide: function() {
|
|
128
|
+
if (!this.get_displayed()) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
this.each(function(item) {
|
|
132
|
+
if (item.childMenu) {
|
|
133
|
+
item.childMenu.hide();
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
if (!this.isRoot()) {
|
|
137
|
+
if (this.get_focused()) {
|
|
138
|
+
this.container.navigateTo(this.parentMenuItem);
|
|
139
|
+
}
|
|
140
|
+
this.element.style.display = 'none';
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
isRoot: function() { return this.rootMenu === this; },
|
|
144
|
+
isStatic: function() { return this.displayMode === 'static'; },
|
|
145
|
+
lastChild: function() { return this.items[this.items.length - 1]; },
|
|
146
|
+
show: function() { this.element.style.display = 'block'; }
|
|
147
|
+
};
|
|
148
|
+
if (Sys.WebForms.Menu.registerClass) {
|
|
149
|
+
Sys.WebForms.Menu.registerClass('Sys.WebForms.Menu');
|
|
150
|
+
}
|
|
151
|
+
Sys.WebForms.MenuItem = function(parentMenu, listElement, topLevelMenuItem) {
|
|
152
|
+
this.keyMap = parentMenu.keyMap;
|
|
153
|
+
this.parentMenu = parentMenu;
|
|
154
|
+
this.container = parentMenu.container;
|
|
155
|
+
this.element = listElement;
|
|
156
|
+
this.topLevelMenuItem = topLevelMenuItem || this;
|
|
157
|
+
this._anchor = Sys.WebForms.Menu._domHelper.firstChild(listElement);
|
|
158
|
+
while (this._anchor && this._anchor.tagName !== 'A') {
|
|
159
|
+
this._anchor = Sys.WebForms.Menu._domHelper.nextSibling(this._anchor);
|
|
160
|
+
}
|
|
161
|
+
if (this._anchor) {
|
|
162
|
+
this._anchor.tabIndex = -1;
|
|
163
|
+
var subMenu = this._anchor;
|
|
164
|
+
while (subMenu && subMenu.tagName !== 'UL') {
|
|
165
|
+
subMenu = Sys.WebForms.Menu._domHelper.nextSibling(subMenu);
|
|
166
|
+
}
|
|
167
|
+
if (subMenu) {
|
|
168
|
+
this.childMenu = new Sys.WebForms.Menu({ element: subMenu, parentMenuItem: this, depth: parentMenu.depth + 1, container: this.container, keyMap: this.keyMap });
|
|
169
|
+
if (!this.childMenu.isStatic()) {
|
|
170
|
+
Sys.WebForms.Menu._domHelper.appendCssClass(this.element, 'has-popup');
|
|
171
|
+
Sys.WebForms.Menu._domHelper.appendAttributeValue(this.element, 'aria-haspopup', this.childMenu.element.id);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
Sys.WebForms.Menu._elementObjectMapper.map(listElement, this);
|
|
176
|
+
Sys.WebForms.Menu._domHelper.appendAttributeValue(listElement, 'role', 'menuitem');
|
|
177
|
+
Sys.WebForms.Menu._domHelper.appendCssClass(listElement, parentMenu.displayMode);
|
|
178
|
+
if (this._anchor) {
|
|
179
|
+
Sys.WebForms.Menu._domHelper.appendCssClass(this._anchor, parentMenu.displayMode);
|
|
180
|
+
}
|
|
181
|
+
this.element.style.position = "relative";
|
|
182
|
+
if (this.parentMenu.depth == 1 && this.container.orientation == 'horizontal') {
|
|
183
|
+
Sys.WebForms.Menu._domHelper.setFloat(this.element, this.container.rightToLeft ? "right" : "left");
|
|
184
|
+
}
|
|
185
|
+
if (!this.container.disabled) {
|
|
186
|
+
Sys.WebForms.Menu._domHelper.addEvent(this.element, 'mouseover', Sys.WebForms.MenuItem._onmouseover);
|
|
187
|
+
Sys.WebForms.Menu._domHelper.addEvent(this.element, 'mouseout', Sys.WebForms.MenuItem._onmouseout);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
Sys.WebForms.MenuItem.prototype = {
|
|
191
|
+
applyUp: function(fn, condition) {
|
|
192
|
+
condition = condition || function(menuItem) { return menuItem; };
|
|
193
|
+
var menuItem = this;
|
|
194
|
+
var lastMenuItem = null;
|
|
195
|
+
while (condition(menuItem)) {
|
|
196
|
+
fn(menuItem);
|
|
197
|
+
lastMenuItem = menuItem;
|
|
198
|
+
menuItem = menuItem.parentMenu.parentMenuItem;
|
|
199
|
+
}
|
|
200
|
+
return lastMenuItem;
|
|
201
|
+
},
|
|
202
|
+
blur: function() { this.setTabIndex(-1); },
|
|
203
|
+
doDispose: function() {
|
|
204
|
+
Sys.WebForms.Menu._domHelper.removeEvent(this.element, 'mouseover', Sys.WebForms.MenuItem._onmouseover);
|
|
205
|
+
Sys.WebForms.Menu._domHelper.removeEvent(this.element, 'mouseout', Sys.WebForms.MenuItem._onmouseout);
|
|
206
|
+
if (this.childMenu) {
|
|
207
|
+
this.childMenu.doDispose();
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
focus: function() {
|
|
211
|
+
if (!this.parentMenu.get_displayed()) {
|
|
212
|
+
this.parentMenu.show();
|
|
213
|
+
}
|
|
214
|
+
this.setTabIndex(0);
|
|
215
|
+
this.container.focused = true;
|
|
216
|
+
this._anchor.focus();
|
|
217
|
+
},
|
|
218
|
+
get_highlighted: function() { return /(^|\s)highlighted(\s|$)/.test(this._anchor.className); },
|
|
219
|
+
getTabIndex: function() { return this._anchor.tabIndex; },
|
|
220
|
+
highlight: function(highlighting) {
|
|
221
|
+
if (highlighting) {
|
|
222
|
+
this.applyUp(function(menuItem) {
|
|
223
|
+
menuItem.parentMenu.parentMenuItem.highlight(true);
|
|
224
|
+
},
|
|
225
|
+
function(menuItem) {
|
|
226
|
+
return !menuItem.parentMenu.isStatic() && menuItem.parentMenu.parentMenuItem;
|
|
227
|
+
}
|
|
228
|
+
);
|
|
229
|
+
Sys.WebForms.Menu._domHelper.appendCssClass(this._anchor, 'highlighted');
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
Sys.WebForms.Menu._domHelper.removeCssClass(this._anchor, 'highlighted');
|
|
233
|
+
this.setTabIndex(-1);
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
hover: function(hovering) {
|
|
237
|
+
if (hovering) {
|
|
238
|
+
var currentHoveredItem = this.container.hoveredMenuItem;
|
|
239
|
+
if (currentHoveredItem) {
|
|
240
|
+
currentHoveredItem.hover(false);
|
|
241
|
+
}
|
|
242
|
+
var currentFocusedItem = this.container.focusedMenuItem;
|
|
243
|
+
if (currentFocusedItem && currentFocusedItem !== this) {
|
|
244
|
+
currentFocusedItem.hover(false);
|
|
245
|
+
}
|
|
246
|
+
this.applyUp(function(menuItem) {
|
|
247
|
+
if (menuItem.childMenu && !menuItem.childMenu.get_displayed()) {
|
|
248
|
+
menuItem.childMenu.show();
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
this.container.hoveredMenuItem = this;
|
|
252
|
+
this.highlight(true);
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
var menuItem = this;
|
|
256
|
+
while (menuItem) {
|
|
257
|
+
menuItem.highlight(false);
|
|
258
|
+
if (menuItem.childMenu) {
|
|
259
|
+
if (!menuItem.childMenu.isStatic()) {
|
|
260
|
+
menuItem.childMenu.hide();
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
menuItem = menuItem.parentMenu.parentMenuItem;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
isSiblingOf: function(menuItem) { return menuItem.parentMenu === this.parentMenu; },
|
|
268
|
+
mouseout: function() {
|
|
269
|
+
var menuItem = this,
|
|
270
|
+
id = this.container.pendingMouseoutId,
|
|
271
|
+
disappearAfter = this.container.disappearAfter;
|
|
272
|
+
if (id) {
|
|
273
|
+
window.clearTimeout(id);
|
|
274
|
+
}
|
|
275
|
+
if (disappearAfter > -1) {
|
|
276
|
+
this.container.pendingMouseoutId =
|
|
277
|
+
window.setTimeout(function() { menuItem.hover(false); }, disappearAfter);
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
mouseover: function() {
|
|
281
|
+
var id = this.container.pendingMouseoutId;
|
|
282
|
+
if (id) {
|
|
283
|
+
window.clearTimeout(id);
|
|
284
|
+
this.container.pendingMouseoutId = null;
|
|
285
|
+
}
|
|
286
|
+
this.hover(true);
|
|
287
|
+
if (this.container.menu.get_focused()) {
|
|
288
|
+
this.container.navigateTo(this);
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
navigate: function(keyCode) {
|
|
292
|
+
switch (this.keyMap[keyCode]) {
|
|
293
|
+
case this.keyMap.next:
|
|
294
|
+
this.navigateNext();
|
|
295
|
+
break;
|
|
296
|
+
case this.keyMap.previous:
|
|
297
|
+
this.navigatePrevious();
|
|
298
|
+
break;
|
|
299
|
+
case this.keyMap.child:
|
|
300
|
+
this.navigateChild();
|
|
301
|
+
break;
|
|
302
|
+
case this.keyMap.parent:
|
|
303
|
+
this.navigateParent();
|
|
304
|
+
break;
|
|
305
|
+
case this.keyMap.tab:
|
|
306
|
+
this.navigateOut();
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
navigateChild: function() {
|
|
311
|
+
var subMenu = this.childMenu;
|
|
312
|
+
if (subMenu) {
|
|
313
|
+
var firstChild = subMenu.firstChild();
|
|
314
|
+
if (firstChild) {
|
|
315
|
+
this.container.navigateTo(firstChild);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
if (this.container.orientation === 'horizontal') {
|
|
320
|
+
var nextItem = this.topLevelMenuItem.nextSibling || this.topLevelMenuItem.parentMenu.firstChild();
|
|
321
|
+
if (nextItem == this.topLevelMenuItem) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
this.topLevelMenuItem.childMenu.hide();
|
|
325
|
+
this.container.navigateTo(nextItem);
|
|
326
|
+
if (nextItem.childMenu) {
|
|
327
|
+
this.container.navigateTo(nextItem.childMenu.firstChild());
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
navigateNext: function() {
|
|
333
|
+
if (this.childMenu) {
|
|
334
|
+
this.childMenu.hide();
|
|
335
|
+
}
|
|
336
|
+
var nextMenuItem = this.nextSibling;
|
|
337
|
+
if (!nextMenuItem && this.parentMenu.isRoot()) {
|
|
338
|
+
nextMenuItem = this.parentMenu.parentMenuItem;
|
|
339
|
+
if (nextMenuItem) {
|
|
340
|
+
nextMenuItem = nextMenuItem.nextSibling;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
if (!nextMenuItem) {
|
|
344
|
+
nextMenuItem = this.parentMenu.firstChild();
|
|
345
|
+
}
|
|
346
|
+
if (nextMenuItem) {
|
|
347
|
+
this.container.navigateTo(nextMenuItem);
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
navigateOut: function() {
|
|
351
|
+
this.parentMenu.blur();
|
|
352
|
+
},
|
|
353
|
+
navigateParent: function() {
|
|
354
|
+
var parentMenu = this.parentMenu,
|
|
355
|
+
horizontal = this.container.orientation === 'horizontal';
|
|
356
|
+
if (!parentMenu) return;
|
|
357
|
+
if (horizontal && this.childMenu && parentMenu.isRoot()) {
|
|
358
|
+
this.navigateChild();
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
if (parentMenu.parentMenuItem && !parentMenu.isRoot()) {
|
|
362
|
+
if (horizontal && this.parentMenu.depth === 2) {
|
|
363
|
+
var previousItem = this.parentMenu.parentMenuItem.previousSibling;
|
|
364
|
+
if (!previousItem) {
|
|
365
|
+
previousItem = this.parentMenu.rootMenu.lastChild();
|
|
366
|
+
}
|
|
367
|
+
this.topLevelMenuItem.childMenu.hide();
|
|
368
|
+
this.container.navigateTo(previousItem);
|
|
369
|
+
if (previousItem.childMenu) {
|
|
370
|
+
this.container.navigateTo(previousItem.childMenu.firstChild());
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
this.parentMenu.hide();
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
navigatePrevious: function() {
|
|
379
|
+
if (this.childMenu) {
|
|
380
|
+
this.childMenu.hide();
|
|
381
|
+
}
|
|
382
|
+
var previousMenuItem = this.previousSibling;
|
|
383
|
+
if (previousMenuItem) {
|
|
384
|
+
var childMenu = previousMenuItem.childMenu;
|
|
385
|
+
if (childMenu && childMenu.isRoot()) {
|
|
386
|
+
previousMenuItem = childMenu.lastChild();
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
if (!previousMenuItem && this.parentMenu.isRoot()) {
|
|
390
|
+
previousMenuItem = this.parentMenu.parentMenuItem;
|
|
391
|
+
}
|
|
392
|
+
if (!previousMenuItem) {
|
|
393
|
+
previousMenuItem = this.parentMenu.lastChild();
|
|
394
|
+
}
|
|
395
|
+
if (previousMenuItem) {
|
|
396
|
+
this.container.navigateTo(previousMenuItem);
|
|
397
|
+
}
|
|
398
|
+
},
|
|
399
|
+
setTabIndex: function(index) { if (this._anchor) this._anchor.tabIndex = index; }
|
|
400
|
+
};
|
|
401
|
+
Sys.WebForms.MenuItem._onmouseout = function(e) {
|
|
402
|
+
var menuItem = Sys.WebForms.Menu._elementObjectMapper.getMappedObject(this);
|
|
403
|
+
if (!menuItem) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
menuItem.mouseout();
|
|
407
|
+
Sys.WebForms.Menu._domHelper.cancelEvent(e);
|
|
408
|
+
};
|
|
409
|
+
Sys.WebForms.MenuItem._onmouseover = function(e) {
|
|
410
|
+
var menuItem = Sys.WebForms.Menu._elementObjectMapper.getMappedObject(this);
|
|
411
|
+
if (!menuItem) {
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
menuItem.mouseover();
|
|
415
|
+
Sys.WebForms.Menu._domHelper.cancelEvent(e);
|
|
416
|
+
};
|
|
417
|
+
Sys.WebForms.Menu._domHelper = {
|
|
418
|
+
addEvent: function(element, eventName, fn, useCapture) {
|
|
419
|
+
if (element.addEventListener) {
|
|
420
|
+
element.addEventListener(eventName, fn, !!useCapture);
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
element['on' + eventName] = fn;
|
|
424
|
+
}
|
|
425
|
+
},
|
|
426
|
+
appendAttributeValue: function(element, name, value) {
|
|
427
|
+
this.updateAttributeValue('append', element, name, value);
|
|
428
|
+
},
|
|
429
|
+
appendCssClass: function(element, value) {
|
|
430
|
+
this.updateClassName('append', element, name, value);
|
|
431
|
+
},
|
|
432
|
+
appendString: function(getString, setString, value) {
|
|
433
|
+
var currentValue = getString();
|
|
434
|
+
if (!currentValue) {
|
|
435
|
+
setString(value);
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
var regex = this._regexes.getRegex('(^| )' + value + '($| )');
|
|
439
|
+
if (regex.test(currentValue)) {
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
setString(currentValue + ' ' + value);
|
|
443
|
+
},
|
|
444
|
+
cancelEvent: function(e) {
|
|
445
|
+
var event = e || window.event;
|
|
446
|
+
if (event) {
|
|
447
|
+
event.cancelBubble = true;
|
|
448
|
+
if (event.stopPropagation) {
|
|
449
|
+
event.stopPropagation();
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
},
|
|
453
|
+
contains: function(ancestor, descendant) {
|
|
454
|
+
for (; descendant && (descendant !== ancestor); descendant = descendant.parentNode) { }
|
|
455
|
+
return !!descendant;
|
|
456
|
+
},
|
|
457
|
+
firstChild: function(element) {
|
|
458
|
+
var child = element.firstChild;
|
|
459
|
+
if (child && child.nodeType !== 1) {
|
|
460
|
+
child = this.nextSibling(child);
|
|
461
|
+
}
|
|
462
|
+
return child;
|
|
463
|
+
},
|
|
464
|
+
getElement: function(elementOrId) { return typeof elementOrId === 'string' ? document.getElementById(elementOrId) : elementOrId; },
|
|
465
|
+
getElementDirection: function(element) {
|
|
466
|
+
if (element) {
|
|
467
|
+
if (element.dir) {
|
|
468
|
+
return element.dir;
|
|
469
|
+
}
|
|
470
|
+
return this.getElementDirection(element.parentNode);
|
|
471
|
+
}
|
|
472
|
+
return "ltr";
|
|
473
|
+
},
|
|
474
|
+
getKeyCode: function(event) { return event.keyCode || event.charCode || 0; },
|
|
475
|
+
insertAfter: function(element, elementToInsert) {
|
|
476
|
+
var next = element.nextSibling;
|
|
477
|
+
if (next) {
|
|
478
|
+
element.parentNode.insertBefore(elementToInsert, next);
|
|
479
|
+
}
|
|
480
|
+
else if (element.parentNode) {
|
|
481
|
+
element.parentNode.appendChild(elementToInsert);
|
|
482
|
+
}
|
|
483
|
+
},
|
|
484
|
+
nextSibling: function(element) {
|
|
485
|
+
var sibling = element.nextSibling;
|
|
486
|
+
while (sibling) {
|
|
487
|
+
if (sibling.nodeType === 1) {
|
|
488
|
+
return sibling;
|
|
489
|
+
}
|
|
490
|
+
sibling = sibling.nextSibling;
|
|
491
|
+
}
|
|
492
|
+
},
|
|
493
|
+
removeAttributeValue: function(element, name, value) {
|
|
494
|
+
this.updateAttributeValue('remove', element, name, value);
|
|
495
|
+
},
|
|
496
|
+
removeCssClass: function(element, value) {
|
|
497
|
+
this.updateClassName('remove', element, name, value);
|
|
498
|
+
},
|
|
499
|
+
removeEvent: function(element, eventName, fn, useCapture) {
|
|
500
|
+
if (element.removeEventListener) {
|
|
501
|
+
element.removeEventListener(eventName, fn, !!useCapture);
|
|
502
|
+
}
|
|
503
|
+
else if (element.detachEvent) {
|
|
504
|
+
element.detachEvent('on' + eventName, fn)
|
|
505
|
+
}
|
|
506
|
+
element['on' + eventName] = null;
|
|
507
|
+
},
|
|
508
|
+
removeString: function(getString, setString, valueToRemove) {
|
|
509
|
+
var currentValue = getString();
|
|
510
|
+
if (currentValue) {
|
|
511
|
+
var regex = this._regexes.getRegex('(\\s|\\b)' + valueToRemove + '$|\\b' + valueToRemove + '\\s+');
|
|
512
|
+
setString(currentValue.replace(regex, ''));
|
|
513
|
+
}
|
|
514
|
+
},
|
|
515
|
+
setFloat: function(element, direction) {
|
|
516
|
+
element.style.styleFloat = direction;
|
|
517
|
+
element.style.cssFloat = direction;
|
|
518
|
+
},
|
|
519
|
+
updateAttributeValue: function(operation, element, name, value) {
|
|
520
|
+
this[operation + 'String'](
|
|
521
|
+
function() {
|
|
522
|
+
return element.getAttribute(name);
|
|
523
|
+
},
|
|
524
|
+
function(newValue) {
|
|
525
|
+
element.setAttribute(name, newValue);
|
|
526
|
+
},
|
|
527
|
+
value
|
|
528
|
+
);
|
|
529
|
+
},
|
|
530
|
+
updateClassName: function(operation, element, name, value) {
|
|
531
|
+
this[operation + 'String'](
|
|
532
|
+
function() {
|
|
533
|
+
return element.className;
|
|
534
|
+
},
|
|
535
|
+
function(newValue) {
|
|
536
|
+
element.className = newValue;
|
|
537
|
+
},
|
|
538
|
+
value
|
|
539
|
+
);
|
|
540
|
+
},
|
|
541
|
+
_regexes: {
|
|
542
|
+
getRegex: function(pattern) {
|
|
543
|
+
var regex = this[pattern];
|
|
544
|
+
if (!regex) {
|
|
545
|
+
this[pattern] = regex = new RegExp(pattern);
|
|
546
|
+
}
|
|
547
|
+
return regex;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
Sys.WebForms.Menu._elementObjectMapper = {
|
|
552
|
+
_computedId: 0,
|
|
553
|
+
_mappings: {},
|
|
554
|
+
_mappingIdName: 'Sys.WebForms.Menu.Mapping',
|
|
555
|
+
getMappedObject: function(element) {
|
|
556
|
+
var id = element[this._mappingIdName];
|
|
557
|
+
if (id) {
|
|
558
|
+
return this._mappings[this._mappingIdName + ':' + id];
|
|
559
|
+
}
|
|
560
|
+
},
|
|
561
|
+
map: function(element, theObject) {
|
|
562
|
+
var mappedObject = element[this._mappingIdName];
|
|
563
|
+
if (mappedObject === theObject) {
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
var objectId = element[this._mappingIdName] || element.id || '%' + (++this._computedId);
|
|
567
|
+
element[this._mappingIdName] = objectId;
|
|
568
|
+
this._mappings[this._mappingIdName + ':' + objectId] = theObject;
|
|
569
|
+
theObject.mappingId = objectId;
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
Sys.WebForms.Menu._keyboardMapping = new (function() {
|
|
573
|
+
var LEFT_ARROW = 37;
|
|
574
|
+
var UP_ARROW = 38;
|
|
575
|
+
var RIGHT_ARROW = 39;
|
|
576
|
+
var DOWN_ARROW = 40;
|
|
577
|
+
var TAB = 9;
|
|
578
|
+
var ESCAPE = 27;
|
|
579
|
+
this.vertical = { next: 0, previous: 1, child: 2, parent: 3, tab: 4 };
|
|
580
|
+
this.vertical[DOWN_ARROW] = this.vertical.next;
|
|
581
|
+
this.vertical[UP_ARROW] = this.vertical.previous;
|
|
582
|
+
this.vertical[RIGHT_ARROW] = this.vertical.child;
|
|
583
|
+
this.vertical[LEFT_ARROW] = this.vertical.parent;
|
|
584
|
+
this.vertical[TAB] = this.vertical[ESCAPE] = this.vertical.tab;
|
|
585
|
+
this.verticalRtl = { next: 0, previous: 1, child: 2, parent: 3, tab: 4 };
|
|
586
|
+
this.verticalRtl[DOWN_ARROW] = this.verticalRtl.next;
|
|
587
|
+
this.verticalRtl[UP_ARROW] = this.verticalRtl.previous;
|
|
588
|
+
this.verticalRtl[LEFT_ARROW] = this.verticalRtl.child;
|
|
589
|
+
this.verticalRtl[RIGHT_ARROW] = this.verticalRtl.parent;
|
|
590
|
+
this.verticalRtl[TAB] = this.verticalRtl[ESCAPE] = this.verticalRtl.tab;
|
|
591
|
+
this.horizontal = { next: 0, previous: 1, child: 2, parent: 3, tab: 4 };
|
|
592
|
+
this.horizontal[RIGHT_ARROW] = this.horizontal.next;
|
|
593
|
+
this.horizontal[LEFT_ARROW] = this.horizontal.previous;
|
|
594
|
+
this.horizontal[DOWN_ARROW] = this.horizontal.child;
|
|
595
|
+
this.horizontal[UP_ARROW] = this.horizontal.parent;
|
|
596
|
+
this.horizontal[TAB] = this.horizontal[ESCAPE] = this.horizontal.tab;
|
|
597
|
+
this.horizontalRtl = { next: 0, previous: 1, child: 2, parent: 3, tab: 4 };
|
|
598
|
+
this.horizontalRtl[RIGHT_ARROW] = this.horizontalRtl.previous;
|
|
599
|
+
this.horizontalRtl[LEFT_ARROW] = this.horizontalRtl.next;
|
|
600
|
+
this.horizontalRtl[DOWN_ARROW] = this.horizontalRtl.child;
|
|
601
|
+
this.horizontalRtl[UP_ARROW] = this.horizontalRtl.parent;
|
|
602
|
+
this.horizontalRtl[TAB] = this.horizontalRtl[ESCAPE] = this.horizontalRtl.tab;
|
|
603
|
+
this.horizontal.contains = this.horizontalRtl.contains = this.vertical.contains = this.verticalRtl.contains = function(keycode) {
|
|
604
|
+
return this[keycode] != null;
|
|
605
|
+
};
|
|
606
|
+
})();
|
|
607
|
+
Sys.WebForms._MenuContainer = function(options) {
|
|
608
|
+
this.focused = false;
|
|
609
|
+
this.disabled = options.disabled;
|
|
610
|
+
this.staticDisplayLevels = options.staticDisplayLevels || 1;
|
|
611
|
+
this.element = options.element;
|
|
612
|
+
this.orientation = options.orientation || 'vertical';
|
|
613
|
+
this.disappearAfter = options.disappearAfter;
|
|
614
|
+
this.rightToLeft = Sys.WebForms.Menu._domHelper.getElementDirection(this.element) === 'rtl';
|
|
615
|
+
Sys.WebForms.Menu._elementObjectMapper.map(this.element, this);
|
|
616
|
+
this.menu = options.menu;
|
|
617
|
+
this.menu.rootMenu = this.menu;
|
|
618
|
+
this.menu.displayMode = 'static';
|
|
619
|
+
this.menu.element.style.position = 'relative';
|
|
620
|
+
this.menu.element.style.width = 'auto';
|
|
621
|
+
if (this.orientation === 'vertical') {
|
|
622
|
+
Sys.WebForms.Menu._domHelper.appendAttributeValue(this.menu.element, 'role', 'menu');
|
|
623
|
+
if (this.rightToLeft) {
|
|
624
|
+
this.menu.keyMap = Sys.WebForms.Menu._keyboardMapping.verticalRtl;
|
|
625
|
+
}
|
|
626
|
+
else {
|
|
627
|
+
this.menu.keyMap = Sys.WebForms.Menu._keyboardMapping.vertical;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
else {
|
|
631
|
+
Sys.WebForms.Menu._domHelper.appendAttributeValue(this.menu.element, 'role', 'menubar');
|
|
632
|
+
if (this.rightToLeft) {
|
|
633
|
+
this.menu.keyMap = Sys.WebForms.Menu._keyboardMapping.horizontalRtl;
|
|
634
|
+
}
|
|
635
|
+
else {
|
|
636
|
+
this.menu.keyMap = Sys.WebForms.Menu._keyboardMapping.horizontal;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
var floatBreak = document.createElement('div');
|
|
640
|
+
floatBreak.style.clear = this.rightToLeft ? "right" : "left";
|
|
641
|
+
this.element.appendChild(floatBreak);
|
|
642
|
+
Sys.WebForms.Menu._domHelper.setFloat(this.element, this.rightToLeft ? "right" : "left");
|
|
643
|
+
Sys.WebForms.Menu._domHelper.insertAfter(this.element, floatBreak);
|
|
644
|
+
if (!this.disabled) {
|
|
645
|
+
Sys.WebForms.Menu._domHelper.addEvent(this.menu.element, 'focus', this._onfocus, true);
|
|
646
|
+
Sys.WebForms.Menu._domHelper.addEvent(this.menu.element, 'keydown', this._onkeydown);
|
|
647
|
+
var menuContainer = this;
|
|
648
|
+
this.element.dispose = function() {
|
|
649
|
+
if (menuContainer.element.dispose) {
|
|
650
|
+
menuContainer.element.dispose = null;
|
|
651
|
+
Sys.WebForms.Menu._domHelper.removeEvent(menuContainer.menu.element, 'focus', menuContainer._onfocus, true);
|
|
652
|
+
Sys.WebForms.Menu._domHelper.removeEvent(menuContainer.menu.element, 'keydown', menuContainer._onkeydown);
|
|
653
|
+
menuContainer.menu.doDispose();
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
Sys.WebForms.Menu._domHelper.addEvent(window, 'unload', function() {
|
|
657
|
+
if (menuContainer.element.dispose) {
|
|
658
|
+
menuContainer.element.dispose();
|
|
659
|
+
}
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
};
|
|
663
|
+
Sys.WebForms._MenuContainer.prototype = {
|
|
664
|
+
blur: function() {
|
|
665
|
+
this.focused = false;
|
|
666
|
+
this.isBlurring = false;
|
|
667
|
+
this.menu.collapse();
|
|
668
|
+
this.focusedMenuItem = null;
|
|
669
|
+
},
|
|
670
|
+
focus: function(e) { this.focused = true; },
|
|
671
|
+
navigateTo: function(menuItem) {
|
|
672
|
+
if (this.focusedMenuItem && this.focusedMenuItem !== this) {
|
|
673
|
+
this.focusedMenuItem.highlight(false);
|
|
674
|
+
}
|
|
675
|
+
menuItem.highlight(true);
|
|
676
|
+
menuItem.focus();
|
|
677
|
+
this.focusedMenuItem = menuItem;
|
|
678
|
+
},
|
|
679
|
+
_onfocus: function(e) {
|
|
680
|
+
var event = e || window.event;
|
|
681
|
+
if (event.srcElement && this) {
|
|
682
|
+
if (Sys.WebForms.Menu._domHelper.contains(this.element, event.srcElement)) {
|
|
683
|
+
if (!this.focused) {
|
|
684
|
+
this.focus();
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
},
|
|
689
|
+
_onkeydown: function(e) {
|
|
690
|
+
var thisMenu = Sys.WebForms.Menu._elementObjectMapper.getMappedObject(this);
|
|
691
|
+
var keyCode = Sys.WebForms.Menu._domHelper.getKeyCode(e || window.event);
|
|
692
|
+
if (thisMenu) {
|
|
693
|
+
thisMenu.handleKeyPress(keyCode);
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
};
|