fslightbox 3.3.1 → 3.3.2-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/FsLightbox.js +110 -0
- package/README.md +37 -33
- package/components/helpers/renderSvg.js +17 -0
- package/components/nav/renderAndGetToolbarButton.js +11 -0
- package/components/nav/renderCloseButton.js +10 -0
- package/components/nav/renderFullscreenButton.js +42 -0
- package/components/nav/renderNav.js +17 -0
- package/components/nav/renderSlideNumber.js +33 -0
- package/components/nav/renderToolbar.js +13 -0
- package/components/renderSlideButton.js +11 -0
- package/components/renderSlideButtonContainer.js +15 -0
- package/components/renderSlideButtons.js +7 -0
- package/components/renderSlideSwipingHoverer.js +6 -0
- package/components/sources/proper-sources/renderCustom.js +15 -0
- package/components/sources/proper-sources/renderImage.js +18 -0
- package/components/sources/proper-sources/renderInvalid.js +19 -0
- package/components/sources/proper-sources/renderVideo.js +31 -0
- package/components/sources/proper-sources/renderYoutube.js +26 -0
- package/components/sources/renderSourceAnimationWrapper.js +4 -0
- package/components/sources/renderSourceMainWrapper.js +32 -0
- package/components/sources/renderSourceWrappersContainer.js +22 -0
- package/constants/classes-names.js +27 -0
- package/constants/core-constants.js +6 -0
- package/constants/css-constants.js +1 -0
- package/constants/dom-constants.js +1 -0
- package/constants/elements.js +3 -0
- package/constants/local-storage-constants.js +2 -0
- package/core/collections/fillSourcesOutersTransformersCollection.js +13 -0
- package/core/elements/setUpClassFacade.js +9 -0
- package/core/events/setUpEventsDispatcher.js +7 -0
- package/core/events/setUpGlobalEventsController.js +34 -0
- package/core/fullscreen/setUpFullscreenToggler.js +30 -0
- package/core/keyboard/KeyboardController.js +20 -0
- package/core/main-component/closing/LightboxCloseActioner.js +46 -0
- package/core/main-component/closing/setUpLightboxCloser.js +11 -0
- package/core/main-component/initializing/initializeLightbox.js +38 -0
- package/core/main-component/opening/setUpLightboxOpener.js +47 -0
- package/core/scrollbar/getInnerElementOfWidthGetter.js +5 -0
- package/core/scrollbar/getOuterElementOfWidthGetter.js +9 -0
- package/core/scrollbar/getScrollbarWidth.js +31 -0
- package/core/scrollbar/setUpScrollbarRecompensor.js +20 -0
- package/core/setUpCore.js +30 -0
- package/core/sizes/setUpWindowResizeActioner.js +35 -0
- package/core/slide/setUpSlideChangeFacade.js +23 -0
- package/core/slide/setUpSlideIndexChanger.js +60 -0
- package/core/sources/SourceLoadActioner.js +29 -0
- package/core/sources/SourceLoadHandler.js +41 -0
- package/core/sources/SourceSizer.js +36 -0
- package/core/sources/creating/CreatingSourcesBucket.js +29 -0
- package/core/sources/creating/CreatingSourcesLocalStorageManager.js +55 -0
- package/core/sources/creating/createSources.js +28 -0
- package/core/sources/pointering/down/setUpSourcesPointerDown.js +36 -0
- package/core/sources/pointering/move/SourcesPointerMove.js +16 -0
- package/core/sources/pointering/move/SourcesPointerMoveActioner.js +37 -0
- package/core/sources/pointering/up/SourcesPointerUp.js +13 -0
- package/core/sources/pointering/up/SourcesPointerUpActioner.js +38 -0
- package/core/sources/pointering/up/SourcesPointerUpActionerBucket.js +35 -0
- package/core/sources/setUpSourceDisplayFacade.js +26 -0
- package/core/sources/types/AutomaticTypeDetector.js +70 -0
- package/core/sources/types/DetectedTypeActioner.js +44 -0
- package/core/sources/types/getAutomaticTypeDetectorBucket.js +14 -0
- package/core/stage/setUpStageManager.js +60 -0
- package/core/styles/createAndAppendStyles.js +9 -0
- package/core/styles/injectStylesIfNotInDom.js +8 -0
- package/core/styles/styles-injection/styles-injection.js +5 -0
- package/core/timeouts/getQueuedAction.js +15 -0
- package/core/transforms/SourceMainWrapperTransformer.js +27 -0
- package/fslightbox.js +1 -0
- package/helpers/elements/addToElementClassIfNotContains.js +6 -0
- package/helpers/elements/removeFromElementChildIfContains.js +5 -0
- package/helpers/elements/removeFromElementClassIfContains.js +6 -0
- package/helpers/objects/assignToObject.js +10 -0
- package/helpers/source/setUpSourceClassName.js +13 -0
- package/helpers/source/setUpSourceCustomAttributes.js +5 -0
- package/helpers/state/ifOnUpdateExistsHandleItForState.js +6 -0
- package/i.js +86 -0
- package/index.js +1 -1
- package/package.json +4 -39
- package/styles.js +1 -0
- package/jest-setup.js +0 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CreatingSourcesLocalStorageManager } from "./CreatingSourcesLocalStorageManager";
|
|
2
|
+
import { DetectedTypeActioner } from "../types/DetectedTypeActioner";
|
|
3
|
+
import { CreatingSourcesBucket } from "./CreatingSourcesBucket";
|
|
4
|
+
import { CUSTOM_TYPE } from "../../../constants/core-constants";
|
|
5
|
+
|
|
6
|
+
export function createSources({ props: { sources }, resolve }) {
|
|
7
|
+
const localStorageManager = resolve(CreatingSourcesLocalStorageManager);
|
|
8
|
+
const detectedTypeActioner = resolve(DetectedTypeActioner);
|
|
9
|
+
const creatingSourcesBucket = resolve(CreatingSourcesBucket, [localStorageManager, detectedTypeActioner]);
|
|
10
|
+
|
|
11
|
+
for (let i = 0; i < sources.length; i++) {
|
|
12
|
+
if (typeof sources[i] !== "string") {
|
|
13
|
+
detectedTypeActioner.runActionsForSourceTypeAndIndex(CUSTOM_TYPE, i);
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const typeSetManuallyByClient = creatingSourcesBucket.getTypeSetByClientForIndex(i);
|
|
18
|
+
if (typeSetManuallyByClient) {
|
|
19
|
+
detectedTypeActioner.runActionsForSourceTypeAndIndex(typeSetManuallyByClient, i);
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const sourceTypeRetrievedWithoutXhr = localStorageManager.getSourceTypeFromLocalStorageByUrl(sources[i]);
|
|
24
|
+
(sourceTypeRetrievedWithoutXhr) ?
|
|
25
|
+
detectedTypeActioner.runActionsForSourceTypeAndIndex(sourceTypeRetrievedWithoutXhr, i) :
|
|
26
|
+
creatingSourcesBucket.retrieveTypeWithXhrForIndex(i);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { SOURCE_MAIN_WRAPPERS } from "../../../../constants/elements";
|
|
2
|
+
import { TRANSFORM_TRANSITION_CLASS_NAME } from "../../../../constants/classes-names";
|
|
3
|
+
|
|
4
|
+
export function setUpSourcesPointerDown(
|
|
5
|
+
{
|
|
6
|
+
core: { classFacade, sourcesPointerDown: self },
|
|
7
|
+
elements: { sources },
|
|
8
|
+
sourcePointerProps,
|
|
9
|
+
stageIndexes
|
|
10
|
+
}
|
|
11
|
+
) {
|
|
12
|
+
self.listener = (e) => {
|
|
13
|
+
/**
|
|
14
|
+
* Preventing default to disable image 'copying' behavior on Firefox desktop browser.
|
|
15
|
+
* Cannot prevent default on video click because video would become unclickable in IE11.
|
|
16
|
+
*/
|
|
17
|
+
if (e.target.tagName !== 'VIDEO') {
|
|
18
|
+
e.preventDefault();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
sourcePointerProps.isPointering = true;
|
|
22
|
+
|
|
23
|
+
sourcePointerProps.downScreenX = e.screenX;
|
|
24
|
+
|
|
25
|
+
sourcePointerProps.swipedX = 0;
|
|
26
|
+
|
|
27
|
+
const currentElement = sources[stageIndexes.current];
|
|
28
|
+
(currentElement && currentElement.contains(e.target)) ?
|
|
29
|
+
sourcePointerProps.isSourceDownEventTarget = true :
|
|
30
|
+
sourcePointerProps.isSourceDownEventTarget = false;
|
|
31
|
+
|
|
32
|
+
classFacade.removeFromEachElementClassIfContains(SOURCE_MAIN_WRAPPERS, TRANSFORM_TRANSITION_CLASS_NAME);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SourcesPointerMoveActioner } from "./SourcesPointerMoveActioner";
|
|
2
|
+
|
|
3
|
+
export function SourcesPointerMove({ props: { sources }, resolve, sourcePointerProps }) {
|
|
4
|
+
const sourcesPointerMoveActioner = resolve(SourcesPointerMoveActioner);
|
|
5
|
+
|
|
6
|
+
(sources.length === 1) ?
|
|
7
|
+
this.listener = () => {
|
|
8
|
+
// if there is only one slide we need to simulate swipe to prevent lightbox from closing
|
|
9
|
+
sourcePointerProps.swipedX = 1;
|
|
10
|
+
} :
|
|
11
|
+
this.listener = (e) => {
|
|
12
|
+
if (sourcePointerProps.isPointering) {
|
|
13
|
+
sourcesPointerMoveActioner.runActionsForEvent(e);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { CURSOR_GRABBING_CLASS_NAME } from "../../../../constants/classes-names";
|
|
2
|
+
import { addToElementClassIfNotContains } from "../../../../helpers/elements/addToElementClassIfNotContains";
|
|
3
|
+
|
|
4
|
+
export function SourcesPointerMoveActioner(
|
|
5
|
+
{
|
|
6
|
+
collections: { sourceMainWrappersTransformers },
|
|
7
|
+
elements,
|
|
8
|
+
sourcePointerProps,
|
|
9
|
+
stageIndexes
|
|
10
|
+
}
|
|
11
|
+
) {
|
|
12
|
+
this.runActionsForEvent = (e) => {
|
|
13
|
+
// we are showing InvisibleHover component in move event not in down event
|
|
14
|
+
// due to IE problems with videos sources controlling
|
|
15
|
+
if (!elements.container.contains(elements.slideSwipingHoverer)) {
|
|
16
|
+
elements.container.appendChild(elements.slideSwipingHoverer);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
addToElementClassIfNotContains(elements.container, CURSOR_GRABBING_CLASS_NAME);
|
|
20
|
+
|
|
21
|
+
sourcePointerProps.swipedX = e.screenX - sourcePointerProps.downScreenX;
|
|
22
|
+
|
|
23
|
+
transformSourceHolderAtIndexToPosition(stageIndexes.current, 'zero');
|
|
24
|
+
// if there are only two slides we need to check if source we want to transform exists
|
|
25
|
+
if (stageIndexes.previous !== undefined && sourcePointerProps.swipedX > 0) {
|
|
26
|
+
transformSourceHolderAtIndexToPosition(stageIndexes.previous, 'negative');
|
|
27
|
+
} else if (stageIndexes.next !== undefined && sourcePointerProps.swipedX < 0) {
|
|
28
|
+
transformSourceHolderAtIndexToPosition(stageIndexes.next, 'positive');
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
function transformSourceHolderAtIndexToPosition(index, position) {
|
|
33
|
+
sourceMainWrappersTransformers[index]
|
|
34
|
+
.byValue(sourcePointerProps.swipedX)
|
|
35
|
+
[position]();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SourcesPointerUpActioner } from "./SourcesPointerUpActioner";
|
|
2
|
+
|
|
3
|
+
export function SourcesPointerUp({ resolve, sourcePointerProps }) {
|
|
4
|
+
const sourcesPointerUpActioner = resolve(SourcesPointerUpActioner);
|
|
5
|
+
|
|
6
|
+
this.listener = () => {
|
|
7
|
+
if (sourcePointerProps.isPointering) {
|
|
8
|
+
(sourcePointerProps.swipedX) ?
|
|
9
|
+
sourcesPointerUpActioner.runActions() :
|
|
10
|
+
sourcesPointerUpActioner.runNoSwipeActions();
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { SourcesPointerUpActionerBucket } from "./SourcesPointerUpActionerBucket";
|
|
2
|
+
import { CURSOR_GRABBING_CLASS_NAME } from "../../../../constants/classes-names";
|
|
3
|
+
import { removeFromElementChildIfContains } from '../../../../helpers/elements/removeFromElementChildIfContains';
|
|
4
|
+
|
|
5
|
+
export function SourcesPointerUpActioner(
|
|
6
|
+
{
|
|
7
|
+
core: { lightboxCloser },
|
|
8
|
+
elements,
|
|
9
|
+
resolve,
|
|
10
|
+
sourcePointerProps
|
|
11
|
+
}
|
|
12
|
+
) {
|
|
13
|
+
const sourcesPointerUpActionsBucket = resolve(SourcesPointerUpActionerBucket);
|
|
14
|
+
|
|
15
|
+
this.runNoSwipeActions = () => {
|
|
16
|
+
removeFromElementChildIfContains(elements.container, elements.slideSwipingHoverer);
|
|
17
|
+
|
|
18
|
+
if (!sourcePointerProps.isSourceDownEventTarget) {
|
|
19
|
+
lightboxCloser.closeLightbox();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
sourcePointerProps.isPointering = false;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
this.runActions = () => {
|
|
26
|
+
if (sourcePointerProps.swipedX > 0) {
|
|
27
|
+
sourcesPointerUpActionsBucket.runPositiveSwipedXActions();
|
|
28
|
+
} else {
|
|
29
|
+
sourcesPointerUpActionsBucket.runNegativeSwipedXActions();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
removeFromElementChildIfContains(elements.container, elements.slideSwipingHoverer);
|
|
33
|
+
|
|
34
|
+
elements.container.classList.remove(CURSOR_GRABBING_CLASS_NAME);
|
|
35
|
+
|
|
36
|
+
sourcePointerProps.isPointering = false;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { TRANSFORM_TRANSITION_CLASS_NAME } from "../../../../constants/classes-names";
|
|
2
|
+
|
|
3
|
+
export function SourcesPointerUpActionerBucket(
|
|
4
|
+
{
|
|
5
|
+
collections: { sourceMainWrappersTransformers },
|
|
6
|
+
core: { slideIndexChanger },
|
|
7
|
+
elements: { sourceMainWrappers },
|
|
8
|
+
stageIndexes
|
|
9
|
+
}
|
|
10
|
+
) {
|
|
11
|
+
this.runPositiveSwipedXActions = () => {
|
|
12
|
+
if (stageIndexes.previous === undefined) {
|
|
13
|
+
addTransitionToCurrentSourceHolderAndTransformItToPosition('zero');
|
|
14
|
+
} else {
|
|
15
|
+
addTransitionToCurrentSourceHolderAndTransformItToPosition('positive');
|
|
16
|
+
slideIndexChanger.changeTo(stageIndexes.previous);
|
|
17
|
+
addTransitionToCurrentSourceHolderAndTransformItToPosition('zero');
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
this.runNegativeSwipedXActions = () => {
|
|
22
|
+
if (stageIndexes.next === undefined) {
|
|
23
|
+
addTransitionToCurrentSourceHolderAndTransformItToPosition('zero');
|
|
24
|
+
} else {
|
|
25
|
+
addTransitionToCurrentSourceHolderAndTransformItToPosition('negative');
|
|
26
|
+
slideIndexChanger.changeTo(stageIndexes.next);
|
|
27
|
+
addTransitionToCurrentSourceHolderAndTransformItToPosition('zero');
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const addTransitionToCurrentSourceHolderAndTransformItToPosition = (position) => {
|
|
32
|
+
sourceMainWrappers[stageIndexes.current].classList.add(TRANSFORM_TRANSITION_CLASS_NAME);
|
|
33
|
+
sourceMainWrappersTransformers[stageIndexes.current][position]();
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export function setUpSourceDisplayFacade(
|
|
2
|
+
{
|
|
3
|
+
collections: { sourcesRenderFunctions },
|
|
4
|
+
core: { sourceDisplayFacade: self },
|
|
5
|
+
props,
|
|
6
|
+
stageIndexes
|
|
7
|
+
}
|
|
8
|
+
) {
|
|
9
|
+
self.displaySourcesWhichShouldBeDisplayed = () => {
|
|
10
|
+
if (props.loadOnlyCurrentSource) {
|
|
11
|
+
runRenderActionsForSourceWithIndex(stageIndexes.current);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
for (let i in stageIndexes) {
|
|
16
|
+
runRenderActionsForSourceWithIndex(stageIndexes[i]);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
function runRenderActionsForSourceWithIndex(i) {
|
|
21
|
+
if (sourcesRenderFunctions[i]) {
|
|
22
|
+
sourcesRenderFunctions[i]();
|
|
23
|
+
delete sourcesRenderFunctions[i];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IMAGE_TYPE,
|
|
3
|
+
INVALID_TYPE,
|
|
4
|
+
VIDEO_TYPE,
|
|
5
|
+
YOUTUBE_TYPE,
|
|
6
|
+
} from "../../../constants/core-constants";
|
|
7
|
+
import { getAutomaticTypeDetectorBucket } from "./getAutomaticTypeDetectorBucket";
|
|
8
|
+
|
|
9
|
+
export function AutomaticTypeDetector() {
|
|
10
|
+
const automaticTypeDetectorBucket = getAutomaticTypeDetectorBucket();
|
|
11
|
+
|
|
12
|
+
let url;
|
|
13
|
+
let resolveSourceType;
|
|
14
|
+
let xhr;
|
|
15
|
+
|
|
16
|
+
this.setUrlToCheck = (urlToCheck) => {
|
|
17
|
+
url = urlToCheck;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Asynchronous method takes callback which will be called after source type is received with source type as param.
|
|
22
|
+
* @param {Function} callback
|
|
23
|
+
*/
|
|
24
|
+
this.getSourceType = (callback) => {
|
|
25
|
+
if (automaticTypeDetectorBucket.isUrlYoutubeOne(url)) {
|
|
26
|
+
return callback(YOUTUBE_TYPE);
|
|
27
|
+
}
|
|
28
|
+
resolveSourceType = callback;
|
|
29
|
+
xhr = new XMLHttpRequest();
|
|
30
|
+
xhr.onreadystatechange = onRequestStateChange;
|
|
31
|
+
xhr.open('GET', url, true);
|
|
32
|
+
xhr.send();
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
function onRequestStateChange() {
|
|
36
|
+
// If state 4 is executed without state 2 - request has failed (most likely by CORS) so need to resolve invalid type.
|
|
37
|
+
// No need to abort request because it is already finished.
|
|
38
|
+
if (xhr.readyState === 4) {
|
|
39
|
+
resolveSourceType(INVALID_TYPE);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (xhr.readyState !== 2) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const headerType = automaticTypeDetectorBucket.getTypeFromResponseContentType(
|
|
48
|
+
xhr.getResponseHeader('content-type')
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
let finalType;
|
|
52
|
+
switch (headerType) {
|
|
53
|
+
case 'image':
|
|
54
|
+
finalType = IMAGE_TYPE;
|
|
55
|
+
break;
|
|
56
|
+
case 'video':
|
|
57
|
+
finalType = VIDEO_TYPE;
|
|
58
|
+
break;
|
|
59
|
+
default:
|
|
60
|
+
finalType = INVALID_TYPE;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Need to reset onreadystatechange because after xhr.abort() if request is sent (xhr.send())
|
|
64
|
+
// xhr will call onreadystatechange with readyState 4: https://xhr.spec.whatwg.org/#the-abort()-method
|
|
65
|
+
xhr.onreadystatechange = null;
|
|
66
|
+
xhr.abort();
|
|
67
|
+
|
|
68
|
+
resolveSourceType(finalType);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { CUSTOM_TYPE, IMAGE_TYPE, INVALID_TYPE, VIDEO_TYPE, YOUTUBE_TYPE } from "../../../constants/core-constants";
|
|
2
|
+
import { SourceLoadHandler } from "../SourceLoadHandler";
|
|
3
|
+
import { renderImage } from "../../../components/sources/proper-sources/renderImage";
|
|
4
|
+
import { renderVideo } from "../../../components/sources/proper-sources/renderVideo";
|
|
5
|
+
import { renderYoutube } from "../../../components/sources/proper-sources/renderYoutube";
|
|
6
|
+
import { renderCustom } from "../../../components/sources/proper-sources/renderCustom";
|
|
7
|
+
import { renderInvalid } from "../../../components/sources/proper-sources/renderInvalid";
|
|
8
|
+
|
|
9
|
+
export function DetectedTypeActioner(fsLightbox) {
|
|
10
|
+
const {
|
|
11
|
+
collections: { sourceLoadHandlers, sourcesRenderFunctions },
|
|
12
|
+
core: { sourceDisplayFacade },
|
|
13
|
+
resolve
|
|
14
|
+
} = fsLightbox;
|
|
15
|
+
|
|
16
|
+
this.runActionsForSourceTypeAndIndex = (type, i) => {
|
|
17
|
+
if (type !== INVALID_TYPE) {
|
|
18
|
+
sourceLoadHandlers[i] = resolve(SourceLoadHandler, [i]);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let renderFunction;
|
|
22
|
+
|
|
23
|
+
switch (type) {
|
|
24
|
+
case IMAGE_TYPE:
|
|
25
|
+
renderFunction = renderImage;
|
|
26
|
+
break;
|
|
27
|
+
case VIDEO_TYPE:
|
|
28
|
+
renderFunction = renderVideo;
|
|
29
|
+
break;
|
|
30
|
+
case YOUTUBE_TYPE:
|
|
31
|
+
renderFunction = renderYoutube;
|
|
32
|
+
break;
|
|
33
|
+
case CUSTOM_TYPE:
|
|
34
|
+
renderFunction = renderCustom;
|
|
35
|
+
break;
|
|
36
|
+
default:
|
|
37
|
+
renderFunction = renderInvalid;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
sourcesRenderFunctions[i] = () => renderFunction(fsLightbox, i);
|
|
42
|
+
sourceDisplayFacade.displaySourcesWhichShouldBeDisplayed();
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function getAutomaticTypeDetectorBucket() {
|
|
2
|
+
return {
|
|
3
|
+
isUrlYoutubeOne: (url) => {
|
|
4
|
+
const parser = document.createElement("a");
|
|
5
|
+
parser.href = url;
|
|
6
|
+
return parser.hostname === "www.youtube.com"
|
|
7
|
+
|| parser.hostname === "youtu.be";
|
|
8
|
+
},
|
|
9
|
+
|
|
10
|
+
getTypeFromResponseContentType: (responseContentType) => {
|
|
11
|
+
return responseContentType.slice(0, responseContentType.indexOf("/"));
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export function setUpStageManager(
|
|
2
|
+
{
|
|
3
|
+
stageIndexes,
|
|
4
|
+
core: { stageManager: self },
|
|
5
|
+
props: { sources }
|
|
6
|
+
}
|
|
7
|
+
) {
|
|
8
|
+
const lastSourceIndex = sources.length - 1;
|
|
9
|
+
|
|
10
|
+
self.getPreviousSlideIndex = () => {
|
|
11
|
+
return (stageIndexes.current === 0) ?
|
|
12
|
+
lastSourceIndex :
|
|
13
|
+
stageIndexes.current - 1;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
self.getNextSlideIndex = () => {
|
|
17
|
+
return (stageIndexes.current === lastSourceIndex) ?
|
|
18
|
+
0 :
|
|
19
|
+
stageIndexes.current + 1;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// set up updateStageIndexes
|
|
23
|
+
if (lastSourceIndex === 0) {
|
|
24
|
+
self.updateStageIndexes = () => {};
|
|
25
|
+
} else if (lastSourceIndex === 1) {
|
|
26
|
+
self.updateStageIndexes = () => {
|
|
27
|
+
if (stageIndexes.current === 0) {
|
|
28
|
+
stageIndexes.next = 1;
|
|
29
|
+
delete stageIndexes.previous;
|
|
30
|
+
} else {
|
|
31
|
+
stageIndexes.previous = 0;
|
|
32
|
+
delete stageIndexes.next;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
} else {
|
|
36
|
+
self.updateStageIndexes = () => {
|
|
37
|
+
stageIndexes.previous = self.getPreviousSlideIndex();
|
|
38
|
+
stageIndexes.next = self.getNextSlideIndex();
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
// set up isSourceInStage
|
|
44
|
+
// if there are 3, 2, 1 slides all sources will be always in stage
|
|
45
|
+
(lastSourceIndex <= 2) ?
|
|
46
|
+
self.isSourceInStage = () => true :
|
|
47
|
+
self.isSourceInStage = (index) => {
|
|
48
|
+
const currentIndex = stageIndexes.current;
|
|
49
|
+
|
|
50
|
+
if ((currentIndex === 0 && index === lastSourceIndex)
|
|
51
|
+
|| (currentIndex === lastSourceIndex && index === 0))
|
|
52
|
+
return true;
|
|
53
|
+
|
|
54
|
+
const difference = currentIndex - index;
|
|
55
|
+
|
|
56
|
+
return difference === -1 ||
|
|
57
|
+
difference === 0 ||
|
|
58
|
+
difference === 1;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { styles } from "../../styles";
|
|
2
|
+
import { FSLIGHTBOX_STYLES } from "../../constants/classes-names";
|
|
3
|
+
|
|
4
|
+
export function createAndAppendStyles() {
|
|
5
|
+
const style = document.createElement('style');
|
|
6
|
+
style.className = FSLIGHTBOX_STYLES;
|
|
7
|
+
style.appendChild(document.createTextNode(styles));
|
|
8
|
+
document.head.appendChild(style);
|
|
9
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createAndAppendStyles } from "./createAndAppendStyles";
|
|
2
|
+
import { FSLIGHTBOX_STYLES } from "../../constants/classes-names";
|
|
3
|
+
|
|
4
|
+
export function injectStylesIfNotInDom() {
|
|
5
|
+
if (!document.getElementsByClassName(FSLIGHTBOX_STYLES).length) {
|
|
6
|
+
createAndAppendStyles();
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function SourceMainWrapperTransformer({ elements: { sourceMainWrappers }, props }, i) {
|
|
2
|
+
let additionalTransformValue = 0;
|
|
3
|
+
|
|
4
|
+
this.byValue = (value) => {
|
|
5
|
+
additionalTransformValue = value;
|
|
6
|
+
return this;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
this.negative = () => {
|
|
10
|
+
setFinalTransformAndCleanTransformer(-getDefaultTransformDistance());
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
this.zero = () => {
|
|
14
|
+
setFinalTransformAndCleanTransformer(0);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
this.positive = () => {
|
|
18
|
+
setFinalTransformAndCleanTransformer(getDefaultTransformDistance());
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const setFinalTransformAndCleanTransformer = (value) => {
|
|
22
|
+
sourceMainWrappers[i].style.transform = `translateX(${value + additionalTransformValue}px)`;
|
|
23
|
+
additionalTransformValue = 0;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const getDefaultTransformDistance = () => (1 + props.slideDistance) * innerWidth;
|
|
27
|
+
}
|
package/fslightbox.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(window,(function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t);var o,r="fslightbox-",i="".concat(r,"styles"),s="".concat(r,"cursor-grabbing"),a="".concat(r,"full-dimension"),c="".concat(r,"flex-centered"),l="".concat(r,"open"),u="".concat(r,"transform-transition"),d="".concat(r,"absoluted"),p="".concat(r,"slide-btn"),f="".concat(p,"-container"),h="".concat(r,"fade-in"),m="".concat(r,"fade-out"),g=h+"-strong",v=m+"-strong",b="".concat(r,"opacity-"),x="".concat(b,"1"),y="".concat(r,"source");function S(e){return(S="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}"object"===("undefined"==typeof document?"undefined":S(document))&&((o=document.createElement("style")).className=i,o.appendChild(document.createTextNode(".fslightbox-absoluted{position:absolute;top:0;left:0}.fslightbox-fade-in{animation:fslightbox-fade-in .3s cubic-bezier(0,0,.7,1)}.fslightbox-fade-out{animation:fslightbox-fade-out .3s ease}.fslightbox-fade-in-strong{animation:fslightbox-fade-in-strong .3s cubic-bezier(0,0,.7,1)}.fslightbox-fade-out-strong{animation:fslightbox-fade-out-strong .3s ease}@keyframes fslightbox-fade-in{from{opacity:.65}to{opacity:1}}@keyframes fslightbox-fade-out{from{opacity:.35}to{opacity:0}}@keyframes fslightbox-fade-in-strong{from{opacity:.3}to{opacity:1}}@keyframes fslightbox-fade-out-strong{from{opacity:1}to{opacity:0}}.fslightbox-cursor-grabbing{cursor:grabbing}.fslightbox-full-dimension{width:100%;height:100%}.fslightbox-open{overflow:hidden;height:100%}.fslightbox-flex-centered{display:flex;justify-content:center;align-items:center}.fslightbox-opacity-0{opacity:0!important}.fslightbox-opacity-1{opacity:1!important}.fslightbox-scrollbarfix{padding-right:17px}.fslightbox-transform-transition{transition:transform .3s}.fslightbox-container{font-family:Arial,sans-serif;position:fixed;top:0;left:0;background:linear-gradient(rgba(30,30,30,.9),#000 1810%);touch-action:pinch-zoom;z-index:1000000000;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}.fslightbox-container *{box-sizing:border-box}.fslightbox-svg-path{transition:fill .15s ease;fill:#ddd}.fslightbox-nav{height:45px;width:100%;position:absolute;top:0;left:0}.fslightbox-slide-number-container{display:flex;justify-content:center;align-items:center;position:relative;height:100%;font-size:15px;color:#d7d7d7;z-index:0;max-width:55px;text-align:left}.fslightbox-slide-number-container .fslightbox-flex-centered{height:100%}.fslightbox-slash{display:block;margin:0 5px;width:1px;height:12px;transform:rotate(15deg);background:#fff}.fslightbox-toolbar{position:absolute;z-index:3;right:0;top:0;height:100%;display:flex;background:rgba(35,35,35,.65)}.fslightbox-toolbar-button{height:100%;width:45px;cursor:pointer}.fslightbox-toolbar-button:hover .fslightbox-svg-path{fill:#fff}.fslightbox-slide-btn-container{display:flex;align-items:center;padding:12px 12px 12px 6px;position:absolute;top:50%;cursor:pointer;z-index:3;transform:translateY(-50%)}@media (min-width:476px){.fslightbox-slide-btn-container{padding:22px 22px 22px 6px}}@media (min-width:768px){.fslightbox-slide-btn-container{padding:30px 30px 30px 6px}}.fslightbox-slide-btn-container:hover .fslightbox-svg-path{fill:#f1f1f1}.fslightbox-slide-btn{padding:9px;font-size:26px;background:rgba(35,35,35,.65)}@media (min-width:768px){.fslightbox-slide-btn{padding:10px}}@media (min-width:1600px){.fslightbox-slide-btn{padding:11px}}.fslightbox-slide-btn-container-previous{left:0}@media (max-width:475.99px){.fslightbox-slide-btn-container-previous{padding-left:3px}}.fslightbox-slide-btn-container-next{right:0;padding-left:12px;padding-right:3px}@media (min-width:476px){.fslightbox-slide-btn-container-next{padding-left:22px}}@media (min-width:768px){.fslightbox-slide-btn-container-next{padding-left:30px}}@media (min-width:476px){.fslightbox-slide-btn-container-next{padding-right:6px}}.fslightbox-down-event-detector{position:absolute;z-index:1}.fslightbox-slide-swiping-hoverer{z-index:4}.fslightbox-invalid-file-wrapper{font-size:22px;color:#eaebeb;margin:auto}.fslightbox-video{object-fit:cover}.fslightbox-youtube-iframe{border:0}.fslightbox-loader{display:block;margin:auto;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:67px;height:67px}.fslightbox-loader div{box-sizing:border-box;display:block;position:absolute;width:54px;height:54px;margin:6px;border:5px solid;border-color:#999 transparent transparent transparent;border-radius:50%;animation:fslightbox-loader 1.2s cubic-bezier(.5,0,.5,1) infinite}.fslightbox-loader div:nth-child(1){animation-delay:-.45s}.fslightbox-loader div:nth-child(2){animation-delay:-.3s}.fslightbox-loader div:nth-child(3){animation-delay:-.15s}@keyframes fslightbox-loader{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}.fslightbox-source{position:relative;z-index:2;opacity:0}")),document.head.appendChild(o));function w(e){var t,n=e.props,o=0,r={};this.getSourceTypeFromLocalStorageByUrl=function(e){return t[e]?t[e]:i(e)},this.handleReceivedSourceTypeForUrl=function(e,n){!1===r[n]&&(o--,"invalid"!==e?r[n]=e:delete r[n],0===o&&(!function(e,t){for(var n in t)e[n]=t[n]}(t,r),localStorage.setItem("fslightbox-types",JSON.stringify(t))))};var i=function(e){o++,r[e]=!1};n.disableLocalStorage?(this.getSourceTypeFromLocalStorageByUrl=function(){},this.handleReceivedSourceTypeForUrl=function(){}):(t=JSON.parse(localStorage.getItem("fslightbox-types")))||(t={},this.getSourceTypeFromLocalStorageByUrl=i)}function L(e,t,n,o){var r=e.data,i=e.elements.sources,s=n/o,a=0;this.adjustSize=function(){if((a=r.maxSourceWidth/s)<r.maxSourceHeight)return n<r.maxSourceWidth&&(a=o),c();a=o>r.maxSourceHeight?r.maxSourceHeight:o,c()};var c=function(){i[t].style.width=a*s+"px",i[t].style.height=a+"px"}}function C(e,t){var n=this,o=e.collections.sourceSizers,r=e.elements,i=r.sourceAnimationWrappers,s=r.sourceMainWrappers,a=r.sources,c=e.resolve;function l(e,n){o[t]=c(L,[t,e,n]),o[t].adjustSize()}this.runActions=function(e,o){a[t].classList.add(x),i[t].classList.add(g),s[t].removeChild(s[t].firstChild),l(e,o),n.runActions=l}}function F(e,t){var n,o=this,r=e.elements.sources,i=e.props,s=(0,e.resolve)(C,[t]);this.handleImageLoad=function(e){var t=e.target,n=t.naturalWidth,o=t.naturalHeight;s.runActions(n,o)},this.handleVideoLoad=function(e){var t=e.target,o=t.videoWidth,r=t.videoHeight;n=!0,s.runActions(o,r)},this.handleNotMetaDatedVideoLoad=function(){n||o.handleYoutubeLoad()},this.handleYoutubeLoad=function(){var e=1920,t=1080;i.maxYoutubeDimensions&&(e=i.maxYoutubeDimensions.width,t=i.maxYoutubeDimensions.height),s.runActions(e,t)},this.handleCustomLoad=function(){setTimeout((function(){var e=r[t];s.runActions(e.offsetWidth,e.offsetHeight)}))}}function A(e,t,n){var o=e.elements.sources,r=e.props.customClasses,i=r[t]?r[t]:"";o[t].className=n+" "+i}function I(e,t){var n=e.elements.sources,o=e.props.customAttributes;for(var r in o[t])n[t].setAttribute(r,o[t][r])}function T(e,t){var n=e.collections.sourceLoadHandlers,o=e.elements,r=o.sources,i=o.sourceAnimationWrappers,s=e.props.sources;r[t]=document.createElement("img"),A(e,t,y),r[t].src=s[t],r[t].onload=n[t].handleImageLoad,I(e,t),i[t].appendChild(r[t])}function E(e,t){var n=e.collections.sourceLoadHandlers,o=e.elements,r=o.sources,i=o.sourceAnimationWrappers,s=e.props,a=s.sources,c=s.videosPosters;r[t]=document.createElement("video"),A(e,t,y),r[t].src=a[t],r[t].onloadedmetadata=function(e){n[t].handleVideoLoad(e)},r[t].controls=!0,I(e,t),c[t]&&(r[t].poster=c[t]);var l=document.createElement("source");l.src=a[t],r[t].appendChild(l),setTimeout(n[t].handleNotMetaDatedVideoLoad,3e3),i[t].appendChild(r[t])}function N(e,t){var n=e.collections.sourceLoadHandlers,o=e.elements,i=o.sources,s=o.sourceAnimationWrappers,a=e.props.sources;i[t]=document.createElement("iframe"),A(e,t,"".concat(y," ").concat(r,"youtube-iframe"));var c=a[t],l=c.split("?")[1];i[t].src="https://www.youtube.com/embed/".concat(c.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/)[2],"?").concat(l||""),i[t].allowFullscreen=!0,I(e,t),s[t].appendChild(i[t]),n[t].handleYoutubeLoad()}function W(e,t){var n=e.collections.sourceLoadHandlers,o=e.elements,r=o.sources,i=o.sourceAnimationWrappers,s=e.props.sources;r[t]=s[t],A(e,t,"".concat(r[t].className," ").concat(y)),i[t].appendChild(r[t]),n[t].handleCustomLoad()}function z(e,t){var n=e.elements,o=n.sources,i=n.sourceAnimationWrappers,s=n.sourceMainWrappers;e.props.sources;o[t]=document.createElement("div"),o[t].className="".concat(r,"invalid-file-wrapper ").concat(c),o[t].innerHTML="Invalid source",i[t].classList.add(g),i[t].appendChild(o[t]),s[t].removeChild(s[t].firstChild)}function P(e){var t=e.collections,n=t.sourceLoadHandlers,o=t.sourcesRenderFunctions,r=e.core.sourceDisplayFacade,i=e.resolve;this.runActionsForSourceTypeAndIndex=function(t,s){var a;switch("invalid"!==t&&(n[s]=i(F,[s])),t){case"image":a=T;break;case"video":a=E;break;case"youtube":a=N;break;case"custom":a=W;break;default:a=z}o[s]=function(){return a(e,s)},r.displaySourcesWhichShouldBeDisplayed()}}function M(){var e,t,n,o={isUrlYoutubeOne:function(e){var t=document.createElement("a");return t.href=e,"www.youtube.com"===t.hostname||"youtu.be"===t.hostname},getTypeFromResponseContentType:function(e){return e.slice(0,e.indexOf("/"))}};function r(){if(4!==n.readyState){if(2===n.readyState){var e;switch(o.getTypeFromResponseContentType(n.getResponseHeader("content-type"))){case"image":e="image";break;case"video":e="video";break;default:e="invalid"}n.onreadystatechange=null,n.abort(),t(e)}}else t("invalid")}this.setUrlToCheck=function(t){e=t},this.getSourceType=function(i){if(o.isUrlYoutubeOne(e))return i("youtube");t=i,(n=new XMLHttpRequest).onreadystatechange=r,n.open("GET",e,!0),n.send()}}function H(e,t,n){var o=e.props,r=o.types,i=o.type,s=o.sources,a=e.resolve;this.getTypeSetByClientForIndex=function(e){var t;return r&&r[e]?t=r[e]:i&&(t=i),t},this.retrieveTypeWithXhrForIndex=function(e){var o=a(M);o.setUrlToCheck(s[e]),o.getSourceType((function(o){t.handleReceivedSourceTypeForUrl(o,s[e]),n.runActionsForSourceTypeAndIndex(o,e)}))}}function O(e,t){var n=e.componentsServices.hideSourceLoaderIfNotYetCollection,o=e.elements,r=o.sourceWrappersContainer,i=o.sourceMainWrappers;i[t]=document.createElement("div"),i[t].className="".concat(d," ").concat(a," ").concat(c),i[t].innerHTML='<div class="fslightbox-loader"><div></div><div></div><div></div><div></div></div>';var s=i[t].firstChild;n[t]=function(){i[t].contains(s)&&i[t].removeChild(s)},r.appendChild(i[t]),function(e,t){var n=e.elements,o=n.sourceMainWrappers,r=n.sourceAnimationWrappers;r[t]=document.createElement("div"),o[t].appendChild(r[t])}(e,t)}function k(e,t,n,o){var i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttributeNS(null,"width",t),i.setAttributeNS(null,"height",t),i.setAttributeNS(null,"viewBox",n);var s=document.createElementNS("http://www.w3.org/2000/svg","path");return s.setAttributeNS(null,"class","".concat(r,"svg-path")),s.setAttributeNS(null,"d",o),i.appendChild(s),e.appendChild(i),i}function R(e,t){var n=document.createElement("div");return n.className="".concat(r,"toolbar-button ").concat(c),n.title=t,e.appendChild(n),n}function D(e,t){var n=document.createElement("div");n.className="".concat(r,"toolbar"),t.appendChild(n),function(e,t){var n=e.componentsServices,o=e.core.fullscreenToggler,r=e.data,i="M4.5 11H3v4h4v-1.5H4.5V11zM3 7h1.5V4.5H7V3H3v4zm10.5 6.5H11V15h4v-4h-1.5v2.5zM11 3v1.5h2.5V7H15V3h-4z",s=R(t);s.title="Enter fullscreen";var a=k(s,"20px","0 0 18 18",i);n.enterFullscreen=function(){r.isFullscreenOpen=!0,s.title="Exit fullscreen",a.setAttributeNS(null,"width","24px"),a.setAttributeNS(null,"height","24px"),a.setAttributeNS(null,"viewBox","0 0 950 1024"),a.firstChild.setAttributeNS(null,"d","M682 342h128v84h-212v-212h84v128zM598 810v-212h212v84h-128v128h-84zM342 342v-128h84v212h-212v-84h128zM214 682v-84h212v212h-84v-128h-128z")},n.exitFullscreen=function(){r.isFullscreenOpen=!1,s.title="Enter fullscreen",a.setAttributeNS(null,"width","20px"),a.setAttributeNS(null,"height","20px"),a.setAttributeNS(null,"viewBox","0 0 18 18"),a.firstChild.setAttributeNS(null,"d",i)},s.onclick=function(){r.isFullscreenOpen?o.exitFullscreen():o.enterFullscreen()}}(e,n),function(e,t){var n=R(t,"Close");n.onclick=e.core.lightboxCloser.closeLightbox,k(n,"20px","0 0 24 24","M 4.7070312 3.2929688 L 3.2929688 4.7070312 L 10.585938 12 L 3.2929688 19.292969 L 4.7070312 20.707031 L 12 13.414062 L 19.292969 20.707031 L 20.707031 19.292969 L 13.414062 12 L 20.707031 4.7070312 L 19.292969 3.2929688 L 12 10.585938 L 4.7070312 3.2929688 z")}(e,n)}function j(e){var t=e.props.sources,n=e.elements.container,o=document.createElement("div");o.className="".concat(r,"nav"),n.appendChild(o),D(e,o),t.length>1&&function(e,t){var n=e.componentsServices,o=e.props.sources,i=(e.stageIndexes,document.createElement("div"));i.className="".concat(r,"slide-number-container");var s=document.createElement("div");s.className=c;var a=document.createElement("span");n.setSlideNumber=function(e){return a.innerHTML=e};var l=document.createElement("span");l.className="".concat(r,"slash");var u=document.createElement("div");u.innerHTML=o.length,i.appendChild(s),s.appendChild(a),s.appendChild(l),s.appendChild(u),t.appendChild(i),setTimeout((function(){s.offsetWidth>55&&(i.style.justifyContent="flex-start")}))}(e,o)}function X(e,t){var n=this,o=e.elements.sourceMainWrappers,r=e.props,i=0;this.byValue=function(e){return i=e,n},this.negative=function(){s(-a())},this.zero=function(){s(0)},this.positive=function(){s(a())};var s=function(e){o[t].style.transform="translateX(".concat(e+i,"px)"),i=0},a=function(){return(1+r.slideDistance)*innerWidth}}function B(e,t,n,o){var r=e.elements.container,i=n.charAt(0).toUpperCase()+n.slice(1),s=document.createElement("div");s.className="".concat(f," ").concat(f,"-").concat(n),s.title="".concat(i," slide"),s.onclick=t,function(e,t){var n=document.createElement("div");n.className="".concat(p," ").concat(c),k(n,"20px","0 0 20 20",t),e.appendChild(n)}(s,o),r.appendChild(s)}function U(e,t){var n=e.classList;n.contains(t)&&n.remove(t)}function V(e){var t=this,n=e.core,o=n.eventsDispatcher,r=n.fullscreenToggler,i=n.globalEventsController,s=n.scrollbarRecompensor,a=e.data,c=e.elements,u=e.props,d=e.sourcePointerProps;this.isLightboxFadingOut=!1,this.runActions=function(){t.isLightboxFadingOut=!0,c.container.classList.add(v),i.removeListeners(),u.exitFullscreenOnClose&&a.isFullscreenOpen&&r.exitFullscreen(),setTimeout((function(){t.isLightboxFadingOut=!1,d.isPointering=!1,c.container.classList.remove(v),document.documentElement.classList.remove(l),s.removeRecompense(),document.body.removeChild(c.container),o.dispatch("onClose")}),270)}}function Y(e){var t,n,o,r=e.collections.sourceMainWrappersTransformers,i=e.componentsServices,s=e.core,a=s.classFacade,c=s.slideIndexChanger,l=s.sourceDisplayFacade,d=s.stageManager,p=e.elements.sourceAnimationWrappers,f=e.stageIndexes,v=(t=function(){a.removeFromEachElementClassIfContains("sourceAnimationWrappers",m)},n=300,o=[],function(){o.push(!0),setTimeout((function(){o.pop(),o.length||t()}),n)});c.changeTo=function(e){f.current=e,d.updateStageIndexes(),i.setSlideNumber(e+1),l.displaySourcesWhichShouldBeDisplayed()},c.jumpTo=function(e){var t=f.current;c.changeTo(e),a.removeFromEachElementClassIfContains("sourceMainWrappers",u),U(p[t],g),U(p[t],h),p[t].classList.add(m),U(p[e],g),U(p[e],m),p[e].classList.add(h),v(),r[e].zero(),setTimeout((function(){t!==f.current&&r[t].negative()}),270)}}function _(e){var t=e.core,n=t.lightboxCloser,o=t.fullscreenToggler,r=t.slideChangeFacade;this.listener=function(e){switch(e.key){case"Escape":n.closeLightbox();break;case"ArrowLeft":r.changeToPrevious();break;case"ArrowRight":r.changeToNext();break;case"F11":e.preventDefault(),o.enterFullscreen()}}}function q(e){var t=e.collections.sourceMainWrappersTransformers,n=e.elements,o=e.sourcePointerProps,r=e.stageIndexes;function i(e,n){t[e].byValue(o.swipedX)[n]()}this.runActionsForEvent=function(e){var t,a,c;n.container.contains(n.slideSwipingHoverer)||n.container.appendChild(n.slideSwipingHoverer),t=n.container,a=s,(c=t.classList).contains(a)||c.add(a),o.swipedX=e.screenX-o.downScreenX,i(r.current,"zero"),void 0!==r.previous&&o.swipedX>0?i(r.previous,"negative"):void 0!==r.next&&o.swipedX<0&&i(r.next,"positive")}}function J(e){var t=e.props.sources,n=e.resolve,o=e.sourcePointerProps,r=n(q);1===t.length?this.listener=function(){o.swipedX=1}:this.listener=function(e){o.isPointering&&r.runActionsForEvent(e)}}function G(e){var t=e.collections.sourceMainWrappersTransformers,n=e.core.slideIndexChanger,o=e.elements.sourceMainWrappers,r=e.stageIndexes;this.runPositiveSwipedXActions=function(){void 0===r.previous||(i("positive"),n.changeTo(r.previous)),i("zero")},this.runNegativeSwipedXActions=function(){void 0===r.next||(i("negative"),n.changeTo(r.next)),i("zero")};var i=function(e){o[r.current].classList.add(u),t[r.current][e]()}}function $(e,t){e.contains(t)&&e.removeChild(t)}function K(e){var t=e.core.lightboxCloser,n=e.elements,o=e.resolve,r=e.sourcePointerProps,i=o(G);this.runNoSwipeActions=function(){$(n.container,n.slideSwipingHoverer),r.isSourceDownEventTarget||t.closeLightbox(),r.isPointering=!1},this.runActions=function(){r.swipedX>0?i.runPositiveSwipedXActions():i.runNegativeSwipedXActions(),$(n.container,n.slideSwipingHoverer),n.container.classList.remove(s),r.isPointering=!1}}function Q(e){var t=e.resolve,n=e.sourcePointerProps,o=t(K);this.listener=function(){n.isPointering&&(n.swipedX?o.runActions():o.runNoSwipeActions())}}function Z(e){var t,n,o;n=(t=e).core.classFacade,o=t.elements,n.removeFromEachElementClassIfContains=function(e,t){for(var n=0;n<o[e].length;n++)U(o[e][n],t)},function(e){var t=e.core.eventsDispatcher,n=e.props;t.dispatch=function(e){n[e]&&n[e]()}}(e),function(e){var t=e.componentsServices,n=e.core.fullscreenToggler;n.enterFullscreen=function(){t.enterFullscreen();var e=document.documentElement;e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen&&e.msRequestFullscreen()},n.exitFullscreen=function(){t.exitFullscreen(),document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen&&document.msExitFullscreen()}}(e),function(e){var t=e.core,n=t.globalEventsController,o=t.windowResizeActioner,r=e.resolve,i=r(_),s=r(J),a=r(Q);n.attachListeners=function(){document.addEventListener("pointermove",s.listener),document.addEventListener("pointerup",a.listener),addEventListener("resize",o.runActions),document.addEventListener("keydown",i.listener)},n.removeListeners=function(){document.removeEventListener("pointermove",s.listener),document.removeEventListener("pointerup",a.listener),removeEventListener("resize",o.runActions),document.removeEventListener("keydown",i.listener)}}(e),function(e){var t=e.core.lightboxCloser,n=(0,e.resolve)(V);t.closeLightbox=function(){n.isLightboxFadingOut||n.runActions()}}(e),ne(e),function(e){var t=e.data,n=e.core.scrollbarRecompensor;function o(){document.body.offsetHeight>innerHeight&&(document.body.style.marginRight=t.scrollbarWidth+"px")}n.addRecompense=function(){"complete"===document.readyState?o():addEventListener("load",(function(){o(),n.addRecompense=o}))},n.removeRecompense=function(){document.body.style.removeProperty("margin-right")}}(e),function(e){var t=e.core,n=t.slideChangeFacade,o=t.slideIndexChanger,r=t.stageManager;e.props.sources.length>1?(n.changeToPrevious=function(){o.jumpTo(r.getPreviousSlideIndex())},n.changeToNext=function(){o.jumpTo(r.getNextSlideIndex())}):(n.changeToPrevious=function(){},n.changeToNext=function(){})}(e),Y(e),function(e){var t=e.core,n=t.classFacade,o=t.sourcesPointerDown,r=e.elements.sources,i=e.sourcePointerProps,s=e.stageIndexes;o.listener=function(e){"VIDEO"!==e.target.tagName&&e.preventDefault(),i.isPointering=!0,i.downScreenX=e.screenX,i.swipedX=0;var t=r[s.current];t&&t.contains(e.target)?i.isSourceDownEventTarget=!0:i.isSourceDownEventTarget=!1,n.removeFromEachElementClassIfContains("sourceMainWrappers",u)}}(e),function(e){var t=e.collections.sourcesRenderFunctions,n=e.core.sourceDisplayFacade,o=e.props,r=e.stageIndexes;function i(e){t[e]&&(t[e](),delete t[e])}n.displaySourcesWhichShouldBeDisplayed=function(){if(o.loadOnlyCurrentSource)i(r.current);else for(var e in r)i(r[e])}}(e),function(e){var t=e.stageIndexes,n=e.core.stageManager,o=e.props.sources.length-1;n.getPreviousSlideIndex=function(){return 0===t.current?o:t.current-1},n.getNextSlideIndex=function(){return t.current===o?0:t.current+1},n.updateStageIndexes=0===o?function(){}:1===o?function(){0===t.current?(t.next=1,delete t.previous):(t.previous=0,delete t.next)}:function(){t.previous=n.getPreviousSlideIndex(),t.next=n.getNextSlideIndex()},n.isSourceInStage=o<=2?function(){return!0}:function(e){var n=t.current;if(0===n&&e===o||n===o&&0===e)return!0;var r=n-e;return-1===r||0===r||1===r}}(e),function(e){var t=e.collections,n=t.sourceMainWrappersTransformers,o=t.sourceSizers,r=e.core.windowResizeActioner,i=e.data,s=e.elements.sourceMainWrappers,a=e.props,c=e.stageIndexes;r.runActions=function(){innerWidth<992?i.maxSourceWidth=innerWidth:i.maxSourceWidth=.9*innerWidth,i.maxSourceHeight=.9*innerHeight;for(var e=0;e<a.sources.length;e++)U(s[e],u),e!==c.current&&n[e].negative(),o[e]&&o[e].adjustSize()}}(e)}function ee(e){var t=e.props.disableLocalStorage;if(!t){var n=localStorage.getItem("fslightbox-scrollbar-width");if(n)return n}var o=function(){var e=document.createElement("div"),t=e.style;return t.visibility="hidden",t.width="100px",t.msOverflowStyle="scrollbar",t.overflow="scroll",e}(),r=function(){var e=document.createElement("div");return e.style.width="100%",e}();document.body.appendChild(o);var i=o.offsetWidth;o.appendChild(r);var s=r.offsetWidth;document.body.removeChild(o);var a=i-s;return t||localStorage.setItem("fslightbox-scrollbar-width",a.toString()),a}function te(e){var t=e.core.eventsDispatcher,n=e.data,o=e.elements,i=e.props.sources;n.isInitialized=!0,n.scrollbarWidth=ee(e),function(e){for(var t=e.collections.sourceMainWrappersTransformers,n=e.props.sources,o=e.resolve,r=0;r<n.length;r++)t[r]=o(X,[r])}(e),Z(e),o.container=document.createElement("div"),o.container.className="".concat(r,"container ").concat(a," ").concat(g),function(e){var t=e.elements;t.slideSwipingHoverer=document.createElement("div"),t.slideSwipingHoverer.className="".concat(r,"slide-swiping-hoverer ").concat(a," ").concat(d)}(e),j(e),function(e){var t=e.core.sourcesPointerDown,n=e.elements,o=e.props.sources,r=document.createElement("div");r.className="".concat(d," ").concat(a),n.container.appendChild(r),r.addEventListener("pointerdown",t.listener),n.sourceWrappersContainer=r;for(var i=0;i<o.length;i++)O(e,i)}(e),i.length>1&&function(e){var t=e.core.slideChangeFacade;B(e,t.changeToPrevious,"previous","M18.271,9.212H3.615l4.184-4.184c0.306-0.306,0.306-0.801,0-1.107c-0.306-0.306-0.801-0.306-1.107,0L1.21,9.403C1.194,9.417,1.174,9.421,1.158,9.437c-0.181,0.181-0.242,0.425-0.209,0.66c0.005,0.038,0.012,0.071,0.022,0.109c0.028,0.098,0.075,0.188,0.142,0.271c0.021,0.026,0.021,0.061,0.045,0.085c0.015,0.016,0.034,0.02,0.05,0.033l5.484,5.483c0.306,0.307,0.801,0.307,1.107,0c0.306-0.305,0.306-0.801,0-1.105l-4.184-4.185h14.656c0.436,0,0.788-0.353,0.788-0.788S18.707,9.212,18.271,9.212z"),B(e,t.changeToNext,"next","M1.729,9.212h14.656l-4.184-4.184c-0.307-0.306-0.307-0.801,0-1.107c0.305-0.306,0.801-0.306,1.106,0l5.481,5.482c0.018,0.014,0.037,0.019,0.053,0.034c0.181,0.181,0.242,0.425,0.209,0.66c-0.004,0.038-0.012,0.071-0.021,0.109c-0.028,0.098-0.075,0.188-0.143,0.271c-0.021,0.026-0.021,0.061-0.045,0.085c-0.015,0.016-0.034,0.02-0.051,0.033l-5.483,5.483c-0.306,0.307-0.802,0.307-1.106,0c-0.307-0.305-0.307-0.801,0-1.105l4.184-4.185H1.729c-0.436,0-0.788-0.353-0.788-0.788S1.293,9.212,1.729,9.212z")}(e),function(e){for(var t=e.props.sources,n=e.resolve,o=n(w),r=n(P),i=n(H,[o,r]),s=0;s<t.length;s++)if("string"==typeof t[s]){var a=i.getTypeSetByClientForIndex(s);if(a)r.runActionsForSourceTypeAndIndex(a,s);else{var c=o.getSourceTypeFromLocalStorageByUrl(t[s]);c?r.runActionsForSourceTypeAndIndex(c,s):i.retrieveTypeWithXhrForIndex(s)}}else r.runActionsForSourceTypeAndIndex("custom",s)}(e),t.dispatch("onInit")}function ne(e){var t=e.collections.sourceMainWrappersTransformers,n=e.componentsServices,o=e.core,r=o.eventsDispatcher,i=o.lightboxOpener,s=o.globalEventsController,a=o.scrollbarRecompensor,c=o.sourceDisplayFacade,u=o.stageManager,d=o.windowResizeActioner,p=e.data,f=e.elements,h=e.stageIndexes;i.open=function(){var o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;h.current=o,p.isInitialized?r.dispatch("onShow"):te(e),u.updateStageIndexes(),c.displaySourcesWhichShouldBeDisplayed(),n.setSlideNumber(o+1),document.body.appendChild(f.container),document.documentElement.classList.add(l),a.addRecompense(),s.attachListeners(),d.runActions(),t[h.current].zero(),r.dispatch("onOpen")}}function oe(e,t,n){return(oe=re()?Reflect.construct.bind():function(e,t,n){var o=[null];o.push.apply(o,t);var r=new(Function.bind.apply(e,o));return n&&ie(r,n.prototype),r}).apply(null,arguments)}function re(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function ie(e,t){return(ie=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function se(e){return function(e){if(Array.isArray(e))return ae(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return ae(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ae(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ae(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function ce(){for(var e=document.getElementsByTagName("a"),t=function(t){if(!e[t].hasAttribute("data-fslightbox"))return"continue";var n=e[t].getAttribute("data-fslightbox"),o=e[t].hasAttribute("data-href")?e[t].getAttribute("data-href"):e[t].getAttribute("href");fsLightboxInstances[n]||(fsLightboxInstances[n]=new FsLightbox);var r=null;"#"===o.charAt(0)?(r=document.getElementById(o.substring(1)).cloneNode(!0)).removeAttribute("id"):r=o,fsLightboxInstances[n].props.sources.push(r),fsLightboxInstances[n].elements.a.push(e[t]);var i=fsLightboxInstances[n].props.sources.length-1;e[t].onclick=function(e){e.preventDefault(),fsLightboxInstances[n].open(i)},d("types","data-type"),d("videosPosters","data-video-poster"),d("customClasses","data-class"),d("customClasses","data-custom-class");for(var s=["href","data-fslightbox","data-href","data-type","data-video-poster","data-class","data-custom-class"],a=e[t].attributes,c=fsLightboxInstances[n].props.customAttributes,l=0;l<a.length;l++)if(-1===s.indexOf(a[l].name)&&"data-"===a[l].name.substr(0,5)){c[i]||(c[i]={});var u=a[l].name.substr(5);c[i][u]=a[l].value}function d(o,r){e[t].hasAttribute(r)&&(fsLightboxInstances[n].props[o][i]=e[t].getAttribute(r))}},n=0;n<e.length;n++)t(n);var o=Object.keys(fsLightboxInstances);window.fsLightbox=fsLightboxInstances[o[o.length-1]]}window.FsLightbox=function(){var e=this;this.props={sources:[],customAttributes:[],customClasses:[],types:[],videosPosters:[],slideDistance:.3},this.data={isInitialized:!1,isFullscreenOpen:!1,maxSourceWidth:0,maxSourceHeight:0,scrollbarWidth:0},this.sourcePointerProps={downScreenX:null,isPointering:!1,isSourceDownEventTarget:!1,swipedX:0},this.stageIndexes={},this.elements={a:[],container:null,slideSwipingHoverer:null,sourceWrappersContainer:null,sources:[],sourceMainWrappers:[],sourceAnimationWrappers:[]},this.componentsServices={enterFullscreen:null,exitFullscreen:null,hideSourceLoaderIfNotYetCollection:[],setSlideNumber:function(){}},this.resolve=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return n.unshift(e),oe(t,se(n))},this.collections={sourceMainWrappersTransformers:[],sourceLoadHandlers:[],sourcesRenderFunctions:[],sourceSizers:[]},this.core={classFacade:{},eventsDispatcher:{},fullscreenToggler:{},globalEventsController:{},lightboxCloser:{},lightboxOpener:{},lightboxUpdater:{},scrollbarRecompensor:{},slideChangeFacade:{},slideIndexChanger:{},sourcesPointerDown:{},sourceDisplayFacade:{},stageManager:{},windowResizeActioner:{}},ne(this),this.open=function(t){return e.core.lightboxOpener.open(t)},this.close=function(){return e.core.lightboxCloser.closeLightbox()}},window.fsLightboxInstances={},ce(),window.refreshFsLightbox=function(){for(var e in fsLightboxInstances){var t=fsLightboxInstances[e].props;fsLightboxInstances[e]=new FsLightbox,fsLightboxInstances[e].props=t,fsLightboxInstances[e].props.sources=[],fsLightboxInstances[e].elements.a=[]}ce()}}])}));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function assigns to object properties from second one
|
|
3
|
+
* @param { Object } object
|
|
4
|
+
* @param { Object } toAssign
|
|
5
|
+
*/
|
|
6
|
+
export function assignToObject(object, toAssign) {
|
|
7
|
+
for (let toAssignPropertyName in toAssign) {
|
|
8
|
+
object[toAssignPropertyName] = toAssign[toAssignPropertyName];
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Set up source class with custom class if set
|
|
3
|
+
*/
|
|
4
|
+
export function setUpSourceClassName(
|
|
5
|
+
{
|
|
6
|
+
elements: { sources },
|
|
7
|
+
props: { customClasses }
|
|
8
|
+
},
|
|
9
|
+
i, baseClassName
|
|
10
|
+
) {
|
|
11
|
+
const customClassName = customClasses[i] ? customClasses[i] : '';
|
|
12
|
+
sources[i].className = baseClassName + ' ' + customClassName;
|
|
13
|
+
}
|