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