|
111 | 111 | $elem = $( selector ); |
112 | 112 | } |
113 | 113 |
|
| 114 | + var include = function(haystack, needle) { |
| 115 | + for (var i = 0; i < haystack.length; i++) { |
| 116 | + if(haystack[i] === needle) { return(true); } |
| 117 | + } |
| 118 | + return(false); |
| 119 | + }, |
| 120 | + hrefs = [], |
| 121 | + i = 0, |
| 122 | + currentHref = $(this).attr('href'); |
| 123 | + |
114 | 124 | $elem.each( function() { |
115 | 125 |
|
116 | 126 | var title = null, |
|
120 | 130 | title = $( this ).attr( 'title' ); |
121 | 131 | } |
122 | 132 |
|
123 | | - |
124 | 133 | if ( $( this ).attr( 'href' ) ) { |
125 | 134 | href = $( this ).attr( 'href' ); |
126 | 135 | } |
127 | 136 |
|
128 | | - elements.push( { |
129 | | - href: href, |
130 | | - title: title |
131 | | - } ); |
| 137 | + if(include(hrefs, href)) { |
| 138 | + } else { |
| 139 | + if(currentHref === href) { index = i; } |
| 140 | + hrefs.push(href); |
| 141 | + elements.push( { |
| 142 | + href: href, |
| 143 | + title: title |
| 144 | + } ); |
| 145 | + i++; |
| 146 | + } |
132 | 147 | } ); |
133 | 148 |
|
134 | | - index = $elem.index( $( this ) ); |
135 | 149 | event.preventDefault(); |
136 | 150 | event.stopPropagation(); |
137 | 151 | ui.target = $( event.target ); |
|
220 | 234 | } |
221 | 235 | }, false ); |
222 | 236 |
|
223 | | - |
224 | 237 | } else { |
225 | 238 |
|
226 | 239 | width = window.innerWidth ? window.innerWidth : $( window ).width(); |
|
756 | 769 | if ( a.search ) { |
757 | 770 | qs = JSON.parse( '{"' + a.search.toLowerCase().replace('?','').replace(/&/g,'","').replace(/=/g,'":"') + '"}' ); |
758 | 771 | } |
759 | | - |
| 772 | + |
760 | 773 | // Extend with custom data |
761 | 774 | if ( $.isPlainObject( customData ) ) { |
762 | 775 | qs = $.extend( qs, customData, plugin.settings.queryStringData ); // The dev has always the final word |
|
798 | 811 | 'portrait' : '0', |
799 | 812 | 'color': plugin.settings.vimeoColor |
800 | 813 | }); |
801 | | - iframe = '<iframe width="560" height="315" src="//player.vimeo.com/video/' + vimeoUrl[1] + '?' + qs + '" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'; |
| 814 | + iframe = '<iframe width="560" height="315" src="//player.vimeo.com/video/' + vimeoUrl[1] + '?' + qs + '" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'; |
802 | 815 |
|
803 | 816 | } else { |
804 | 817 | iframe = '<iframe width="560" height="315" src="' + url + '" frameborder="0" allowfullscreen></iframe>'; |
|
811 | 824 | * Load image |
812 | 825 | */ |
813 | 826 | loadMedia : function ( src, callback ) { |
814 | | - // Inline content |
815 | | - if ( src.trim().indexOf('#') === 0 ) { |
816 | | - callback.call( |
817 | | - $('<div>', { |
818 | | - 'class' : 'swipebox-inline-container' |
819 | | - }) |
820 | | - .append( |
821 | | - $(src) |
822 | | - .clone() |
823 | | - .toggleClass( plugin.settings.toggleClassOnLoad ) |
824 | | - ) |
825 | | - ); |
826 | | - } |
827 | | - // Everything else |
828 | | - else { |
829 | | - if ( ! this.isVideo( src ) ) { |
830 | | - var img = $( '<img>' ).on( 'load', function() { |
831 | | - callback.call( img ); |
832 | | - } ); |
833 | | - |
834 | | - img.attr( 'src', src ); |
835 | | - } |
836 | | - } |
| 827 | + // Inline content |
| 828 | + if ( src.trim().indexOf('#') === 0 ) { |
| 829 | + callback.call( |
| 830 | + $('<div>', { |
| 831 | + 'class' : 'swipebox-inline-container' |
| 832 | + }) |
| 833 | + .append( |
| 834 | + $(src) |
| 835 | + .clone() |
| 836 | + .toggleClass( plugin.settings.toggleClassOnLoad ) |
| 837 | + ) |
| 838 | + ); |
| 839 | + } |
| 840 | + // Everything else |
| 841 | + else { |
| 842 | + if ( ! this.isVideo( src ) ) { |
| 843 | + var img = $( '<img>' ).on( 'load', function() { |
| 844 | + callback.call( img ); |
| 845 | + } ); |
| 846 | + |
| 847 | + img.attr( 'src', src ); |
| 848 | + } |
| 849 | + } |
837 | 850 | }, |
838 | 851 |
|
839 | 852 | /** |
|
0 commit comments