Show and hide option to view all events instead of disabling checkbox

This commit is contained in:
Brian Miyaji
2014-03-17 22:33:54 +11:00
parent e24cd547e2
commit a8587bd811
3 changed files with 7 additions and 3 deletions

View File

@@ -55,7 +55,7 @@ class SportsPress_Widget_Events_Calendar extends WP_Widget {
?>
</p>
<p><input class="checkbox sp-events-calendar-show-all-toggle" type="checkbox" id="<?php echo $this->get_field_id('show_all_events_link'); ?>" name="<?php echo $this->get_field_name('show_all_events_link'); ?>" value="1" <?php checked( $show_all_events_link, 1 ); ?> <?php disabled( true, ( ! $id ) ); ?>>
<p class="sp-events-calendar-show-all-toggle<?php if ( ! $id ): ?> hidden<?php endif; ?>"><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_all_events_link'); ?>" name="<?php echo $this->get_field_name('show_all_events_link'); ?>" value="1" <?php checked( $show_all_events_link, 1 ); ?>>
<label for="<?php echo $this->get_field_id('show_all_events_link'); ?>"><?php _e( 'Display link to view all events', 'sportspress' ); ?></label></p>
<?php
}

View File

@@ -73,7 +73,7 @@ class SportsPress_Widget_Events_List extends WP_Widget {
<?php endforeach; ?>
</p>
<p><input class="checkbox sp-events-calendar-show-all-toggle" type="checkbox" id="<?php echo $this->get_field_id('show_all_events_link'); ?>" name="<?php echo $this->get_field_name('show_all_events_link'); ?>" value="1" <?php checked( $show_all_events_link, 1 ); ?> <?php disabled( true, ( ! $id ) ); ?>>
<p class="sp-events-calendar-show-all-toggle<?php if ( ! $id ): ?> hidden<?php endif; ?>"><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_all_events_link'); ?>" name="<?php echo $this->get_field_name('show_all_events_link'); ?>" value="1" <?php checked( $show_all_events_link, 1 ); ?>>
<label for="<?php echo $this->get_field_id('show_all_events_link'); ?>"><?php _e( 'Display link to view all events', 'sportspress' ); ?></label></p>
<?php
}

View File

@@ -38,7 +38,11 @@ jQuery(document).ready(function($){
// Calendar affects view all link checkbox in widget options
$("body.widgets-php").on("change", ".sp-events-calendar-select", function() {
$(this).closest(".widget-content").find(".sp-events-calendar-show-all-toggle").prop("disabled", $(this).val() == 0);
$el = $(this).closest(".widget-content").find(".sp-events-calendar-show-all-toggle");
if($(this).val() == 0)
$el.hide();
else
$el.show();
});
// Tab switcher