1if (!window.Sys) { window.Sys = {}; } 2if (!Sys.WebForms) { Sys.WebForms = {}; } 3Sys.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}; 86Sys.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}; 148if (Sys.WebForms.Menu.registerClass) { 149 Sys.WebForms.Menu.registerClass('Sys.WebForms.Menu'); 150} 151Sys.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}; 190Sys.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}; 401Sys.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}; 409Sys.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}; 417Sys.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}; 551Sys.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}; 572Sys.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})(); 607Sys.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}; 663Sys.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};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.