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