Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions source/shadowbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@
// Opacity for the overlay.
overlayOpacity: 0.5,

// Parent element for the overlay. This should be a DOM element.
parentElement: document.body,

// The index in the current gallery at which to start when first opening.
startIndex: 0

Expand Down Expand Up @@ -115,7 +118,7 @@
/**
* Appends Shadowbox to the DOM and initializes DOM references.
*/
function initialize() {
function initialize(parentElement) {
if (containerElement)
return; // Don't initialize twice!

Expand Down Expand Up @@ -145,7 +148,7 @@
var previousElement = makeDom("div", { id: "sb-prev" });

// Append #shadowbox to the DOM.
makeDom(document.body, [
makeDom(parentElement, [
makeDom(containerElement, [
overlayElement,
makeDom(wrapperElement, [
Expand Down Expand Up @@ -224,7 +227,7 @@
// Display the first item in the gallery, if there's anything left.
if (currentGallery.length > 0) {
if (currentIndex == -1) {
initialize();
initialize(currentOptions.parentElement);

if (isFunction(currentOptions.onOpen))
currentOptions.onOpen();
Expand Down