diff options
Diffstat (limited to 'extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js')
-rw-r--r-- | extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js | 79 |
1 files changed, 37 insertions, 42 deletions
diff --git a/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js b/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js index 9024ba1d..e1bc6f15 100644 --- a/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js +++ b/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js @@ -236,28 +236,6 @@ fn: { * @param {Object} source */ doAction : function( context, action, source ) { - // Verify that this has been called from a source that's within the toolbar - // 'trackAction' defined in click tracking - if ( mw.config.get( 'wgWikiEditorToolbarClickTracking' ) && $.trackAction !== undefined && source.closest( '.wikiEditor-ui-toolbar' ).size() ) { - // Build a unique id for this action by tracking the parent rel attributes up to the toolbar level - var rels = []; - var step = source; - var i = 0; - while ( !step.hasClass( 'wikiEditor-ui-toolbar' ) ) { - if ( i > 25 ) { - break; - } - i++; - var rel = step.attr( 'rel' ); - if ( rel ) { - rels.push( step.attr( 'rel' ) ); - } - step = step.parent(); - } - rels.reverse(); - var id = rels.join( '.' ); - $.trackAction( id ); - } switch ( action.type ) { case 'replace': case 'encapsulate': @@ -300,7 +278,7 @@ fn: { var $group = $( '<div/>' ).attr( { 'class' : 'group group-' + id, 'rel' : id } ); var label = $.wikiEditor.autoMsg( group, 'label' ); if ( label ) { - $group.append( '<div class="label">' + label + '</div>' ); + $group.append( '<span class="label">' + label + '</div>' ); } var empty = true; if ( 'tools' in group ) { @@ -336,13 +314,13 @@ fn: { var offsetOrIcon = $.wikiEditor.autoIconOrOffset( tool.icon, tool.offset, $.wikiEditor.imgPath + 'toolbar/' ); - if ( typeof offsetOrIcon == 'object' ) { + if ( typeof offsetOrIcon === 'object' ) { $button = $( '<a/>' ) .attr( { 'href' : '#', - 'alt' : label, 'title' : label, 'rel' : id, + 'role' : 'button', 'class' : 'tool tool-button wikiEditor-toolbar-spritedButton' } ) .text( label ) @@ -358,6 +336,7 @@ fn: { 'alt' : label, 'title' : label, 'rel' : id, + 'role' : 'button', 'class' : 'tool tool-button' } ); } @@ -461,10 +440,6 @@ fn: { $(this).attr( 'rel' ), { expires: 30, path: '/' } ); - // Click tracking - if ( mw.config.get( 'wgWikiEditorToolbarClickTracking' ) && $.trackAction !== undefined ) { - $.trackAction(section + '.' + $(this).attr('rel')); - } context.fn.restoreCursorAndScrollTop(); // No dragging! event.preventDefault(); @@ -601,7 +576,12 @@ fn: { var $link = $( '<a/>' ) .addClass( selected == id ? 'current' : null ) - .attr( 'href', '#' ) + .attr( { + href: '#', + role: 'button', + 'aria-pressed': 'false', + 'aria-controls': 'wikiEditor-section-' + id + } ) .text( $.wikiEditor.autoMsg( section, 'label' ) ) .data( 'context', context ) .mouseup( function( e ) { @@ -613,14 +593,23 @@ fn: { return false; } ) .click( function( e ) { + // We have to set aria-pressed over here, as NVDA wont recognize it + // if we do it in the below .each as it seems + $(this).attr( 'aria-pressed', 'true' ); + $( '.tab > a' ).each( function( i, elem ) { + if ( elem !== e.target ) { + $( elem ).attr( 'aria-pressed', 'false' ); + } + } ); var $sections = $(this).data( 'context' ).$ui.find( '.sections' ); var $section = $(this).data( 'context' ).$ui.find( '.section-' + $(this).parent().attr( 'rel' ) ); var show = $section.css( 'display' ) == 'none'; - var $previousSections = $section.parent().find( '.section-visible' ); - $previousSections.css( 'position', 'absolute' ); - $previousSections.removeClass( 'section-visible' ); - $previousSections.fadeOut( 'fast', function() { $(this).css( 'position', 'static' ); } ); + $section.parent().find( '.section-visible' ) + .css( 'position', 'absolute' ) + .attr( 'aria-expanded', 'false' ) + .removeClass( 'section-visible' ) + .fadeOut( 'fast', function() { $(this).css( 'position', 'static' ); } ); $(this).parent().parent().find( 'a' ).removeClass( 'current' ); $sections.css( 'overflow', 'hidden' ); var animate = function( $that ) { @@ -632,8 +621,9 @@ fn: { } ); }; if ( show ) { - $section.addClass( 'section-visible' ); - $section.fadeIn( 'fast' ); + $section.addClass( 'section-visible' ) + .attr( 'aria-expanded', 'true' ) + .fadeIn( 'fast' ); if ( $section.hasClass( 'loading' ) ) { // Loading of this section was deferred, load it now var $that = $(this); @@ -655,10 +645,6 @@ fn: { context.fn.trigger( 'resize' ); } ); } - // Click tracking - if ( mw.config.get( 'wgWikiEditorToolbarClickTracking' ) && $.trackAction !== undefined ) { - $.trackAction( $section.attr('rel') + '.' + ( show ? 'show': 'hide' ) ); - } // Save the currently visible section $.cookie( 'wikiEditor-' + $(this).data( 'context' ).instance + '-toolbar-section', @@ -676,7 +662,11 @@ fn: { .append( $link ); }, buildSection: function( context, id, section ) { - var $section = $( '<div/>' ).attr( { 'class': section.type + ' section section-' + id, 'rel': id } ); + var $section = $( '<div/>' ).attr( { + 'class': section.type + ' section section-' + id, + 'rel': id, + id: 'wikiEditor-section-' + id + } ); var selected = $.cookie( 'wikiEditor-' + context.instance + '-toolbar-section' ); var show = selected == id; @@ -693,7 +683,10 @@ fn: { // Show or hide section if ( id !== 'main' ) { - $section.css( 'display', show ? 'block' : 'none' ); + $section + .css( 'display', show ? 'block' : 'none' ) + .attr( 'aria-expanded', show ? 'true' : 'false' ); + if ( show ) { $section.addClass( 'section-visible' ); } @@ -776,6 +769,8 @@ fn: { var oldValue = $( 'body' ).css( 'position' ); $( 'body' ).css( 'position', 'static' ); $( 'body' ).css( 'position', oldValue ); + + context.$textarea.trigger( 'wikiEditor-toolbar-doneInitialSections' ); }, 'loop' : function( i, s ) { s.$sections.append( $.wikiEditor.modules.toolbar.fn.buildSection( s.context, s.id, s.config ) ); |