Setup wizard: hide settings until a service is enabled.

This commit is contained in:
Jeff Stieler 2017-09-16 17:57:17 -07:00
parent 3a09d74ed4
commit e6dc95432a
6 changed files with 18 additions and 4 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -558,6 +558,18 @@ body {
}
}
}
.wc-wizard-service-settings {
display: none;
margin-bottom: 0;
cursor: default;
}
&.checked {
.wc-wizard-service-settings {
display: inline-block;
}
}
}
// Toggle display a list of services

View File

@ -23,8 +23,10 @@ jQuery( function( $ ) {
$( '.wc-wizard-services' ).on( 'change', '.wc-wizard-service-enable input', function() {
if ( $( this ).is( ':checked' ) ) {
$( this ).closest( '.wc-wizard-service-toggle' ).removeClass( 'disabled' );
$( this ).closest( '.wc-wizard-service-item' ).addClass( 'checked' );
} else {
$( this ).closest( '.wc-wizard-service-toggle' ).addClass( 'disabled' );
$( this ).closest( '.wc-wizard-service-item' ).removeClass( 'checked' );
}
} );

View File

@ -1 +1 @@
jQuery(function(e){function i(){e(".wc-setup-content").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}function c(){e("form.activate-jetpack").submit()}function t(){wp.ajax.post("setup_wizard_check_jetpack").then(function(e){if(!e||!e.is_active||"yes"===e.is_active)return c();setTimeout(t,3e3)}).fail(function(){c()})}e(".button-next").on("click",function(){var c=e(this).parents("form").get(0);return("function"!=typeof c.checkValidity||c.checkValidity())&&i(),!0}),e(".wc-wizard-services").on("change",".wc-wizard-service-enable input",function(){e(this).is(":checked")?e(this).closest(".wc-wizard-service-toggle").removeClass("disabled"):e(this).closest(".wc-wizard-service-toggle").addClass("disabled")}),e(".wc-wizard-services").on("click",".wc-wizard-service-enable",function(i){i.stopPropagation();var c=e(this).find(".wc-wizard-service-toggle input");c.prop("checked",!c.prop("checked")).change()}),e(".wc-wizard-services-list-toggle").on("change",".wc-wizard-service-enable input",function(){e(this).closest(".wc-wizard-services").find(".wc-wizard-service-item").slideToggle().css("display","flex")}),e(".wc-wizard-services").on("change",".wc-wizard-shipping-method-select .method",function(i){var c=e(this).parent("div"),t=i.target.value,n=c.find(".shipping-method-description");n.find("p").hide(),n.find("p."+t).show();var s=c.find(".shipping-method-settings");s.find("div").hide(),s.find("div."+t).show()}),e(".button-jetpack-connect").on("click",function(e){if(i(),"no"===wc_setup_params.pending_jetpack_install)return!0;e.preventDefault(),t()})});
jQuery(function(e){function i(){e(".wc-setup-content").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}function c(){e("form.activate-jetpack").submit()}function t(){wp.ajax.post("setup_wizard_check_jetpack").then(function(e){if(!e||!e.is_active||"yes"===e.is_active)return c();setTimeout(t,3e3)}).fail(function(){c()})}e(".button-next").on("click",function(){var c=e(this).parents("form").get(0);return("function"!=typeof c.checkValidity||c.checkValidity())&&i(),!0}),e(".wc-wizard-services").on("change",".wc-wizard-service-enable input",function(){e(this).is(":checked")?(e(this).closest(".wc-wizard-service-toggle").removeClass("disabled"),e(this).closest(".wc-wizard-service-item").addClass("checked")):(e(this).closest(".wc-wizard-service-toggle").addClass("disabled"),e(this).closest(".wc-wizard-service-item").removeClass("checked"))}),e(".wc-wizard-services").on("click",".wc-wizard-service-enable",function(i){i.stopPropagation();var c=e(this).find(".wc-wizard-service-toggle input");c.prop("checked",!c.prop("checked")).change()}),e(".wc-wizard-services-list-toggle").on("change",".wc-wizard-service-enable input",function(){e(this).closest(".wc-wizard-services").find(".wc-wizard-service-item").slideToggle().css("display","flex")}),e(".wc-wizard-services").on("change",".wc-wizard-shipping-method-select .method",function(i){var c=e(this).parent("div"),t=i.target.value,s=c.find(".shipping-method-description");s.find("p").hide(),s.find("p."+t).show();var n=c.find(".shipping-method-settings");n.find("div").hide(),n.find("div."+t).show()}),e(".button-jetpack-connect").on("click",function(e){if(i(),"no"===wc_setup_params.pending_jetpack_install)return!0;e.preventDefault(),t()})});

View File

@ -963,7 +963,7 @@ class WC_Admin_Setup_Wizard {
<div class="wc-wizard-service-description">
<?php echo wp_kses_post( wpautop( $item_info['description'] ) ); ?>
<?php if ( ! empty( $item_info['settings'] ) ) : ?>
<div>
<div class="wc-wizard-service-settings">
<?php foreach ( $item_info['settings'] as $setting_id => $setting ) : ?>
<label for="<?php echo esc_attr( $item_id ); ?>_<?php echo esc_attr( $setting_id ); ?>"><?php echo esc_html( $setting['label'] ); ?>:</label>
<input