9292 }
9393
9494 elements = [ ] ;
95- var index , relType , relVal ;
95+ var index , relType , relVal ;
9696
9797 // Allow for HTML5 compliant attribute before legacy use of rel
9898 if ( ! relVal ) {
9999 relType = 'data-rel' ;
100- relVal = $ ( this ) . attr ( relType ) ;
100+ relVal = $ ( this ) . attr ( relType ) ;
101101 }
102102
103103 if ( ! relVal ) {
111111 $elem = $ ( selector ) ;
112112 }
113113
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+
114124 $elem . each ( function ( ) {
115125
116126 var title = null ,
120130 title = $ ( this ) . attr ( 'title' ) ;
121131 }
122132
123-
124133 if ( $ ( this ) . attr ( 'href' ) ) {
125134 href = $ ( this ) . attr ( 'href' ) ;
126135 }
127136
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+ }
132147 } ) ;
133148
134- index = $elem . index ( $ ( this ) ) ;
135149 event . preventDefault ( ) ;
136150 event . stopPropagation ( ) ;
137151 ui . target = $ ( event . target ) ;
220234 }
221235 } , false ) ;
222236
223-
224237 } else {
225238
226239 width = window . innerWidth ? window . innerWidth : $ ( window ) . width ( ) ;
748761 if ( a . search ) {
749762 qs = JSON . parse ( '{"' + a . search . toLowerCase ( ) . replace ( '?' , '' ) . replace ( / & / g, '","' ) . replace ( / = / g, '":"' ) + '"}' ) ;
750763 }
751-
764+
752765 // Extend with custom data
753766 if ( $ . isPlainObject ( customData ) ) {
754767 qs = $ . extend ( qs , customData , plugin . settings . queryStringData ) ; // The dev has always the final word
790803 'portrait' : '0' ,
791804 'color' : plugin . settings . vimeoColor
792805 } ) ;
793- iframe = '<iframe width="560" height="315" src="//player.vimeo.com/video/' + vimeoUrl [ 1 ] + '?' + qs + '" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>' ;
806+ iframe = '<iframe width="560" height="315" src="//player.vimeo.com/video/' + vimeoUrl [ 1 ] + '?' + qs + '" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>' ;
794807
795808 } else {
796809 iframe = '<iframe width="560" height="315" src="' + url + '" frameborder="0" allowfullscreen></iframe>' ;
803816 * Load image
804817 */
805818 loadMedia : function ( src , callback ) {
806- // Inline content
807- if ( src . trim ( ) . indexOf ( '#' ) === 0 ) {
808- callback . call (
809- $ ( '<div>' , {
810- 'class' : 'swipebox-inline-container'
811- } )
812- . append (
813- $ ( src )
814- . clone ( )
815- . toggleClass ( plugin . settings . toggleClassOnLoad )
816- )
817- ) ;
818- }
819- // Everything else
820- else {
821- if ( ! this . isVideo ( src ) ) {
822- var img = $ ( '<img>' ) . on ( 'load' , function ( ) {
823- callback . call ( img ) ;
824- } ) ;
825-
826- img . attr ( 'src' , src ) ;
827- }
828- }
819+ // Inline content
820+ if ( src . trim ( ) . indexOf ( '#' ) === 0 ) {
821+ callback . call (
822+ $ ( '<div>' , {
823+ 'class' : 'swipebox-inline-container'
824+ } )
825+ . append (
826+ $ ( src )
827+ . clone ( )
828+ . toggleClass ( plugin . settings . toggleClassOnLoad )
829+ )
830+ ) ;
831+ }
832+ // Everything else
833+ else {
834+ if ( ! this . isVideo ( src ) ) {
835+ var img = $ ( '<img>' ) . on ( 'load' , function ( ) {
836+ callback . call ( img ) ;
837+ } ) ;
838+
839+ img . attr ( 'src' , src ) ;
840+ }
841+ }
829842 } ,
830843
831844 /**
947960
948961 } ;
949962
950- } ( window , document , jQuery ) ) ;
963+ } ( window , document , jQuery ) ) ;
0 commit comments