@@ -151,7 +151,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.debounce', 'ui.bootstrap
151
151
id : popupId ,
152
152
matches : 'matches' ,
153
153
active : 'activeIdx' ,
154
- select : 'select(activeIdx)' ,
154
+ select : 'select(activeIdx, evt )' ,
155
155
'move-in-progress' : 'moveInProgress' ,
156
156
query : 'query' ,
157
157
position : 'position' ,
@@ -202,7 +202,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.debounce', 'ui.bootstrap
202
202
return false ;
203
203
} ;
204
204
205
- var getMatchesAsync = function ( inputValue ) {
205
+ var getMatchesAsync = function ( inputValue , evt ) {
206
206
var locals = { $viewValue : inputValue } ;
207
207
isLoadingSetter ( originalScope , true ) ;
208
208
isNoResultsSetter ( originalScope , false ) ;
@@ -238,10 +238,10 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.debounce', 'ui.bootstrap
238
238
if ( selectOnExact && scope . matches . length === 1 && inputIsExactMatch ( inputValue , 0 ) ) {
239
239
if ( angular . isNumber ( scope . debounceUpdate ) || angular . isObject ( scope . debounceUpdate ) ) {
240
240
$$debounce ( function ( ) {
241
- scope . select ( 0 ) ;
241
+ scope . select ( 0 , evt ) ;
242
242
} , angular . isNumber ( scope . debounceUpdate ) ? scope . debounceUpdate : scope . debounceUpdate [ 'default' ] ) ;
243
243
} else {
244
- scope . select ( 0 ) ;
244
+ scope . select ( 0 , evt ) ;
245
245
}
246
246
}
247
247
@@ -329,7 +329,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.debounce', 'ui.bootstrap
329
329
isOpenSetter ( originalScope , isOpen ) ;
330
330
} ;
331
331
332
- scope . select = function ( activeIdx ) {
332
+ scope . select = function ( activeIdx , evt ) {
333
333
//called from within the $digest() cycle
334
334
var locals = { } ;
335
335
var model , item ;
@@ -344,7 +344,8 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.debounce', 'ui.bootstrap
344
344
onSelectCallback ( originalScope , {
345
345
$item : item ,
346
346
$model : model ,
347
- $label : parserResult . viewMapper ( originalScope , locals )
347
+ $label : parserResult . viewMapper ( originalScope , locals ) ,
348
+ $event : evt
348
349
} ) ;
349
350
350
351
resetMatches ( ) ;
@@ -378,10 +379,10 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.debounce', 'ui.bootstrap
378
379
scope . $apply ( function ( ) {
379
380
if ( angular . isNumber ( scope . debounceUpdate ) || angular . isObject ( scope . debounceUpdate ) ) {
380
381
$$debounce ( function ( ) {
381
- scope . select ( scope . activeIdx ) ;
382
+ scope . select ( scope . activeIdx , evt ) ;
382
383
} , angular . isNumber ( scope . debounceUpdate ) ? scope . debounceUpdate : scope . debounceUpdate [ 'default' ] ) ;
383
384
} else {
384
- scope . select ( scope . activeIdx ) ;
385
+ scope . select ( scope . activeIdx , evt ) ;
385
386
}
386
387
} ) ;
387
388
break ;
@@ -404,25 +405,25 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.debounce', 'ui.bootstrap
404
405
}
405
406
} ) ;
406
407
407
- element . bind ( 'focus' , function ( ) {
408
+ element . bind ( 'focus' , function ( evt ) {
408
409
hasFocus = true ;
409
410
if ( minLength === 0 && ! modelCtrl . $viewValue ) {
410
411
$timeout ( function ( ) {
411
- getMatchesAsync ( modelCtrl . $viewValue ) ;
412
+ getMatchesAsync ( modelCtrl . $viewValue , evt ) ;
412
413
} , 0 ) ;
413
414
}
414
415
} ) ;
415
416
416
- element . bind ( 'blur' , function ( ) {
417
+ element . bind ( 'blur' , function ( evt ) {
417
418
if ( isSelectOnBlur && scope . matches . length && scope . activeIdx !== - 1 && ! selected ) {
418
419
selected = true ;
419
420
scope . $apply ( function ( ) {
420
421
if ( angular . isObject ( scope . debounceUpdate ) && angular . isNumber ( scope . debounceUpdate . blur ) ) {
421
422
$$debounce ( function ( ) {
422
- scope . select ( scope . activeIdx ) ;
423
+ scope . select ( scope . activeIdx , evt ) ;
423
424
} , scope . debounceUpdate . blur ) ;
424
425
} else {
425
- scope . select ( scope . activeIdx ) ;
426
+ scope . select ( scope . activeIdx , evt ) ;
426
427
}
427
428
} ) ;
428
429
}
@@ -585,14 +586,14 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.debounce', 'ui.bootstrap
585
586
scope . active = matchIdx ;
586
587
} ;
587
588
588
- scope . selectMatch = function ( activeIdx ) {
589
+ scope . selectMatch = function ( activeIdx , evt ) {
589
590
var debounce = scope . debounce ( ) ;
590
591
if ( angular . isNumber ( debounce ) || angular . isObject ( debounce ) ) {
591
592
$$debounce ( function ( ) {
592
- scope . select ( { activeIdx : activeIdx } ) ;
593
+ scope . select ( { activeIdx : activeIdx , evt : evt } ) ;
593
594
} , angular . isNumber ( debounce ) ? debounce : debounce [ 'default' ] ) ;
594
595
} else {
595
- scope . select ( { activeIdx : activeIdx } ) ;
596
+ scope . select ( { activeIdx : activeIdx , evt : evt } ) ;
596
597
}
597
598
} ;
598
599
}
0 commit comments