PageSourceSearch

https://svkorean.com/js/jquery.swipebox.js

js svkorean.com collected 2026-10-07 13:39:58 UTC 22,502 bytes, 874 lines download raw bytes

1/*! Swipebox v1.3.0.2 | Constantin Saguin csag.co | MIT License | github.com/brutaldesign/swipebox */
2
3;( function ( window, document, $, undefined ) {
4
5	$.swipebox = function( elem, options ) {
6
7		// Default options
8		var ui,
9			defaults = {
10				useCSS : true,
11				useSVG : true,
12				initialIndexOnArray : 0,
13				hideCloseButtonOnMobile : false,
14				hideBarsDelay : 3000,
15				videoMaxWidth : 1140,
16				vimeoColor : 'cccccc',
17				beforeOpen: null,
18				afterOpen: null,
19				afterClose: null,
20				loopAtEnd: false,
21				autoplayVideos: false
22			},
23
24			plugin = this,
25			elements = [], // slides array [ { href:'...', title:'...' }, ...],
26			$elem,
27			selector = elem.selector,
28			$selector = $( selector ),
29			isMobile = navigator.userAgent.match( /(iPad)|(iPhone)|(iPod)|(Android)|(PlayBook)|(BB10)|(BlackBerry)|(Opera Mini)|(IEMobile)|(webOS)|(MeeGo)/i ),
30			isTouch = isMobile !== null || document.createTouch !== undefined || ( 'ontouchstart' in window ) || ( 'onmsgesturechange' in window ) || navigator.msMaxTouchPoints,
31			supportSVG = !! document.createElementNS && !! document.createElementNS( 'http://www.w3.org/2000/svg', 'svg').createSVGRect,
32			winWidth = window.innerWidth ? window.innerWidth : $( window ).width(),
33			winHeight = window.innerHeight ? window.innerHeight : $( window ).height(),
34			currentX = 0,
35			/* jshint multistr: true */
36			html = '<div id="swipebox-overlay">\
37					<div id="swipebox-container">\
38						<div id="swipebox-slider"></div>\
39						<div id="swipebox-top-bar">\
40							<div id="swipebox-title"></div>\
41						</div>\
42						<div id="swipebox-bottom-bar">\
43							<div id="swipebox-arrows">\
44								<a id="swipebox-prev"></a>\
45								<a id="swipebox-next"></a>\
46							</div>\
47						</div>\
48						<a id="swipebox-close"></a>\
49					</div>\
50			</div>';
51
52		plugin.settings = {};
53
54		$.swipebox.close = function () {
55			ui.closeSlide();
56		};
57
58		$.swipebox.extend = function () {
59			return ui;
60		};
61
62		plugin.init = function() {
63
64			plugin.settings = $.extend( {}, defaults, options );
65
66			if ( $.isArray( elem ) ) {
67
68				elements = elem;
69				ui.target = $( window );
70				ui.init( plugin.settings.initialIndexOnArray );
71
72			} else {
73
74				$( document ).on( 'click', selector, function( event ) {
75
76					// console.log( isTouch );
77
78					if ( event.target.parentNode.className === 'slide current' ) {
79
80						return false;
81					}
82
83					if ( ! $.isArray( elem ) ) {
84						ui.destroy();
85						$elem = $( selector );
86						ui.actions();
87					}
88
89					elements = [];
90					var index , relType, relVal;
91
92					// Allow for HTML5 compliant attribute before legacy use of rel
93					if ( ! relVal ) {
94						relType = 'data-rel';
95						relVal  = $( this ).attr( relType );
96					}
97
98					if ( ! relVal ) {
99						relType = 'rel';
100						relVal = $( this ).attr( relType );
101					}
102
103					if ( relVal && relVal !== '' && relVal !== 'nofollow' ) {
104						$elem = $selector.filter( '[' + relType + '="' + relVal + '"]' );
105					} else {
106						$elem = $( selector );
107					}
108
109					$elem.each( function() {
110
111						var title = null,
112							href = null;
113
114						if ( $( this ).attr( 'title' ) ) {
115							title = $( this ).attr( 'title' );
116						}
117
118
119						if ( $( this ).attr( 'href' ) ) {
120							href = $( this ).attr( 'href' );
121						}
122
123						elements.push( {
124							href: href,
125							title: title
126						} );
127					} );
128
129					index = $elem.index( $( this ) );
130					event.preventDefault();
131					event.stopPropagation();
132					ui.target = $( event.target );
133					ui.init( index );
134				} );
135			}
136		};
137
138		ui = {
139
140			/**
141			 * Initiate Swipebox
142			 */
143			init : function( index ) {
144				if ( plugin.settings.beforeOpen ) {
145					plugin.settings.beforeOpen();
146				}
147				this.target.trigger( 'swipebox-start' );
148				$.swipebox.isOpen = true;
149				this.build();
150				this.openSlide( index );
151				this.openMedia( index );
152				this.preloadMedia( index+1 );
153				this.preloadMedia( index-1 );
154				if ( plugin.settings.afterOpen ) {
155					plugin.settings.afterOpen();
156				}
157			},
158
159			/**
160			 * Built HTML containers and fire main functions
161			 */
162			build : function () {
163				var $this = this, bg;
164
165				$( 'body' ).append( html );
166
167				if ( supportSVG && plugin.settings.useSVG === true ) {
168					bg = $( '#swipebox-close' ).css( 'background-image' );
169					bg = bg.replace( 'png', 'svg' );
170					$( '#swipebox-prev, #swipebox-next, #swipebox-close' ).css( {
171						'background-image' : bg
172					} );
173				}
174
175				if ( isMobile ) {
176					$( '#swipebox-bottom-bar, #swipebox-top-bar' ).remove();
177				}
178
179				$.each( elements,  function() {
180					$( '#swipebox-slider' ).append( '<div class="slide"></div>' );
181				} );
182
183				$this.setDim();
184				$this.actions();
185
186				if ( isTouch ) {
187					$this.gesture();
188				}
189
190				// Devices can have both touch and keyboard input so always allow key events
191				$this.keyboard();
192
193				$this.animBars();
194				$this.resize();
195
196			},
197
198			/**
199			 * Set dimensions depending on windows width and height
200			 */
201			setDim : function () {
202
203				var width, height, sliderCss = {};
204
205				// Reset dimensions on mobile orientation change
206				if ( 'onorientationchange' in window ) {
207
208					window.addEventListener( 'orientationchange', function() {
209						if ( window.orientation === 0 ) {
210							width = winWidth;
211							height = winHeight;
212						} else if ( window.orientation === 90 || window.orientation === -90 ) {
213							width = winHeight;
214							height = winWidth;
215						}
216					}, false );
217
218
219				} else {
220
221					width = window.innerWidth ? window.innerWidth : $( window ).width();
222					height = window.innerHeight ? window.innerHeight : $( window ).height();
223				}
224
225				sliderCss = {
226					width : width,
227					height : height
228				};
229
230				$( '#swipebox-overlay' ).css( sliderCss );
231
232			},
233
234			/**
235			 * Reset dimensions on window resize envent
236			 */
237			resize : function () {
238				var $this = this;
239
240				$( window ).resize( function() {
241					$this.setDim();
242				} ).resize();
243			},
244
245			/**
246			 * Check if device supports CSS transitions
247			 */
248			supportTransition : function () {
249
250				var prefixes = 'transition WebkitTransition MozTransition OTransition msTransition KhtmlTransition'.split( ' ' ),
251					i;
252
253				for ( i = 0; i < prefixes.length; i++ ) {
254					if ( document.createElement( 'div' ).style[ prefixes[i] ] !== undefined ) {
255						return prefixes[i];
256					}
257				}
258				return false;
259			},
260
261			/**
262			 * Check if CSS transitions are allowed (options + devicesupport)
263			 */
264			doCssTrans : function () {
265				if ( plugin.settings.useCSS && this.supportTransition() ) {
266					return true;
267				}
268			},
269
270			/**
271			 * Touch navigation
272			 */
273			gesture : function () {
274
275				var $this = this,
276					index,
277					hDistance,
278					vDistance,
279					hDistanceLast,
280					vDistanceLast,
281					hDistancePercent,
282					vSwipe = false,
283					hSwipe = false,
284					hSwipMinDistance = 10,
285					vSwipMinDistance = 50,
286					startCoords = {},
287					endCoords = {},
288					bars = $( '#swipebox-top-bar, #swipebox-bottom-bar' ),
289					slider = $( '#swipebox-slider' );
290
291				bars.addClass( 'visible-bars' );
292				$this.setTimeout();
293
294				$( 'body' ).bind( 'touchstart', function( event ) {
295
296					$( this ).addClass( 'touching' );
297					index = $( '#swipebox-slider .slide' ).index( $( '#swipebox-slider .slide.current' ) );
298					endCoords = event.originalEvent.targetTouches[0];
299					startCoords.pageX = event.originalEvent.targetTouches[0].pageX;
300					startCoords.pageY = event.originalEvent.targetTouches[0].pageY;
301
302					$( '#swipebox-slider' ).css( {
303						'-webkit-transform' : 'translate3d(' + currentX +'%, 0, 0)',
304						'transform' : 'translate3d(' + currentX + '%, 0, 0)'
305					} );
306
307					$( '.touching' ).bind( 'touchmove',function( event ) {
308						event.preventDefault();
309						event.stopPropagation();
310						endCoords = event.originalEvent.targetTouches[0];
311
312						if ( ! hSwipe ) {
313							vDistanceLast = vDistance;
314							vDistance = endCoords.pageY - startCoords.pageY;
315							if ( Math.abs( vDistance ) >= vSwipMinDistance || vSwipe ) {
316								var opacity = 0.75 - Math.abs(vDistance) / slider.height();
317
318								slider.css( { 'top': vDistance + 'px' } );
319								slider.css( { 'opacity': opacity } );
320
321								vSwipe = true;
322							}
323						}
324
325						hDistanceLast = hDistance;
326						hDistance = endCoords.pageX - startCoords.pageX;
327						hDistancePercent = hDistance * 100 / winWidth;
328
329						if ( ! hSwipe && ! vSwipe && Math.abs( hDistance ) >= hSwipMinDistance ) {
330							$( '#swipebox-slider' ).css( {
331								'-webkit-transition' : '',
332								'transition' : ''
333							} );
334							hSwipe = true;
335						}
336
337						if ( hSwipe ) {
338
339							// swipe left
340							if ( 0 < hDistance ) {
341
342								// first slide
343								if ( 0 === index ) {
344									// console.log( 'first' );
345									$( '#swipebox-overlay' ).addClass( 'leftSpringTouch' );
346								} else {
347									// Follow gesture
348									$( '#swipebox-overlay' ).removeClass( 'leftSpringTouch' ).removeClass( 'rightSpringTouch' );
349									$( '#swipebox-slider' ).css( {
350										'-webkit-transform' : 'translate3d(' + ( currentX + hDistancePercent ) +'%, 0, 0)',
351										'transform' : 'translate3d(' + ( currentX + hDistancePercent ) + '%, 0, 0)'
352									} );
353								}
354
355							// swipe rught
356							} else if ( 0 > hDistance ) {
357
358								// last Slide
359								if ( elements.length === index +1 ) {
360									// console.log( 'last' );
361									$( '#swipebox-overlay' ).addClass( 'rightSpringTouch' );
362								} else {
363									$( '#swipebox-overlay' ).removeClass( 'leftSpringTouch' ).removeClass( 'rightSpringTouch' );
364									$( '#swipebox-slider' ).css( {
365										'-webkit-transform' : 'translate3d(' + ( currentX + hDistancePercent ) +'%, 0, 0)',
366										'transform' : 'translate3d(' + ( currentX + hDistancePercent ) + '%, 0, 0)'
367									} );
368								}
369
370							}
371						}
372					} );
373
374					return false;
375
376				} ).bind( 'touchend',function( event ) {
377					event.preventDefault();
378					event.stopPropagation();
379
380					$( '#swipebox-slider' ).css( {
381						'-webkit-transition' : '-webkit-transform 0.4s ease',
382						'transition' : 'transform 0.4s ease'
383					} );
384
385					vDistance = endCoords.pageY - startCoords.pageY;
386					hDistance = endCoords.pageX - startCoords.pageX;
387					hDistancePercent = hDistance*100/winWidth;
388
389					// Swipe to bottom to close
390					if ( vSwipe ) {
391						vSwipe = false;
392						if ( Math.abs( vDistance ) >= 2 * vSwipMinDistance && Math.abs( vDistance ) > Math.abs( vDistanceLast ) ) {
393							var vOffset = vDistance > 0 ? slider.height() : - slider.height();
394							slider.animate( { top: vOffset + 'px', 'opacity': 0 },
395								300,
396								function () {
397									$this.closeSlide();
398								} );
399						} else {
400							slider.animate( { top: 0, 'opacity': 1 }, 300 );
401						}
402
403					} else if ( hSwipe ) {
404
405						hSwipe = false;
406
407						// swipeLeft
408						if( hDistance >= hSwipMinDistance && hDistance >= hDistanceLast) {
409
410							$this.getPrev();
411
412						// swipeRight
413						} else if ( hDistance <= -hSwipMinDistance && hDistance <= hDistanceLast) {
414
415							$this.getNext();
416						}
417
418					} else { // Top and bottom bars have been removed on touchable devices
419						// tap
420						if ( ! bars.hasClass( 'visible-bars' ) ) {
421							$this.showBars();
422							$this.setTimeout();
423						} else {
424							$this.clearTimeout();
425							$this.hideBars();
426						}
427					}
428
429					$( '#swipebox-slider' ).css( {
430						'-webkit-transform' : 'translate3d(' + currentX + '%, 0, 0)',
431						'transform' : 'translate3d(' + currentX + '%, 0, 0)'
432					} );
433
434					$( '#swipebox-overlay' ).removeClass( 'leftSpringTouch' ).removeClass( 'rightSpringTouch' );
435					$( '.touching' ).off( 'touchmove' ).removeClass( 'touching' );
436
437				} );
438			},
439
440			/**
441			 * Set timer to hide the action bars
442			 */
443			setTimeout: function () {
444				if ( plugin.settings.hideBarsDelay > 0 ) {
445					var $this = this;
446					$this.clearTimeout();
447					$this.timeout = window.setTimeout( function() {
448							$this.hideBars();
449						},
450
451						plugin.settings.hideBarsDelay
452					);
453				}
454			},
455
456			/**
457			 * Clear timer
458			 */
459			clearTimeout: function () {
460				window.clearTimeout( this.timeout );
461				this.timeout = null;
462			},
463
464			/**
465			 * Show navigation and title bars
466			 */
467			showBars : function () {
468				var bars = $( '#swipebox-top-bar, #swipebox-bottom-bar' );
469				if ( this.doCssTrans() ) {
470					bars.addClass( 'visible-bars' );
471				} else {
472					$( '#swipebox-top-bar' ).animate( { top : 0 }, 500 );
473					$( '#swipebox-bottom-bar' ).animate( { bottom : 0 }, 500 );
474					setTimeout( function() {
475						bars.addClass( 'visible-bars' );
476					}, 1000 );
477				}
478			},
479
480			/**
481			 * Hide navigation and title bars
482			 */
483			hideBars : function () {
484				var bars = $( '#swipebox-top-bar, #swipebox-bottom-bar' );
485				if ( this.doCssTrans() ) {
486					bars.removeClass( 'visible-bars' );
487				} else {
488					$( '#swipebox-top-bar' ).animate( { top : '-50px' }, 500 );
489					$( '#swipebox-bottom-bar' ).animate( { bottom : '-50px' }, 500 );
490					setTimeout( function() {
491						bars.removeClass( 'visible-bars' );
492					}, 1000 );
493				}
494			},
495
496			/**
497			 * Animate navigation and top bars
498			 */
499			animBars : function () {
500				var $this = this,
501					bars = $( '#swipebox-top-bar, #swipebox-bottom-bar' );
502
503				bars.addClass( 'visible-bars' );
504				$this.setTimeout();
505
506				$( '#swipebox-slider' ).click( function() {
507					if ( ! bars.hasClass( 'visible-bars' ) ) {
508						$this.showBars();
509						$this.setTimeout();
510					}
511				} );
512
513				$( '#swipebox-bottom-bar' ).hover( function() {
514					$this.showBars();
515					bars.addClass( 'visible-bars' );
516					$this.clearTimeout();
517
518				}, function() {
519					if ( plugin.settings.hideBarsDelay > 0 ) {
520						bars.removeClass( 'visible-bars' );
521						$this.setTimeout();
522					}
523
524				} );
525			},
526
527			/**
528			 * Keyboard navigation
529			 */
530			keyboard : function () {
531				var $this = this;
532				$( window ).bind( 'keyup', function( event ) {
533					event.preventDefault();
534					event.stopPropagation();
535
536					if ( event.keyCode === 37 ) {
537
538						$this.getPrev();
539
540					} else if ( event.keyCode === 39 ) {
541
542						$this.getNext();
543
544					} else if ( event.keyCode === 27 ) {
545
546						$this.closeSlide();
547					}
548				} );
549			},
550
551			/**
552			 * Navigation events : go to next slide, go to prevous slide and close
553			 */
554			actions : function () {
555				var $this = this,
556					action = 'touchend click'; // Just detect for both event types to allow for multi-input
557
558				if ( elements.length < 2 ) {
559
560					$( '#swipebox-bottom-bar' ).hide();
561
562					if ( undefined === elements[ 1 ] ) {
563						$( '#swipebox-top-bar' ).hide();
564					}
565
566				} else {
567					$( '#swipebox-prev' ).bind( action, function( event ) {
568						event.preventDefault();
569						event.stopPropagation();
570						$this.getPrev();
571						$this.setTimeout();
572					} );
573
574					$( '#swipebox-next' ).bind( action, function( event ) {
575						event.preventDefault();
576						event.stopPropagation();
577						$this.getNext();
578						$this.setTimeout();
579					} );
580				}
581
582				$( '#swipebox-close' ).bind( action, function() {
583					$this.closeSlide();
584				} );
585			},
586
587			/**
588			 * Set current slide
589			 */
590			setSlide : function ( index, isFirst ) {
591
592				isFirst = isFirst || false;
593
594				var slider = $( '#swipebox-slider' );
595
596				currentX = -index*100;
597
598				if ( this.doCssTrans() ) {
599					slider.css( {
600						'-webkit-transform' : 'translate3d(' + (-index*100)+'%, 0, 0)',
601						'transform' : 'translate3d(' + (-index*100)+'%, 0, 0)'
602					} );
603				} else {
604					slider.animate( { left : ( -index*100 )+'%' } );
605				}
606
607				$( '#swipebox-slider .slide' ).removeClass( 'current' );
608				$( '#swipebox-slider .slide' ).eq( index ).addClass( 'current' );
609				this.setTitle( index );
610
611				if ( isFirst ) {
612					slider.fadeIn();
613				}
614
615				$( '#swipebox-prev, #swipebox-next' ).removeClass( 'disabled' );
616
617				if ( index === 0 ) {
618					$( '#swipebox-prev' ).addClass( 'disabled' );
619				} else if ( index === elements.length - 1 && plugin.settings.loopAtEnd !== true ) {
620					$( '#swipebox-next' ).addClass( 'disabled' );
621				}
622			},
623
624			/**
625			 * Open slide
626			 */
627			openSlide : function ( index ) {
628				$( 'html' ).addClass( 'swipebox-html' );
629				if ( isTouch ) {
630					$( 'html' ).addClass( 'swipebox-touch' );
631
632					if ( plugin.settings.hideCloseButtonOnMobile ) {
633						$( 'html' ).addClass( 'swipebox-no-close-button' );
634					}
635				} else {
636					$( 'html' ).addClass( 'swipebox-no-touch' );
637				}
638				$( window ).trigger( 'resize' ); // fix scroll bar visibility on desktop
639				this.setSlide( index, true );
640			},
641
642			/**
643			 * Set a time out if the media is a video
644			 */
645			preloadMedia : function ( index ) {
646				var $this = this,
647					src = null;
648
649				if ( elements[ index ] !== undefined ) {
650					src = elements[ index ].href;
651				}
652
653				if ( ! $this.isVideo( src ) ) {
654					setTimeout( function() {
655						$this.openMedia( index );
656					}, 1000);
657				} else {
658					$this.openMedia( index );
659				}
660			},
661
662			/**
663			 * Open
664			 */
665			openMedia : function ( index ) {
666				var $this = this,
667					src,
668					slide;
669
670				if ( elements[ index ] !== undefined ) {
671					src = elements[ index ].href;
672				}
673
674				if ( index < 0 || index >= elements.length ) {
675					return false;
676				}
677
678				slide = $( '#swipebox-slider .slide' ).eq( index );
679
680				if ( ! $this.isVideo( src ) ) {
681					slide.addClass( 'slide-loading' );
682					$this.loadMedia( src, function() {
683						slide.removeClass( 'slide-loading' );
684						slide.html( this );
685					} );
686				} else {
687					slide.html( $this.getVideo( src ) );
688				}
689
690			},
691
692			/**
693			 * Set link title attribute as caption
694			 */
695			setTitle : function ( index ) {
696				var title = null;
697
698				$( '#swipebox-title' ).empty();
699
700				if ( elements[ index ] !== undefined ) {
701					title = elements[ index ].title;
702				}
703
704				if ( title ) {
705					$( '#swipebox-top-bar' ).show();
706					$( '#swipebox-title' ).append( title );
707				} else {
708					$( '#swipebox-top-bar' ).hide();
709				}
710			},
711
712			/**
713			 * Check if the URL is a video
714			 */
715			isVideo : function ( src ) {
716
717				if ( src ) {
718					if ( src.match( /youtube\.com\/watch\?v=([a-zA-Z0-9\-_]+)/) || src.match( /vimeo\.com\/([0-9]*)/ ) || src.match( /youtu\.be\/([a-zA-Z0-9\-_]+)/ ) ) {
719						return true;
720					}
721
722					if ( src.toLowerCase().indexOf( 'swipeboxvideo=1' ) >= 0 ) {
723
724						return true;
725					}
726				}
727
728			},
729
730			/**
731			 * Get video iframe code from URL
732			 */
733			getVideo : function( url ) {
734				var iframe = '',
735					youtubeUrl = url.match( /watch\?v=([a-zA-Z0-9\-_]+)/ ),
736					youtubeShortUrl = url.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/),
737					vimeoUrl = url.match( /vimeo\.com\/([0-9]*)/ );
738				if ( youtubeUrl || youtubeShortUrl) {
739					if ( youtubeShortUrl ) {
740						youtubeUrl = youtubeShortUrl;
741					}
742					iframe = '<iframe width="560" height="315" src="//www.youtube.com/embed/' + youtubeUrl[1] + '?autoplay='+ plugin.settings.autoplayVideos + '" frameborder="0" allowfullscreen></iframe>';
743
744				} else if ( vimeoUrl ) {
745
746					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>';
747
748				}
749
750				if ( youtubeUrl || youtubeShortUrl || vimeoUrl ) {
751
752				} else {
753					iframe = '<iframe width="560" height="315" src="' + url + '" frameborder="0" allowfullscreen></iframe>';
754				}
755
756				return '<div class="swipebox-video-container" style="max-width:' + plugin.settings.videomaxWidth + 'px"><div class="swipebox-video">' + iframe + '</div></div>';
757			},
758
759			/**
760			 * Load image
761			 */
762			loadMedia : function ( src, callback ) {
763				if ( ! this.isVideo( src ) ) {
764					var img = $( '<img>' ).on( 'load', function() {
765						callback.call( img );
766					} );
767
768					img.attr( 'src', src );
769				}
770			},
771
772			/**
773			 * Get next slide
774			 */
775			getNext : function () {
776				var $this = this,
777					src,
778					index = $( '#swipebox-slider .slide' ).index( $( '#swipebox-slider .slide.current' ) );
779				if ( index + 1 < elements.length ) {
780
781					src = $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src' );
782					$( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src', src );
783					index++;
784					$this.setSlide( index );
785					$this.preloadMedia( index+1 );
786				} else {
787
788					if ( plugin.settings.loopAtEnd === true ) {
789						src = $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src' );
790						$( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src', src );
791						index = 0;
792						$this.preloadMedia( index );
793						$this.setSlide( index );
794						$this.preloadMedia( index + 1 );
795					} else {
796						$( '#swipebox-overlay' ).addClass( 'rightSpring' );
797						setTimeout( function() {
798							$( '#swipebox-overlay' ).removeClass( 'rightSpring' );
799						}, 500 );
800					}
801				}
802			},
803
804			/**
805			 * Get previous slide
806			 */
807			getPrev : function () {
808				var index = $( '#swipebox-slider .slide' ).index( $( '#swipebox-slider .slide.current' ) ),
809					src;
810				if ( index > 0 ) {
811					src = $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe').attr( 'src' );
812					$( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src', src );
813					index--;
814					this.setSlide( index );
815					this.preloadMedia( index-1 );
816				} else {
817					$( '#swipebox-overlay' ).addClass( 'leftSpring' );
818					setTimeout( function() {
819						$( '#swipebox-overlay' ).removeClass( 'leftSpring' );
820					}, 500 );
821				}
822			},
823
824			/**
825			 * Close
826			 */
827			closeSlide : function () {
828				$( 'html' ).removeClass( 'swipebox-html' );
829				$( 'html' ).removeClass( 'swipebox-touch' );
830				$( window ).trigger( 'resize' );
831				this.destroy();
832			},
833
834			/**
835			 * Destroy the whole thing
836			 */
837			destroy : function () {
838				$( window ).unbind( 'keyup' );
839				$( 'body' ).unbind( 'touchstart' );
840				$( 'body' ).unbind( 'touchmove' );
841				$( 'body' ).unbind( 'touchend' );
842				$( '#swipebox-slider' ).unbind();
843				$( '#swipebox-overlay' ).remove();
844
845				if ( ! $.isArray( elem ) ) {
846					elem.removeData( '_swipebox' );
847				}
848
849				if ( this.target ) {
850					this.target.trigger( 'swipebox-destroy' );
851				}
852
853				$.swipebox.isOpen = false;
854
855				if ( plugin.settings.afterClose ) {
856					plugin.settings.afterClose();
857				}
858			}
859		};
860
861		plugin.init();
862	};
863
864	$.fn.swipebox = function( options ) {
865
866		if ( ! $.data( this, '_swipebox' ) ) {
867			var swipebox = new $.swipebox( this, options );
868			this.data( '_swipebox', swipebox );
869		}
870		return this.data( '_swipebox' );
871
872	};
873
874}( window, document, jQuery ) );

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.