@@ -142,7 +142,7 @@ $.api = $.fn.api = function(parameters) {
142
142
response = JSON.parse(response);
143
143
}
144
144
catch(e) {
145
- // isn't json string
145
+ // isnt json string
146
146
}
147
147
}
148
148
return response;
@@ -2220,7 +2220,7 @@ $.fn.dimmer = function(parameters) {
2220
2220
2221
2221
event: {
2222
2222
click: function(event) {
2223
- module.verbose('Determining if event occurred on dimmer', event);
2223
+ module.verbose('Determining if event occured on dimmer', event);
2224
2224
if( $dimmer.find(event.target).length === 0 || $(event.target).is(selector.content) ) {
2225
2225
module.hide();
2226
2226
event.stopImmediatePropagation();
@@ -2827,6 +2827,13 @@ $.fn.dimmer.settings = {
2827
2827
*
2828
2828
*/
2829
2829
2830
+ /*
2831
+ * Copyright 2019 The Gitea Authors
2832
+ * Released under the MIT license
2833
+ * http://opensource.org/licenses/MIT
2834
+ * This version has been modified by Gitea to improve accessibility.
2835
+ */
2836
+
2830
2837
;(function ($, window, document, undefined) {
2831
2838
2832
2839
'use strict';
@@ -2860,6 +2867,7 @@ $.fn.dropdown = function(parameters) {
2860
2867
query = arguments[0],
2861
2868
methodInvoked = (typeof query == 'string'),
2862
2869
queryArguments = [].slice.call(arguments, 1),
2870
+ lastAriaID = 1,
2863
2871
returnedValue
2864
2872
;
2865
2873
@@ -2952,6 +2960,8 @@ $.fn.dropdown = function(parameters) {
2952
2960
2953
2961
module.observeChanges();
2954
2962
module.instantiate();
2963
+
2964
+ module.aria.setup();
2955
2965
}
2956
2966
2957
2967
},
@@ -3152,6 +3162,86 @@ $.fn.dropdown = function(parameters) {
3152
3162
}
3153
3163
},
3154
3164
3165
+ aria: {
3166
+ setup: function() {
3167
+ var role = module.aria.guessRole();
3168
+ if( role !== 'menu' ) {
3169
+ return;
3170
+ }
3171
+ $module.attr('aria-busy', 'true');
3172
+ $module.attr('role', 'menu');
3173
+ $module.attr('aria-haspopup', 'menu');
3174
+ $module.attr('aria-expanded', 'false');
3175
+ $menu.find('.divider').attr('role', 'separator');
3176
+ $item.attr('role', 'menuitem');
3177
+ $item.each(function (index, item) {
3178
+ if( !item.id ) {
3179
+ item.id = module.aria.nextID('menuitem');
3180
+ }
3181
+ });
3182
+ $text = $module
3183
+ .find('> .text')
3184
+ .eq(0)
3185
+ ;
3186
+ if( $module.data('content') ) {
3187
+ $text.attr('aria-hidden');
3188
+ $module.attr('aria-label', $module.data('content'));
3189
+ }
3190
+ else {
3191
+ $text.attr('id', module.aria.nextID('menutext'));
3192
+ $module.attr('aria-labelledby', $text.attr('id'));
3193
+ }
3194
+ $module.attr('aria-busy', 'false');
3195
+ },
3196
+ nextID: function(prefix) {
3197
+ var nextID;
3198
+ do {
3199
+ nextID = prefix + '_' + lastAriaID++;
3200
+ } while( document.getElementById(nextID) );
3201
+ return nextID;
3202
+ },
3203
+ setExpanded: function(expanded) {
3204
+ if( $module.attr('aria-haspopup') ) {
3205
+ $module.attr('aria-expanded', expanded);
3206
+ }
3207
+ },
3208
+ refreshDescendant: function() {
3209
+ if( $module.attr('aria-haspopup') !== 'menu' ) {
3210
+ return;
3211
+ }
3212
+ var
3213
+ $currentlySelected = $item.not(selector.unselectable).filter('.' + className.selected).eq(0),
3214
+ $activeItem = $menu.children('.' + className.active).eq(0),
3215
+ $selectedItem = ($currentlySelected.length > 0)
3216
+ ? $currentlySelected
3217
+ : $activeItem
3218
+ ;
3219
+ if( $selectedItem ) {
3220
+ $module.attr('aria-activedescendant', $selectedItem.attr('id'));
3221
+ }
3222
+ else {
3223
+ module.aria.removeDescendant();
3224
+ }
3225
+ },
3226
+ removeDescendant: function() {
3227
+ if( $module.attr('aria-haspopup') == 'menu' ) {
3228
+ $module.removeAttr('aria-activedescendant');
3229
+ }
3230
+ },
3231
+ guessRole: function() {
3232
+ var
3233
+ isIcon = $module.hasClass('icon'),
3234
+ hasSearch = module.has.search(),
3235
+ hasInput = ($input.length > 0),
3236
+ isMultiple = module.is.multiple()
3237
+ ;
3238
+ if ( !isIcon && !hasSearch && !hasInput && !isMultiple ) {
3239
+ return 'menu';
3240
+ }
3241
+ return 'unknown';
3242
+ }
3243
+ },
3244
+
3155
3245
setup: {
3156
3246
api: function() {
3157
3247
var
@@ -3198,6 +3288,7 @@ $.fn.dropdown = function(parameters) {
3198
3288
if(settings.allowTab) {
3199
3289
module.set.tabbable();
3200
3290
}
3291
+ $item.attr('tabindex', '-1');
3201
3292
},
3202
3293
select: function() {
3203
3294
var
@@ -3344,6 +3435,8 @@ $.fn.dropdown = function(parameters) {
3344
3435
return true;
3345
3436
}
3346
3437
if(settings.onShow.call(element) !== false) {
3438
+ module.aria.setExpanded(true);
3439
+ module.aria.refreshDescendant();
3347
3440
module.animate.show(function() {
3348
3441
if( module.can.click() ) {
3349
3442
module.bind.intent();
@@ -3366,9 +3459,11 @@ $.fn.dropdown = function(parameters) {
3366
3459
if( module.is.active() && !module.is.animatingOutward() ) {
3367
3460
module.debug('Hiding dropdown');
3368
3461
if(settings.onHide.call(element) !== false) {
3462
+ module.aria.setExpanded(false);
3463
+ module.aria.removeDescendant();
3369
3464
module.animate.hide(function() {
3370
3465
module.remove.visible();
3371
- // hiding search focus
3466
+ // hidding search focus
3372
3467
if ( module.is.focusedOnSearch() && preventBlur !== true ) {
3373
3468
$search.blur();
3374
3469
}
@@ -4319,7 +4414,7 @@ $.fn.dropdown = function(parameters) {
4319
4414
// allow selection with menu closed
4320
4415
if(isAdditionWithoutMenu) {
4321
4416
module.verbose('Selecting item from keyboard shortcut', $selectedItem);
4322
- module.event.item. click.call($selectedItem, event );
4417
+ $selectedItem[0]. click( );
4323
4418
if(module.is.searchSelection()) {
4324
4419
module.remove.searchTerm();
4325
4420
}
@@ -4339,7 +4434,7 @@ $.fn.dropdown = function(parameters) {
4339
4434
}
4340
4435
else if(selectedIsSelectable) {
4341
4436
module.verbose('Selecting item from keyboard shortcut', $selectedItem);
4342
- module.event.item. click.call($selectedItem, event );
4437
+ $selectedItem[0]. click( );
4343
4438
if(module.is.searchSelection()) {
4344
4439
module.remove.searchTerm();
4345
4440
if(module.is.multiple()) {
@@ -4367,6 +4462,7 @@ $.fn.dropdown = function(parameters) {
4367
4462
.closest(selector.item)
4368
4463
.addClass(className.selected)
4369
4464
;
4465
+ module.aria.refreshDescendant();
4370
4466
event.preventDefault();
4371
4467
}
4372
4468
}
@@ -4383,6 +4479,7 @@ $.fn.dropdown = function(parameters) {
4383
4479
.find(selector.item).eq(0)
4384
4480
.addClass(className.selected)
4385
4481
;
4482
+ module.aria.refreshDescendant();
4386
4483
event.preventDefault();
4387
4484
}
4388
4485
}
@@ -4407,6 +4504,7 @@ $.fn.dropdown = function(parameters) {
4407
4504
$nextItem
4408
4505
.addClass(className.selected)
4409
4506
;
4507
+ module.aria.refreshDescendant();
4410
4508
module.set.scrollPosition($nextItem);
4411
4509
if(settings.selectOnKeydown && module.is.single()) {
4412
4510
module.set.selectedItem($nextItem);
@@ -4434,6 +4532,7 @@ $.fn.dropdown = function(parameters) {
4434
4532
$nextItem
4435
4533
.addClass(className.selected)
4436
4534
;
4535
+ module.aria.refreshDescendant();
4437
4536
module.set.scrollPosition($nextItem);
4438
4537
if(settings.selectOnKeydown && module.is.single()) {
4439
4538
module.set.selectedItem($nextItem);
@@ -5403,6 +5502,7 @@ $.fn.dropdown = function(parameters) {
5403
5502
module.set.scrollPosition($nextValue);
5404
5503
$selectedItem.removeClass(className.selected);
5405
5504
$nextValue.addClass(className.selected);
5505
+ module.aria.refreshDescendant();
5406
5506
if(settings.selectOnKeydown && module.is.single()) {
5407
5507
module.set.selectedItem($nextValue);
5408
5508
}
@@ -11937,7 +12037,7 @@ $.fn.progress = function(parameters) {
11937
12037
*
11938
12038
* @param min A minimum value within multiple values
11939
12039
* @param total A total amount of multiple values
11940
- * @returns {number} A precision . Could be 1, 10, 100, ... 1e+10.
12040
+ * @returns {number} A precison . Could be 1, 10, 100, ... 1e+10.
11941
12041
*/
11942
12042
derivePrecision: function(min, total) {
11943
12043
var precisionPower = 0
@@ -12837,7 +12937,7 @@ $.fn.progress.settings = {
12837
12937
nonNumeric : 'Progress value is non numeric',
12838
12938
tooHigh : 'Value specified is above 100%',
12839
12939
tooLow : 'Value specified is below 0%',
12840
- sumExceedsTotal : 'Sum of multiple values exceed total',
12940
+ sumExceedsTotal : 'Sum of multple values exceed total',
12841
12941
},
12842
12942
12843
12943
regExp: {
@@ -18076,7 +18176,7 @@ $.fn.transition.settings = {
18076
18176
18077
18177
// possible errors
18078
18178
error: {
18079
- noAnimation : 'Element is no longer attached to DOM. Unable to animate. Use silent setting to suppress this warning in production.',
18179
+ noAnimation : 'Element is no longer attached to DOM. Unable to animate. Use silent setting to surpress this warning in production.',
18080
18180
repeated : 'That animation is already occurring, cancelling repeated animation',
18081
18181
method : 'The method you called is not defined',
18082
18182
support : 'This browser does not support CSS animations'
0 commit comments