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

Commit fb3d343

Browse files
committed
change sort-enabled to sortable, prevent drop in search input
1 parent 83b7eb1 commit fb3d343

File tree

6 files changed

+14
-13
lines changed

6 files changed

+14
-13
lines changed

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" sort-enabled="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="false" 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>

examples/demo-tagging.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ <h1>Tagging Demos</h1>
6666

6767
<h3>Simple String Tags</h3>
6868
<h4>(With Custom Tag Label / Sort Enabled)</h4>
69-
<ui-select multiple tagging tagging-label="(custom 'new' label)" ng-model="multipleDemo.colors" theme="bootstrap" sort-enabled="true" ng-disabled="disabled" style="width: 300px;" title="Choose a color">
69+
<ui-select multiple tagging tagging-label="(custom 'new' label)" ng-model="multipleDemo.colors" theme="bootstrap" sortable="true" ng-disabled="disabled" style="width: 300px;" title="Choose a color">
7070
<ui-select-match placeholder="Select colors...">{{$item}}</ui-select-match>
7171
<ui-select-choices repeat="color in availableColors | filter:$select.search">
7272
{{color}}

examples/select2-bootstrap3.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
<label class="col-sm-3 control-label">Multiple</label>
6969
<div class="col-sm-6">
7070

71-
<ui-select multiple sort-enabled="true" ng-model="person.selected" theme="select2" class="form-control" title="Choose a person">
71+
<ui-select multiple sortable="true" ng-model="person.selected" theme="select2" class="form-control" title="Choose a person">
7272
<ui-select-match placeholder="Select or search a person in the list...">{{$select.selected.name}}</ui-select-match>
7373
<ui-select-choices repeat="item in people | filter: $select.search">
7474
<div ng-bind-html="item.name | highlight: $select.search"></div>

src/bootstrap/select-multiple.tpl.html

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

src/select.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
.constant('uiSelectConfig', {
9191
theme: 'bootstrap',
9292
searchEnabled: true,
93-
sortEnabled: false,
93+
sortable: false,
9494
placeholder: '', // Empty by default, like HTML tag <select>
9595
refreshDelay: 1000, // In milliseconds
9696
closeOnSelect: true,
@@ -184,7 +184,7 @@
184184
ctrl.focusser = undefined; //Reference to input element used to handle focus events
185185
ctrl.disabled = undefined; // Initialized inside uiSelect directive link function
186186
ctrl.searchEnabled = undefined; // Initialized inside uiSelect directive link function
187-
ctrl.sortEnabled = undefined; // Initialized inside uiSelect directive link function
187+
ctrl.sortable = undefined; // Initialized inside uiSelect directive link function
188188
ctrl.resetSearchInput = undefined; // Initialized inside uiSelect directive link function
189189
ctrl.refreshDelay = undefined; // Initialized inside uiSelectChoices directive link function
190190
ctrl.multiple = false; // Initialized inside uiSelect directive link function
@@ -1080,9 +1080,9 @@
10801080
$select.searchEnabled = searchEnabled !== undefined ? searchEnabled : uiSelectConfig.searchEnabled;
10811081
});
10821082

1083-
scope.$watch('sortEnabled', function() {
1084-
var sortEnabled = scope.$eval(attrs.sortEnabled);
1085-
$select.sortEnabled = sortEnabled !== undefined ? sortEnabled : uiSelectConfig.sortEnabled;
1083+
scope.$watch('sortable', function() {
1084+
var sortable = scope.$eval(attrs.sortable);
1085+
$select.sortable = sortable !== undefined ? sortable : uiSelectConfig.sortable;
10861086
});
10871087

10881088
attrs.$observe('disabled', function() {
@@ -1325,7 +1325,7 @@
13251325
}])
13261326

13271327
// Make multiple matches sortable
1328-
.directive('uiSelectSort', ['$timeout', '$log', 'uiSelectConfig', 'uiSelectMinErr', function($timeout, $log, uiSelectConfig, uiSelectMinErr) {
1328+
.directive('uiSelectSort', ['$timeout', 'uiSelectConfig', 'uiSelectMinErr', function($timeout, uiSelectConfig, uiSelectMinErr) {
13291329
return {
13301330
require: '^uiSelect',
13311331
link: function(scope, element, attrs, $select) {
@@ -1345,9 +1345,8 @@
13451345
droppingAfterClassName = 'dropping-after';
13461346

13471347
scope.$watch(function(){
1348-
return $select.sortEnabled;
1348+
return $select.sortable;
13491349
}, function(n){
1350-
$log.log(n);
13511350
if (n) {
13521351
element.attr('draggable', true);
13531352
} else {

src/select2/select-multiple.tpl.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
ng-hide="$select.disabled"
2222
ng-model="$select.search"
2323
ng-click="$select.activate()"
24-
style="width: 34px;">
24+
style="width: 34px;"
25+
ondrop="return false;">
2526
</li>
2627
</ul>
2728
<div class="select2-drop select2-with-searchbox select2-drop-active"

0 commit comments

Comments
 (0)