158158 ctrl . selected = undefined ;
159159 ctrl . open = false ;
160160 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
162162 ctrl . disabled = undefined ; // Initialized inside uiSelect directive link function
163163 ctrl . searchEnabled = undefined ; // Initialized inside uiSelect directive link function
164164 ctrl . resetSearchInput = undefined ; // Initialized inside uiSelect directive link function
257257 var filteredItems = items . filter ( function ( i ) { return ctrl . selected . indexOf ( i ) < 0 ; } ) ;
258258 setItemsFn ( filteredItems ) ;
259259 } else {
260- setItemsFn ( items ) ;
260+ setItemsFn ( items ) ;
261261 }
262262 ctrl . ngModel . $modelValue = null ; //Force scope model value and ngModel value to be out of sync to re-run formatters
263263
267267 } ) ;
268268
269269 if ( ctrl . multiple ) {
270- //Remove already selected items
270+ //Remove already selected items
271271 $scope . $watchCollection ( '$select.selected' , function ( selectedItems ) {
272272 if ( ! selectedItems . length ) return ;
273273 var data = ctrl . parserResult . source ( $scope ) ;
307307 } ;
308308
309309 ctrl . isActive = function ( itemScope ) {
310- return ctrl . items . indexOf ( itemScope [ ctrl . itemProperty ] ) === ctrl . activeIndex ;
310+ if ( typeof itemScope [ ctrl . itemProperty ] === 'undefined' ) {
311+ return false ;
312+ }
311313 } ;
312314
313315 ctrl . isDisabled = function ( itemScope ) {
357359 _resetSearchInput ( ) ;
358360 ctrl . open = false ;
359361 $timeout ( function ( ) {
360- ctrl . focusser [ 0 ] . focus ( ) ;
362+ ctrl . focusser [ 0 ] . focus ( ) ;
361363 } , 0 , false ) ;
362364 }
363365 } ;
427429 // Handles selected options in "multiple" mode
428430 function _handleMatchSelection ( key ) {
429431 var caretPosition = _getCaretPosition ( _searchInput [ 0 ] ) ,
430- length = ctrl . selected . length ,
432+ length = ctrl . selected . length ,
431433 // none = -1,
432434 first = 0 ,
433435 last = length - 1 ,
450452 break ;
451453 case KEY . RIGHT :
452454 // Open drop-down
453- if ( ! ~ ctrl . activeMatchIndex || curr === last ) {
455+ if ( ! ~ ctrl . activeMatchIndex || curr === last ) {
454456 ctrl . activate ( ) ;
455457 return false ;
456458 }
473475 return curr ;
474476 }
475477 else return false ;
476- }
478+ }
477479 }
478480
479481 newIndex = getNewActiveMatchIndex ( ) ;
500502 if ( ctrl . multiple && KEY . isHorizontalMovement ( key ) ) {
501503 processed = _handleMatchSelection ( key ) ;
502504 }
503-
505+
504506 if ( ! processed && ( ctrl . items . length > 0 || ctrl . tagging . isActivated ) ) {
505507 processed = _handleDropDownSelection ( key ) ;
506508 }
507-
509+
508510 if ( processed && key != KEY . TAB ) {
509511 //TODO Check si el tab selecciona aun correctamente
510512 //Crear test
612614
613615 //From model --> view
614616 ngModel . $formatters . unshift ( function ( inputValue ) {
615- var data = $select . parserResult . source ( scope , { $select : { search :'' } } ) , //Overwrite $search
617+ var data = $select . parserResult . source ( scope , { $select : { search :'' } } ) , //Overwrite $search
616618 locals = { } ,
617619 result ;
618620 if ( data ) {
664666 if ( attrs . tabindex ) {
665667 //tabindex might be an expression, wait until it contains the actual value before we set the focusser tabindex
666668 attrs . $observe ( 'tabindex' , function ( value ) {
667- //If we are using multiple, add tabindex to the search input
669+ //If we are using multiple, add tabindex to the search input
668670 if ( $select . multiple ) {
669671 searchInput . attr ( "tabindex" , value ) ;
670672 } else {
719721 if ( e . which === KEY . TAB || KEY . isControl ( e ) || KEY . isFunctionKey ( e ) || e . which === KEY . ESC || e . which == KEY . ENTER || e . which === KEY . BACKSPACE ) {
720722 return ;
721723 }
722-
724+
723725 $select . activate ( focusser . val ( ) ) ; //User pressed some regular key, so we pass it to the search input
724726 focusser . val ( '' ) ;
725727 scope . $digest ( ) ;
857859 if ( ! tAttrs . repeat ) throw uiSelectMinErr ( 'repeat' , "Expected 'repeat' expression." ) ;
858860
859861 return function link ( scope , element , attrs , $select , transcludeFn ) {
860-
862+
861863 // var repeat = RepeatParser.parse(attrs.repeat);
862864 var groupByExp = attrs . groupBy ;
863865
@@ -965,4 +967,4 @@ $templateCache.put("select2/select-multiple.tpl.html","<div class=\"ui-select-mu
965967$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>" ) ;
966968$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>" ) ;
967969$templateCache . put ( "selectize/match.tpl.html" , "<div ng-hide=\"$select.searchEnabled && ($select.open || $select.isEmpty())\" class=\"ui-select-match\" ng-transclude=\"\"></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>" ) ; } ] ) ;
970+ $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