Skip to content

Commit

Permalink
Add touch gesture support to the Dynamic Webcomic widget.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Sisk committed Jan 31, 2013
1 parent 173988c commit c8aa1dd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions -/php/widgets.php
Expand Up @@ -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 ) ) {
Expand All @@ -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;
Expand Down Expand Up @@ -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
}
}
Expand Down

0 comments on commit c8aa1dd

Please sign in to comment.