Skip to content

Commit 29c6f6e

Browse files
author
Kevin Kotosky
committed
added in editability, proper arrow key and backspace handling, handled sortable classes being removed properly, removed references to bower
1 parent 2d1422d commit 29c6f6e

13 files changed

+328
-240
lines changed

dist/select.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* ui-select
33
* http://github.com/angular-ui/ui-select
4-
* Version: 0.12.0 - 2015-05-28T07:44:11.364Z
4+
* Version: 0.12.0 - 2015-06-04T17:31:50.812Z
55
* License: MIT
66
*/
77

dist/select.js

Lines changed: 156 additions & 113 deletions
Large diffs are not rendered by default.

dist/select.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/select.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/demo-multi-select.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ <h3>Array of strings</h3>
122122
<p>Selected: {{multipleDemo.colors}}</p>
123123
<hr>
124124
<h3>Array of objects (sorting enabled)</h3>
125-
<ui-select multiple ng-model="multipleDemo.selectedPeople" theme="bootstrap" ng-disabled="disabled" sortable="true" close-on-select="false" style="width: 800px;">
125+
<ui-select multiple ng-model="multipleDemo.selectedPeople" theme="bootstrap" ng-disabled="disabled" sortable="true" close-on-select="true" style="width: 800px;">
126126
<ui-select-match placeholder="Select person...">{{$item.name}} &lt;{{$item.email}}&gt;</ui-select-match>
127127
<ui-select-choices repeat="person in people | propsFilter: {name: $select.search, age: $select.search}">
128128
<div ng-bind-html="person.name | highlight: $select.search"></div>

gulpfile.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var rename = require('gulp-rename');
99
var es = require('event-stream');
1010
var del = require('del');
1111
var uglify = require('gulp-uglify');
12-
var minifyHtml = require('gulp-minify-html');
12+
var minifyHtml = require('gulp-minify-html');
1313
var minifyCSS = require('gulp-minify-css');
1414
var templateCache = require('gulp-angular-templatecache');
1515
var gutil = require('gulp-util');
@@ -30,7 +30,7 @@ gulp.task('default', ['build','test']);
3030
gulp.task('build', ['scripts', 'styles']);
3131
gulp.task('test', ['build', 'karma']);
3232

33-
gulp.task('watch', ['build','karma-watch'], function() {
33+
gulp.task('watch', ['build'], function() {
3434
gulp.watch(['src/**/*.{js,html}'], ['build']);
3535
});
3636

@@ -60,7 +60,6 @@ gulp.task('scripts', ['clean'], function() {
6060
.pipe(footer('\n}());'))
6161
.pipe(jshint())
6262
.pipe(jshint.reporter('jshint-stylish'))
63-
.pipe(jshint.reporter('fail'));
6463
};
6564

6665
return es.merge(buildLib(), buildTemplates())

karma.conf.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ module.exports = function(config) {
99

1010
// List of files / patterns to load in the browser
1111
files: [
12-
'bower_components/jquery/dist/jquery.js',
13-
'bower_components/angular/angular.js',
14-
'bower_components/angular-sanitize/angular-sanitize.js',
15-
'bower_components/angular-mocks/angular-mocks.js',
12+
'node_modules/jquery/dist/jquery.js',
13+
'node_modules/angular/angular.js',
14+
'node_modules/angular-sanitize/angular-sanitize.js',
15+
'node_modules/angular-mocks/angular-mocks.js',
1616

1717
'dist/select.js',
1818
'test/helpers.js',

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
},
99
"version": "0.12.0",
1010
"devDependencies": {
11-
"bower": "~1.3",
11+
"angular": "^1.2.18",
12+
"angular-mocks": "^1.2.18",
13+
"angular-sanitize": "^1.2.18",
1214
"del": "~0.1.1",
1315
"event-stream": "~3.1.0",
1416
"gulp": "~3.8.5",
@@ -23,6 +25,7 @@
2325
"gulp-rename": "~0.2.2",
2426
"gulp-uglify": "~0.3.1",
2527
"gulp-util": "^2.2.19",
28+
"jquery":"~1.11",
2629
"jshint-stylish": "~0.3.0",
2730
"karma": "^0.12.16",
2831
"karma-chrome-launcher": "^0.1.3",
@@ -33,7 +36,6 @@
3336
"karma-coverage": "~0.2"
3437
},
3538
"scripts": {
36-
"postinstall": "bower install",
3739
"test": "gulp test"
3840
},
3941
"license": "MIT"

src/bootstrap/match-multiple.tpl.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
tabindex="-1"
66
type="button"
77
ng-disabled="$select.disabled"
8-
ng-click="$selectMultiple.activeMatchIndex = $index;"
9-
ng-class="{'btn-primary':$selectMultiple.activeMatchIndex === $index, 'select-locked':$select.isLocked(this, $index)}"
8+
ng-class="{'btn-primary':$selectMultiple.activeMatchIndex === $index, 'select-locked':$select.isLocked(this, $index),
9+
'grabbable': $select.isGrabbable()}"
10+
ng-dblclick="$selectMultiple.editTag(this, $index)"
1011
ui-select-sort="$select.selected">
1112
<span class="close ui-select-match-close" ng-hide="$select.disabled" ng-click="$selectMultiple.removeChoice($index)">&nbsp;&times;</span>
1213
<span uis-transclude-append></span>

src/bootstrap/select-multiple.tpl.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
ng-click="$select.activate()"
1414
ng-model="$select.search"
1515
role="combobox"
16-
aria-label="{{ $select.baseTitle }}"
16+
aria-label="{{::$select.baseTitle }}"
1717
ondrop="return false;">
1818
</div>
1919
<div class="ui-select-choices"></div>

src/uiSelectController.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* put as much logic in the controller (instead of the link functions) as possible so it can be easily tested.
66
*/
77
uis.controller('uiSelectCtrl',
8-
['$scope', '$element', '$timeout', '$filter', 'uisRepeatParser', 'uiSelectMinErr', 'uiSelectConfig',
9-
function($scope, $element, $timeout, $filter, RepeatParser, uiSelectMinErr, uiSelectConfig) {
8+
['$scope', '$element', '$timeout', '$filter', '$log', 'uisRepeatParser', 'uiSelectMinErr', 'uiSelectConfig',
9+
function($scope, $element, $timeout, $filter, $log, RepeatParser, uiSelectMinErr, uiSelectConfig) {
1010

1111
var ctrl = this;
1212

@@ -38,6 +38,7 @@ uis.controller('uiSelectCtrl',
3838
ctrl.lockChoiceExpression = undefined; // Initialized inside uiSelectMatch directive link function
3939
ctrl.clickTriggeredSelect = false;
4040
ctrl.$filter = $filter;
41+
ctrl.$element = $element;
4142

4243
ctrl.searchInput = $element.querySelectorAll('input.ui-select-search');
4344
if (ctrl.searchInput.length !== 1) {
@@ -50,6 +51,7 @@ uis.controller('uiSelectCtrl',
5051

5152
// Most of the time the user does not want to empty the search input when in typeahead mode
5253
function _resetSearchInput() {
54+
console.log('reset search input');
5355
if (ctrl.resetSearchInput || (ctrl.resetSearchInput === undefined && uiSelectConfig.resetSearchInput)) {
5456
ctrl.search = EMPTY_SEARCH;
5557
//reset activeIndex
@@ -72,9 +74,8 @@ uis.controller('uiSelectCtrl',
7274
}
7375

7476
// When the user clicks on ui-select, displays the dropdown list
75-
ctrl.activate = function(initSearchValue, avoidReset) {
77+
ctrl.activate = function(initSearchValue, editing) {
7678
if (!ctrl.disabled && !ctrl.open) {
77-
if(!avoidReset) _resetSearchInput();
7879

7980
$scope.$broadcast('uis:activate');
8081

@@ -102,6 +103,10 @@ uis.controller('uiSelectCtrl',
102103
})[0];
103104
};
104105

106+
ctrl.isGrabbable = function() {
107+
return ctrl.sortable;
108+
};
109+
105110
ctrl.parseRepeatAttr = function(repeatAttr, groupByExp, groupFilterExp) {
106111
function updateGroups(items) {
107112
var groupFn = $scope.$eval(groupByExp);
@@ -154,7 +159,10 @@ uis.controller('uiSelectCtrl',
154159
}
155160
}
156161
};
157-
162+
ctrl.editTag = function(item, thing) {
163+
console.log(item);
164+
console.log(thing);
165+
}
158166
// See https://github.com/angular/angular.js/blob/v1.2.15/src/ng/directive/ngRepeat.js#L259
159167
$scope.$watchCollection(ctrl.parserResult.source, function(items) {
160168
if (items === undefined || items === null) {
@@ -279,7 +287,7 @@ uis.controller('uiSelectCtrl',
279287
}
280288
// search ctrl.selected for dupes potentially caused by tagging and return early if found
281289
if ( ctrl.selected && angular.isArray(ctrl.selected) && ctrl.selected.filter( function (selection) { return angular.equals(selection, item); }).length > 0 ) {
282-
ctrl.close(skipFocusser);
290+
ctrl.close(skipFocusser, true);
283291
return;
284292
}
285293
}
@@ -297,7 +305,7 @@ uis.controller('uiSelectCtrl',
297305
});
298306

299307
if (ctrl.closeOnSelect) {
300-
ctrl.close(skipFocusser);
308+
ctrl.close(skipFocusser, true);
301309
}
302310
if ($event && $event.type === 'click') {
303311
ctrl.clickTriggeredSelect = true;
@@ -307,14 +315,12 @@ uis.controller('uiSelectCtrl',
307315
};
308316

309317
// Closes the dropdown
310-
ctrl.close = function(skipFocusser) {
318+
ctrl.close = function(skipFocusser, resetInput) {
311319
if (!ctrl.open) return;
312-
if (ctrl.ngModel && ctrl.ngModel.$setTouched) ctrl.ngModel.$setTouched();
313-
_resetSearchInput();
320+
if (ctrl.ngModel && ctrl.ngModel.$setTouched) ctrl.ngModel.$setTouched();
321+
if (resetInput) _resetSearchInput();
314322
ctrl.open = false;
315-
316323
$scope.$broadcast('uis:close', skipFocusser);
317-
318324
};
319325

320326
ctrl.setFocus = function(){
@@ -387,11 +393,11 @@ uis.controller('uiSelectCtrl',
387393
var processed = true;
388394
switch (key) {
389395
case KEY.DOWN:
390-
if (!ctrl.open && ctrl.multiple) ctrl.activate(false, true); //In case its the search input in 'multiple' mode
396+
if (!ctrl.open && ctrl.multiple) ctrl.activate(false); //In case its the search input in 'multiple' mode
391397
else if (ctrl.activeIndex < ctrl.items.length - 1) { ctrl.activeIndex++; }
392398
break;
393399
case KEY.UP:
394-
if (!ctrl.open && ctrl.multiple) ctrl.activate(false, true); //In case its the search input in 'multiple' mode
400+
if (!ctrl.open && ctrl.multiple) ctrl.activate(false); //In case its the search input in 'multiple' mode
395401
else if (ctrl.activeIndex > 0 || (ctrl.search.length === 0 && ctrl.tagging.isActivated && ctrl.activeIndex > -1)) { ctrl.activeIndex--; }
396402
break;
397403
case KEY.TAB:
@@ -401,7 +407,7 @@ uis.controller('uiSelectCtrl',
401407
if(ctrl.open && (ctrl.tagging.isActivated || ctrl.activeIndex >= 0)){
402408
ctrl.select(ctrl.items[ctrl.activeIndex]); // Make sure at least one dropdown item is highlighted before adding if not in tagging mode
403409
} else {
404-
ctrl.activate(false, true); //In case its the search input in 'multiple' mode
410+
ctrl.activate(false); //In case its the search input in 'multiple' mode
405411
}
406412
break;
407413
case KEY.ESC:

0 commit comments

Comments
 (0)