@magicfeedback/popup-sdk 1.0.4 → 1.0.6
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/dist/assets/assets/style.css +844 -0
- package/dist/index.d.mts +17 -4
- package/dist/index.d.ts +17 -4
- package/dist/index.js +231 -83
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +231 -83
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -87,10 +87,23 @@ interface PopupActionDecline {
|
|
|
87
87
|
label: string;
|
|
88
88
|
cooldownDays?: number;
|
|
89
89
|
}
|
|
90
|
+
/** Start Surveys Action */
|
|
91
|
+
interface PopupActionStart {
|
|
92
|
+
label: string;
|
|
93
|
+
}
|
|
94
|
+
/** Acción de completar (aceptar y completar encuesta automáticamente) */
|
|
95
|
+
interface PopupActionComplete {
|
|
96
|
+
label: string;
|
|
97
|
+
surveyId: string;
|
|
98
|
+
autoCompleteParams: Record<string, unknown>;
|
|
99
|
+
cooldownDays?: number;
|
|
100
|
+
}
|
|
90
101
|
/** Conjunto de acciones disponibles en el popup */
|
|
91
102
|
interface PopupActions {
|
|
92
|
-
accept
|
|
93
|
-
decline
|
|
103
|
+
accept?: PopupActionAccept;
|
|
104
|
+
decline?: PopupActionDecline;
|
|
105
|
+
complete?: PopupActionComplete;
|
|
106
|
+
start?: PopupActionStart;
|
|
94
107
|
}
|
|
95
108
|
/** Estilos configurables del popup */
|
|
96
109
|
interface PopupStyle {
|
|
@@ -110,10 +123,10 @@ interface PopupDefinition {
|
|
|
110
123
|
title: string;
|
|
111
124
|
message: string;
|
|
112
125
|
trigger: PopupTrigger;
|
|
113
|
-
actions
|
|
126
|
+
actions?: PopupActions;
|
|
114
127
|
surveyId: string;
|
|
115
128
|
productId: string;
|
|
116
|
-
style
|
|
129
|
+
style?: PopupStyle;
|
|
117
130
|
segments?: PopupSegments;
|
|
118
131
|
}
|
|
119
132
|
|
package/dist/index.d.ts
CHANGED
|
@@ -87,10 +87,23 @@ interface PopupActionDecline {
|
|
|
87
87
|
label: string;
|
|
88
88
|
cooldownDays?: number;
|
|
89
89
|
}
|
|
90
|
+
/** Start Surveys Action */
|
|
91
|
+
interface PopupActionStart {
|
|
92
|
+
label: string;
|
|
93
|
+
}
|
|
94
|
+
/** Acción de completar (aceptar y completar encuesta automáticamente) */
|
|
95
|
+
interface PopupActionComplete {
|
|
96
|
+
label: string;
|
|
97
|
+
surveyId: string;
|
|
98
|
+
autoCompleteParams: Record<string, unknown>;
|
|
99
|
+
cooldownDays?: number;
|
|
100
|
+
}
|
|
90
101
|
/** Conjunto de acciones disponibles en el popup */
|
|
91
102
|
interface PopupActions {
|
|
92
|
-
accept
|
|
93
|
-
decline
|
|
103
|
+
accept?: PopupActionAccept;
|
|
104
|
+
decline?: PopupActionDecline;
|
|
105
|
+
complete?: PopupActionComplete;
|
|
106
|
+
start?: PopupActionStart;
|
|
94
107
|
}
|
|
95
108
|
/** Estilos configurables del popup */
|
|
96
109
|
interface PopupStyle {
|
|
@@ -110,10 +123,10 @@ interface PopupDefinition {
|
|
|
110
123
|
title: string;
|
|
111
124
|
message: string;
|
|
112
125
|
trigger: PopupTrigger;
|
|
113
|
-
actions
|
|
126
|
+
actions?: PopupActions;
|
|
114
127
|
surveyId: string;
|
|
115
128
|
productId: string;
|
|
116
|
-
style
|
|
129
|
+
style?: PopupStyle;
|
|
117
130
|
segments?: PopupSegments;
|
|
118
131
|
}
|
|
119
132
|
|
package/dist/index.js
CHANGED
|
@@ -1734,7 +1734,7 @@ function ensureMagicFeedbackStyles(popup) {
|
|
|
1734
1734
|
}
|
|
1735
1735
|
const link = document.createElement("link");
|
|
1736
1736
|
link.rel = "stylesheet";
|
|
1737
|
-
link.href = "https://cdn.jsdelivr.net/npm/@magicfeedback/
|
|
1737
|
+
link.href = "https://cdn.jsdelivr.net/npm/@magicfeedback/popup-sdk/dist/assets/style.css";
|
|
1738
1738
|
link.setAttribute(DATA_ATTR, "true");
|
|
1739
1739
|
popup.appendChild(link);
|
|
1740
1740
|
}
|
|
@@ -1759,7 +1759,7 @@ function ensureResponsiveStyles(popup) {
|
|
|
1759
1759
|
.deepdots-popup {
|
|
1760
1760
|
width: 100% !important;
|
|
1761
1761
|
max-width: 100% !important;
|
|
1762
|
-
height:
|
|
1762
|
+
height: 90vh !important;
|
|
1763
1763
|
max-height: 100vh !important;
|
|
1764
1764
|
border-radius: 0 !important;
|
|
1765
1765
|
padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)) 16px !important;
|
|
@@ -1767,12 +1767,15 @@ function ensureResponsiveStyles(popup) {
|
|
|
1767
1767
|
}
|
|
1768
1768
|
.deepdots-popup .mf-spinner-circle { width: 32px; height: 32px; border-width: 4px; }
|
|
1769
1769
|
.deepdots-popup button { font-size: 16px !important; }
|
|
1770
|
-
.deepdots-popup-
|
|
1770
|
+
.deepdots-popup-header button { width:48px; height:48px; }
|
|
1771
|
+
.deepdots-popup-header button svg { width:26px; height:26px; }
|
|
1772
|
+
.deepdots-popup-footer { flex-direction: column-reverse !important; gap: 12px !important; }
|
|
1771
1773
|
.deepdots-popup-footer button { width: 100%; }
|
|
1772
1774
|
}
|
|
1773
1775
|
@media (max-width: 400px) {
|
|
1774
1776
|
.deepdots-popup { padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom)) 12px !important; }
|
|
1775
|
-
.deepdots-popup button {
|
|
1777
|
+
.deepdots-popup-header button { width:48px; height:48px; }
|
|
1778
|
+
.deepdots-popup-header button svg { width:26px; height:26px; }
|
|
1776
1779
|
}
|
|
1777
1780
|
@media (orientation: landscape) and (max-height: 480px) {
|
|
1778
1781
|
.deepdots-popup {
|
|
@@ -1786,6 +1789,7 @@ function ensureResponsiveStyles(popup) {
|
|
|
1786
1789
|
}
|
|
1787
1790
|
async function renderPopup(container, surveyId, productId, actions, emit, onClose) {
|
|
1788
1791
|
let surveyCompletedEmitted = false;
|
|
1792
|
+
let stylesInjected = false;
|
|
1789
1793
|
const popup = document.createElement("div");
|
|
1790
1794
|
popup.className = "deepdots-popup";
|
|
1791
1795
|
popup.style.cssText = `
|
|
@@ -1800,33 +1804,41 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
1800
1804
|
max-width: 600px;
|
|
1801
1805
|
width: 90%;
|
|
1802
1806
|
min-height: 200px;
|
|
1803
|
-
max-height: 80vh; /* l\xEDmite general del popup */
|
|
1804
|
-
overflow: hidden; /* quita scroll del contenedor principal */
|
|
1805
1807
|
`;
|
|
1806
1808
|
const header = document.createElement("div");
|
|
1807
1809
|
header.className = "deepdots-popup-header";
|
|
1808
|
-
header.style.cssText = "display:flex; justify-content:flex-end; align-items:center; width:100%;
|
|
1810
|
+
header.style.cssText = "display:flex; justify-content:flex-end; align-items:center; width:100%;";
|
|
1809
1811
|
const closeBtn = document.createElement("button");
|
|
1810
1812
|
closeBtn.type = "button";
|
|
1811
1813
|
closeBtn.setAttribute("aria-label", "Close popup");
|
|
1812
|
-
closeBtn.innerHTML =
|
|
1814
|
+
closeBtn.innerHTML = `
|
|
1815
|
+
<svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
1816
|
+
<path d="M6 6L18 18M6 18L18 6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
1817
|
+
</svg>
|
|
1818
|
+
`;
|
|
1813
1819
|
closeBtn.style.cssText = `
|
|
1814
1820
|
background:transparent;
|
|
1815
1821
|
border:none;
|
|
1816
|
-
|
|
1817
|
-
|
|
1822
|
+
width:32px;
|
|
1823
|
+
height:32px;
|
|
1824
|
+
display:flex;
|
|
1825
|
+
align-items:center;
|
|
1826
|
+
justify-content:center;
|
|
1827
|
+
border-radius: 8px;
|
|
1818
1828
|
cursor:pointer;
|
|
1819
|
-
color:#
|
|
1829
|
+
color:#111;
|
|
1820
1830
|
padding:4px;
|
|
1821
|
-
transition: color .15s ease, transform .15s ease;
|
|
1822
|
-
box-shadow: none;
|
|
1831
|
+
transition: color .15s ease, transform .15s ease, background .15s ease;
|
|
1832
|
+
box-shadow: none !important;
|
|
1823
1833
|
`;
|
|
1824
1834
|
closeBtn.onmouseenter = () => {
|
|
1825
|
-
closeBtn.style.color = "#
|
|
1826
|
-
closeBtn.style.
|
|
1835
|
+
closeBtn.style.color = "#000000";
|
|
1836
|
+
closeBtn.style.background = "rgba(0,0,0,0.06)";
|
|
1837
|
+
closeBtn.style.transform = "scale(1.06)";
|
|
1827
1838
|
};
|
|
1828
1839
|
closeBtn.onmouseleave = () => {
|
|
1829
|
-
closeBtn.style.color = "#
|
|
1840
|
+
closeBtn.style.color = "#111";
|
|
1841
|
+
closeBtn.style.background = "transparent";
|
|
1830
1842
|
closeBtn.style.transform = "scale(1)";
|
|
1831
1843
|
};
|
|
1832
1844
|
closeBtn.onclick = () => {
|
|
@@ -1837,11 +1849,20 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
1837
1849
|
ensureMagicFeedbackStyles(popup);
|
|
1838
1850
|
ensureSpinnerStyles(popup);
|
|
1839
1851
|
ensureResponsiveStyles(popup);
|
|
1852
|
+
const containerContent = document.createElement("div");
|
|
1853
|
+
containerContent.className = "deepdots-popup-container-conetent";
|
|
1854
|
+
containerContent.style.cssText = `
|
|
1855
|
+
display:flex;
|
|
1856
|
+
flex-direction:column;
|
|
1857
|
+
padding: 0 20px 12px 20px;
|
|
1858
|
+
max-height: 80vh; /* l\xEDmite general del popup */
|
|
1859
|
+
overflow: hidden; /* quita scroll del contenedor principal */
|
|
1860
|
+
`;
|
|
1840
1861
|
const main = document.createElement("div");
|
|
1841
1862
|
main.className = "deepdots-popup-main";
|
|
1842
|
-
main.style.cssText = "display:flex; flex-direction:column; width:100%;
|
|
1863
|
+
main.style.cssText = "display:flex; flex-direction:column; width:100%; max-height:80vh; overflow-y:auto;";
|
|
1843
1864
|
const formWrapper = document.createElement("div");
|
|
1844
|
-
formWrapper.style.cssText = "
|
|
1865
|
+
formWrapper.style.cssText = "width:100%; flex: 1 1 auto;";
|
|
1845
1866
|
const spinnerEl = document.createElement("div");
|
|
1846
1867
|
spinnerEl.className = "mf-spinner";
|
|
1847
1868
|
spinnerEl.setAttribute("role", "status");
|
|
@@ -1858,25 +1879,84 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
1858
1879
|
const footer = document.createElement("div");
|
|
1859
1880
|
footer.className = "deepdots-popup-footer";
|
|
1860
1881
|
footer.setAttribute("data-actions-wrapper", "true");
|
|
1861
|
-
footer.style.cssText = "display:flex; justify-content:space-between; align-items:center; gap:8px; margin-top:
|
|
1862
|
-
const
|
|
1863
|
-
|
|
1864
|
-
|
|
1882
|
+
footer.style.cssText = "display:flex; flex-direction: row-reverse ;justify-content:space-between; align-items:center; gap:8px; margin-top:auto; width:100%; padding-top:16px;";
|
|
1883
|
+
const backButton = document.createElement("button");
|
|
1884
|
+
backButton.textContent = "Back";
|
|
1885
|
+
backButton.style.cssText = `
|
|
1865
1886
|
background: transparent;
|
|
1866
1887
|
color: #333;
|
|
1867
|
-
border: 1px solid #
|
|
1868
|
-
padding:
|
|
1888
|
+
border: 1px solid #999;
|
|
1889
|
+
padding: 12px 24px;
|
|
1890
|
+
border-radius: 4px;
|
|
1891
|
+
cursor: pointer;
|
|
1892
|
+
font-size: 14px;
|
|
1893
|
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
1894
|
+
transition: filter .15s ease;
|
|
1895
|
+
display: inline-flex;
|
|
1896
|
+
align-items: center;
|
|
1897
|
+
justify-content: center;
|
|
1898
|
+
text-align: center;
|
|
1899
|
+
`;
|
|
1900
|
+
backButton.onmouseenter = () => {
|
|
1901
|
+
backButton.style.filter = "brightness(0.9)";
|
|
1902
|
+
};
|
|
1903
|
+
backButton.onmouseleave = () => {
|
|
1904
|
+
backButton.style.filter = "brightness(1)";
|
|
1905
|
+
};
|
|
1906
|
+
backButton.onclick = () => {
|
|
1907
|
+
emit("popup_clicked", surveyId, { action: "back" });
|
|
1908
|
+
formInstance?.back?.();
|
|
1909
|
+
};
|
|
1910
|
+
const startButton = document.createElement("button");
|
|
1911
|
+
startButton.textContent = actions?.start ? actions.start.label : "Start survey";
|
|
1912
|
+
startButton.style.cssText = `
|
|
1913
|
+
background: #1E293B;
|
|
1914
|
+
color: #fff;
|
|
1915
|
+
border: none;
|
|
1916
|
+
padding: 12px 24px;
|
|
1869
1917
|
border-radius: 4px;
|
|
1870
1918
|
cursor: pointer;
|
|
1871
1919
|
font-size: 14px;
|
|
1872
|
-
|
|
1920
|
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
1921
|
+
transition: filter .15s ease;
|
|
1922
|
+
display: inline-flex;
|
|
1923
|
+
align-items: center;
|
|
1924
|
+
justify-content: center;
|
|
1925
|
+
text-align: center;
|
|
1873
1926
|
`;
|
|
1874
|
-
|
|
1875
|
-
emit("popup_clicked", surveyId, { action: "
|
|
1927
|
+
startButton.onclick = () => {
|
|
1928
|
+
emit("popup_clicked", surveyId, { action: "start_survey" });
|
|
1929
|
+
formInstance?.startForm?.();
|
|
1930
|
+
};
|
|
1931
|
+
const closeButton = document.createElement("button");
|
|
1932
|
+
closeButton.textContent = actions?.complete ? actions.complete.label : "Complete survey";
|
|
1933
|
+
closeButton.style.cssText = `
|
|
1934
|
+
background: #1E293B;
|
|
1935
|
+
color: #fff;
|
|
1936
|
+
border: none;
|
|
1937
|
+
padding: 12px 24px;
|
|
1938
|
+
border-radius: 4px;
|
|
1939
|
+
cursor: pointer;
|
|
1940
|
+
font-size: 14px;
|
|
1941
|
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
1942
|
+
transition: filter .15s ease;
|
|
1943
|
+
display: inline-flex;
|
|
1944
|
+
align-items: center;
|
|
1945
|
+
justify-content: center;
|
|
1946
|
+
text-align: center;
|
|
1947
|
+
`;
|
|
1948
|
+
closeButton.onmouseenter = () => {
|
|
1949
|
+
closeButton.style.filter = "brightness(0.9)";
|
|
1950
|
+
};
|
|
1951
|
+
closeButton.onmouseleave = () => {
|
|
1952
|
+
closeButton.style.filter = "brightness(1)";
|
|
1953
|
+
};
|
|
1954
|
+
closeButton.onclick = () => {
|
|
1955
|
+
emit("popup_clicked", surveyId, { action: "complete" });
|
|
1876
1956
|
onClose();
|
|
1877
1957
|
};
|
|
1878
1958
|
const submitButton = document.createElement("button");
|
|
1879
|
-
submitButton.textContent = actions?.accept ? actions.accept.label : "
|
|
1959
|
+
submitButton.textContent = actions?.accept ? actions.accept.label : "Send";
|
|
1880
1960
|
submitButton.style.cssText = `
|
|
1881
1961
|
background: #1E293B;
|
|
1882
1962
|
color: #fff;
|
|
@@ -1887,6 +1967,10 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
1887
1967
|
font-size: 14px;
|
|
1888
1968
|
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
1889
1969
|
transition: filter .15s ease;
|
|
1970
|
+
display: inline-flex;
|
|
1971
|
+
align-items: center;
|
|
1972
|
+
justify-content: center;
|
|
1973
|
+
text-align: center;
|
|
1890
1974
|
`;
|
|
1891
1975
|
submitButton.onclick = () => {
|
|
1892
1976
|
if (!surveyCompletedEmitted) {
|
|
@@ -1894,11 +1978,55 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
1894
1978
|
formInstance?.send?.();
|
|
1895
1979
|
}
|
|
1896
1980
|
};
|
|
1897
|
-
|
|
1981
|
+
backButton.style.display = "none";
|
|
1982
|
+
startButton.style.display = "none";
|
|
1983
|
+
submitButton.style.display = "none";
|
|
1984
|
+
closeButton.style.display = "none";
|
|
1985
|
+
footer.appendChild(backButton);
|
|
1986
|
+
footer.appendChild(closeButton);
|
|
1898
1987
|
footer.appendChild(submitButton);
|
|
1988
|
+
footer.appendChild(startButton);
|
|
1989
|
+
main.appendChild(footer);
|
|
1990
|
+
containerContent.appendChild(main);
|
|
1991
|
+
function updateButtons(state) {
|
|
1992
|
+
backButton.style.display = "none";
|
|
1993
|
+
startButton.style.display = "none";
|
|
1994
|
+
submitButton.style.display = "none";
|
|
1995
|
+
closeButton.style.display = "none";
|
|
1996
|
+
backButton.style.width = "";
|
|
1997
|
+
startButton.style.width = "";
|
|
1998
|
+
submitButton.style.width = "";
|
|
1999
|
+
closeButton.style.width = "";
|
|
2000
|
+
switch (state) {
|
|
2001
|
+
case "loading":
|
|
2002
|
+
break;
|
|
2003
|
+
case "start":
|
|
2004
|
+
startButton.style.display = "inline-flex";
|
|
2005
|
+
startButton.style.width = "100%";
|
|
2006
|
+
break;
|
|
2007
|
+
case "in_progress_first":
|
|
2008
|
+
submitButton.style.display = "inline-flex";
|
|
2009
|
+
submitButton.style.width = "";
|
|
2010
|
+
setLoading(false);
|
|
2011
|
+
break;
|
|
2012
|
+
case "in_progress_next":
|
|
2013
|
+
backButton.style.display = "inline-flex";
|
|
2014
|
+
submitButton.style.display = "inline-flex";
|
|
2015
|
+
setLoading(false);
|
|
2016
|
+
break;
|
|
2017
|
+
case "completed":
|
|
2018
|
+
closeButton.style.display = "inline-flex";
|
|
2019
|
+
closeButton.style.width = "100%";
|
|
2020
|
+
setLoading(false);
|
|
2021
|
+
break;
|
|
2022
|
+
case "error":
|
|
2023
|
+
closeButton.style.display = "inline-flex";
|
|
2024
|
+
setLoading(false);
|
|
2025
|
+
break;
|
|
2026
|
+
}
|
|
2027
|
+
}
|
|
1899
2028
|
popup.appendChild(header);
|
|
1900
|
-
popup.appendChild(
|
|
1901
|
-
popup.appendChild(footer);
|
|
2029
|
+
popup.appendChild(containerContent);
|
|
1902
2030
|
container.innerHTML = "";
|
|
1903
2031
|
container.appendChild(popup);
|
|
1904
2032
|
container.style.display = "flex";
|
|
@@ -1907,10 +2035,16 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
1907
2035
|
if (!isLoading) {
|
|
1908
2036
|
formHost.style.visibility = "visible";
|
|
1909
2037
|
}
|
|
1910
|
-
|
|
2038
|
+
footer.style.display = isLoading ? "none" : "flex";
|
|
2039
|
+
backButton.disabled = isLoading;
|
|
2040
|
+
startButton.disabled = isLoading;
|
|
2041
|
+
closeButton.disabled = isLoading;
|
|
1911
2042
|
submitButton.disabled = isLoading;
|
|
1912
2043
|
submitButton.style.opacity = isLoading ? "0.6" : "1";
|
|
1913
2044
|
submitButton.style.cursor = isLoading ? "not-allowed" : "pointer";
|
|
2045
|
+
if (isLoading) {
|
|
2046
|
+
updateButtons("loading");
|
|
2047
|
+
}
|
|
1914
2048
|
}
|
|
1915
2049
|
setLoading(true);
|
|
1916
2050
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
@@ -1929,12 +2063,13 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
1929
2063
|
addButton: false,
|
|
1930
2064
|
getMetaData: true
|
|
1931
2065
|
};
|
|
1932
|
-
generateOptions.onLoadedEvent = ({ formData }) => {
|
|
2066
|
+
generateOptions.onLoadedEvent = ({ formData, progress }) => {
|
|
1933
2067
|
try {
|
|
1934
2068
|
} catch (e) {
|
|
1935
2069
|
}
|
|
1936
2070
|
const s = formData?.style;
|
|
1937
|
-
if (s) {
|
|
2071
|
+
if (s && !stylesInjected) {
|
|
2072
|
+
stylesInjected = true;
|
|
1938
2073
|
if (s.boxBackgroundColor) {
|
|
1939
2074
|
popup.style.background = s.boxBackgroundColor;
|
|
1940
2075
|
}
|
|
@@ -1945,50 +2080,66 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
1945
2080
|
submitButton.style.background = s.buttonPrimaryColor;
|
|
1946
2081
|
submitButton.style.border = "none";
|
|
1947
2082
|
submitButton.style.color = "#fff";
|
|
2083
|
+
startButton.style.background = s.buttonPrimaryColor;
|
|
2084
|
+
startButton.style.border = "none";
|
|
2085
|
+
startButton.style.color = "#fff";
|
|
2086
|
+
closeButton.style.background = s.buttonPrimaryColor;
|
|
2087
|
+
closeButton.style.border = "none";
|
|
2088
|
+
closeButton.style.color = "#fff";
|
|
1948
2089
|
}
|
|
1949
2090
|
if (s.buttonSecondaryColor) {
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
cancelButton.style.color = "#333";
|
|
2091
|
+
backButton.style.color = "#fff";
|
|
2092
|
+
backButton.style.border = `1px solid ${s.buttonSecondaryColor}`;
|
|
1953
2093
|
}
|
|
1954
2094
|
if (s.logo) {
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
2095
|
+
if (!document.getElementById("deepdots-popup-logo")) {
|
|
2096
|
+
const logoImg = document.createElement("img");
|
|
2097
|
+
logoImg.id = "deepdots-popup-logo";
|
|
2098
|
+
logoImg.src = s.logo;
|
|
2099
|
+
logoImg.alt = "Logo";
|
|
2100
|
+
logoImg.style.cssText = "max-height:40px; max-width:100%; object-fit:contain;";
|
|
2101
|
+
if (s.logoSize) {
|
|
2102
|
+
switch (s.logoSize) {
|
|
2103
|
+
case "small":
|
|
2104
|
+
logoImg.style.maxHeight = "30px";
|
|
2105
|
+
break;
|
|
2106
|
+
case "medium":
|
|
2107
|
+
logoImg.style.maxHeight = "50px";
|
|
2108
|
+
break;
|
|
2109
|
+
case "large":
|
|
2110
|
+
logoImg.style.maxHeight = "70px";
|
|
2111
|
+
break;
|
|
2112
|
+
}
|
|
1970
2113
|
}
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
2114
|
+
if (s.logoPosition) {
|
|
2115
|
+
switch (s.logoPosition) {
|
|
2116
|
+
case "left":
|
|
2117
|
+
logoImg.style.margin = "0 16px 42px 0";
|
|
2118
|
+
logoImg.style.display = "block";
|
|
2119
|
+
logoImg.style.marginLeft = "0";
|
|
2120
|
+
break;
|
|
2121
|
+
case "right":
|
|
2122
|
+
logoImg.style.margin = "0 0 42px 16px";
|
|
2123
|
+
logoImg.style.display = "block";
|
|
2124
|
+
logoImg.style.marginLeft = "auto";
|
|
2125
|
+
break;
|
|
2126
|
+
case "center":
|
|
2127
|
+
logoImg.style.margin = "0 auto 42px auto";
|
|
2128
|
+
logoImg.style.display = "block";
|
|
2129
|
+
break;
|
|
2130
|
+
}
|
|
1988
2131
|
}
|
|
2132
|
+
containerContent.insertBefore(logoImg, main);
|
|
1989
2133
|
}
|
|
1990
|
-
popup.insertBefore(logoImg, main);
|
|
1991
2134
|
}
|
|
2135
|
+
if (s.startMessage && s.startMessage !== "") {
|
|
2136
|
+
console.log(s.startMessage);
|
|
2137
|
+
updateButtons("start");
|
|
2138
|
+
} else {
|
|
2139
|
+
updateButtons("in_progress_first");
|
|
2140
|
+
}
|
|
2141
|
+
} else {
|
|
2142
|
+
updateButtons("in_progress_first");
|
|
1992
2143
|
}
|
|
1993
2144
|
emit("popup_clicked", surveyId, { action: "loaded" });
|
|
1994
2145
|
setLoading(false);
|
|
@@ -1998,32 +2149,29 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
1998
2149
|
emit("popup_clicked", surveyId, { action: "before_submit" });
|
|
1999
2150
|
};
|
|
2000
2151
|
generateOptions.afterSubmitEvent = ({ error, completed, total, progress }) => {
|
|
2001
|
-
setLoading(false);
|
|
2002
2152
|
if (error) {
|
|
2003
2153
|
emit("popup_clicked", surveyId, { action: "submit_error", error });
|
|
2154
|
+
updateButtons("error");
|
|
2004
2155
|
return;
|
|
2005
2156
|
}
|
|
2006
2157
|
if (completed) {
|
|
2007
2158
|
emit("survey_completed", surveyId, { action: "completed" });
|
|
2008
2159
|
surveyCompletedEmitted = true;
|
|
2009
|
-
|
|
2160
|
+
updateButtons("completed");
|
|
2161
|
+
return;
|
|
2010
2162
|
}
|
|
2011
|
-
if (total > 1 && progress < total) {
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
formInstance.back();
|
|
2016
|
-
};
|
|
2163
|
+
if (total > 1 && progress > 0 && progress < total) {
|
|
2164
|
+
updateButtons("in_progress_next");
|
|
2165
|
+
} else {
|
|
2166
|
+
updateButtons("in_progress_first");
|
|
2017
2167
|
}
|
|
2018
2168
|
};
|
|
2019
2169
|
generateOptions.onBackEvent = ({ progress }) => {
|
|
2020
2170
|
emit("popup_clicked", surveyId, { action: "back" });
|
|
2021
2171
|
if (progress === 0) {
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
onClose();
|
|
2026
|
-
};
|
|
2172
|
+
updateButtons("in_progress_first");
|
|
2173
|
+
} else {
|
|
2174
|
+
updateButtons("in_progress_next");
|
|
2027
2175
|
}
|
|
2028
2176
|
};
|
|
2029
2177
|
formInstance.generate(formDivId, generateOptions).catch((err) => {
|