Changeset 3975
- Timestamp:
- 03/20/10 07:57:06 (7 days ago)
- Files:
-
- 1 modified
-
trunk/ui/jquery.ui.autocomplete.js (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ui/jquery.ui.autocomplete.js
r3942 r3975 103 103 var item = ui.item.data( "item.autocomplete" ); 104 104 if ( false !== self._trigger( "focus", null, { item: item } ) ) { 105 // use value to match what will end up in the input 106 self.element.val( item.value ); 105 // use value to match what will end up in the input, if it was a key event 106 if ( /^key/.test(event.originalEvent.type) ) { 107 self.element.val( item.value ); 108 } 107 109 } 108 110 }, … … 287 289 return; 288 290 } 289 this.menu[ direction ]( );291 this.menu[ direction ]( event ); 290 292 }, 291 293 … … 351 353 .attr("tabindex", -1) 352 354 // mouseenter doesn't work with event delegation 353 .mouseenter(function( ) {354 self.activate( $(this).parent());355 .mouseenter(function( event ) { 356 self.activate( event, $(this).parent() ); 355 357 }) 356 358 .mouseleave(function() { … … 359 361 }, 360 362 361 activate: function( item) {363 activate: function( event, item ) { 362 364 this.deactivate(); 363 365 if (this.hasScroll()) { … … 376 378 .attr("id", "ui-active-menuitem") 377 379 .end(); 378 this._trigger("focus", null, { item: item });380 this._trigger("focus", event, { item: item }); 379 381 }, 380 382 … … 389 391 }, 390 392 391 next: function( ) {392 this.move("next", "li:first" );393 }, 394 395 previous: function( ) {396 this.move("prev", "li:last" );393 next: function(event) { 394 this.move("next", "li:first", event); 395 }, 396 397 previous: function(event) { 398 this.move("prev", "li:last", event); 397 399 }, 398 400 … … 405 407 }, 406 408 407 move: function(direction, edge ) {409 move: function(direction, edge, event) { 408 410 if (!this.active) { 409 this.activate( this.element.children(edge));411 this.activate(event, this.element.children(edge)); 410 412 return; 411 413 } 412 414 var next = this.active[direction](); 413 415 if (next.length) { 414 this.activate( next);416 this.activate(event, next); 415 417 } else { 416 this.activate( this.element.children(edge));418 this.activate(event, this.element.children(edge)); 417 419 } 418 420 }, 419 421 420 422 // TODO merge with previousPage 421 nextPage: function( ) {423 nextPage: function(event) { 422 424 if (this.hasScroll()) { 423 425 // TODO merge with no-scroll-else 424 426 if (!this.active || this.last()) { 425 this.activate( this.element.children(":first"));427 this.activate(event, this.element.children(":first")); 426 428 return; 427 429 } … … 438 440 result = this.element.children(":last"); 439 441 } 440 this.activate( result);442 this.activate(event, result); 441 443 } else { 442 this.activate( this.element.children(!this.active || this.last() ? ":first" : ":last"));444 this.activate(event, this.element.children(!this.active || this.last() ? ":first" : ":last")); 443 445 } 444 446 }, 445 447 446 448 // TODO merge with nextPage 447 previousPage: function( ) {449 previousPage: function(event) { 448 450 if (this.hasScroll()) { 449 451 // TODO merge with no-scroll-else 450 452 if (!this.active || this.first()) { 451 this.activate( this.element.children(":last"));453 this.activate(event, this.element.children(":last")); 452 454 return; 453 455 } … … 465 467 result = this.element.children(":first"); 466 468 } 467 this.activate( result);469 this.activate(event, result); 468 470 } else { 469 this.activate( this.element.children(!this.active || this.first() ? ":last" : ":first"));471 this.activate(event, this.element.children(!this.active || this.first() ? ":last" : ":first")); 470 472 } 471 473 },