2
2
* angular-ui-bootstrap
3
3
* http://angular-ui.github.io/bootstrap/
4
4
5
- * Version: 1.3.2 - 2016-04-14
5
+ * Version: 1.3.3 - 2016-05-22
6
6
* License: MIT
7
7
*/ angular . module ( "ui.bootstrap" , [ "ui.bootstrap.tpls" , "ui.bootstrap.collapse" , "ui.bootstrap.accordion" , "ui.bootstrap.alert" , "ui.bootstrap.buttons" , "ui.bootstrap.carousel" , "ui.bootstrap.dateparser" , "ui.bootstrap.isClass" , "ui.bootstrap.datepicker" , "ui.bootstrap.position" , "ui.bootstrap.datepickerPopup" , "ui.bootstrap.debounce" , "ui.bootstrap.dropdown" , "ui.bootstrap.stackedMap" , "ui.bootstrap.modal" , "ui.bootstrap.paging" , "ui.bootstrap.pager" , "ui.bootstrap.pagination" , "ui.bootstrap.tooltip" , "ui.bootstrap.popover" , "ui.bootstrap.progressbar" , "ui.bootstrap.rating" , "ui.bootstrap.tabs" , "ui.bootstrap.timepicker" , "ui.bootstrap.typeahead" ] ) ;
8
8
angular . module ( "ui.bootstrap.tpls" , [ "uib/template/accordion/accordion-group.html" , "uib/template/accordion/accordion.html" , "uib/template/alert/alert.html" , "uib/template/carousel/carousel.html" , "uib/template/carousel/slide.html" , "uib/template/datepicker/datepicker.html" , "uib/template/datepicker/day.html" , "uib/template/datepicker/month.html" , "uib/template/datepicker/year.html" , "uib/template/datepickerPopup/popup.html" , "uib/template/modal/backdrop.html" , "uib/template/modal/window.html" , "uib/template/pager/pager.html" , "uib/template/pagination/pagination.html" , "uib/template/tooltip/tooltip-html-popup.html" , "uib/template/tooltip/tooltip-popup.html" , "uib/template/tooltip/tooltip-template-popup.html" , "uib/template/popover/popover-html.html" , "uib/template/popover/popover-template.html" , "uib/template/popover/popover.html" , "uib/template/progressbar/bar.html" , "uib/template/progressbar/progress.html" , "uib/template/progressbar/progressbar.html" , "uib/template/rating/rating.html" , "uib/template/tabs/tab.html" , "uib/template/tabs/tabset.html" , "uib/template/timepicker/timepicker.html" , "uib/template/typeahead/typeahead-match.html" , "uib/template/typeahead/typeahead-popup.html" ] ) ;
@@ -234,13 +234,23 @@ angular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse'])
234
234
link : function ( scope , element , attrs , controller ) {
235
235
scope . $watch ( function ( ) { return controller [ attrs . uibAccordionTransclude ] ; } , function ( heading ) {
236
236
if ( heading ) {
237
- var elem = angular . element ( element [ 0 ] . querySelector ( '[uib-accordion-header]' ) ) ;
237
+ var elem = angular . element ( element [ 0 ] . querySelector ( getHeaderSelectors ( ) ) ) ;
238
238
elem . html ( '' ) ;
239
239
elem . append ( heading ) ;
240
240
}
241
241
} ) ;
242
242
}
243
243
} ;
244
+
245
+ function getHeaderSelectors ( ) {
246
+ return 'uib-accordion-header,' +
247
+ 'data-uib-accordion-header,' +
248
+ 'x-uib-accordion-header,' +
249
+ 'uib\\:accordion-header,' +
250
+ '[uib-accordion-header],' +
251
+ '[data-uib-accordion-header],' +
252
+ '[x-uib-accordion-header]' ;
253
+ }
244
254
} ) ;
245
255
246
256
angular . module ( 'ui.bootstrap.alert' , [ ] )
@@ -1184,8 +1194,9 @@ angular.module('ui.bootstrap.dateparser', [])
1184
1194
return date && timezone ? convertTimezoneToLocal ( date , timezone , true ) : date ;
1185
1195
}
1186
1196
1187
- //https://github.com/angular/angular.js/blob/4daafd3dbe6a80d578f5a31df1bb99c77559543e /src/Angular.js#L1207
1197
+ //https://github.com/angular/angular.js/blob/622c42169699ec07fc6daaa19fe6d224e5d2f70e /src/Angular.js#L1207
1188
1198
function timezoneToOffset ( timezone , fallback ) {
1199
+ timezone = timezone . replace ( / : / g, '' ) ;
1189
1200
var requestedTimezoneOffset = Date . parse ( 'Jan 01, 1970 00:00:00 ' + timezone ) / 60000 ;
1190
1201
return isNaN ( requestedTimezoneOffset ) ? fallback : requestedTimezoneOffset ;
1191
1202
}
@@ -1198,8 +1209,9 @@ angular.module('ui.bootstrap.dateparser', [])
1198
1209
1199
1210
function convertTimezoneToLocal ( date , timezone , reverse ) {
1200
1211
reverse = reverse ? - 1 : 1 ;
1201
- var timezoneOffset = timezoneToOffset ( timezone , date . getTimezoneOffset ( ) ) ;
1202
- return addDateMinutes ( date , reverse * ( timezoneOffset - date . getTimezoneOffset ( ) ) ) ;
1212
+ var dateTimezoneOffset = date . getTimezoneOffset ( ) ;
1213
+ var timezoneOffset = timezoneToOffset ( timezone , dateTimezoneOffset ) ;
1214
+ return addDateMinutes ( date , reverse * ( timezoneOffset - dateTimezoneOffset ) ) ;
1203
1215
}
1204
1216
} ] ) ;
1205
1217
@@ -1471,8 +1483,9 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
1471
1483
self . activeDate = new Date ( ) ;
1472
1484
}
1473
1485
1474
- this . activeDate = ngModelCtrl . $modelValue ?
1475
- dateParser . fromTimezone ( new Date ( ngModelCtrl . $modelValue ) , ngModelOptions . timezone ) :
1486
+ var date = ngModelCtrl . $modelValue ? new Date ( ngModelCtrl . $modelValue ) : new Date ( ) ;
1487
+ this . activeDate = ! isNaN ( date ) ?
1488
+ dateParser . fromTimezone ( date , ngModelOptions . timezone ) :
1476
1489
dateParser . fromTimezone ( new Date ( ) , ngModelOptions . timezone ) ;
1477
1490
1478
1491
ngModelCtrl . $render = function ( ) {
@@ -2677,12 +2690,12 @@ function($scope, $element, $attrs, $compile, $log, $parse, $window, $document, $
2677
2690
return value ;
2678
2691
}
2679
2692
2680
- $scope . date = dateParser . fromTimezone ( value , timezone ) ;
2681
-
2682
- if ( angular . isNumber ( $scope . date ) ) {
2683
- $scope . date = new Date ( $scope . date ) ;
2693
+ if ( angular . isNumber ( value ) ) {
2694
+ value = new Date ( value ) ;
2684
2695
}
2685
2696
2697
+ $scope . date = dateParser . fromTimezone ( value , timezone ) ;
2698
+
2686
2699
return dateParser . filter ( $scope . date , dateFormat ) ;
2687
2700
} ) ;
2688
2701
} else {
@@ -3217,7 +3230,8 @@ angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position'])
3217
3230
if ( appendTo && self . dropdownMenu ) {
3218
3231
var pos = $position . positionElements ( $element , self . dropdownMenu , 'bottom-left' , true ) ,
3219
3232
css ,
3220
- rightalign ;
3233
+ rightalign ,
3234
+ scrollbarWidth ;
3221
3235
3222
3236
css = {
3223
3237
top : pos . top + 'px' ,
@@ -3230,7 +3244,8 @@ angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position'])
3230
3244
css . right = 'auto' ;
3231
3245
} else {
3232
3246
css . left = 'auto' ;
3233
- css . right = window . innerWidth -
3247
+ scrollbarWidth = $position . scrollbarWidth ( true ) ;
3248
+ css . right = window . innerWidth - scrollbarWidth -
3234
3249
( pos . left + $element . prop ( 'offsetWidth' ) ) + 'px' ;
3235
3250
}
3236
3251
@@ -4117,30 +4132,27 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap', 'ui.bootstrap.p
4117
4132
//controllers
4118
4133
if ( modalOptions . controller ) {
4119
4134
ctrlLocals . $scope = modalScope ;
4135
+ ctrlLocals . $scope . $resolve = { } ;
4120
4136
ctrlLocals . $uibModalInstance = modalInstance ;
4121
4137
angular . forEach ( tplAndVars [ 1 ] , function ( value , key ) {
4122
4138
ctrlLocals [ key ] = value ;
4139
+ ctrlLocals . $scope . $resolve [ key ] = value ;
4123
4140
} ) ;
4124
4141
4125
4142
// the third param will make the controller instantiate later,private api
4126
4143
// @see https://github.com/angular/angular.js/blob/master/src/ng/controller.js#L126
4127
- ctrlInstantiate = $controller ( modalOptions . controller , ctrlLocals , true ) ;
4128
- if ( modalOptions . controllerAs ) {
4144
+ ctrlInstantiate = $controller ( modalOptions . controller , ctrlLocals , true , modalOptions . controllerAs ) ;
4145
+ if ( modalOptions . controllerAs && modalOptions . bindToController ) {
4129
4146
ctrlInstance = ctrlInstantiate . instance ;
4130
-
4131
- if ( modalOptions . bindToController ) {
4132
- ctrlInstance . $close = modalScope . $close ;
4133
- ctrlInstance . $dismiss = modalScope . $dismiss ;
4134
- angular . extend ( ctrlInstance , providedScope ) ;
4135
- }
4136
-
4137
- ctrlInstance = ctrlInstantiate ( ) ;
4138
-
4139
- modalScope [ modalOptions . controllerAs ] = ctrlInstance ;
4140
- } else {
4141
- ctrlInstance = ctrlInstantiate ( ) ;
4147
+ ctrlInstance . $close = modalScope . $close ;
4148
+ ctrlInstance . $dismiss = modalScope . $dismiss ;
4149
+ angular . extend ( ctrlInstance , {
4150
+ $resolve : ctrlLocals . $scope . $resolve
4151
+ } , providedScope ) ;
4142
4152
}
4143
4153
4154
+ ctrlInstance = ctrlInstantiate ( ) ;
4155
+
4144
4156
if ( angular . isFunction ( ctrlInstance . $onInit ) ) {
4145
4157
ctrlInstance . $onInit ( ) ;
4146
4158
}
@@ -5445,7 +5457,8 @@ angular.module('ui.bootstrap.tabs', [])
5445
5457
var previousSelected = ctrl . tabs [ previousIndex ] ;
5446
5458
if ( previousSelected ) {
5447
5459
previousSelected . tab . onDeselect ( {
5448
- $event : evt
5460
+ $event : evt ,
5461
+ $selectedIndex : index
5449
5462
} ) ;
5450
5463
if ( evt && evt . isDefaultPrevented ( ) ) {
5451
5464
return ;
@@ -5461,7 +5474,7 @@ angular.module('ui.bootstrap.tabs', [])
5461
5474
selected . tab . active = true ;
5462
5475
ctrl . active = selected . index ;
5463
5476
oldIndex = selected . index ;
5464
- } else if ( ! selected && angular . isNumber ( oldIndex ) ) {
5477
+ } else if ( ! selected && angular . isDefined ( oldIndex ) ) {
5465
5478
ctrl . active = null ;
5466
5479
oldIndex = null ;
5467
5480
}
@@ -5485,7 +5498,7 @@ angular.module('ui.bootstrap.tabs', [])
5485
5498
return 0 ;
5486
5499
} ) ;
5487
5500
5488
- if ( tab . index === ctrl . active || ! angular . isNumber ( ctrl . active ) && ctrl . tabs . length === 1 ) {
5501
+ if ( tab . index === ctrl . active || ! angular . isDefined ( ctrl . active ) && ctrl . tabs . length === 1 ) {
5489
5502
var newActiveIndex = findTabIndex ( tab . index ) ;
5490
5503
ctrl . select ( newActiveIndex ) ;
5491
5504
}
@@ -5510,7 +5523,7 @@ angular.module('ui.bootstrap.tabs', [])
5510
5523
} ;
5511
5524
5512
5525
$scope . $watch ( 'tabset.active' , function ( val ) {
5513
- if ( angular . isNumber ( val ) && val !== oldIndex ) {
5526
+ if ( angular . isDefined ( val ) && val !== oldIndex ) {
5514
5527
ctrl . select ( findTabIndex ( val ) ) ;
5515
5528
}
5516
5529
} ) ;
@@ -5548,9 +5561,6 @@ angular.module('ui.bootstrap.tabs', [])
5548
5561
scope . $parent . $eval ( attrs . vertical ) : false ;
5549
5562
scope . justified = angular . isDefined ( attrs . justified ) ?
5550
5563
scope . $parent . $eval ( attrs . justified ) : false ;
5551
- if ( angular . isUndefined ( attrs . active ) ) {
5552
- scope . active = 0 ;
5553
- }
5554
5564
}
5555
5565
} ;
5556
5566
} )
@@ -6281,7 +6291,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.debounce', 'ui.bootstrap
6281
6291
originalScope . $watch ( attrs . typeaheadMinLength , function ( newVal ) {
6282
6292
minLength = ! newVal && newVal !== 0 ? 1 : newVal ;
6283
6293
} ) ;
6284
-
6294
+
6285
6295
//minimal wait time after last character typed before typeahead kicks-in
6286
6296
var waitTime = originalScope . $eval ( attrs . typeaheadWaitMs ) || 0 ;
6287
6297
@@ -6294,6 +6304,12 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.debounce', 'ui.bootstrap
6294
6304
//binding to a variable that indicates if matches are being retrieved asynchronously
6295
6305
var isLoadingSetter = $parse ( attrs . typeaheadLoading ) . assign || angular . noop ;
6296
6306
6307
+ //a function to determine if an event should cause selection
6308
+ var isSelectEvent = attrs . typeaheadShouldSelect ? $parse ( attrs . typeaheadShouldSelect ) : function ( scope , vals ) {
6309
+ var evt = vals . $event ;
6310
+ return evt . which === 13 || evt . which === 9 ;
6311
+ } ;
6312
+
6297
6313
//a callback executed when a match is selected
6298
6314
var onSelectCallback = $parse ( attrs . typeaheadOnSelect ) ;
6299
6315
@@ -6609,13 +6625,15 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.debounce', 'ui.bootstrap
6609
6625
return ;
6610
6626
}
6611
6627
6628
+ var shouldSelect = isSelectEvent ( originalScope , { $event : evt } ) ;
6629
+
6612
6630
/**
6613
6631
* if there's nothing selected (i.e. focusFirst) and enter or tab is hit
6614
6632
* or
6615
6633
* shift + tab is pressed to bring focus to the previous element
6616
6634
* then clear the results
6617
6635
*/
6618
- if ( scope . activeIdx === - 1 && ( evt . which === 9 || evt . which === 13 ) || evt . which === 9 && ! ! evt . shiftKey ) {
6636
+ if ( scope . activeIdx === - 1 && shouldSelect || evt . which === 9 && ! ! evt . shiftKey ) {
6619
6637
resetMatches ( ) ;
6620
6638
scope . $digest ( ) ;
6621
6639
return ;
@@ -6624,36 +6642,36 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.debounce', 'ui.bootstrap
6624
6642
evt . preventDefault ( ) ;
6625
6643
var target ;
6626
6644
switch ( evt . which ) {
6627
- case 9 :
6628
- case 13 :
6629
- scope . $apply ( function ( ) {
6630
- if ( angular . isNumber ( scope . debounceUpdate ) || angular . isObject ( scope . debounceUpdate ) ) {
6631
- $$debounce ( function ( ) {
6632
- scope . select ( scope . activeIdx , evt ) ;
6633
- } , angular . isNumber ( scope . debounceUpdate ) ? scope . debounceUpdate : scope . debounceUpdate [ 'default' ] ) ;
6634
- } else {
6635
- scope . select ( scope . activeIdx , evt ) ;
6636
- }
6637
- } ) ;
6638
- break ;
6639
- case 27 :
6645
+ case 27 : // escape
6640
6646
evt . stopPropagation ( ) ;
6641
6647
6642
6648
resetMatches ( ) ;
6643
6649
originalScope . $digest ( ) ;
6644
6650
break ;
6645
- case 38 :
6651
+ case 38 : // up arrow
6646
6652
scope . activeIdx = ( scope . activeIdx > 0 ? scope . activeIdx : scope . matches . length ) - 1 ;
6647
6653
scope . $digest ( ) ;
6648
6654
target = popUpEl . find ( 'li' ) [ scope . activeIdx ] ;
6649
6655
target . parentNode . scrollTop = target . offsetTop ;
6650
6656
break ;
6651
- case 40 :
6657
+ case 40 : // down arrow
6652
6658
scope . activeIdx = ( scope . activeIdx + 1 ) % scope . matches . length ;
6653
6659
scope . $digest ( ) ;
6654
6660
target = popUpEl . find ( 'li' ) [ scope . activeIdx ] ;
6655
6661
target . parentNode . scrollTop = target . offsetTop ;
6656
6662
break ;
6663
+ default :
6664
+ if ( shouldSelect ) {
6665
+ scope . $apply ( function ( ) {
6666
+ if ( angular . isNumber ( scope . debounceUpdate ) || angular . isObject ( scope . debounceUpdate ) ) {
6667
+ $$debounce ( function ( ) {
6668
+ scope . select ( scope . activeIdx , evt ) ;
6669
+ } , angular . isNumber ( scope . debounceUpdate ) ? scope . debounceUpdate : scope . debounceUpdate [ 'default' ] ) ;
6670
+ } else {
6671
+ scope . select ( scope . activeIdx , evt ) ;
6672
+ }
6673
+ } ) ;
6674
+ }
6657
6675
}
6658
6676
} ) ;
6659
6677
0 commit comments