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

Commit 5dd63ad

Browse files
author
Dean Sofer
committed
Cleaning up code and API
1 parent 241b922 commit 5dd63ad

File tree

7 files changed

+18
-18
lines changed

7 files changed

+18
-18
lines changed

dist/select.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ angular.module('ui.select', [])
4343

4444
ctrl.open = false;
4545

46-
ctrl.activate = function($event) {
46+
ctrl.activate = function() {
4747
ctrl.open = true;
4848
// Give it time to appear before focus
49-
$timeout(function() {
49+
setTimeout(function() {
5050
ctrl.input[0].focus();
5151
});
5252
};
@@ -59,7 +59,7 @@ angular.module('ui.select', [])
5959

6060
ctrl.close = function() {
6161
ctrl.open = false;
62-
ctrl.search = "";
62+
ctrl.search = '';
6363
};
6464

6565
ctrl.input = $element.find('input'); // TODO could break if input is at other template
@@ -136,7 +136,7 @@ angular.module('ui.select', [])
136136
compile: function(tElement, tAttrs) {
137137

138138
tElement.querySelectorAll('.ui-select-choices-row')
139-
.attr("ng-repeat", 'item in ' + tAttrs.data)
139+
.attr("ng-repeat", tAttrs.repeat)
140140
.attr("ng-mouseenter", '$select.activeIdx=$index')
141141
.attr("ng-click", '$select.select(item)');
142142

@@ -237,12 +237,12 @@ angular.module('ui.select', [])
237237

238238
angular.module('ui.select').run(['$templateCache', function ($templateCache) {
239239
$templateCache.put('bootstrap/choices.tpl.html', '<ul class="ui-select-choices ui-select-choices-content dropdown-menu" role="menu" aria-labelledby="dLabel"> <li class="ui-select-choices-row" ng-class="{active: $select.activeIdx==$index}"> <a ng-transclude></a> </li> </ul> ');
240-
$templateCache.put('bootstrap/match.tpl.html', '<a class="btn btn-default ui-select-match" ng-hide="$select.open" ng-class="{\'text-success\': $select.selected==undefined}" ng-click="$select.activate($event)"> <span ng-hide="$select.selected" class="text-muted">{{placeholder}}</span> <span ng-show="$select.selected" ng-transclude></span> <span class="caret"></span> </a> ');
241-
$templateCache.put('bootstrap/select.tpl.html', '<div class="dropdown" ng-class="{open:$select.open}"> <div class="ui-select-match" ng-click="$select.activate($event)"></div> <input type="text" class="form-control ui-select-search" autocomplete="off" tabindex="" placeholder="{{$select.placeholder}}" ng-model="$select.search" ng-show="$select.open"> <div class="ui-select-choices"></div> </div> ');
240+
$templateCache.put('bootstrap/match.tpl.html', '<a class="btn btn-default ui-select-match" ng-hide="$select.open" ng-class="{\'text-success\': $select.selected==undefined}" ng-click="$select.activate()"> <span ng-hide="$select.selected" class="text-muted">{{placeholder}}</span> <span ng-show="$select.selected" ng-transclude></span> <span class="caret"></span> </a> ');
241+
$templateCache.put('bootstrap/select.tpl.html', '<div class="dropdown" ng-class="{open:$select.open}"> <div class="ui-select-match" ng-click="$select.activate()"></div> <input type="text" class="form-control ui-select-search" autocomplete="off" tabindex="" placeholder="{{$select.placeholder}}" ng-model="$select.search" ng-show="$select.open"> <div class="ui-select-choices"></div> </div> ');
242242
$templateCache.put('select2/choices.tpl.html', '<ul class="ui-select-choices ui-select-choices-content select2-results"> <li class="ui-select-choices-row" ng-class="{\'select2-highlighted\': $select.activeIdx==$index}"> <div class="select2-result-label" ng-transclude></div> </li> </ul> ');
243-
$templateCache.put('select2/match.tpl.html', '<a class="select2-choice ui-select-match" ng-class="{\'select2-default\': $select.selected==undefined}" ng-click="$select.activate($event)"> <span ng-hide="$select.selected" class="select2-chosen">{{$select.placeholder}}</span> <span ng-show="$select.selected" class="select2-chosen" ng-transclude></span> <span class="select2-arrow"><b></b></span> </a> ');
243+
$templateCache.put('select2/match.tpl.html', '<a class="select2-choice ui-select-match" ng-class="{\'select2-default\': $select.selected==undefined}" ng-click="$select.activate()"> <span ng-hide="$select.selected" class="select2-chosen">{{$select.placeholder}}</span> <span ng-show="$select.selected" class="select2-chosen" ng-transclude></span> <span class="select2-arrow"><b></b></span> </a> ');
244244
$templateCache.put('select2/select.tpl.html', '<div class="select2 select2-container" ng-class="{\'select2-container-active select2-dropdown-open\': $select.open}"> <div class="ui-select-match"></div> <div ng-class="{\'select2-display-none\': !$select.open}" class="select2-drop select2-with-searchbox select2-drop-active"> <div class="select2-search"> <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> ');
245245
$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-row" ng-class="{\'active\': $select.activeIdx==$index}" ng-click="$select(item)" ng-mouseenter="$select.index=$index"> <div class="option" data-selectable ng-transclude></div> </div> </div> </div> ');
246246
$templateCache.put('selectize/match.tpl.html', '<div ng-hide="$select.open || !$select.selected" class="ui-select-match" ng-transclude></div> ');
247-
$templateCache.put('selectize/select.tpl.html', '<div class="selectize-control single"> <div class="selectize-input" ng-class="{\'focus\': $select.open}" ng-click="$select.activate($event)"> <div class="ui-select-match"></div> <input type="text" class="ui-select-search" autocomplete="off" tabindex="" placeholder="{{$select.placeholder}}" ng-model="$select.search" ng-hide="$select.selected && !$select.open"> </div> <div class="ui-select-choices"></div> </div> ');
247+
$templateCache.put('selectize/select.tpl.html', '<div class="selectize-control single"> <div class="selectize-input" ng-class="{\'focus\': $select.open}" ng-click="$select.activate()"> <div class="ui-select-match"></div> <input type="text" class="ui-select-search" autocomplete="off" tabindex="" placeholder="{{$select.placeholder}}" ng-model="$select.search" ng-hide="$select.selected && !$select.open"> </div> <div class="ui-select-choices"></div> </div> ');
248248
}]);

examples/bootstrap.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464

6565
<ui-select ng-model="person.selected" theme="bootstrap">
6666
<match placeholder="Select or search a person in the list...">{{$select.selected.name}}</match>
67-
<choices data="people | filter: $select.search">
67+
<choices repeat="item in people | filter: $select.search">
6868
<div ng-bind-html="trustAsHtml((item.name | highlight: $select.search))"></div>
6969
<small ng-bind-html="trustAsHtml((item.email | highlight: $select.search))"></small>
7070
</choices>

examples/demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
<p>Select2 theme (default):</p>
5959
<ui-select ng-model="person.selected" style="width: 300px;">
6060
<match placeholder="Select or search a person in the list...">{{$select.selected.name}}</match>
61-
<choices data="people | filter: $select.search">
61+
<choices repeat="item in people | filter: $select.search">
6262
<div ng-bind-html="trustAsHtml((item.name | highlight: $select.search))"></div>
6363
<small ng-bind-html="trustAsHtml((item.email | highlight: $select.search))"></small>
6464
</choices>

examples/select2-bootstrap3.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555

5656
<ui-select ng-model="person.selected" theme="select2" class="form-control">
5757
<match placeholder="Select or search a person in the list...">{{$select.selected.name}}</match>
58-
<choices data="people | filter: $select.search">
58+
<choices repeat="item in people | filter: $select.search">
5959
<div ng-bind-html="trustAsHtml((item.name | highlight: $select.search))"></div>
6060
<small ng-bind-html="trustAsHtml((item.email | highlight: $select.search))"></small>
6161
</choices>
@@ -71,7 +71,7 @@
7171

7272
<ui-select ng-model="person.selected" theme="select2" class="form-control">
7373
<match placeholder="Select or search a person in the list...">{{$select.selected.name}}</match>
74-
<choices data="people | filter: $select.search">
74+
<choices repeat="item in people | filter: $select.search">
7575
<span ng-bind-html="trustAsHtml((item.name | highlight: $select.search))"></span>
7676
<small ng-bind-html="trustAsHtml((item.email | highlight: $select.search))"></small>
7777
</choices>

examples/selectize-bootstrap3.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070

7171
<ui-select ng-model="person.selected" theme="selectize">
7272
<match placeholder="Select or search a person in the list...">{{$select.selected.name}}</match>
73-
<choices data="people | filter: $select.search">
73+
<choices repeat="item in people | filter: $select.search">
7474
<div ng-bind-html="trustAsHtml((item.name | highlight: $select.search))"></div>
7575
<small ng-bind-html="trustAsHtml((item.email | highlight: $select.search))"></small>
7676
</choices>
@@ -86,7 +86,7 @@
8686

8787
<ui-select ng-model="person.selected" theme="selectize">
8888
<match placeholder="Select or search a person in the list...">{{$select.selected.name}}</match>
89-
<choices data="people | filter: $select.search">
89+
<choices repeat="item in people | filter: $select.search">
9090
<span ng-bind-html="trustAsHtml((item.name | highlight: $select.search))"></span>
9191
<small ng-bind-html="trustAsHtml((item.email | highlight: $select.search))"></small>
9292
</choices>

src/select.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ angular.module('ui.select', [])
4646
ctrl.activate = function() {
4747
ctrl.open = true;
4848
// Give it time to appear before focus
49-
$timeout(function() {
49+
setTimeout(function() {
5050
ctrl.input[0].focus();
5151
});
5252
};
@@ -59,7 +59,7 @@ angular.module('ui.select', [])
5959

6060
ctrl.close = function() {
6161
ctrl.open = false;
62-
ctrl.search = "";
62+
ctrl.search = '';
6363
};
6464

6565
ctrl.input = $element.find('input'); // TODO could break if input is at other template
@@ -136,7 +136,7 @@ angular.module('ui.select', [])
136136
compile: function(tElement, tAttrs) {
137137

138138
tElement.querySelectorAll('.ui-select-choices-row')
139-
.attr("ng-repeat", 'item in ' + tAttrs.data)
139+
.attr("ng-repeat", tAttrs.repeat)
140140
.attr("ng-mouseenter", '$select.activeIdx=$index')
141141
.attr("ng-click", '$select.select(item)');
142142

test/select.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('ui-select tests', function() {
3131
return compileTemplate(
3232
'<ui-select ng-model="selection"> \
3333
<match placeholder="Pick one...">{{$select.selected.name}}</match> \
34-
<choices data="matches | filter: $select.search"> \
34+
<choices repeat="item in matches | filter: $select.search"> \
3535
<div ng-bind-html="trustAsHtml((item.name | highlight: $select.search))"></div> \
3636
<div>{{item.email}}</div> \
3737
</choices> \

0 commit comments

Comments
 (0)