@@ -114,7 +114,7 @@ angular.module('ui.select', [])
114
114
ctrl . open = false ;
115
115
ctrl . disabled = undefined ; // Initialized inside uiSelect directive link function
116
116
ctrl . resetSearchInput = undefined ; // Initialized inside uiSelect directive link function
117
- ctrl . refreshDelay = undefined ; // Initialized inside choices directive link function
117
+ ctrl . refreshDelay = undefined ; // Initialized inside uiSelectChoices directive link function
118
118
119
119
var _searchInput = $element . querySelectorAll ( 'input.ui-select-search' ) ;
120
120
if ( _searchInput . length !== 1 ) {
@@ -174,15 +174,14 @@ angular.module('ui.select', [])
174
174
ctrl . refresh = function ( refreshAttr ) {
175
175
if ( refreshAttr !== undefined ) {
176
176
177
- // Throttle / debounce
178
- //
177
+ // Debounce
179
178
// See https://github.com/angular-ui/bootstrap/blob/0.10.0/src/typeahead/typeahead.js#L155
180
179
// FYI AngularStrap typeahead does not have debouncing: https://github.com/mgcrea/angular-strap/blob/v2.0.0-rc.4/src/typeahead/typeahead.js#L177
181
180
if ( _refreshDelayPromise ) {
182
181
$timeout . cancel ( _refreshDelayPromise ) ;
183
182
}
184
183
_refreshDelayPromise = $timeout ( function ( ) {
185
- $scope . $apply ( refreshAttr ) ;
184
+ $scope . $eval ( refreshAttr ) ;
186
185
} , ctrl . refreshDelay ) ;
187
186
}
188
187
} ;
@@ -233,7 +232,6 @@ angular.module('ui.select', [])
233
232
}
234
233
235
234
// Bind to keyboard shortcuts
236
- // Cannot specify a namespace: not supported by jqLite
237
235
_searchInput . on ( 'keydown' , function ( e ) {
238
236
// Keyboard shortcuts are all about the items,
239
237
// does not make sense (and will crash) if ctrl.items is empty
@@ -282,8 +280,8 @@ angular.module('ui.select', [])
282
280
} ] )
283
281
284
282
. directive ( 'uiSelect' ,
285
- [ '$document' , 'uiSelectConfig' ,
286
- function ( $document , uiSelectConfig ) {
283
+ [ '$document' , 'uiSelectConfig' , 'uiSelectMinErr' ,
284
+ function ( $document , uiSelectConfig , uiSelectMinErr ) {
287
285
288
286
return {
289
287
restrict : 'EA' ,
@@ -324,8 +322,7 @@ angular.module('ui.select', [])
324
322
$select . selected = ngModel . $viewValue ;
325
323
} ;
326
324
327
- // See Click everywhere but here event http://stackoverflow.com/questions/12931369
328
- $document . on ( 'mousedown' , function ( e ) {
325
+ function onDocumentClick ( e ) {
329
326
var contains = false ;
330
327
331
328
if ( window . jQuery ) {
@@ -340,10 +337,13 @@ angular.module('ui.select', [])
340
337
$select . close ( ) ;
341
338
scope . $digest ( ) ;
342
339
}
343
- } ) ;
340
+ }
341
+
342
+ // See Click everywhere but here event http://stackoverflow.com/questions/12931369
343
+ $document . on ( 'click' , onDocumentClick ) ;
344
344
345
345
scope . $on ( '$destroy' , function ( ) {
346
- $document . off ( 'mousedown' ) ;
346
+ $document . off ( 'click' , onDocumentClick ) ;
347
347
} ) ;
348
348
349
349
// Move transcluded elements to their correct position in main template
@@ -371,7 +371,7 @@ angular.module('ui.select', [])
371
371
} ;
372
372
} ] )
373
373
374
- . directive ( 'choices ' ,
374
+ . directive ( 'uiSelectChoices ' ,
375
375
[ 'uiSelectConfig' , 'RepeatParser' , 'uiSelectMinErr' ,
376
376
function ( uiSelectConfig , RepeatParser , uiSelectMinErr ) {
377
377
@@ -416,7 +416,7 @@ angular.module('ui.select', [])
416
416
} ;
417
417
} ] )
418
418
419
- . directive ( 'match ' , [ 'uiSelectConfig' , function ( uiSelectConfig ) {
419
+ . directive ( 'uiSelectMatch ' , [ 'uiSelectConfig' , function ( uiSelectConfig ) {
420
420
return {
421
421
restrict : 'EA' ,
422
422
require : '^uiSelect' ,
@@ -453,10 +453,10 @@ angular.module('ui.select', [])
453
453
454
454
angular . module ( 'ui.select' ) . run ( [ '$templateCache' , function ( $templateCache ) {
455
455
$templateCache . put ( 'bootstrap/choices.tpl.html' , '<ul class="ui-select-choices ui-select-choices-content dropdown-menu" role="menu" aria-labelledby="dLabel" ng-show="$select.items.length> 0"> <li class="ui-select-choices-row" ng-class="{active: $select.activeIndex===$index}"> <a href="javascript:void(0)" ng-transclude></a> </li> </ul> ' ) ;
456
- $templateCache . put ( 'bootstrap/match.tpl.html' , '<button class="btn btn-default form-control ui-select-match" ng-hide="$select.open" ng-disabled="$select.disabled" ng-click="$select.activate()"> <span ng-hide="$select.selected !==undefined" class="text-muted">{{$select.placeholder}}</span> <span ng-show="$select.selected !==undefined" ng-transclude></span> <span class="caret"></span> </button> ' ) ;
456
+ $templateCache . put ( 'bootstrap/match.tpl.html' , '<button type="button" class="btn btn-default form-control ui-select-match" ng-hide="$select.open" ng-disabled="$select.disabled" ng-click="$select.activate()"> <span ng-hide="$select.selected !==undefined" class="text-muted">{{$select.placeholder}}</span> <span ng-show="$select.selected !==undefined" ng-transclude></span> <span class="caret"></span> </button> ' ) ;
457
457
$templateCache . put ( 'bootstrap/select.tpl.html' , '<div class="ui-select-bootstrap dropdown" ng-class="{open: $select.open}"> <div class="ui-select-match"></div> <input type="text" autocomplete="off" tabindex="" class="form-control ui-select-search" placeholder="{{$select.placeholder}}" ng-model="$select.search" ng-show="$select.open"> <div class="ui-select-choices"></div> </div> ' ) ;
458
458
$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.activeIndex===$index}"> <div class="select2-result-label" ng-transclude></div> </li> </ul> ' ) ;
459
- $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 !==undefined" class="select2-chosen">{{$select.placeholder}}</span> <span ng-show="$select.selected !==undefined" class="select2-chosen" ng-transclude></span> <span class="select2-arrow"><b></b></span> </a> ' ) ;
459
+ $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 !==undefined" class="select2-chosen">{{$select.placeholder}}</span> <span ng-show="$select.selected !==undefined" class="select2-chosen" ng-transclude></span> <span class="select2-arrow"><b></b></span> </a> ' ) ;
460
460
$templateCache . put ( 'select2/select.tpl.html' , '<div class="select2 select2-container" ng-class="{\'select2-container-active select2-dropdown-open\': $select.open, \'select2-container-disabled\': $select.disabled}"> <div class="ui-select-match"></div> <div class="select2-drop select2-with-searchbox select2-drop-active" ng-class="{\'select2-display-none\': !$select.open}"> <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> ' ) ;
461
461
$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.activeIndex===$index}"> <div class="option" data-selectable ng-transclude></div> </div> </div> </div> ' ) ;
462
462
$templateCache . put ( 'selectize/match.tpl.html' , '<div ng-hide="$select.open || $select.selected===undefined" class="ui-select-match" ng-transclude></div> ' ) ;
0 commit comments