PageSourceSearch

https://www.stocanada.com/wp-content/plugins/sto-docs-management-t…/assets/js/jquery.swipebox.min.js?ver=1.3.1

js stocanada.com collected 2026-10-04 01:37:03 UTC 35,954 bytes, 969 lines download raw bytes

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