Skip to content

Commit

Permalink
Merge pull request #1046 from Automattic/slideshow-one-image
Browse files Browse the repository at this point in the history
Slideshow one image
  • Loading branch information
rase- committed Aug 27, 2014
2 parents 6437bb0 + 5ddc397 commit 867d2d7
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 33 deletions.
68 changes: 36 additions & 32 deletions modules/shortcodes/js/slideshow-shortcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,40 +94,44 @@ JetpackSlideshow.prototype.finishInit_ = function() {
this.renderControls_();

var self = this;
// Initialize Cycle instance.
this.element.cycle( {
fx: this.transition,
prev: this.controls.prev,
next: this.controls.next,
slideExpr: '.slideshow-slide',
onPrevNextEvent: function() {
return self.onCyclePrevNextClick_.apply( self, arguments );
}
} );

var slideshow = this.element;
jQuery( this.controls.stop ).click( function() {
var button = jQuery(this);
if ( ! button.hasClass( 'paused' ) ) {
slideshow.cycle( 'pause' );
button.removeClass( 'running' );
button.addClass( 'paused' );
} else {
button.addClass( 'running' );
button.removeClass( 'paused' );
slideshow.cycle( 'resume', true );
}
return false;
} );
if ( this.images.length > 1 ) {
// Initialize Cycle instance.
this.element.cycle( {
fx: this.transition,
prev: this.controls.prev,
next: this.controls.next,
slideExpr: '.slideshow-slide',
onPrevNextEvent: function() {
return self.onCyclePrevNextClick_.apply( self, arguments );
}
} );

var controls = jQuery( this.controlsDiv_ );
slideshow.mouseenter( function() {
controls.fadeIn();
} );
slideshow.mouseleave( function() {
controls.fadeOut();
} );
var slideshow = this.element;
jQuery( this.controls.stop ).click( function() {
var button = jQuery(this);
if ( ! button.hasClass( 'paused' ) ) {
slideshow.cycle( 'pause' );
button.removeClass( 'running' );
button.addClass( 'paused' );
} else {
button.addClass( 'running' );
button.removeClass( 'paused' );
slideshow.cycle( 'resume', true );
}
return false;
} );

var controls = jQuery( this.controlsDiv_ );
slideshow.mouseenter( function() {
controls.fadeIn();
} );
slideshow.mouseleave( function() {
controls.fadeOut();
} );
} else {
this.element.children( ':first' ).show();
this.element.css( 'position', 'relative' );
}
this.initialized_ = true;
};

Expand Down
2 changes: 1 addition & 1 deletion modules/shortcodes/slideshow.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function shortcode_callback( $attr, $content = null ) {
'exclude' => $attr['exclude'],
) );

if ( count( $attachments ) < 2 )
if ( count( $attachments ) < 1 )
return;

$gallery_instance = sprintf( "gallery-%d-%d", $attr['id'], ++$this->instance_count );
Expand Down
3 changes: 3 additions & 0 deletions modules/widgets/gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ public function slideshow_widget( $args, $instance ) {
if ( ! class_exists( 'Jetpack_Slideshow_Shortcode' ) )
return;

if ( count( $instance['attachments'] ) < 1 )
return;

$slideshow = new Jetpack_Slideshow_Shortcode();

$slideshow->enqueue_scripts();
Expand Down

0 comments on commit 867d2d7

Please sign in to comment.