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

Adding fixes mainly to tagging functionality #1371

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/.idea
/.tmp
.DS_Store
public
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.13.2 - 2015-10-09T15:34:24.045Z
* Version: 0.13.2 - 2016-01-31T11:42:51.520Z
* License: MIT
*/

Expand Down
269 changes: 152 additions & 117 deletions dist/select.js

Large diffs are not rendered by default.

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.

27 changes: 22 additions & 5 deletions src/uiSelectController.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,17 @@ uis.controller('uiSelectCtrl',
// Debounce
// See https://github.com/angular-ui/bootstrap/blob/0.10.0/src/typeahead/typeahead.js#L155
// FYI AngularStrap typeahead does not have debouncing: https://github.com/mgcrea/angular-strap/blob/v2.0.0-rc.4/src/typeahead/typeahead.js#L177
if (_refreshDelayPromise) {
$timeout.cancel(_refreshDelayPromise);
if (ctrl.refreshDelay > 0) {
if (_refreshDelayPromise) {
$timeout.cancel(_refreshDelayPromise);
}
_refreshDelayPromise = $timeout(function () {
$scope.$eval(refreshAttr);
}, ctrl.refreshDelay);
}
_refreshDelayPromise = $timeout(function() {
else {
$scope.$eval(refreshAttr);
}, ctrl.refreshDelay);
}
}
};

Expand Down Expand Up @@ -305,7 +310,12 @@ uis.controller('uiSelectCtrl',
}
}
// search ctrl.selected for dupes potentially caused by tagging and return early if found
if ( ctrl.selected && angular.isArray(ctrl.selected) && ctrl.selected.filter( function (selection) { return angular.equals(selection, item); }).length > 0 ) {
if (ctrl.selected && angular.isArray(ctrl.selected) && ctrl.selected.filter(function (selection) {
return ctrl.isNewTagDuplication !== angular.noop ? ctrl.isNewTagDuplication($scope, {
newItem: item,
existingItem: angular.copy(selection)
}) : angular.equals(angular.copy(selection), item);
}).length > 0) {
ctrl.close(skipFocusser);
return;
}
Expand All @@ -326,6 +336,9 @@ uis.controller('uiSelectCtrl',
if (ctrl.closeOnSelect) {
ctrl.close(skipFocusser);
}
else {
_resetSearchInput();
}
if ($event && $event.type === 'click') {
ctrl.clickTriggeredSelect = true;
}
Expand Down Expand Up @@ -496,6 +509,7 @@ uis.controller('uiSelectCtrl',
var data = e.originalEvent.clipboardData.getData('text/plain');
if (data && data.length > 0 && ctrl.taggingTokens.isActivated && ctrl.tagging.fct) {
var items = data.split(ctrl.taggingTokens.tokens[0]); // split by first token only
items = items.filter(Boolean);
if (items && items.length > 0) {
angular.forEach(items, function (item) {
var newItem = ctrl.tagging.fct(item);
Expand All @@ -517,6 +531,9 @@ uis.controller('uiSelectCtrl',

// See https://github.com/ivaynberg/select2/blob/3.4.6/select2.js#L1431
function _ensureHighlightVisible() {
if (!ctrl.open) {
return;
}
var container = $element.querySelectorAll('.ui-select-choices-content');
var choices = container.querySelectorAll('.ui-select-choices-row');
if (choices.length < 1) {
Expand Down
5 changes: 4 additions & 1 deletion src/uiSelectDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ uis.directive('uiSelect',

$select.onSelectCallback = $parse(attrs.onSelect);
$select.onRemoveCallback = $parse(attrs.onRemove);
$select.isNewTagDuplication = $parse(attrs.isNewTagDuplication);

//Limit the number of selections allowed
$select.limit = (angular.isDefined(attrs.limit)) ? parseInt(attrs.limit, 10) : undefined;
Expand Down Expand Up @@ -253,6 +254,8 @@ uis.directive('uiSelect',
element[0].style.left = '';
element[0].style.top = '';
element[0].style.width = originalWidth;

$select.setFocus();
}

// Hold on to a reference to the .ui-select-dropdown element for direction support.
Expand Down Expand Up @@ -300,7 +303,7 @@ uis.directive('uiSelect',
}

// Hide the dropdown so there is no flicker until $timeout is done executing.
dropdown[0].style.opacity = 0;
//dropdown[0].style.opacity = 0;

// Delay positioning the dropdown until all choices have been added so its height is correct.
$timeout(function(){
Expand Down
Loading