1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

fix swipebox

This commit is contained in:
Luke Pulverenti 2014-11-26 14:29:49 -05:00
parent 9d64691fc1
commit f85a900730
6 changed files with 89 additions and 74 deletions

View file

@ -110,7 +110,7 @@
@media all and (min-width: 600px) { @media all and (min-width: 600px) {
.itemsContainer:not(.fullWidthItemsContainer):not(.smallItemsContainer) { .itemsContainer:not(.fullWidthItemsContainer):not(.smallItemsContainer) {
padding: 0 1em; padding: 0 .8em;
margin-right: 10px; margin-right: 10px;
} }
} }

View file

@ -192,8 +192,10 @@
}; };
}); });
index = Math.max(index || 0, 0);
$.swipebox(slideshowItems, { $.swipebox(slideshowItems, {
initialIndexOnArray: index || 0, initialIndexOnArray: index,
hideBarsDelay: 30000 hideBarsDelay: 30000
}); });
} }

View file

@ -823,6 +823,10 @@
} }
else if (action == 'photoslideshow') { else if (action == 'photoslideshow') {
if (!$(elem).hasClass('card')) {
elem = $(elem).parents('.card')[0];
}
itemsContainer = $(elem).parents('.itemsContainer'); itemsContainer = $(elem).parents('.itemsContainer');
index = $('.card', itemsContainer).get().indexOf(elem); index = $('.card', itemsContainer).get().indexOf(elem);

View file

@ -289,6 +289,14 @@
}); });
}; };
self.get = function (url) {
return self.ajax({
type: "GET",
url: url
});
};
self.getJSON = function (url) { self.getJSON = function (url) {
return self.ajax({ return self.ajax({

View file

@ -1,4 +1,4 @@
/*! Swipebox v1.3.0.1 | Constantin Saguin csag.co | MIT License | github.com/brutaldesign/swipebox */ /*! Swipebox v1.3.0.2 | Constantin Saguin csag.co | MIT License | github.com/brutaldesign/swipebox */
;( function ( window, document, $, undefined ) { ;( function ( window, document, $, undefined ) {
@ -17,9 +17,10 @@
beforeOpen: null, beforeOpen: null,
afterOpen: null, afterOpen: null,
afterClose: null, afterClose: null,
loopAtEnd: false loopAtEnd: false,
autoplayVideos: false
}, },
plugin = this, plugin = this,
elements = [], // slides array [ { href:'...', title:'...' }, ...], elements = [], // slides array [ { href:'...', title:'...' }, ...],
$elem, $elem,
@ -78,13 +79,13 @@
return false; return false;
} }
if ( ! $.isArray( elem ) ) { if ( ! $.isArray( elem ) ) {
ui.destroy(); ui.destroy();
$elem = $( selector ); $elem = $( selector );
ui.actions(); ui.actions();
} }
elements = []; elements = [];
var index , relType, relVal; var index , relType, relVal;
@ -109,16 +110,16 @@
var title = null, var title = null,
href = null; href = null;
if ( $( this ).attr( 'title' ) ) { if ( $( this ).attr( 'title' ) ) {
title = $( this ).attr( 'title' ); title = $( this ).attr( 'title' );
} }
if ( $( this ).attr( 'href' ) ) { if ( $( this ).attr( 'href' ) ) {
href = $( this ).attr( 'href' ); href = $( this ).attr( 'href' );
} }
elements.push( { elements.push( {
href: href, href: href,
title: title title: title
@ -174,24 +175,24 @@
if ( isMobile ) { if ( isMobile ) {
$( '#swipebox-bottom-bar, #swipebox-top-bar' ).remove(); $( '#swipebox-bottom-bar, #swipebox-top-bar' ).remove();
} }
$.each( elements, function() { $.each( elements, function() {
$( '#swipebox-slider' ).append( '<div class="slide"></div>' ); $( '#swipebox-slider' ).append( '<div class="slide"></div>' );
} ); } );
$this.setDim(); $this.setDim();
$this.actions(); $this.actions();
if ( isTouch ) { if ( isTouch ) {
$this.gesture(); $this.gesture();
} }
// Devices can have both touch and keyboard input so always allow key events // Devices can have both touch and keyboard input so always allow key events
$this.keyboard(); $this.keyboard();
$this.animBars(); $this.animBars();
$this.resize(); $this.resize();
}, },
/** /**
@ -200,7 +201,7 @@
setDim : function () { setDim : function () {
var width, height, sliderCss = {}; var width, height, sliderCss = {};
// Reset dimensions on mobile orientation change // Reset dimensions on mobile orientation change
if ( 'onorientationchange' in window ) { if ( 'onorientationchange' in window ) {
@ -213,8 +214,8 @@
height = winWidth; height = winWidth;
} }
}, false ); }, false );
} else { } else {
width = window.innerWidth ? window.innerWidth : $( window ).width(); width = window.innerWidth ? window.innerWidth : $( window ).width();
@ -235,7 +236,7 @@
*/ */
resize : function () { resize : function () {
var $this = this; var $this = this;
$( window ).resize( function() { $( window ).resize( function() {
$this.setDim(); $this.setDim();
} ).resize(); } ).resize();
@ -245,10 +246,10 @@
* Check if device supports CSS transitions * Check if device supports CSS transitions
*/ */
supportTransition : function () { supportTransition : function () {
var prefixes = 'transition WebkitTransition MozTransition OTransition msTransition KhtmlTransition'.split( ' ' ), var prefixes = 'transition WebkitTransition MozTransition OTransition msTransition KhtmlTransition'.split( ' ' ),
i; i;
for ( i = 0; i < prefixes.length; i++ ) { for ( i = 0; i < prefixes.length; i++ ) {
if ( document.createElement( 'div' ).style[ prefixes[i] ] !== undefined ) { if ( document.createElement( 'div' ).style[ prefixes[i] ] !== undefined ) {
return prefixes[i]; return prefixes[i];
@ -270,7 +271,7 @@
* Touch navigation * Touch navigation
*/ */
gesture : function () { gesture : function () {
var $this = this, var $this = this,
index, index,
hDistance, hDistance,
@ -337,7 +338,7 @@
// swipe left // swipe left
if ( 0 < hDistance ) { if ( 0 < hDistance ) {
// first slide // first slide
if ( 0 === index ) { if ( 0 === index ) {
// console.log( 'first' ); // console.log( 'first' );
@ -365,11 +366,11 @@
'transform' : 'translate3d(' + ( currentX + hDistancePercent ) + '%, 0, 0)' 'transform' : 'translate3d(' + ( currentX + hDistancePercent ) + '%, 0, 0)'
} ); } );
} }
} }
} }
} ); } );
return false; return false;
} ).bind( 'touchend',function( event ) { } ).bind( 'touchend',function( event ) {
@ -400,20 +401,20 @@
} }
} else if ( hSwipe ) { } else if ( hSwipe ) {
hSwipe = false; hSwipe = false;
// swipeLeft // swipeLeft
if( hDistance >= hSwipMinDistance && hDistance >= hDistanceLast) { if( hDistance >= hSwipMinDistance && hDistance >= hDistanceLast) {
$this.getPrev(); $this.getPrev();
// swipeRight // swipeRight
} else if ( hDistance <= -hSwipMinDistance && hDistance <= hDistanceLast) { } else if ( hDistance <= -hSwipMinDistance && hDistance <= hDistanceLast) {
$this.getNext(); $this.getNext();
} }
} else { // Top and bottom bars have been removed on touchable devices } else { // Top and bottom bars have been removed on touchable devices
// tap // tap
if ( ! bars.hasClass( 'visible-bars' ) ) { if ( ! bars.hasClass( 'visible-bars' ) ) {
@ -432,7 +433,7 @@
$( '#swipebox-overlay' ).removeClass( 'leftSpringTouch' ).removeClass( 'rightSpringTouch' ); $( '#swipebox-overlay' ).removeClass( 'leftSpringTouch' ).removeClass( 'rightSpringTouch' );
$( '.touching' ).off( 'touchmove' ).removeClass( 'touching' ); $( '.touching' ).off( 'touchmove' ).removeClass( 'touching' );
} ); } );
}, },
@ -446,12 +447,12 @@
$this.timeout = window.setTimeout( function() { $this.timeout = window.setTimeout( function() {
$this.hideBars(); $this.hideBars();
}, },
plugin.settings.hideBarsDelay plugin.settings.hideBarsDelay
); );
} }
}, },
/** /**
* Clear timer * Clear timer
*/ */
@ -498,10 +499,10 @@
animBars : function () { animBars : function () {
var $this = this, var $this = this,
bars = $( '#swipebox-top-bar, #swipebox-bottom-bar' ); bars = $( '#swipebox-top-bar, #swipebox-bottom-bar' );
bars.addClass( 'visible-bars' ); bars.addClass( 'visible-bars' );
$this.setTimeout(); $this.setTimeout();
$( '#swipebox-slider' ).click( function() { $( '#swipebox-slider' ).click( function() {
if ( ! bars.hasClass( 'visible-bars' ) ) { if ( ! bars.hasClass( 'visible-bars' ) ) {
$this.showBars(); $this.showBars();
@ -513,7 +514,7 @@
$this.showBars(); $this.showBars();
bars.addClass( 'visible-bars' ); bars.addClass( 'visible-bars' );
$this.clearTimeout(); $this.clearTimeout();
}, function() { }, function() {
if ( plugin.settings.hideBarsDelay > 0 ) { if ( plugin.settings.hideBarsDelay > 0 ) {
bars.removeClass( 'visible-bars' ); bars.removeClass( 'visible-bars' );
@ -531,17 +532,17 @@
$( window ).bind( 'keyup', function( event ) { $( window ).bind( 'keyup', function( event ) {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
if ( event.keyCode === 37 ) { if ( event.keyCode === 37 ) {
$this.getPrev(); $this.getPrev();
} else if ( event.keyCode === 39 ) { } else if ( event.keyCode === 39 ) {
$this.getNext(); $this.getNext();
} else if ( event.keyCode === 27 ) { } else if ( event.keyCode === 27 ) {
$this.closeSlide(); $this.closeSlide();
} }
} ); } );
@ -553,15 +554,15 @@
actions : function () { actions : function () {
var $this = this, var $this = this,
action = 'touchend click'; // Just detect for both event types to allow for multi-input action = 'touchend click'; // Just detect for both event types to allow for multi-input
if ( elements.length < 2 ) { if ( elements.length < 2 ) {
$( '#swipebox-bottom-bar' ).hide(); $( '#swipebox-bottom-bar' ).hide();
if ( undefined === elements[ 1 ] ) { if ( undefined === elements[ 1 ] ) {
$( '#swipebox-top-bar' ).hide(); $( '#swipebox-top-bar' ).hide();
} }
} else { } else {
$( '#swipebox-prev' ).bind( action, function( event ) { $( '#swipebox-prev' ).bind( action, function( event ) {
event.preventDefault(); event.preventDefault();
@ -569,7 +570,7 @@
$this.getPrev(); $this.getPrev();
$this.setTimeout(); $this.setTimeout();
} ); } );
$( '#swipebox-next' ).bind( action, function( event ) { $( '#swipebox-next' ).bind( action, function( event ) {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
@ -582,18 +583,18 @@
$this.closeSlide(); $this.closeSlide();
} ); } );
}, },
/** /**
* Set current slide * Set current slide
*/ */
setSlide : function ( index, isFirst ) { setSlide : function ( index, isFirst ) {
isFirst = isFirst || false; isFirst = isFirst || false;
var slider = $( '#swipebox-slider' ); var slider = $( '#swipebox-slider' );
currentX = -index*100; currentX = -index*100;
if ( this.doCssTrans() ) { if ( this.doCssTrans() ) {
slider.css( { slider.css( {
'-webkit-transform' : 'translate3d(' + (-index*100)+'%, 0, 0)', '-webkit-transform' : 'translate3d(' + (-index*100)+'%, 0, 0)',
@ -602,7 +603,7 @@
} else { } else {
slider.animate( { left : ( -index*100 )+'%' } ); slider.animate( { left : ( -index*100 )+'%' } );
} }
$( '#swipebox-slider .slide' ).removeClass( 'current' ); $( '#swipebox-slider .slide' ).removeClass( 'current' );
$( '#swipebox-slider .slide' ).eq( index ).addClass( 'current' ); $( '#swipebox-slider .slide' ).eq( index ).addClass( 'current' );
this.setTitle( index ); this.setTitle( index );
@ -612,14 +613,14 @@
} }
$( '#swipebox-prev, #swipebox-next' ).removeClass( 'disabled' ); $( '#swipebox-prev, #swipebox-next' ).removeClass( 'disabled' );
if ( index === 0 ) { if ( index === 0 ) {
$( '#swipebox-prev' ).addClass( 'disabled' ); $( '#swipebox-prev' ).addClass( 'disabled' );
} else if ( index === elements.length - 1 && plugin.settings.loopAtEnd !== true ) { } else if ( index === elements.length - 1 && plugin.settings.loopAtEnd !== true ) {
$( '#swipebox-next' ).addClass( 'disabled' ); $( '#swipebox-next' ).addClass( 'disabled' );
} }
}, },
/** /**
* Open slide * Open slide
*/ */
@ -637,7 +638,7 @@
$( window ).trigger( 'resize' ); // fix scroll bar visibility on desktop $( window ).trigger( 'resize' ); // fix scroll bar visibility on desktop
this.setSlide( index, true ); this.setSlide( index, true );
}, },
/** /**
* Set a time out if the media is a video * Set a time out if the media is a video
*/ */
@ -657,7 +658,7 @@
$this.openMedia( index ); $this.openMedia( index );
} }
}, },
/** /**
* Open * Open
*/ */
@ -685,7 +686,7 @@
} else { } else {
slide.html( $this.getVideo( src ) ); slide.html( $this.getVideo( src ) );
} }
}, },
/** /**
@ -723,7 +724,7 @@
return true; return true;
} }
} }
}, },
/** /**
@ -738,12 +739,12 @@
if ( youtubeShortUrl ) { if ( youtubeShortUrl ) {
youtubeUrl = youtubeShortUrl; youtubeUrl = youtubeShortUrl;
} }
iframe = '<iframe width="560" height="315" src="//www.youtube.com/embed/' + youtubeUrl[1] + '" frameborder="0" allowfullscreen></iframe>'; iframe = '<iframe width="560" height="315" src="//www.youtube.com/embed/' + youtubeUrl[1] + '?autoplay='+ plugin.settings.autoplayVideos + '" frameborder="0" allowfullscreen></iframe>';
} else if ( vimeoUrl ) { } else if ( vimeoUrl ) {
iframe = '<iframe width="560" height="315" src="//player.vimeo.com/video/' + vimeoUrl[1] + '?byline=0&amp;portrait=0&amp;color='+plugin.settings.vimeoColor+'" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'; iframe = '<iframe width="560" height="315" src="//player.vimeo.com/video/' + vimeoUrl[1] + '?byline=0&amp;portrait=0&amp;color=' + plugin.settings.vimeoColor + '&autoplay=' + plugin.settings.autoplayVideos + '" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
} }
if ( youtubeUrl || youtubeShortUrl || vimeoUrl ) { if ( youtubeUrl || youtubeShortUrl || vimeoUrl ) {
@ -752,9 +753,9 @@
iframe = '<iframe width="560" height="315" src="' + url + '" frameborder="0" allowfullscreen></iframe>'; iframe = '<iframe width="560" height="315" src="' + url + '" frameborder="0" allowfullscreen></iframe>';
} }
return '<div class="swipebox-video-container" style="max-width:' + plugin.settings.videomaxWidth + 'px"><div class="swipebox-video">'+iframe+'</div></div>'; return '<div class="swipebox-video-container" style="max-width:' + plugin.settings.videomaxWidth + 'px"><div class="swipebox-video">' + iframe + '</div></div>';
}, },
/** /**
* Load image * Load image
*/ */
@ -767,7 +768,7 @@
img.attr( 'src', src ); img.attr( 'src', src );
} }
}, },
/** /**
* Get next slide * Get next slide
*/ */
@ -776,14 +777,14 @@
src, src,
index = $( '#swipebox-slider .slide' ).index( $( '#swipebox-slider .slide.current' ) ); index = $( '#swipebox-slider .slide' ).index( $( '#swipebox-slider .slide.current' ) );
if ( index + 1 < elements.length ) { if ( index + 1 < elements.length ) {
src = $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src' ); src = $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src' );
$( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src', src ); $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src', src );
index++; index++;
$this.setSlide( index ); $this.setSlide( index );
$this.preloadMedia( index+1 ); $this.preloadMedia( index+1 );
} else { } else {
if ( plugin.settings.loopAtEnd === true ) { if ( plugin.settings.loopAtEnd === true ) {
src = $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src' ); src = $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src' );
$( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src', src ); $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src', src );
@ -799,7 +800,7 @@
} }
} }
}, },
/** /**
* Get previous slide * Get previous slide
*/ */
@ -840,17 +841,17 @@
$( 'body' ).unbind( 'touchend' ); $( 'body' ).unbind( 'touchend' );
$( '#swipebox-slider' ).unbind(); $( '#swipebox-slider' ).unbind();
$( '#swipebox-overlay' ).remove(); $( '#swipebox-overlay' ).remove();
if ( ! $.isArray( elem ) ) { if ( ! $.isArray( elem ) ) {
elem.removeData( '_swipebox' ); elem.removeData( '_swipebox' );
} }
if ( this.target ) { if ( this.target ) {
this.target.trigger( 'swipebox-destroy' ); this.target.trigger( 'swipebox-destroy' );
} }
$.swipebox.isOpen = false; $.swipebox.isOpen = false;
if ( plugin.settings.afterClose ) { if ( plugin.settings.afterClose ) {
plugin.settings.afterClose(); plugin.settings.afterClose();
} }
@ -867,7 +868,7 @@
this.data( '_swipebox', swipebox ); this.data( '_swipebox', swipebox );
} }
return this.data( '_swipebox' ); return this.data( '_swipebox' );
}; };
}( window, document, jQuery ) ); }( window, document, jQuery ) );

File diff suppressed because one or more lines are too long