Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slideshow one image #1046

Merged
merged 3 commits into from
Aug 27, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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