Changeset 40789
- Timestamp:
- 05/19/2017 04:00:32 AM (8 years ago)
- Location:
- trunk/src/wp-admin
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/css/dashboard.css
r40643 r40789 324 324 325 325 .community-events-errors[aria-hidden="true"], 326 .community-events-errors *[aria-hidden="true"],326 .community-events-errors [aria-hidden="true"], 327 327 .community-events-loading[aria-hidden="true"], 328 328 .community-events[aria-hidden="true"], 329 .community-events *[aria-hidden="true"] {329 .community-events [aria-hidden="true"] { 330 330 display: none; 331 331 } … … 343 343 .community-events-form .regular-text { 344 344 width: 40%; 345 height: 28px; 345 height: 29px; 346 margin: 0; 347 vertical-align: top; 346 348 } 347 349 348 350 .community-events li.event-none { 349 border-left: 4px solid #00 70AE;351 border-left: 4px solid #00a0d2; 350 352 } 351 353 352 354 .community-events-form label { 353 355 display: inline-block; 354 padding-bottom: 3px; 356 vertical-align: top; 357 line-height: 28px; 358 height: 28px; 355 359 } 356 360 … … 360 364 } 361 365 366 .community-events-toggle-location { 367 vertical-align: middle; 368 } 369 362 370 #community-events-submit { 363 margin-left: 2px;364 } 365 366 .community-events .button-link:hover, 367 .community-events .button-link:active { 368 color: #00a0d2; 369 } 370 371 .community-events-cancel.button.button-link { 372 color: #0073aa;371 margin-left: 3px; 372 margin-right: 3px; 373 } 374 375 /* Needs higher specificity than #dashboard-widgets .button-link */ 376 #dashboard-widgets .community-events-cancel.button-link { 377 vertical-align: top; 378 /* Same properties as the submit button for cross-browsers alignment. */ 379 line-height: 26px; 380 height: 28px; 373 381 text-decoration: underline; 374 margin-left: 2px;375 382 } 376 383 … … 1236 1243 .community-events-toggle-location { 1237 1244 height: 38px; 1245 vertical-align: baseline; 1238 1246 } 1239 1247 1240 1248 .community-events-form .regular-text { 1241 height: 31px; 1249 height: 32px; 1250 } 1251 1252 #community-events-submit { 1253 margin-bottom: 0; 1254 } 1255 1256 .community-events-form label, 1257 #dashboard-widgets .community-events-cancel.button-link { 1258 /* Same properties as the submit button for cross-browsers alignment. */ 1259 font-size: 14px; 1260 line-height: normal; 1261 height: auto; 1262 padding: 6px 0; 1263 border: 1px solid transparent; 1242 1264 } 1243 1265 } -
trunk/src/wp-admin/includes/dashboard.php
r40776 r40789 1174 1174 <?php submit_button( __( 'Submit' ), 'secondary', 'community-events-submit', false ); ?> 1175 1175 1176 <button class="community-events-cancel button button-link" type="button" aria-expanded="false">1176 <button class="community-events-cancel button-link" type="button" aria-expanded="false"> 1177 1177 <?php _e( 'Cancel' ); ?> 1178 1178 </button> -
trunk/src/wp-admin/js/dashboard.js
r40607 r40789 192 192 jQuery( function( $ ) { 193 193 'use strict'; 194 195 var communityEventsData = window.communityEventsData || {}; 196 197 var app = window.wp.communityEvents = { 194 195 var communityEventsData = window.communityEventsData || {}, 196 app; 197 198 app = window.wp.communityEvents = { 198 199 initialized: false, 199 200 model: null, … … 213 214 /* 214 215 * When JavaScript is disabled, the errors container is shown, so 215 * that "This widget requires Java script" message can be seen.216 * that "This widget requires JavaScript" message can be seen. 216 217 * 217 218 * When JS is enabled, the container is hidden at first, and then … … 228 229 */ 229 230 $( '.community-events-errors' ) 230 .attr( 'aria-hidden', true)231 .attr( 'aria-hidden', 'true' ) 231 232 .removeClass( 'hide-if-js' ); 232 233 … … 236 237 event.preventDefault(); 237 238 238 app.getEvents( 239 app.getEvents({ 239 240 location: $( '#community-events-location' ).val() 240 241 }); … … 256 257 * 257 258 * @param {event|string} action 'show' or 'hide' to specify a state; 258 * Or an event object to flip between states259 * or an event object to flip between states. 259 260 */ 260 261 toggleLocationForm: function( action ) { 261 262 var $toggleButton = $( '.community-events-toggle-location' ), 262 $cancelButton = $( '.community-events-cancel' ), 263 $form = $( '.community-events-form' ); 263 $cancelButton = $( '.community-events-cancel' ), 264 $form = $( '.community-events-form' ), 265 $target = $(); 264 266 265 267 if ( 'object' === typeof action ) { 266 // Strict comparison doesn't work in this case. 268 // The action is the event object: get the clicked element. 269 $target = $( action.target ); 270 /* 271 * Strict comparison doesn't work in this case because sometimes 272 * we explicitly pass a string as value of aria-expanded and 273 * sometimes a boolean as the result of an evaluation. 274 */ 267 275 action = 'true' == $toggleButton.attr( 'aria-expanded' ) ? 'hide' : 'show'; 268 276 } 269 277 270 278 if ( 'hide' === action ) { 271 $toggleButton.attr( 'aria-expanded', false ); 272 $cancelButton.attr( 'aria-expanded', false ); 273 $form.attr( 'aria-hidden', true ); 279 $toggleButton.attr( 'aria-expanded', 'false' ); 280 $cancelButton.attr( 'aria-expanded', 'false' ); 281 $form.attr( 'aria-hidden', 'true' ); 282 /* 283 * If the Cancel button has been clicked, bring the focus back 284 * to the toggle button so users relying on screen readers don't 285 * lose their place. 286 */ 287 if ( $target.hasClass( 'community-events-cancel' ) ) { 288 $toggleButton.focus(); 289 } 274 290 } else { 275 $toggleButton.attr( 'aria-expanded', true);276 $cancelButton.attr( 'aria-expanded', true);277 $form.attr( 'aria-hidden', false);291 $toggleButton.attr( 'aria-expanded', 'true' ); 292 $cancelButton.attr( 'aria-expanded', 'true' ); 293 $form.attr( 'aria-hidden', 'false' ); 278 294 } 279 295 }, … … 288 304 getEvents: function( requestParams ) { 289 305 var initiatedBy, 290 291 306 app = this, 307 $spinner = $( '.community-events-form' ).children( '.spinner' ); 292 308 293 309 requestParams = requestParams || {}; … … 315 331 * annoy them. 316 332 */ 317 318 333 delete response.error; 319 334 } … … 323 338 324 339 .fail( function() { 325 app.renderEventsTemplate( 340 app.renderEventsTemplate({ 326 341 'location' : false, 327 342 'error' : true … … 335 350 * @since 4.8.0 336 351 * 337 * @param {Object} templateParams The various parameters that will get passed to wp.template 352 * @param {Object} templateParams The various parameters that will get passed to wp.template. 338 353 * @param {string} initiatedBy 'user' to indicate that this was triggered manually by the user; 339 354 * 'app' to indicate it was triggered automatically by the app itself. … … 341 356 renderEventsTemplate: function( templateParams, initiatedBy ) { 342 357 var template, 343 elementVisibility, 344 l10nPlaceholder = /%(?:\d\$)?s/g, // Match `%s`, `%1$s`, `%2$s`, etc. 345 $locationMessage = $( '#community-events-location-message' ), 346 $results = $( '.community-events-results' ); 358 elementVisibility, 359 l10nPlaceholder = /%(?:\d\$)?s/g, // Match `%s`, `%1$s`, `%2$s`, etc. 360 $toggleButton = $( '.community-events-toggle-location' ), 361 $locationMessage = $( '#community-events-location-message' ), 362 $results = $( '.community-events-results' ); 347 363 348 364 /* … … 351 367 * could have been shown at an earlier point. 352 368 * 353 * The exception to that is that the .community-events container . It's hidden369 * The exception to that is that the .community-events container is hidden 354 370 * when the page is first loaded, because the content isn't ready yet, 355 371 * but once we've reached this point, it should always be shown. … … 381 397 $results.html( template( templateParams ) ); 382 398 } 383 wp.a11y.speak( communityEventsData.l10n.city_updated.replace( l10nPlaceholder, templateParams.location ));399 wp.a11y.speak( communityEventsData.l10n.city_updated.replace( l10nPlaceholder, templateParams.location.description ), 'assertive' ); 384 400 385 401 elementVisibility['#community-events-location-message'] = true; … … 406 422 elementVisibility['.community-events-errors'] = true; 407 423 elementVisibility['.community-events-error-occurred'] = true; 408 409 424 } else { 410 425 $locationMessage.text( communityEventsData.l10n.enter_closest_city ); … … 419 434 }); 420 435 421 $( '.community-events-toggle-location' ).attr( 'aria-expanded', elementVisibility['.community-events-toggle-location'] ); 422 423 /* 424 * During the initial page load, the location form should be hidden 425 * by default if the user has saved a valid location during a previous 426 * session. It's safe to assume that they want to continue using that 427 * location, and displaying the form would unnecessarily clutter the 428 * widget. 429 */ 430 if ( 'app' === initiatedBy && templateParams.location ) { 436 $toggleButton.attr( 'aria-expanded', elementVisibility['.community-events-toggle-location'] ); 437 438 if ( templateParams.location ) { 439 // Hide the form when there's a valid location. 431 440 app.toggleLocationForm( 'hide' ); 441 442 if ( 'user' === initiatedBy ) { 443 /* 444 * When the form is programmatically hidden after a user search, 445 * bring the focus back to the toggle button so users relying 446 * on screen readers don't lose their place. 447 */ 448 $toggleButton.focus(); 449 } 432 450 } else { 433 451 app.toggleLocationForm( 'show' );
Note: See TracChangeset
for help on using the changeset viewer.