Skip to content

Commit

Permalink
Removes duplicates from gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
firedev committed Mar 15, 2016
1 parent c622743 commit 1b9344d
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 41 deletions.
8 changes: 0 additions & 8 deletions src/css/swipebox.css
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,9 @@ html.swipebox-html.swipebox-touch {
0% {
left: 0;
}

50% {
left: -30px;
}

100% {
left: 0;
}
Expand All @@ -229,11 +227,9 @@ html.swipebox-html.swipebox-touch {
0% {
left: 0;
}

50% {
left: -30px;
}

100% {
left: 0;
}
Expand All @@ -242,11 +238,9 @@ html.swipebox-html.swipebox-touch {
0% {
left: 0;
}

50% {
left: 30px;
}

100% {
left: 0;
}
Expand All @@ -255,11 +249,9 @@ html.swipebox-html.swipebox-touch {
0% {
left: 0;
}

50% {
left: 30px;
}

100% {
left: 0;
}
Expand Down
77 changes: 45 additions & 32 deletions src/js/jquery.swipebox.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@
$elem = $( selector );
}

var include = function(haystack, needle) {
for (var i = 0; i < haystack.length; i++) {
if(haystack[i] === needle) { return(true); }
}
return(false);
},
hrefs = [],
i = 0,
currentHref = $(this).attr('href');

$elem.each( function() {

var title = null,
Expand All @@ -120,18 +130,22 @@
title = $( this ).attr( 'title' );
}


if ( $( this ).attr( 'href' ) ) {
href = $( this ).attr( 'href' );
}

elements.push( {
href: href,
title: title
} );
if(include(hrefs, href)) {
} else {
if(currentHref === href) { index = i; }
hrefs.push(href);
elements.push( {
href: href,
title: title
} );
i++;
}
} );

index = $elem.index( $( this ) );
event.preventDefault();
event.stopPropagation();
ui.target = $( event.target );
Expand Down Expand Up @@ -220,7 +234,6 @@
}
}, false );


} else {

width = window.innerWidth ? window.innerWidth : $( window ).width();
Expand Down Expand Up @@ -756,7 +769,7 @@
if ( a.search ) {
qs = JSON.parse( '{"' + a.search.toLowerCase().replace('?','').replace(/&/g,'","').replace(/=/g,'":"') + '"}' );
}

// Extend with custom data
if ( $.isPlainObject( customData ) ) {
qs = $.extend( qs, customData, plugin.settings.queryStringData ); // The dev has always the final word
Expand Down Expand Up @@ -798,7 +811,7 @@
'portrait' : '0',
'color': plugin.settings.vimeoColor
});
iframe = '<iframe width="560" height="315" src="//player.vimeo.com/video/' + vimeoUrl[1] + '?' + qs + '" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
iframe = '<iframe width="560" height="315" src="//player.vimeo.com/video/' + vimeoUrl[1] + '?' + qs + '" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';

} else {
iframe = '<iframe width="560" height="315" src="' + url + '" frameborder="0" allowfullscreen></iframe>';
Expand All @@ -811,29 +824,29 @@
* Load image
*/
loadMedia : function ( src, callback ) {
// Inline content
if ( src.trim().indexOf('#') === 0 ) {
callback.call(
$('<div>', {
'class' : 'swipebox-inline-container'
})
.append(
$(src)
.clone()
.toggleClass( plugin.settings.toggleClassOnLoad )
)
);
}
// Everything else
else {
if ( ! this.isVideo( src ) ) {
var img = $( '<img>' ).on( 'load', function() {
callback.call( img );
} );

img.attr( 'src', src );
}
}
// Inline content
if ( src.trim().indexOf('#') === 0 ) {
callback.call(
$('<div>', {
'class' : 'swipebox-inline-container'
})
.append(
$(src)
.clone()
.toggleClass( plugin.settings.toggleClassOnLoad )
)
);
}
// Everything else
else {
if ( ! this.isVideo( src ) ) {
var img = $( '<img>' ).on( 'load', function() {
callback.call( img );
} );

img.attr( 'src', src );
}
}
},

/**
Expand Down
Loading

0 comments on commit 1b9344d

Please sign in to comment.