@@ -518,6 +518,77 @@ function InteractiveVideo(params, id, contentData) {
518
518
self . handleAnswered ( ) ;
519
519
}
520
520
521
+
522
+ /**
523
+ * Disable tab indexes hidden behind overlay.
524
+ */
525
+ self . disableTabIndexes = ( elementToExclude = '.h5p-dialog-wrapper' ) => {
526
+ var self = this ;
527
+ // Make all other elements in container not tabbable. When dialog is open,
528
+ // it's like the elements behind does not exist.
529
+ var $elementToExclude = self . $container . find ( elementToExclude ) ;
530
+ self . $tabbables = self . $container . find ( 'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, *[tabindex], *[contenteditable]' ) . filter ( function ( ) {
531
+ var $tabbable = $ ( this ) ;
532
+ var insideWrapper = $ . contains ( $elementToExclude . get ( 0 ) , $tabbable . get ( 0 ) ) ;
533
+
534
+ // tabIndex has already been modified, keep it in the set.
535
+ if ( $tabbable . data ( 'tabindex' ) ) {
536
+ return true ;
537
+ }
538
+
539
+ if ( ! insideWrapper ) {
540
+ // Store current tabindex, so we can set it back when dialog closes
541
+ var tabIndex = $tabbable . attr ( 'tabindex' ) ;
542
+ $tabbable . data ( 'tabindex' , tabIndex ) ;
543
+
544
+ // Make it non tabbable
545
+ $tabbable . attr ( 'tabindex' , '-1' ) ;
546
+ return true ;
547
+ }
548
+ // If element is part of dialog wrapper, just ignore it
549
+ return false ;
550
+ } ) ;
551
+ } ;
552
+
553
+ /**
554
+ * Restore tab indexes that was previously disabled.
555
+ * @param {H5P.jQuery } [$withinContainer] Only restore tab indexes of elements within this container.
556
+ */
557
+ self . restoreTabIndexes = ( $withinContainer ) => {
558
+ var self = this ;
559
+ // Resetting tabindex on background elements
560
+ if ( self . $tabbables ) {
561
+ self . $tabbables . each ( function ( ) {
562
+ var $element = $ ( this ) ;
563
+ var tabindex = $element . data ( 'tabindex' ) ;
564
+
565
+ // Only restore elements within container when specified
566
+ if ( $withinContainer && ! $ . contains ( $withinContainer . get ( 0 ) , $element . get ( 0 ) ) ) {
567
+ return true ;
568
+ }
569
+
570
+ // Specifically handle jquery ui slider, since it overwrites data in an inconsistent way
571
+ if ( $element . hasClass ( 'ui-slider-handle' ) ) {
572
+ $element . attr ( 'tabindex' , 0 ) ;
573
+ $element . removeData ( 'tabindex' ) ;
574
+ }
575
+ else if ( tabindex !== undefined ) {
576
+ $element . attr ( 'tabindex' , tabindex ) ;
577
+ $element . removeData ( 'tabindex' ) ;
578
+ }
579
+ else {
580
+ $element . removeAttr ( 'tabindex' ) ;
581
+ }
582
+ } ) ;
583
+
584
+ // Do not remove reference if only restored partially
585
+ if ( ! $withinContainer ) {
586
+ // Has been restored, remove reference
587
+ self . $tabbables = undefined ;
588
+ }
589
+ }
590
+ } ;
591
+
521
592
/**
522
593
* Toggle mute
523
594
* @param {Boolean } [refocus=true]
@@ -3162,77 +3233,6 @@ InteractiveVideo.prototype.restorePosterTabIndexes = function () {
3162
3233
} ) ;
3163
3234
} ;
3164
3235
3165
-
3166
- /**
3167
- * Disable tab indexes hidden behind overlay.
3168
- */
3169
- InteractiveVideo . prototype . disableTabIndexes = function ( elementToExclude = '.h5p-dialog-wrapper' ) {
3170
- var self = this ;
3171
- // Make all other elements in container not tabbable. When dialog is open,
3172
- // it's like the elements behind does not exist.
3173
- var $elementToExclude = self . $container . find ( elementToExclude ) ;
3174
- self . $tabbables = self . $container . find ( 'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, *[tabindex], *[contenteditable]' ) . filter ( function ( ) {
3175
- var $tabbable = $ ( this ) ;
3176
- var insideWrapper = $ . contains ( $elementToExclude . get ( 0 ) , $tabbable . get ( 0 ) ) ;
3177
-
3178
- // tabIndex has already been modified, keep it in the set.
3179
- if ( $tabbable . data ( 'tabindex' ) ) {
3180
- return true ;
3181
- }
3182
-
3183
- if ( ! insideWrapper ) {
3184
- // Store current tabindex, so we can set it back when dialog closes
3185
- var tabIndex = $tabbable . attr ( 'tabindex' ) ;
3186
- $tabbable . data ( 'tabindex' , tabIndex ) ;
3187
-
3188
- // Make it non tabbable
3189
- $tabbable . attr ( 'tabindex' , '-1' ) ;
3190
- return true ;
3191
- }
3192
- // If element is part of dialog wrapper, just ignore it
3193
- return false ;
3194
- } ) ;
3195
- } ;
3196
-
3197
- /**
3198
- * Restore tab indexes that was previously disabled.
3199
- * @param {H5P.jQuery } [$withinContainer] Only restore tab indexes of elements within this container.
3200
- */
3201
- InteractiveVideo . prototype . restoreTabIndexes = function ( $withinContainer ) {
3202
- var self = this ;
3203
- // Resetting tabindex on background elements
3204
- if ( self . $tabbables ) {
3205
- self . $tabbables . each ( function ( ) {
3206
- var $element = $ ( this ) ;
3207
- var tabindex = $element . data ( 'tabindex' ) ;
3208
-
3209
- // Only restore elements within container when specified
3210
- if ( $withinContainer && ! $ . contains ( $withinContainer . get ( 0 ) , $element . get ( 0 ) ) ) {
3211
- return true ;
3212
- }
3213
-
3214
- // Specifically handle jquery ui slider, since it overwrites data in an inconsistent way
3215
- if ( $element . hasClass ( 'ui-slider-handle' ) ) {
3216
- $element . attr ( 'tabindex' , 0 ) ;
3217
- $element . removeData ( 'tabindex' ) ;
3218
- }
3219
- else if ( tabindex !== undefined ) {
3220
- $element . attr ( 'tabindex' , tabindex ) ;
3221
- $element . removeData ( 'tabindex' ) ;
3222
- }
3223
- else {
3224
- $element . removeAttr ( 'tabindex' ) ;
3225
- }
3226
- } ) ;
3227
-
3228
- // Do not remove reference if only restored partially
3229
- if ( ! $withinContainer ) {
3230
- // Has been restored, remove reference
3231
- self . $tabbables = undefined ;
3232
- }
3233
- }
3234
- } ;
3235
-
3236
3236
/**
3237
3237
* If there are visible required interactions, trap focus
3238
3238
* within them.
0 commit comments