fslightbox 3.3.3 → 3.4.0
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/c/elements/setUpClassFacade.js +9 -0
- package/c/events/setUpEventsDispatcher.js +7 -0
- package/c/events/setUpGlobalEventsController.js +39 -0
- package/c/keyboard/KeyboardController.js +26 -0
- package/c/main-component/closing/LightboxCloseActioner.js +46 -0
- package/c/main-component/closing/setUpLightboxCloser.js +11 -0
- package/c/scrollbar/gsw.js +1 -0
- package/c/scrollbar/setUpScrollbarRecompensor.js +20 -0
- package/c/setUpCore.js +30 -0
- package/c/sfs.js +1 -0
- package/c/sizes/setUpWindowResizeActioner.js +38 -0
- package/c/slide/setUpSlideChangeFacade.js +23 -0
- package/c/slide/setUpSlideIndexChanger.js +89 -0
- package/c/so.js +1 -0
- package/c/sources/SourceLoadActioner.js +32 -0
- package/c/sources/SourceLoadHandler.js +41 -0
- package/c/sources/SourceSizer.js +36 -0
- package/c/sources/creating/CreatingSourcesBucket.js +29 -0
- package/c/sources/creating/CreatingSourcesLocalStorageManager.js +55 -0
- package/c/sources/creating/createSources.js +28 -0
- package/c/sources/pointering/down/setUpSourcesPointerDown.js +38 -0
- package/c/sources/pointering/move/SourcesPointerMove.js +16 -0
- package/c/sources/pointering/move/SourcesPointerMoveActioner.js +34 -0
- package/c/sources/pointering/up/SourcesPointerUp.js +13 -0
- package/c/sources/pointering/up/SourcesPointerUpActioner.js +38 -0
- package/c/sources/pointering/up/SourcesPointerUpActionerBucket.js +1 -0
- package/c/sources/setUpSourceDisplayFacade.js +26 -0
- package/c/sources/types/AutomaticTypeDetector.js +70 -0
- package/c/sources/types/DetectedTypeActioner.js +44 -0
- package/c/sources/types/getAutomaticTypeDetectorBucket.js +14 -0
- package/c/stage/setUpStageManager.js +57 -0
- package/c/stage/ssws.js +2 -0
- package/c/styles/createAndAppendStyles.js +9 -0
- package/c/styles/injectStylesIfNotInDom.js +8 -0
- package/c/styles/styles-injection/styles-injection.js +5 -0
- package/c/timeouts/getQueuedAction.js +15 -0
- package/cm/h/renderSvg.js +17 -0
- package/cm/nav/renderAndGetToolbarButton.js +11 -0
- package/cm/nav/renderCloseButton.js +10 -0
- package/cm/nav/renderFullscreenButton.js +43 -0
- package/cm/nav/renderNav.js +17 -0
- package/cm/nav/renderSlideNumber.js +29 -0
- package/cm/nav/renderToolbar.js +13 -0
- package/cm/renderSlideButton.js +11 -0
- package/cm/renderSlideButtonContainer.js +15 -0
- package/cm/renderSlideButtons.js +7 -0
- package/cm/renderSlideSwipingHoverer.js +6 -0
- package/cm/sources/proper-sources/renderCustom.js +15 -0
- package/cm/sources/proper-sources/renderImage.js +18 -0
- package/cm/sources/proper-sources/renderInvalid.js +18 -0
- package/cm/sources/proper-sources/renderVideo.js +31 -0
- package/cm/sources/proper-sources/renderYoutube.js +26 -0
- package/cm/sources/renderSourceWrappersContainer.js +18 -0
- package/cm/sources/saw.js +1 -0
- package/cm/sources/smw.js +1 -0
- package/cn/classes-names.js +27 -0
- package/cn/core-constants.js +6 -0
- package/cn/css-constants.js +1 -0
- package/cn/dom-constants.js +1 -0
- package/cn/elements.js +3 -0
- package/cn/local-storage-constants.js +2 -0
- package/h/elements/addToElementClassIfNotContains.js +6 -0
- package/h/elements/removeFromElementChildIfContains.js +5 -0
- package/h/elements/removeFromElementClassIfContains.js +6 -0
- package/h/objects/assignToObject.js +10 -0
- package/h/source/setUpSourceClassName.js +13 -0
- package/h/source/setUpSourceCustomAttributes.js +5 -0
- package/h/state/ifOnUpdateExistsHandleItForState.js +6 -0
- package/index.js +1 -1
- package/package.json +7 -6
- package/s.js +1 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { CURSOR_GRABBING_CLASS_NAME } from "../../../../cn/classes-names";
|
|
2
|
+
import { addToElementClassIfNotContains } from "../../../../h/elements/addToElementClassIfNotContains";
|
|
3
|
+
|
|
4
|
+
export function SourcesPointerMoveActioner(
|
|
5
|
+
{
|
|
6
|
+
elements,
|
|
7
|
+
sourcePointerProps,
|
|
8
|
+
stageIndexes
|
|
9
|
+
}
|
|
10
|
+
) {
|
|
11
|
+
this.runActionsForEvent = (e) => {
|
|
12
|
+
// we are showing InvisibleHover component in move event not in down event
|
|
13
|
+
// due to IE problems with videos sources controlling
|
|
14
|
+
if (!elements.container.contains(elements.slideSwipingHoverer)) {
|
|
15
|
+
elements.container.appendChild(elements.slideSwipingHoverer);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
addToElementClassIfNotContains(elements.container, CURSOR_GRABBING_CLASS_NAME);
|
|
19
|
+
|
|
20
|
+
sourcePointerProps.swipedX = e.screenX - sourcePointerProps.downScreenX;
|
|
21
|
+
|
|
22
|
+
var pi=stageIndexes.previous,ni=stageIndexes.next;
|
|
23
|
+
t(stageIndexes.current, "z");
|
|
24
|
+
if (pi !== undefined && sourcePointerProps.swipedX > 0) {
|
|
25
|
+
t(pi, "ne");
|
|
26
|
+
} else if (ni !== undefined && sourcePointerProps.swipedX < 0) {
|
|
27
|
+
t(ni, "p");
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
function t(i, p) {
|
|
32
|
+
elements.smw[i].v(sourcePointerProps.swipedX)[p]()
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -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 "../../../../cn/classes-names";
|
|
3
|
+
import { removeFromElementChildIfContains } from '../../../../h/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 @@
|
|
|
1
|
+
export function SourcesPointerUpActionerBucket({core:{slideIndexChanger},elements:{smw},stageIndexes,sws}){this.runPositiveSwipedXActions=()=>{var i=stageIndexes.previous;if(i===undefined){t("z");}else{t("p");var usi=stageIndexes.next;slideIndexChanger.changeTo(i);var pi=stageIndexes.previous;sws.d(pi);sws.b(usi);t("z");s(pi,"ne");}};this.runNegativeSwipedXActions=()=>{var i=stageIndexes.next;if(i===undefined){t("z");}else{t("ne");var usi=stageIndexes.previous;slideIndexChanger.changeTo(i);var ni=stageIndexes.next;sws.d(ni);sws.b(usi);t("z");s(ni,"p");}};function t(p){var w=smw[stageIndexes.current];w.a();w[p]();}function s(i,p){if(i!==undefined){smw[i].s();smw[i][p]();}}}
|
|
@@ -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 "../../../cn/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 "../../../cn/core-constants";
|
|
2
|
+
import { SourceLoadHandler } from "../SourceLoadHandler";
|
|
3
|
+
import { renderImage } from "../../../cm/sources/proper-sources/renderImage";
|
|
4
|
+
import { renderVideo } from "../../../cm/sources/proper-sources/renderVideo";
|
|
5
|
+
import { renderYoutube } from "../../../cm/sources/proper-sources/renderYoutube";
|
|
6
|
+
import { renderCustom } from "../../../cm/sources/proper-sources/renderCustom";
|
|
7
|
+
import { renderInvalid } from "../../../cm/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,57 @@
|
|
|
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
|
+
(lastSourceIndex <= 2) ?
|
|
43
|
+
self.i = () => true :
|
|
44
|
+
self.i = (index) => {
|
|
45
|
+
const currentIndex = stageIndexes.current;
|
|
46
|
+
|
|
47
|
+
if ((currentIndex === 0 && index === lastSourceIndex)
|
|
48
|
+
|| (currentIndex === lastSourceIndex && index === 0))
|
|
49
|
+
return true;
|
|
50
|
+
|
|
51
|
+
const difference = currentIndex - index;
|
|
52
|
+
|
|
53
|
+
return difference === -1 ||
|
|
54
|
+
difference === 0 ||
|
|
55
|
+
difference === 1;
|
|
56
|
+
};
|
|
57
|
+
}
|
package/c/stage/ssws.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{DISPLAY_NONE_CLASS_NAME,FADE_IN_CLASS_NAME,FADE_IN_STRONG_CLASS_NAME,FADE_OUT_CLASS_NAME}from"../../cn/classes-names";import{removeFromElementClassIfContains}from"../../h/elements/removeFromElementClassIfContains";export function ssws({core:{stageManager},elements:{smw,sourceAnimationWrappers},isl,stageIndexes,sws:self}){self.a=function(){for(var k in stageIndexes){smw[stageIndexes[k]].s()}};self.b=function(i){if(i!==undefined&&!stageManager.i(i)){smw[i].h();smw[i].n();}};self.c=function(){for(var k in stageIndexes){self.d(stageIndexes[k]);}};self.d=function(i){if(!isl[i]){return;}var saw=sourceAnimationWrappers[i];removeFromElementClassIfContains(saw,FADE_IN_STRONG_CLASS_NAME);removeFromElementClassIfContains(saw,FADE_IN_CLASS_NAME);removeFromElementClassIfContains(saw,FADE_OUT_CLASS_NAME)}}
|
|
2
|
+
// In the "b" method, it's checked whether the index is not undefined because it may be when there are only two sources.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { styles } from "../../s";
|
|
2
|
+
import { FSLIGHTBOX_STYLES } from "../../cn/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 "../../cn/classes-names";
|
|
3
|
+
|
|
4
|
+
export function injectStylesIfNotInDom() {
|
|
5
|
+
if (!document.getElementsByClassName(FSLIGHTBOX_STYLES).length) {
|
|
6
|
+
createAndAppendStyles();
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PREFIX } from "../../cn/classes-names";
|
|
2
|
+
|
|
3
|
+
export function renderAndGetSvg(parent, size, viewBox, d) {
|
|
4
|
+
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
5
|
+
svg.setAttributeNS(null, 'width', size);
|
|
6
|
+
svg.setAttributeNS(null, 'height', size);
|
|
7
|
+
svg.setAttributeNS(null, 'viewBox', viewBox);
|
|
8
|
+
|
|
9
|
+
const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
|
10
|
+
path.setAttributeNS(null, 'class', `${PREFIX}svg-path`);
|
|
11
|
+
path.setAttributeNS(null, 'd', d);
|
|
12
|
+
|
|
13
|
+
svg.appendChild(path);
|
|
14
|
+
parent.appendChild(svg);
|
|
15
|
+
|
|
16
|
+
return svg;
|
|
17
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FLEX_CENTERED_CLASS_NAME, PREFIX } from "../../cn/classes-names";
|
|
2
|
+
|
|
3
|
+
export function renderAndGetToolbarButton(parent, title) {
|
|
4
|
+
const toolbarButton = document.createElement('div');
|
|
5
|
+
toolbarButton.className = `${PREFIX}toolbar-button ${FLEX_CENTERED_CLASS_NAME}`;
|
|
6
|
+
toolbarButton.title = title;
|
|
7
|
+
|
|
8
|
+
parent.appendChild(toolbarButton);
|
|
9
|
+
|
|
10
|
+
return toolbarButton;
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { renderAndGetToolbarButton } from "./renderAndGetToolbarButton";
|
|
2
|
+
import { renderAndGetSvg } from "../h/renderSvg";
|
|
3
|
+
|
|
4
|
+
export function renderCloseButton(fsLightbox, parent) {
|
|
5
|
+
const closeButton = renderAndGetToolbarButton(parent, 'Close');
|
|
6
|
+
|
|
7
|
+
closeButton.onclick = fsLightbox.core.lightboxCloser.closeLightbox;
|
|
8
|
+
|
|
9
|
+
renderAndGetSvg(closeButton, '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');
|
|
10
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { renderAndGetSvg } from "../h/renderSvg";
|
|
2
|
+
import { renderAndGetToolbarButton } from "./renderAndGetToolbarButton";
|
|
3
|
+
|
|
4
|
+
export function renderFullscreenButton(
|
|
5
|
+
{
|
|
6
|
+
componentsServices,
|
|
7
|
+
data,
|
|
8
|
+
fs
|
|
9
|
+
},
|
|
10
|
+
parent
|
|
11
|
+
) {
|
|
12
|
+
const enterSize = '20px';
|
|
13
|
+
const enterViewBox = '0 0 18 18';
|
|
14
|
+
const enterD = 'M4.5 11H3v4h4v-1.5H4.5V11zM3 7h1.5V4.5H7V3H3v4zm10.5 6.5H11V15h4v-4h-1.5v2.5zM11 3v1.5h2.5V7H15V3h-4z';
|
|
15
|
+
|
|
16
|
+
const exitSize = '24px';
|
|
17
|
+
const exitViewBox = '0 0 950 1024';
|
|
18
|
+
const exitD = 'M682 342h128v84h-212v-212h84v128zM598 810v-212h212v84h-128v128h-84zM342 342v-128h84v212h-212v-84h128zM214 682v-84h212v212h-84v-128h-128z';
|
|
19
|
+
|
|
20
|
+
const fullscreenButton = renderAndGetToolbarButton(parent);
|
|
21
|
+
fullscreenButton.title = 'Enter fullscreen';
|
|
22
|
+
const svg = renderAndGetSvg(fullscreenButton, enterSize, enterViewBox, enterD);
|
|
23
|
+
|
|
24
|
+
componentsServices.ofs = () => {
|
|
25
|
+
data.ifs = true;
|
|
26
|
+
fullscreenButton.title = 'Exit fullscreen';
|
|
27
|
+
svg.setAttributeNS(null, 'width', exitSize);
|
|
28
|
+
svg.setAttributeNS(null, 'height', exitSize);
|
|
29
|
+
svg.setAttributeNS(null, 'viewBox', exitViewBox);
|
|
30
|
+
svg.firstChild.setAttributeNS(null, 'd', exitD);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
componentsServices.xfs = () => {
|
|
34
|
+
data.ifs = false;
|
|
35
|
+
fullscreenButton.title = 'Enter fullscreen';
|
|
36
|
+
svg.setAttributeNS(null, 'width', enterSize);
|
|
37
|
+
svg.setAttributeNS(null, 'height', enterSize);
|
|
38
|
+
svg.setAttributeNS(null, 'viewBox', enterViewBox);
|
|
39
|
+
svg.firstChild.setAttributeNS(null, 'd', enterD);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
fullscreenButton.onclick = fs.t;
|
|
43
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { renderToolbar } from "./renderToolbar";
|
|
2
|
+
import { renderSlideNumber } from "./renderSlideNumber";
|
|
3
|
+
import { PREFIX } from "../../cn/classes-names";
|
|
4
|
+
|
|
5
|
+
export function renderNav(fsLightbox) {
|
|
6
|
+
const { props: { sources }, elements: { container } } = fsLightbox;
|
|
7
|
+
|
|
8
|
+
const nav = document.createElement('div');
|
|
9
|
+
nav.className = `${PREFIX}nav`;
|
|
10
|
+
container.appendChild(nav);
|
|
11
|
+
|
|
12
|
+
renderToolbar(fsLightbox, nav);
|
|
13
|
+
|
|
14
|
+
if (sources.length > 1) {
|
|
15
|
+
renderSlideNumber(fsLightbox, nav);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FLEX_CENTERED_CLASS_NAME, PREFIX } from "../../cn/classes-names";
|
|
2
|
+
|
|
3
|
+
export function renderSlideNumber({ componentsServices, props: { sources }, stageIndexes }, parent) {
|
|
4
|
+
const slideNumberOuter = document.createElement('div');
|
|
5
|
+
slideNumberOuter.className = `${PREFIX}slide-number-container`;
|
|
6
|
+
|
|
7
|
+
const slideNumberInner = document.createElement('div');
|
|
8
|
+
slideNumberInner.className = FLEX_CENTERED_CLASS_NAME;
|
|
9
|
+
|
|
10
|
+
const currentNumber = document.createElement('span');
|
|
11
|
+
componentsServices.setSlideNumber = (number) => currentNumber.innerHTML = number;
|
|
12
|
+
const slash = document.createElement('span');
|
|
13
|
+
slash.className = `${PREFIX}slash`;
|
|
14
|
+
|
|
15
|
+
const totalNumber = document.createElement('div');
|
|
16
|
+
totalNumber.innerHTML = sources.length;
|
|
17
|
+
|
|
18
|
+
slideNumberOuter.appendChild(slideNumberInner);
|
|
19
|
+
slideNumberInner.appendChild(currentNumber);
|
|
20
|
+
slideNumberInner.appendChild(slash);
|
|
21
|
+
slideNumberInner.appendChild(totalNumber);
|
|
22
|
+
parent.appendChild(slideNumberOuter);
|
|
23
|
+
|
|
24
|
+
setTimeout(() => {
|
|
25
|
+
if (slideNumberInner.offsetWidth > 55) {
|
|
26
|
+
slideNumberOuter.style.justifyContent = 'flex-start';
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PREFIX } from "../../cn/classes-names";
|
|
2
|
+
import { renderFullscreenButton } from "./renderFullscreenButton";
|
|
3
|
+
import { renderCloseButton } from "./renderCloseButton";
|
|
4
|
+
|
|
5
|
+
export function renderToolbar(fsLightbox, parent) {
|
|
6
|
+
const toolbar = document.createElement('div');
|
|
7
|
+
toolbar.className = `${PREFIX}toolbar`;
|
|
8
|
+
|
|
9
|
+
parent.appendChild(toolbar);
|
|
10
|
+
|
|
11
|
+
renderFullscreenButton(fsLightbox, toolbar);
|
|
12
|
+
renderCloseButton(fsLightbox, toolbar);
|
|
13
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FLEX_CENTERED_CLASS_NAME, SLIDE_BTN } from "../cn/classes-names";
|
|
2
|
+
import { renderAndGetSvg } from "./h/renderSvg";
|
|
3
|
+
|
|
4
|
+
export function renderSlideButton(parent, d) {
|
|
5
|
+
const button = document.createElement('div');
|
|
6
|
+
button.className = `${SLIDE_BTN} ${FLEX_CENTERED_CLASS_NAME}`;
|
|
7
|
+
|
|
8
|
+
renderAndGetSvg(button, '20px', '0 0 20 20', d);
|
|
9
|
+
|
|
10
|
+
parent.appendChild(button);
|
|
11
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SLIDE_BTN_CONTAINER } from "../cn/classes-names";
|
|
2
|
+
import { renderSlideButton } from "./renderSlideButton";
|
|
3
|
+
|
|
4
|
+
export function renderSlideButtonContainer({ elements: { container } }, onClick, name, d) {
|
|
5
|
+
const titleName = name.charAt(0).toUpperCase() + name.slice(1);
|
|
6
|
+
|
|
7
|
+
const slideBtnContainer = document.createElement('div');
|
|
8
|
+
slideBtnContainer.className = `${ SLIDE_BTN_CONTAINER } ${ SLIDE_BTN_CONTAINER }-${ name }`;
|
|
9
|
+
slideBtnContainer.title = `${ titleName } slide`;
|
|
10
|
+
slideBtnContainer.onclick = onClick;
|
|
11
|
+
|
|
12
|
+
renderSlideButton(slideBtnContainer, d);
|
|
13
|
+
|
|
14
|
+
container.appendChild(slideBtnContainer);
|
|
15
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { renderSlideButtonContainer } from "./renderSlideButtonContainer";
|
|
2
|
+
|
|
3
|
+
export function renderSlideButtons(fsLightbox) {
|
|
4
|
+
const { core: { slideChangeFacade } } = fsLightbox;
|
|
5
|
+
renderSlideButtonContainer(fsLightbox, slideChangeFacade.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');
|
|
6
|
+
renderSlideButtonContainer(fsLightbox, slideChangeFacade.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');
|
|
7
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ABSOLUTED_CLASS_NAME, FULL_DIMENSION_CLASS_NAME, PREFIX } from "../cn/classes-names";
|
|
2
|
+
|
|
3
|
+
export function renderSlideSwipingHoverer({ elements }) {
|
|
4
|
+
elements.slideSwipingHoverer = document.createElement('div');
|
|
5
|
+
elements.slideSwipingHoverer.className = `${PREFIX}slide-swiping-hoverer ${FULL_DIMENSION_CLASS_NAME} ${ABSOLUTED_CLASS_NAME}`;
|
|
6
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SOURCE_CLASS_NAME } from "../../../cn/classes-names";
|
|
2
|
+
import { setUpSourceClassName } from "../../../h/source/setUpSourceClassName";
|
|
3
|
+
|
|
4
|
+
export function renderCustom(fsLightbox, i) {
|
|
5
|
+
const {
|
|
6
|
+
collections: { sourceLoadHandlers },
|
|
7
|
+
elements: { sources: sourcesElements, sourceAnimationWrappers },
|
|
8
|
+
props: { sources }
|
|
9
|
+
} = fsLightbox;
|
|
10
|
+
|
|
11
|
+
sourcesElements[i] = sources[i];
|
|
12
|
+
setUpSourceClassName(fsLightbox, i, `${sourcesElements[i].className} ${SOURCE_CLASS_NAME}`);
|
|
13
|
+
sourceAnimationWrappers[i].appendChild(sourcesElements[i]);
|
|
14
|
+
sourceLoadHandlers[i].handleCustomLoad();
|
|
15
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SOURCE_CLASS_NAME } from "../../../cn/classes-names";
|
|
2
|
+
import { setUpSourceClassName } from "../../../h/source/setUpSourceClassName";
|
|
3
|
+
import { setUpSourceCustomAttributes } from "../../../h/source/setUpSourceCustomAttributes";
|
|
4
|
+
|
|
5
|
+
export function renderImage(fsLightbox, i) {
|
|
6
|
+
const {
|
|
7
|
+
collections: { sourceLoadHandlers },
|
|
8
|
+
elements: { sources: sourcesElements, sourceAnimationWrappers },
|
|
9
|
+
props: { sources }
|
|
10
|
+
} = fsLightbox;
|
|
11
|
+
|
|
12
|
+
sourcesElements[i] = document.createElement('img');
|
|
13
|
+
setUpSourceClassName(fsLightbox, i, SOURCE_CLASS_NAME);
|
|
14
|
+
sourcesElements[i].src = sources[i];
|
|
15
|
+
sourcesElements[i].onload = sourceLoadHandlers[i].handleImageLoad;
|
|
16
|
+
setUpSourceCustomAttributes(fsLightbox, i);
|
|
17
|
+
sourceAnimationWrappers[i].appendChild(sourcesElements[i]);
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FADE_IN_STRONG_CLASS_NAME, FLEX_CENTERED_CLASS_NAME, PREFIX } from "../../../cn/classes-names";
|
|
2
|
+
|
|
3
|
+
export function renderInvalid(
|
|
4
|
+
{
|
|
5
|
+
elements: { sources: sourcesElements, sourceAnimationWrappers },
|
|
6
|
+
props: { sources }
|
|
7
|
+
}, i
|
|
8
|
+
) {
|
|
9
|
+
sourcesElements[i] = document.createElement('div');
|
|
10
|
+
sourcesElements[i].className = `${PREFIX}invalid-file-wrapper ${FLEX_CENTERED_CLASS_NAME}`;
|
|
11
|
+
sourcesElements[i].innerHTML = 'Invalid source';
|
|
12
|
+
|
|
13
|
+
sourceAnimationWrappers[i].classList.add(FADE_IN_STRONG_CLASS_NAME);
|
|
14
|
+
|
|
15
|
+
sourceAnimationWrappers[i].removeChild(sourceAnimationWrappers[i].firstChild);
|
|
16
|
+
|
|
17
|
+
sourceAnimationWrappers[i].appendChild(sourcesElements[i]);
|
|
18
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SOURCE_CLASS_NAME } from "../../../cn/classes-names";
|
|
2
|
+
import { setUpSourceClassName } from "../../../h/source/setUpSourceClassName";
|
|
3
|
+
import { setUpSourceCustomAttributes } from "../../../h/source/setUpSourceCustomAttributes";
|
|
4
|
+
|
|
5
|
+
export function renderVideo(fsLightbox, i) {
|
|
6
|
+
const {
|
|
7
|
+
collections: { sourceLoadHandlers },
|
|
8
|
+
elements: { sources: sourcesElements, sourceAnimationWrappers },
|
|
9
|
+
props: { sources, videosPosters }
|
|
10
|
+
} = fsLightbox;
|
|
11
|
+
|
|
12
|
+
sourcesElements[i] = document.createElement('video');
|
|
13
|
+
setUpSourceClassName(fsLightbox, i, SOURCE_CLASS_NAME)
|
|
14
|
+
sourcesElements[i].src = sources[i];
|
|
15
|
+
sourcesElements[i].onloadedmetadata = (e) => {
|
|
16
|
+
sourceLoadHandlers[i].handleVideoLoad(e);
|
|
17
|
+
};
|
|
18
|
+
sourcesElements[i].controls = true;
|
|
19
|
+
setUpSourceCustomAttributes(fsLightbox, i);
|
|
20
|
+
if (videosPosters[i]) {
|
|
21
|
+
sourcesElements[i].poster = videosPosters[i];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const source = document.createElement('source');
|
|
25
|
+
source.src = sources[i];
|
|
26
|
+
sourcesElements[i].appendChild(source);
|
|
27
|
+
|
|
28
|
+
setTimeout(sourceLoadHandlers[i].handleNotMetaDatedVideoLoad, 3000);
|
|
29
|
+
|
|
30
|
+
sourceAnimationWrappers[i].appendChild(sourcesElements[i]);
|
|
31
|
+
}
|