158
158
ctrl . selected = undefined ;
159
159
ctrl . open = false ;
160
160
ctrl . focus = false ;
161
- ctrl . focusser = undefined ; //Reference to input element used to handle focus events
161
+ ctrl . focusser = undefined ; //Reference to input element used to handle focus events
162
162
ctrl . disabled = undefined ; // Initialized inside uiSelect directive link function
163
163
ctrl . searchEnabled = undefined ; // Initialized inside uiSelect directive link function
164
164
ctrl . resetSearchInput = undefined ; // Initialized inside uiSelect directive link function
257
257
var filteredItems = items . filter ( function ( i ) { return ctrl . selected . indexOf ( i ) < 0 ; } ) ;
258
258
setItemsFn ( filteredItems ) ;
259
259
} else {
260
- setItemsFn ( items ) ;
260
+ setItemsFn ( items ) ;
261
261
}
262
262
ctrl . ngModel . $modelValue = null ; //Force scope model value and ngModel value to be out of sync to re-run formatters
263
263
267
267
} ) ;
268
268
269
269
if ( ctrl . multiple ) {
270
- //Remove already selected items
270
+ //Remove already selected items
271
271
$scope . $watchCollection ( '$select.selected' , function ( selectedItems ) {
272
272
if ( ! selectedItems ) return ;
273
273
var data = ctrl . parserResult . source ( $scope ) ;
305
305
} ;
306
306
307
307
ctrl . isActive = function ( itemScope ) {
308
- return ctrl . items . indexOf ( itemScope [ ctrl . itemProperty ] ) === ctrl . activeIndex ;
308
+ if ( typeof itemScope [ ctrl . itemProperty ] === 'undefined' ) {
309
+ return false ;
310
+ }
309
311
} ;
310
312
311
313
ctrl . isDisabled = function ( itemScope ) {
355
357
_resetSearchInput ( ) ;
356
358
ctrl . open = false ;
357
359
$timeout ( function ( ) {
358
- ctrl . focusser [ 0 ] . focus ( ) ;
360
+ ctrl . focusser [ 0 ] . focus ( ) ;
359
361
} , 0 , false ) ;
360
362
}
361
363
} ;
425
427
// Handles selected options in "multiple" mode
426
428
function _handleMatchSelection ( key ) {
427
429
var caretPosition = _getCaretPosition ( _searchInput [ 0 ] ) ,
428
- length = ctrl . selected . length ,
430
+ length = ctrl . selected . length ,
429
431
// none = -1,
430
432
first = 0 ,
431
433
last = length - 1 ,
448
450
break ;
449
451
case KEY . RIGHT :
450
452
// Open drop-down
451
- if ( ! ~ ctrl . activeMatchIndex || curr === last ) {
453
+ if ( ! ~ ctrl . activeMatchIndex || curr === last ) {
452
454
ctrl . activate ( ) ;
453
455
return false ;
454
456
}
471
473
return curr ;
472
474
}
473
475
else return false ;
474
- }
476
+ }
475
477
}
476
478
477
479
newIndex = getNewActiveMatchIndex ( ) ;
498
500
if ( ctrl . multiple && KEY . isHorizontalMovement ( key ) ) {
499
501
processed = _handleMatchSelection ( key ) ;
500
502
}
501
-
503
+
502
504
if ( ! processed && ( ctrl . items . length > 0 || ctrl . tagging . isActivated ) ) {
503
505
processed = _handleDropDownSelection ( key ) ;
504
506
}
505
-
507
+
506
508
if ( processed && key != KEY . TAB ) {
507
509
//TODO Check si el tab selecciona aun correctamente
508
510
//Crear test
608
610
609
611
//From model --> view
610
612
ngModel . $formatters . unshift ( function ( inputValue ) {
611
- var data = $select . parserResult . source ( scope , { $select : { search :'' } } ) , //Overwrite $search
613
+ var data = $select . parserResult . source ( scope , { $select : { search :'' } } ) , //Overwrite $search
612
614
locals = { } ,
613
615
result ;
614
616
if ( data ) {
660
662
if ( attrs . tabindex ) {
661
663
//tabindex might be an expression, wait until it contains the actual value before we set the focusser tabindex
662
664
attrs . $observe ( 'tabindex' , function ( value ) {
663
- //If we are using multiple, add tabindex to the search input
665
+ //If we are using multiple, add tabindex to the search input
664
666
if ( $select . multiple ) {
665
667
searchInput . attr ( "tabindex" , value ) ;
666
668
} else {
715
717
if ( e . which === KEY . TAB || KEY . isControl ( e ) || KEY . isFunctionKey ( e ) || e . which === KEY . ESC || e . which == KEY . ENTER || e . which === KEY . BACKSPACE ) {
716
718
return ;
717
719
}
718
-
720
+
719
721
$select . activate ( focusser . val ( ) ) ; //User pressed some regular key, so we pass it to the search input
720
722
focusser . val ( '' ) ;
721
723
scope . $digest ( ) ;
855
857
if ( ! tAttrs . repeat ) throw uiSelectMinErr ( 'repeat' , "Expected 'repeat' expression." ) ;
856
858
857
859
return function link ( scope , element , attrs , $select , transcludeFn ) {
858
-
860
+
859
861
// var repeat = RepeatParser.parse(attrs.repeat);
860
862
var groupByExp = attrs . groupBy ;
861
863
@@ -963,4 +965,4 @@ $templateCache.put("select2/select-multiple.tpl.html","<div class=\"ui-select-mu
963
965
$templateCache . put ( "select2/select.tpl.html" , "<div class=\"select2 select2-container\" ng-class=\"{\'select2-container-active select2-dropdown-open\': $select.open,\n \'select2-container-disabled\': $select.disabled,\n \'select2-container-active\': $select.focus }\"><div class=\"ui-select-match\"></div><div class=\"select2-drop select2-with-searchbox select2-drop-active\" ng-class=\"{\'select2-display-none\': !$select.open}\"><div class=\"select2-search\" ng-show=\"$select.searchEnabled\"><input type=\"text\" autocomplete=\"off\" autocorrect=\"off\" autocapitalize=\"off\" spellcheck=\"false\" class=\"ui-select-search select2-input\" ng-model=\"$select.search\"></div><div class=\"ui-select-choices\"></div></div></div>" ) ;
964
966
$templateCache . put ( "selectize/choices.tpl.html" , "<div ng-show=\"$select.open\" class=\"ui-select-choices selectize-dropdown single\"><div class=\"ui-select-choices-content selectize-dropdown-content\"><div class=\"ui-select-choices-group optgroup\"><div ng-show=\"$select.isGrouped\" class=\"ui-select-choices-group-label optgroup-header\">{{$group.name}}</div><div class=\"ui-select-choices-row\" ng-class=\"{active: $select.isActive(this), disabled: $select.isDisabled(this)}\"><div class=\"option ui-select-choices-row-inner\" data-selectable=\"\"></div></div></div></div></div>" ) ;
965
967
$templateCache . put ( "selectize/match.tpl.html" , "<div ng-hide=\"$select.searchEnabled && ($select.open || $select.isEmpty())\" class=\"ui-select-match\" ng-transclude=\"\"></div>" ) ;
966
- $templateCache . put ( "selectize/select.tpl.html" , "<div class=\"selectize-control single\"><div class=\"selectize-input\" ng-class=\"{\'focus\': $select.open, \'disabled\': $select.disabled, \'selectize-focus\' : $select.focus}\" ng-click=\"$select.activate()\"><div class=\"ui-select-match\"></div><input type=\"text\" autocomplete=\"off\" tabindex=\"-1\" class=\"ui-select-search ui-select-toggle\" ng-click=\"$select.toggle($event)\" placeholder=\"{{$select.placeholder}}\" ng-model=\"$select.search\" ng-hide=\"!$select.searchEnabled || ($select.selected && !$select.open)\" ng-disabled=\"$select.disabled\"></div><div class=\"ui-select-choices\"></div></div>" ) ; } ] ) ;
968
+ $templateCache . put ( "selectize/select.tpl.html" , "<div class=\"selectize-control single\"><div class=\"selectize-input\" ng-class=\"{\'focus\': $select.open, \'disabled\': $select.disabled, \'selectize-focus\' : $select.focus}\" ng-click=\"$select.activate()\"><div class=\"ui-select-match\"></div><input type=\"text\" autocomplete=\"off\" tabindex=\"-1\" class=\"ui-select-search ui-select-toggle\" ng-click=\"$select.toggle($event)\" placeholder=\"{{$select.placeholder}}\" ng-model=\"$select.search\" ng-hide=\"!$select.searchEnabled || ($select.selected && !$select.open)\" ng-disabled=\"$select.disabled\"></div><div class=\"ui-select-choices\"></div></div>" ) ; } ] ) ;
0 commit comments