From 446f388a4465680823132237c01b938846da5d0e Mon Sep 17 00:00:00 2001 From: "Jacob M. Roufa" Date: Wed, 12 Nov 2014 13:16:08 -0600 Subject: [PATCH] Add ability to set a parent element for the player --- source/shadowbox.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/shadowbox.js b/source/shadowbox.js index e5b4757..3c7a293 100644 --- a/source/shadowbox.js +++ b/source/shadowbox.js @@ -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 @@ -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! @@ -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, [ @@ -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();