Changeset 48418
- Timestamp:
- 07/10/2020 06:16:06 AM (4 years ago)
- Location:
- trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/js/_enqueues/wp/updates.js
r48168 r48418 2678 2678 2679 2679 /** 2680 * Click handler for enabling and disabling plugin and theme auto-updates.2680 * Prevents the page form scrolling when activating auto-updates with the Spacebar key. 2681 2681 * 2682 2682 * @since 5.5.0 2683 2683 */ 2684 $document.on( 'click', '.column-auto-updates a.toggle-auto-update, .theme-overlay a.toggle-auto-update', function( event ) { 2685 var data, asset, type, $parent; 2686 var $anchor = $( this ), 2687 action = $anchor.attr( 'data-wp-action' ), 2688 $label = $anchor.find( '.label' ); 2684 $document.on( 'keydown', '.column-auto-updates .toggle-auto-update, .theme-overlay .toggle-auto-update', function( event ) { 2685 if ( 32 === event.which ) { 2686 event.preventDefault(); 2687 } 2688 } ); 2689 2690 /** 2691 * Click and keyup handler for enabling and disabling plugin and theme auto-updates. 2692 * 2693 * These controls can be either links or buttons. When JavaScript is enabled, 2694 * we want them to behave like buttons. An ARIA role `button` is added via 2695 * the JavaScript that targets elements with the CSS class `aria-button-if-js`. 2696 * 2697 * @since 5.5.0 2698 */ 2699 $document.on( 'click keyup', '.column-auto-updates .toggle-auto-update, .theme-overlay .toggle-auto-update', function( event ) { 2700 var data, asset, type, $parent, 2701 $toggler = $( this ), 2702 action = $toggler.attr( 'data-wp-action' ), 2703 $label = $toggler.find( '.label' ); 2704 2705 if ( 'keyup' === event.type && 32 !== event.which ) { 2706 return; 2707 } 2689 2708 2690 2709 if ( 'themes' !== pagenow ) { 2691 $parent = $ anchor.closest( '.column-auto-updates' );2710 $parent = $toggler.closest( '.column-auto-updates' ); 2692 2711 } else { 2693 $parent = $ anchor.closest( '.theme-autoupdate' );2712 $parent = $toggler.closest( '.theme-autoupdate' ); 2694 2713 } 2695 2714 … … 2697 2716 2698 2717 // Prevent multiple simultaneous requests. 2699 if ( $ anchor.attr( 'data-doing-ajax' ) === 'yes' ) {2718 if ( $toggler.attr( 'data-doing-ajax' ) === 'yes' ) { 2700 2719 return; 2701 2720 } 2702 2721 2703 $ anchor.attr( 'data-doing-ajax', 'yes' );2722 $toggler.attr( 'data-doing-ajax', 'yes' ); 2704 2723 2705 2724 switch ( pagenow ) { … … 2707 2726 case 'plugins-network': 2708 2727 type = 'plugin'; 2709 asset = $ anchor.closest( 'tr' ).attr( 'data-plugin' );2728 asset = $toggler.closest( 'tr' ).attr( 'data-plugin' ); 2710 2729 break; 2711 2730 case 'themes-network': 2712 2731 type = 'theme'; 2713 asset = $ anchor.closest( 'tr' ).attr( 'data-slug' );2732 asset = $toggler.closest( 'tr' ).attr( 'data-slug' ); 2714 2733 break; 2715 2734 case 'themes': 2716 2735 type = 'theme'; 2717 asset = $ anchor.attr( 'data-slug' );2736 asset = $toggler.attr( 'data-slug' ); 2718 2737 break; 2719 2738 } … … 2729 2748 } 2730 2749 2731 $ anchor.find( '.dashicons-update' ).removeClass( 'hidden' );2750 $toggler.find( '.dashicons-update' ).removeClass( 'hidden' ); 2732 2751 2733 2752 data = { … … 2741 2760 $.post( window.ajaxurl, data ) 2742 2761 .done( function( response ) { 2743 var $enabled, $disabled, enabledNumber, disabledNumber, errorMessage ;2744 var href = $anchor.attr( 'href' );2762 var $enabled, $disabled, enabledNumber, disabledNumber, errorMessage, 2763 href = $toggler.attr( 'href' ); 2745 2764 2746 2765 if ( ! response.success ) { … … 2785 2804 2786 2805 if ( 'enable' === action ) { 2787 href = href.replace( 'action=enable-auto-update', 'action=disable-auto-update' ); 2788 $anchor.attr( { 2789 'data-wp-action': 'disable', 2790 href: href 2791 } ); 2806 // The toggler control can be either a link or a button. 2807 if ( $toggler[ 0 ].hasAttribute( 'href' ) ) { 2808 href = href.replace( 'action=enable-auto-update', 'action=disable-auto-update' ); 2809 $toggler.attr( 'href', href ); 2810 } 2811 $toggler.attr( 'data-wp-action', 'disable' ); 2792 2812 2793 2813 $label.text( __( 'Disable auto-updates' ) ); 2794 2814 $parent.find( '.auto-update-time' ).removeClass( 'hidden' ); 2795 wp.a11y.speak( __( ' Enable auto-updates' ), 'polite');2815 wp.a11y.speak( __( 'Auto-updates enabled' ) ); 2796 2816 } else { 2797 href = href.replace( 'action=disable-auto-update', 'action=enable-auto-update' ); 2798 $anchor.attr( { 2799 'data-wp-action': 'enable', 2800 href: href 2801 } ); 2817 // The toggler control can be either a link or a button. 2818 if ( $toggler[ 0 ].hasAttribute( 'href' ) ) { 2819 href = href.replace( 'action=disable-auto-update', 'action=enable-auto-update' ); 2820 $toggler.attr( 'href', href ); 2821 } 2822 $toggler.attr( 'data-wp-action', 'enable' ); 2802 2823 2803 2824 $label.text( __( 'Enable auto-updates' ) ); 2804 2825 $parent.find( '.auto-update-time' ).addClass( 'hidden' ); 2805 wp.a11y.speak( __( 'Auto-updates disabled' ) , 'polite');2826 wp.a11y.speak( __( 'Auto-updates disabled' ) ); 2806 2827 } 2807 2828 … … 2817 2838 } ) 2818 2839 .always( function() { 2819 $ anchor.removeAttr( 'data-doing-ajax' ).find( '.dashicons-update' ).addClass( 'hidden' );2840 $toggler.removeAttr( 'data-doing-ajax' ).find( '.dashicons-update' ).addClass( 'hidden' ); 2820 2841 } ); 2821 2842 } -
trunk/src/wp-admin/css/common.css
r48373 r48418 1500 1500 } 1501 1501 1502 .theme-overlay .theme-autoupdate .dashicons-update.spin { 1503 margin-right: 3px; 1504 } 1505 1502 1506 /* Updated icon (check mark). */ 1503 1507 .updated-message p:before, -
trunk/src/wp-admin/css/themes.css
r48390 r48418 683 683 .theme-overlay .theme-autoupdate a { 684 684 text-decoration: none; 685 } 686 687 .theme-overlay .toggle-auto-update { 688 /* Better align spin icon and text. */ 689 display: inline-flex; 690 align-items: center; 691 /* Prevents content after the auto-update toggler from jumping down and up. */ 692 min-height: 20px; /* Same height as the spinning dashicon. */ 693 vertical-align: top; 685 694 } 686 695 -
trunk/src/wp-admin/includes/class-wp-ms-themes-list-table.php
r48109 r48418 745 745 746 746 $html[] = sprintf( 747 '<a href="%s" class="toggle-auto-update " data-wp-action="%s">',747 '<a href="%s" class="toggle-auto-update aria-button-if-js" data-wp-action="%s">', 748 748 wp_nonce_url( $url, 'updates' ), 749 749 $action -
trunk/src/wp-admin/includes/class-wp-plugins-list-table.php
r48377 r48418 1077 1077 1078 1078 $html[] = sprintf( 1079 '<a href="%s" class="toggle-auto-update " data-wp-action="%s">',1079 '<a href="%s" class="toggle-auto-update aria-button-if-js" data-wp-action="%s">', 1080 1080 wp_nonce_url( $url, 'updates' ), 1081 1081 $action -
trunk/src/wp-admin/themes.php
r48115 r48418 563 563 <div class="theme-autoupdate"> 564 564 <# if ( data.autoupdate ) { #> 565 <a href="{{{ data.actions.autoupdate }}}" class="toggle-auto-update" data-slug="{{ data.id }}" data-wp-action="disable"> 566 <span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span> 567 <span class="label">' . __( 'Disable auto-updates' ) . '</span> 568 </a> 565 <button type="button" class="toggle-auto-update button-link" data-slug="{{ data.id }}" data-wp-action="disable"> 566 <span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span><span class="label">' . __( 'Disable auto-updates' ) . '</span> 567 </button> 569 568 <# } else { #> 570 <a href="{{{ data.actions.autoupdate }}}" class="toggle-auto-update" data-slug="{{ data.id }}" data-wp-action="enable"> 571 <span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span> 572 <span class="label">' . __( 'Enable auto-updates' ) . '</span> 569 <button type="button" class="toggle-auto-update button-link" data-slug="{{ data.id }}" data-wp-action="enable"> 570 <span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span><span class="label">' . __( 'Enable auto-updates' ) . '</span> 573 571 </a> 574 572 <# } #>
Note: See TracChangeset
for help on using the changeset viewer.