fslightbox 3.4.0 → 3.4.1
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/index.js +1 -1
- package/package.json +3 -3
- package/c/elements/setUpClassFacade.js +0 -9
- package/c/events/setUpEventsDispatcher.js +0 -7
- package/c/events/setUpGlobalEventsController.js +0 -39
- package/c/keyboard/KeyboardController.js +0 -26
- package/c/main-component/closing/LightboxCloseActioner.js +0 -46
- package/c/main-component/closing/setUpLightboxCloser.js +0 -11
- package/c/scrollbar/gsw.js +0 -1
- package/c/scrollbar/setUpScrollbarRecompensor.js +0 -20
- package/c/setUpCore.js +0 -30
- package/c/sfs.js +0 -1
- package/c/sizes/setUpWindowResizeActioner.js +0 -38
- package/c/slide/setUpSlideChangeFacade.js +0 -23
- package/c/slide/setUpSlideIndexChanger.js +0 -89
- package/c/so.js +0 -1
- package/c/sources/SourceLoadActioner.js +0 -32
- package/c/sources/SourceLoadHandler.js +0 -41
- package/c/sources/SourceSizer.js +0 -36
- package/c/sources/creating/CreatingSourcesBucket.js +0 -29
- package/c/sources/creating/CreatingSourcesLocalStorageManager.js +0 -55
- package/c/sources/creating/createSources.js +0 -28
- package/c/sources/pointering/down/setUpSourcesPointerDown.js +0 -38
- package/c/sources/pointering/move/SourcesPointerMove.js +0 -16
- package/c/sources/pointering/move/SourcesPointerMoveActioner.js +0 -34
- package/c/sources/pointering/up/SourcesPointerUp.js +0 -13
- package/c/sources/pointering/up/SourcesPointerUpActioner.js +0 -38
- package/c/sources/pointering/up/SourcesPointerUpActionerBucket.js +0 -1
- package/c/sources/setUpSourceDisplayFacade.js +0 -26
- package/c/sources/types/AutomaticTypeDetector.js +0 -70
- package/c/sources/types/DetectedTypeActioner.js +0 -44
- package/c/sources/types/getAutomaticTypeDetectorBucket.js +0 -14
- package/c/stage/setUpStageManager.js +0 -57
- package/c/stage/ssws.js +0 -2
- package/c/styles/createAndAppendStyles.js +0 -9
- package/c/styles/injectStylesIfNotInDom.js +0 -8
- package/c/styles/styles-injection/styles-injection.js +0 -5
- package/c/timeouts/getQueuedAction.js +0 -15
- package/cm/h/renderSvg.js +0 -17
- package/cm/nav/renderAndGetToolbarButton.js +0 -11
- package/cm/nav/renderCloseButton.js +0 -10
- package/cm/nav/renderFullscreenButton.js +0 -43
- package/cm/nav/renderNav.js +0 -17
- package/cm/nav/renderSlideNumber.js +0 -29
- package/cm/nav/renderToolbar.js +0 -13
- package/cm/renderSlideButton.js +0 -11
- package/cm/renderSlideButtonContainer.js +0 -15
- package/cm/renderSlideButtons.js +0 -7
- package/cm/renderSlideSwipingHoverer.js +0 -6
- package/cm/sources/proper-sources/renderCustom.js +0 -15
- package/cm/sources/proper-sources/renderImage.js +0 -18
- package/cm/sources/proper-sources/renderInvalid.js +0 -18
- package/cm/sources/proper-sources/renderVideo.js +0 -31
- package/cm/sources/proper-sources/renderYoutube.js +0 -26
- package/cm/sources/renderSourceWrappersContainer.js +0 -18
- package/cm/sources/saw.js +0 -1
- package/cm/sources/smw.js +0 -1
- package/cn/classes-names.js +0 -27
- package/cn/core-constants.js +0 -6
- package/cn/css-constants.js +0 -1
- package/cn/dom-constants.js +0 -1
- package/cn/elements.js +0 -3
- package/cn/local-storage-constants.js +0 -2
- package/h/elements/addToElementClassIfNotContains.js +0 -6
- package/h/elements/removeFromElementChildIfContains.js +0 -5
- package/h/elements/removeFromElementClassIfContains.js +0 -6
- package/h/objects/assignToObject.js +0 -10
- package/h/source/setUpSourceClassName.js +0 -13
- package/h/source/setUpSourceCustomAttributes.js +0 -5
- package/h/state/ifOnUpdateExistsHandleItForState.js +0 -6
- package/s.js +0 -1
package/c/sources/SourceSizer.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export function SourceSizer({ data, elements: { sources } }, i, defaultWidth, defaultHeight) {
|
|
2
|
-
const ratio = defaultWidth / defaultHeight;
|
|
3
|
-
let newHeight = 0;
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* This method takes care of setting sources dimensions.
|
|
7
|
-
* Unfortunately wa cannot only set max width and max height and allow the sources to scale themselves,
|
|
8
|
-
* due tu Youtube source which dimensions needs to be set in advance.
|
|
9
|
-
* In this case we are calculating dimensions mathematically.
|
|
10
|
-
*/
|
|
11
|
-
this.adjustSize = () => {
|
|
12
|
-
newHeight = data.maxSourceWidth / ratio;
|
|
13
|
-
|
|
14
|
-
// wider than higher
|
|
15
|
-
if (newHeight < data.maxSourceHeight) {
|
|
16
|
-
if (defaultWidth < data.maxSourceWidth) {
|
|
17
|
-
newHeight = defaultHeight;
|
|
18
|
-
}
|
|
19
|
-
return updateDimensions();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// higher than wider
|
|
23
|
-
if (defaultHeight > data.maxSourceHeight) {
|
|
24
|
-
newHeight = data.maxSourceHeight;
|
|
25
|
-
} else {
|
|
26
|
-
newHeight = defaultHeight;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
updateDimensions();
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const updateDimensions = () => {
|
|
33
|
-
sources[i].style.width = newHeight * ratio + 'px';
|
|
34
|
-
sources[i].style.height = newHeight + 'px';
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { AutomaticTypeDetector } from "../types/AutomaticTypeDetector";
|
|
2
|
-
|
|
3
|
-
export function CreatingSourcesBucket(
|
|
4
|
-
{
|
|
5
|
-
props: { types, type, sources }, resolve,
|
|
6
|
-
}, localStorageManager, detectedTypeActioner
|
|
7
|
-
) {
|
|
8
|
-
this.getTypeSetByClientForIndex = (i) => {
|
|
9
|
-
let typeSetManuallyByClient;
|
|
10
|
-
|
|
11
|
-
if (types && types[i]) {
|
|
12
|
-
typeSetManuallyByClient = types[i];
|
|
13
|
-
} else if (type) {
|
|
14
|
-
typeSetManuallyByClient = type;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return typeSetManuallyByClient;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
this.retrieveTypeWithXhrForIndex = (i) => {
|
|
21
|
-
// we need to copy index because xhr will for sure come later than next loop iteration
|
|
22
|
-
const automaticTypeDetector = resolve(AutomaticTypeDetector);
|
|
23
|
-
automaticTypeDetector.setUrlToCheck(sources[i]);
|
|
24
|
-
automaticTypeDetector.getSourceType((sourceType) => {
|
|
25
|
-
localStorageManager.handleReceivedSourceTypeForUrl(sourceType, sources[i]);
|
|
26
|
-
detectedTypeActioner.runActionsForSourceTypeAndIndex(sourceType, i)
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { SOURCES_TYPES_KEY } from "../../../cn/local-storage-constants";
|
|
2
|
-
import { assignToObject } from "../../../h/objects/assignToObject";
|
|
3
|
-
|
|
4
|
-
export function CreatingSourcesLocalStorageManager({ props }) {
|
|
5
|
-
const NEW_TYPE_SHOULD_BE_ADDED_HERE = false;
|
|
6
|
-
let decodedSourceTypes;
|
|
7
|
-
let newSourceTypesToDetect = 0;
|
|
8
|
-
const newTypes = {};
|
|
9
|
-
|
|
10
|
-
this.getSourceTypeFromLocalStorageByUrl = (url) => {
|
|
11
|
-
if (!decodedSourceTypes[url]) {
|
|
12
|
-
return addNewUrlToDetect(url);
|
|
13
|
-
}
|
|
14
|
-
return decodedSourceTypes[url];
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
this.handleReceivedSourceTypeForUrl = (sourceType, url) => {
|
|
18
|
-
if (newTypes[url] === NEW_TYPE_SHOULD_BE_ADDED_HERE) {
|
|
19
|
-
newSourceTypesToDetect--;
|
|
20
|
-
|
|
21
|
-
// not storing invalid types
|
|
22
|
-
if (sourceType !== 'invalid') {
|
|
23
|
-
newTypes[url] = sourceType;
|
|
24
|
-
} else {
|
|
25
|
-
delete newTypes[url];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (newSourceTypesToDetect === 0) {
|
|
29
|
-
assignToObject(decodedSourceTypes, newTypes);
|
|
30
|
-
try{localStorage.setItem(SOURCES_TYPES_KEY, JSON.stringify(decodedSourceTypes));}catch{}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const addNewUrlToDetect = (url) => {
|
|
36
|
-
newSourceTypesToDetect++;
|
|
37
|
-
newTypes[url] = NEW_TYPE_SHOULD_BE_ADDED_HERE;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
if (!props.disableLocalStorage) {
|
|
41
|
-
try{decodedSourceTypes = JSON.parse(localStorage.getItem(SOURCES_TYPES_KEY));}catch{}
|
|
42
|
-
// we are checking if detected source types contains at certain key source type
|
|
43
|
-
// when localStorage will be empty we can overwrite this method because we are sure
|
|
44
|
-
// that at every index will be no source type
|
|
45
|
-
if (!decodedSourceTypes) {
|
|
46
|
-
// in ifAllNewTypesAreDetectedStoreAllTypesToLocalStorage we are assigning to
|
|
47
|
-
// decodedSourceTypes new Types so we need to make it an object to avoid errors
|
|
48
|
-
decodedSourceTypes = {};
|
|
49
|
-
this.getSourceTypeFromLocalStorageByUrl = addNewUrlToDetect;
|
|
50
|
-
}
|
|
51
|
-
} else {
|
|
52
|
-
this.getSourceTypeFromLocalStorageByUrl = function () {};
|
|
53
|
-
this.handleReceivedSourceTypeForUrl = function () {};
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { CreatingSourcesLocalStorageManager } from "./CreatingSourcesLocalStorageManager";
|
|
2
|
-
import { DetectedTypeActioner } from "../types/DetectedTypeActioner";
|
|
3
|
-
import { CreatingSourcesBucket } from "./CreatingSourcesBucket";
|
|
4
|
-
import { CUSTOM_TYPE } from "../../../cn/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
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { SOURCE_MAIN_WRAPPERS } from "../../../../cn/elements";
|
|
2
|
-
import { TRANSFORM_TRANSITION_CLASS_NAME } from "../../../../cn/classes-names";
|
|
3
|
-
|
|
4
|
-
export function setUpSourcesPointerDown(
|
|
5
|
-
{
|
|
6
|
-
core: { classFacade, sourcesPointerDown: self },
|
|
7
|
-
elements: { smw, 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
|
-
for (var i=0;i<smw.length;i++) {
|
|
33
|
-
smw[i].d();
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
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]();}}}
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
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.
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
-
}
|
package/cm/h/renderSvg.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
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
|
-
}
|