| @@ -35,9 +35,8 @@ | ||
| 35 | 35 | }); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | function onReady() { |
| 39 | - initAccessibility(); | |
| 40 | 39 | initTabs(); |
| 41 | 40 | |
| 42 | 41 | // open the correct source tab/sub-tab. |
| 43 | 42 | var source = $('#visualizer-chart-id').attr('data-chart-source'); |
| @@ -73,9 +72,8 @@ | ||
| 73 | 72 | |
| 74 | 73 | $('.type-radio').change(function () { |
| 75 | 74 | $('.type-label-selected').removeClass('type-label-selected'); |
| 76 | 75 | $(this).parent().addClass('type-label-selected'); |
| 77 | - updateTypeAriaChecked(); | |
| 78 | 76 | }); |
| 79 | 77 | |
| 80 | 78 | // collapse other open sections of this group |
| 81 | 79 | $(document).on('click', '.viz-group-title', function () { |
| @@ -96,18 +94,15 @@ | ||
| 96 | 94 | * and then show the chart as it was |
| 97 | 95 | * let's close the LHS window and show the chart that is hidden |
| 98 | 96 | */ |
| 99 | 97 | $('body').trigger('visualizer:change:action'); |
| 100 | - updateGroupAriaState($(this)); | |
| 101 | 98 | }); |
| 102 | 99 | |
| 103 | 100 | // collapse other open subsections of this section |
| 104 | 101 | $(document).on('click', '.viz-section-title', function () { |
| 105 | 102 | var grandparent = $(this).parent().parent(); |
| 106 | - grandparent.find('.viz-section-title.open').not(this).each(function () { | |
| 107 | - $(this).removeClass('open').siblings('.viz-section-items').hide(); | |
| 108 | - }); | |
| 109 | - updateSectionAriaState($(this)); | |
| 103 | + grandparent.find('.viz-section-title.open ~ .viz-section-items').hide(); | |
| 104 | + grandparent.find('.viz-section-title.open').removeClass('open'); | |
| 110 | 105 | }); |
| 111 | 106 | |
| 112 | 107 | $('#view-remote-file').click(function () { |
| 113 | 108 | var url = $(this).parent().find('#vz-schedule-url').val(); |
| @@ -159,102 +154,8 @@ | ||
| 159 | 154 | }); |
| 160 | 155 | |
| 161 | 156 | } |
| 162 | 157 | |
| 163 | - function initAccessibility(){ | |
| 164 | - // Chart type picker: treat tiles as radios with keyboard support. | |
| 165 | - var $typePicker = $('#type-picker'); | |
| 166 | - if($typePicker.length){ | |
| 167 | - $typePicker.attr('role', 'radiogroup'); | |
| 168 | - $('.type-label').each(function(){ | |
| 169 | - var $label = $(this); | |
| 170 | - var $input = $label.find('input[type="radio"]'); | |
| 171 | - $label.attr('tabindex', '0').attr('role', 'radio'); | |
| 172 | - if($input.length){ | |
| 173 | - $label.attr('aria-checked', $input.is(':checked') ? 'true' : 'false'); | |
| 174 | - }else{ | |
| 175 | - $label.attr('aria-disabled', 'true'); | |
| 176 | - } | |
| 177 | - }); | |
| 178 | - $(document).on('keydown', '.type-label', function(e){ | |
| 179 | - if(e.key === 'Enter' || e.key === ' '){ | |
| 180 | - e.preventDefault(); | |
| 181 | - var $label = $(this); | |
| 182 | - var $input = $label.find('input[type="radio"]'); | |
| 183 | - if($input.length){ | |
| 184 | - $input.prop('checked', true).trigger('change'); | |
| 185 | - } | |
| 186 | - } | |
| 187 | - }); | |
| 188 | - } | |
| 189 | - | |
| 190 | - // Collapsible groups: add button roles + keyboard activation. | |
| 191 | - $('.viz-group-title').each(function(index){ | |
| 192 | - var $title = $(this); | |
| 193 | - $title.attr('role', 'button').attr('tabindex', '0'); | |
| 194 | - var $content = $title.siblings('.viz-group-content'); | |
| 195 | - if($content.length){ | |
| 196 | - if(!$content.attr('id')){ | |
| 197 | - $content.attr('id', 'viz-group-content-' + index); | |
| 198 | - } | |
| 199 | - $title.attr('aria-controls', $content.attr('id')); | |
| 200 | - updateGroupAriaState($title); | |
| 201 | - } | |
| 202 | - }); | |
| 203 | - $(document).on('keydown', '.viz-group-title', function(e){ | |
| 204 | - if(e.key === 'Enter' || e.key === ' '){ | |
| 205 | - e.preventDefault(); | |
| 206 | - $(this).trigger('click'); | |
| 207 | - } | |
| 208 | - }); | |
| 209 | - | |
| 210 | - // Subsections in source panel. | |
| 211 | - $('.viz-section-title').each(function(index){ | |
| 212 | - var $title = $(this); | |
| 213 | - $title.attr('role', 'button').attr('tabindex', '0'); | |
| 214 | - var $items = $title.siblings('.viz-section-items'); | |
| 215 | - if($items.length){ | |
| 216 | - if(!$items.attr('id')){ | |
| 217 | - $items.attr('id', 'viz-section-items-' + index); | |
| 218 | - } | |
| 219 | - $title.attr('aria-controls', $items.attr('id')); | |
| 220 | - updateSectionAriaState($title); | |
| 221 | - } | |
| 222 | - }); | |
| 223 | - $(document).on('keydown', '.viz-section-title', function(e){ | |
| 224 | - if(e.key === 'Enter' || e.key === ' '){ | |
| 225 | - e.preventDefault(); | |
| 226 | - $(this).trigger('click'); | |
| 227 | - } | |
| 228 | - }); | |
| 229 | - } | |
| 230 | - | |
| 231 | - function updateTypeAriaChecked(){ | |
| 232 | - $('.type-label').each(function(){ | |
| 233 | - var $label = $(this); | |
| 234 | - var $input = $label.find('input[type="radio"]'); | |
| 235 | - if($input.length){ | |
| 236 | - $label.attr('aria-checked', $input.is(':checked') ? 'true' : 'false'); | |
| 237 | - } | |
| 238 | - }); | |
| 239 | - } | |
| 240 | - | |
| 241 | - function updateGroupAriaState($title){ | |
| 242 | - if(!$title || $title.length === 0){ | |
| 243 | - return; | |
| 244 | - } | |
| 245 | - var isOpen = $title.parent().hasClass('open'); | |
| 246 | - $title.attr('aria-expanded', isOpen ? 'true' : 'false'); | |
| 247 | - } | |
| 248 | - | |
| 249 | - function updateSectionAriaState($title){ | |
| 250 | - if(!$title || $title.length === 0){ | |
| 251 | - return; | |
| 252 | - } | |
| 253 | - var isOpen = $title.hasClass('open'); | |
| 254 | - $title.attr('aria-expanded', isOpen ? 'true' : 'false'); | |
| 255 | - } | |
| 256 | - | |
| 257 | 158 | /** |
| 258 | 159 | * Initialize/Update the available chart list based on their supported renderer libraries. |
| 259 | 160 | * |
| 260 | 161 | * @returns {void} |
| @@ -468,10 +369,8 @@ | ||
| 468 | 369 | |
| 469 | 370 | function init_filter_import() { |
| 470 | 371 | $( '#db-filter-save-button' ).on( 'click', function(){ |
| 471 | 372 | $('#vz-filter-wizard').submit(); |
| 472 | - $( '#vz-wp-sync-options' ).hide(); | |
| 473 | - $( '#vz-wp-sync-btn' ).attr( 'aria-expanded', false ); | |
| 474 | 373 | }); |
| 475 | 374 | } |
| 476 | 375 | |
| 477 | 376 | function init_db_import(){ |
| @@ -478,36 +377,8 @@ | ||
| 478 | 377 | $( '#visualizer-db-query' ).css("z-index", "-1").hide(); |
| 479 | 378 | |
| 480 | 379 | init_db_import_component(); |
| 481 | 380 | |
| 482 | - var settings_button = document.querySelector( '#settings-button' ); | |
| 483 | - if ( settings_button ) { | |
| 484 | - settings_button.addEventListener( 'click', function( event ){ | |
| 485 | - $('body').trigger('visualizer:db:query:update', {}); | |
| 486 | - if( $( '#db-chart-button' ).attr( 'data-current' ) !== 'filter' || $( '.visualizer-db-query' ).val().length === 0 ){ | |
| 487 | - return; | |
| 488 | - } | |
| 489 | - | |
| 490 | - event.preventDefault(); | |
| 491 | - event.stopImmediatePropagation(); | |
| 492 | - | |
| 493 | - var query_saved = false; | |
| 494 | - var resume_save = function(){ | |
| 495 | - query_saved = true; | |
| 496 | - settings_button.click(); | |
| 497 | - }; | |
| 498 | - | |
| 499 | - $('body').one( 'visualizer:render:currentchart:update', resume_save ); | |
| 500 | - $( '#thehole' ).one( 'load', function(){ | |
| 501 | - $('body').off( 'visualizer:render:currentchart:update', resume_save ); | |
| 502 | - if ( ! query_saved ) { | |
| 503 | - $( '#db-chart-button' ).trigger( 'click' ); | |
| 504 | - } | |
| 505 | - } ); | |
| 506 | - $( '#db-chart-button' ).trigger( 'click' ); | |
| 507 | - }, true ); | |
| 508 | - } | |
| 509 | - | |
| 510 | 381 | $('#visualizer-query-fetch').on('click', function(e){ |
| 511 | 382 | |
| 512 | 383 | $('body').trigger('visualizer:db:query:update', {}); |
| 513 | 384 | if($('.visualizer-db-query').val() === ''){ |
| @@ -572,29 +443,13 @@ | ||
| 572 | 443 | $( '#db-chart-save-button' ).trigger('click'); |
| 573 | 444 | } |
| 574 | 445 | } ); |
| 575 | 446 | |
| 576 | - $( document ).on( 'click', '#vz-db-sync-btn', function(){ | |
| 577 | - var $options = $( '#vz-db-sync-options' ); | |
| 578 | - var isOpen = $options.is( ':visible' ); | |
| 579 | - $options.toggle(); | |
| 580 | - $( this ).attr( 'aria-expanded', ! isOpen ); | |
| 581 | - } ); | |
| 582 | - | |
| 583 | - $( document ).on( 'click', '#vz-wp-sync-btn', function(){ | |
| 584 | - var $options = $( '#vz-wp-sync-options' ); | |
| 585 | - var isOpen = $options.is( ':visible' ); | |
| 586 | - $options.toggle(); | |
| 587 | - $( this ).attr( 'aria-expanded', ! isOpen ); | |
| 588 | - } ); | |
| 589 | - | |
| 590 | 447 | $( '#db-chart-save-button' ).on( 'click', function(){ |
| 591 | 448 | // submit only if a query has been provided. |
| 592 | 449 | if($('#db-query-form .visualizer-db-query').val().length > 0){ |
| 593 | 450 | $('#viz-db-wizard-params').val($('#db-query-form').serialize()); |
| 594 | 451 | $('#vz-db-wizard').submit(); |
| 595 | - $( '#vz-db-sync-options' ).hide(); | |
| 596 | - $( '#vz-db-sync-btn' ).attr( 'aria-expanded', false ); | |
| 597 | 452 | }else{ |
| 598 | 453 | $('#canvas').unlock(); |
| 599 | 454 | } |
| 600 | 455 | }); |