Skip to content
Browse files

Add touch gesture support to the Dynamic Webcomic widget.

  • Loading branch information...
1 parent 173988c commit c8aa1ddd3e0d17440ed78f3ae1e212d24060ee42 Michael Sisk committed
Showing with 11 additions and 2 deletions.
  1. +11 −2 -/php/widgets.php
View
13 -/php/widgets.php
@@ -200,7 +200,7 @@ public function widget( $args, $instance ) {
$webcomic = new WP_Query( array( 'post_type' => $collection, 'posts_per_page' => 1, 'order' => $reverse ? 'ASC' : 'DESC' ) );
if ( $webcomic->have_posts() ) {
- echo $before_widget, empty( $title ) ? '' : $before_title . $title . $after_title, sprintf( '<div data-webcomic-container="%s">', $widget_id );
+ echo $before_widget, empty( $title ) ? '' : $before_title . $title . $after_title, sprintf( '<div data-webcomic-container="%s"%s>', $widget_id, $gesture ? ' data-webcomic-gestures' : '' );
while ( $webcomic->have_posts() ) { $webcomic->the_post();
if ( !locate_template( array( "webcomic/dynamic-{$widget_id}-{$collection}.php", "webcomic/dynamic-{$widget_id}.php", "webcomic/dynamic-{$collection}.php", 'webcomic/dynamic.php' ), true, false ) ) {
@@ -225,6 +225,7 @@ public function widget( $args, $instance ) {
public function update( $new, $old ) {
$old[ 'title' ] = strip_tags( $new[ 'title' ] );
$old[ 'reverse' ] = $new[ 'reverse' ];
+ $old[ 'gestures' ] = $new[ 'gestures' ];
$old[ 'collection' ] = $new[ 'collection' ];
return $old;
@@ -269,13 +270,21 @@ public function form( $instance ) {
</label>
</p>
<p>
- <label><input type="checkbox" name="<?php echo $this->get_field_name( 'reverse' ); ?>" value="1"<?php echo empty( $reverse ) ? '' : checked( $reverse, true, false ); ?>> <?php _e( 'Start with first webcomic', 'webcomic' ); ?></label><br>
+ <label><input type="checkbox" name="<?php echo $this->get_field_name( 'reverse' ); ?>" value="1"<?php echo empty( $reverse ) ? '' : checked( $reverse, true, false ); ?>> <?php _e( 'Start with first webcomic', 'webcomic' ); ?></label>
</p>
+ <?php if ( $config[ 'gestures' ] ) { ?>
+ <p>
+ <label><input type="checkbox" name="<?php echo $this->get_field_name( 'gestures' ); ?>" value="1"<?php echo empty( $gestures ) ? '' : checked( $gestures, true, false ); ?>> <?php _e( 'Enable touch gestures for webcomic navigation', 'webcomic' ); ?></label>
+ </p>
+ <?php } else { ?>
+ <input type="hidden" name="<?php echo $this->get_field_name( 'gestures' ); ?>" value="<?php echo empty( $gestures ) ? '' : $gestures; ?>">
+ <?php { ?>
<?php } else { ?>
<p style="color:#bc0b0b"><strong><?php _e( 'Please enable the dynamic navigation option on the Settings > Webcomic administrative page to use this widget.', 'webcomic' ); ?></strong></p>
<input type="hidden" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo empty( $title ) ? '' : esc_attr( $title ); ?>">
<input type="hidden" name="<?php echo $this->get_field_name( 'collection' ); ?>" value="<?php echo empty( $collection ) ? '' : $collection; ?>">
<input type="hidden" name="<?php echo $this->get_field_name( 'reverse' ); ?>" value="<?php echo empty( $reverse ) ? '' : $reverse; ?>">
+ <input type="hidden" name="<?php echo $this->get_field_name( 'gestures' ); ?>" value="<?php echo empty( $gestures ) ? '' : $gestures; ?>">
<?php
}
}

0 comments on commit c8aa1dd

Please sign in to comment.
Something went wrong with that request. Please try again.