Skip to content

Commit cab5bc8

Browse files
author
Julian Xhokaxhiu
committed
Add support for inline content.
Fix also videoMaxWidth parameter.
1 parent 198056f commit cab5bc8

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

src/js/jquery.swipebox.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
afterClose: null,
2121
loopAtEnd: false,
2222
autoplayVideos: false,
23-
queryStringData: {}
23+
queryStringData: {},
24+
toggleClassOnLoad: ''
2425
},
2526

2627
plugin = this,
@@ -791,20 +792,31 @@
791792
iframe = '<iframe width="560" height="315" src="' + url + '" frameborder="0" allowfullscreen></iframe>';
792793
}
793794

794-
return '<div class="swipebox-video-container" style="max-width:' + plugin.settings.videomaxWidth + 'px"><div class="swipebox-video">' + iframe + '</div></div>';
795+
return '<div class="swipebox-video-container" style="max-width:' + plugin.settings.videoMaxWidth + 'px"><div class="swipebox-video">' + iframe + '</div></div>';
795796
},
796797

797798
/**
798799
* Load image
799800
*/
800801
loadMedia : function ( src, callback ) {
801-
if ( ! this.isVideo( src ) ) {
802-
var img = $( '<img>' ).on( 'load', function() {
803-
callback.call( img );
804-
} );
805-
806-
img.attr( 'src', src );
807-
}
802+
// Inline content
803+
if ( src.trim().indexOf('#') === 0 ) {
804+
callback.call(
805+
$(src)
806+
.clone()
807+
.toggleClass( plugin.settings.toggleClassOnLoad )
808+
);
809+
}
810+
// Everything else
811+
else {
812+
if ( ! this.isVideo( src ) ) {
813+
var img = $( '<img>' ).on( 'load', function() {
814+
callback.call( img );
815+
} );
816+
817+
img.attr( 'src', src );
818+
}
819+
}
808820
},
809821

810822
/**

0 commit comments

Comments
 (0)