Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

fixed #808 #810

Merged
merged 3 commits into from
Feb 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/select.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* ui-select
* http://github.com/angular-ui/ui-select
* Version: 0.11.2 - 2015-03-17T04:08:46.478Z
* Version: 0.11.2 - 2015-04-27T15:33:22.851Z
* License: MIT
*/

Expand Down
28 changes: 19 additions & 9 deletions dist/select.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* ui-select
* http://github.com/angular-ui/ui-select
* Version: 0.11.2 - 2015-03-17T04:08:46.474Z
* Version: 0.11.2 - 2015-04-27T15:33:22.845Z
* License: MIT
*/

Expand Down Expand Up @@ -279,7 +279,7 @@ uis.controller('uiSelectCtrl',
if (ctrl.searchInput.length !== 1) {
throw uiSelectMinErr('searchInput', "Expected 1 input.ui-select-search but got '{0}'.", ctrl.searchInput.length);
}

ctrl.isEmpty = function() {
return angular.isUndefined(ctrl.selected) || ctrl.selected === null || ctrl.selected === '';
};
Expand Down Expand Up @@ -540,7 +540,9 @@ uis.controller('uiSelectCtrl',
ctrl.clear = function($event) {
ctrl.select(undefined);
$event.stopPropagation();
ctrl.focusser[0].focus();
$timeout(function() {
ctrl.focusser[0].focus();
}, 0, false);
};

// Toggle dropdown
Expand Down Expand Up @@ -632,6 +634,11 @@ uis.controller('uiSelectCtrl',

var key = e.which;

if (~[KEY.ENTER,KEY.ESC].indexOf(key)){
e.preventDefault();
e.stopPropagation();
}

// if(~[KEY.ESC,KEY.TAB].indexOf(key)){
// //TODO: SEGURO?
// ctrl.close();
Expand Down Expand Up @@ -1028,7 +1035,10 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec
$select = $scope.$select,
ngModel;

//Wait for link fn to inject it
if (angular.isUndefined($select.selected))
$select.selected = [];

//Wait for link fn to inject it
$scope.$evalAsync(function(){ ngModel = $scope.ngModel; });

ctrl.activeMatchIndex = -1;
Expand All @@ -1040,7 +1050,7 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec

ctrl.refreshComponent = function(){
//Remove already selected items
//e.g. When user clicks on a selection, the selected array changes and
//e.g. When user clicks on a selection, the selected array changes and
//the dropdown should remove that item
$select.refreshItems();
$select.sizeSearchInput();
Expand Down Expand Up @@ -1075,7 +1085,7 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec

ctrl.getPlaceholder = function(){
//Refactor single?
if($select.selected.length) return;
if ($select.selected.length) return;
return $select.placeholder;
};

Expand Down Expand Up @@ -1139,7 +1149,7 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec
};
if (!inputValue) return resultMultiple; //If ngModel was undefined
for (var k = inputValue.length - 1; k >= 0; k--) {
//Check model array of currently selected items
//Check model array of currently selected items
if (!checkFnMultiple($select.selected, inputValue[k])){
//Check model array of all items available
if (!checkFnMultiple(data, inputValue[k])){
Expand All @@ -1150,8 +1160,8 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec
}
return resultMultiple;
});
//Watch for external model changes

//Watch for external model changes
scope.$watchCollection(function(){ return ngModel.$modelValue; }, function(newValue, oldValue) {
if (oldValue != newValue){
ngModel.$modelValue = null; //Force scope model value and ngModel value to be out of sync to re-run formatters
Expand Down
2 changes: 1 addition & 1 deletion dist/select.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/select.min.js

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion src/uiSelectController.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ uis.controller('uiSelectCtrl',
if (ctrl.searchInput.length !== 1) {
throw uiSelectMinErr('searchInput', "Expected 1 input.ui-select-search but got '{0}'.", ctrl.searchInput.length);
}

ctrl.isEmpty = function() {
return angular.isUndefined(ctrl.selected) || ctrl.selected === null || ctrl.selected === '';
};
Expand Down Expand Up @@ -398,6 +398,11 @@ uis.controller('uiSelectCtrl',

var key = e.which;

if (~[KEY.ENTER,KEY.ESC].indexOf(key)){
e.preventDefault();
e.stopPropagation();
}

// if(~[KEY.ESC,KEY.TAB].indexOf(key)){
// //TODO: SEGURO?
// ctrl.close();
Expand Down
15 changes: 9 additions & 6 deletions src/uiSelectMultipleDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec
$select = $scope.$select,
ngModel;

//Wait for link fn to inject it
if (angular.isUndefined($select.selected))
$select.selected = [];

//Wait for link fn to inject it
$scope.$evalAsync(function(){ ngModel = $scope.ngModel; });

ctrl.activeMatchIndex = -1;
Expand All @@ -21,7 +24,7 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec

ctrl.refreshComponent = function(){
//Remove already selected items
//e.g. When user clicks on a selection, the selected array changes and
//e.g. When user clicks on a selection, the selected array changes and
//the dropdown should remove that item
$select.refreshItems();
$select.sizeSearchInput();
Expand Down Expand Up @@ -56,7 +59,7 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec

ctrl.getPlaceholder = function(){
//Refactor single?
if($select.selected.length) return;
if ($select.selected.length) return;
return $select.placeholder;
};

Expand Down Expand Up @@ -120,7 +123,7 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec
};
if (!inputValue) return resultMultiple; //If ngModel was undefined
for (var k = inputValue.length - 1; k >= 0; k--) {
//Check model array of currently selected items
//Check model array of currently selected items
if (!checkFnMultiple($select.selected, inputValue[k])){
//Check model array of all items available
if (!checkFnMultiple(data, inputValue[k])){
Expand All @@ -131,8 +134,8 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec
}
return resultMultiple;
});
//Watch for external model changes

//Watch for external model changes
scope.$watchCollection(function(){ return ngModel.$modelValue; }, function(newValue, oldValue) {
if (oldValue != newValue){
ngModel.$modelValue = null; //Force scope model value and ngModel value to be out of sync to re-run formatters
Expand Down