Geen omschrijving
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

extended-ui-blockui.js 31KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863
  1. /**
  2. * Notiflix (js)
  3. */
  4. 'use strict';
  5. document.addEventListener('DOMContentLoaded', function (e) {
  6. const section = document.getElementById('section-block'),
  7. sectionBtn = document.querySelector('.btn-section-block'),
  8. sectionBtnOverlay = document.querySelector('.btn-section-block-overlay'),
  9. sectionBtnSpinner = document.querySelector('.btn-section-block-spinner'),
  10. sectionBtnCustom = document.querySelector('.btn-section-block-custom'),
  11. sectionBtnMultiple = document.querySelector('.btn-section-block-multiple'),
  12. sectionId = '#section-block',
  13. cardSection = document.querySelector('#card-block'),
  14. cardBtn = document.querySelector('.btn-card-block'),
  15. cardBtnOverlay = document.querySelector('.btn-card-block-overlay'),
  16. cardBtnSpinner = document.querySelector('.btn-card-block-spinner'),
  17. cardBtnCustom = document.querySelector('.btn-card-block-custom'),
  18. cardBtnMultiple = document.querySelector('.btn-card-block-multiple'),
  19. cardSectionId = '#card-block',
  20. formSection = document.querySelector('.form-block'),
  21. formBtn = document.querySelector('.btn-form-block'),
  22. formBtnOverlay = document.querySelector('.btn-form-block-overlay'),
  23. formBtnSpinner = document.querySelector('.btn-form-block-spinner'),
  24. formBtnCustom = document.querySelector('.btn-form-block-custom'),
  25. formBtnMultiple = document.querySelector('.btn-form-block-multiple'),
  26. formSectionClass = '.form-block',
  27. optionSection = document.querySelector('#option-block'),
  28. optionBtn = document.querySelector('.btn-option-block'),
  29. optionBtnHourglass = document.querySelector('.btn-option-block-hourglass'),
  30. optionBtnCircle = document.querySelector('.btn-option-block-circle'),
  31. optionBtnArrows = document.querySelector('.btn-option-block-arrows'),
  32. optionBtnDots = document.querySelector('.btn-option-block-dots'),
  33. optionBtnPulse = document.querySelector('.btn-option-block-pulse'),
  34. optionSectionId = '#option-block',
  35. pageBtn = document.querySelector('.btn-page-block'),
  36. pageBtnOverlay = document.querySelector('.btn-page-block-overlay'),
  37. pageBtnSpinner = document.querySelector('.btn-page-block-spinner'),
  38. pageBtnCustom = document.querySelector('.btn-page-block-custom'),
  39. pageBtnMultiple = document.querySelector('.btn-page-block-multiple'),
  40. removeBtn = document.querySelector('.remove-btn'),
  41. removeCardBtn = document.querySelector('.remove-card-btn'),
  42. removeFormBtn = document.querySelector('.remove-form-btn'),
  43. removeOptionBtn = document.querySelector('.remove-option-btn'),
  44. removePageBtn = document.querySelector('.remove-page-btn');
  45. // Notiflix
  46. // --------------------------------------------------------------------
  47. // Default
  48. if (section && sectionBtn) {
  49. sectionBtn.addEventListener('click', () => {
  50. Block.circle(sectionId, {
  51. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)',
  52. svgSize: '40px',
  53. svgColor: config.colors.white
  54. });
  55. });
  56. }
  57. // Overlay Color
  58. if (section && sectionBtnOverlay) {
  59. sectionBtnOverlay.addEventListener('click', () => {
  60. Block.standard(sectionId, {
  61. backgroundColor: 'rgba(' + window.Helpers.getCssVar('white-rgb') + ', 0.8)',
  62. svgSize: '0px'
  63. });
  64. let customSpinner = document.createElement('div');
  65. customSpinner.classList.add('spinner-border', 'text-primary');
  66. customSpinner.setAttribute('role', 'status');
  67. let notiflixBlock = document.querySelector('#section-block .notiflix-block');
  68. notiflixBlock.appendChild(customSpinner);
  69. });
  70. }
  71. // Custom Spinner
  72. if (section && sectionBtnSpinner) {
  73. sectionBtnSpinner.addEventListener('click', () => {
  74. Block.standard(sectionId, {
  75. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)',
  76. svgSize: '0px'
  77. });
  78. let customSpinnerHTML = `
  79. <div class="sk-wave mx-auto">
  80. <div class="sk-rect sk-wave-rect"></div>
  81. <div class="sk-rect sk-wave-rect"></div>
  82. <div class="sk-rect sk-wave-rect"></div>
  83. <div class="sk-rect sk-wave-rect"></div>
  84. <div class="sk-rect sk-wave-rect"></div>
  85. </div>
  86. `;
  87. let notiflixBlock = document.querySelector('#section-block .notiflix-block');
  88. notiflixBlock.innerHTML = customSpinnerHTML;
  89. });
  90. }
  91. // Custom Message
  92. if (section && sectionBtnCustom) {
  93. sectionBtnCustom.addEventListener('click', () => {
  94. Block.standard(sectionId, {
  95. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)',
  96. svgSize: '0px'
  97. });
  98. let customSpinnerHTML = `
  99. <div class="d-flex">
  100. <p class="mb-0 text-white">Please wait...</p>
  101. <div class="sk-wave m-0">
  102. <div class="sk-rect sk-wave-rect"></div>
  103. <div class="sk-rect sk-wave-rect"></div>
  104. <div class="sk-rect sk-wave-rect"></div>
  105. <div class="sk-rect sk-wave-rect"></div>
  106. <div class="sk-rect sk-wave-rect"></div>
  107. </div>
  108. </div>
  109. `;
  110. let notiflixBlock = document.querySelector('#section-block .notiflix-block');
  111. notiflixBlock.innerHTML = customSpinnerHTML;
  112. });
  113. }
  114. // Multiple Message
  115. let multiMsg1, multiMsg2, multiMsg3;
  116. if (section && sectionBtnMultiple) {
  117. sectionBtnMultiple.addEventListener('click', () => {
  118. // Step 1: Initial block with spinner and "Please wait..." message
  119. Block.standard(sectionId, {
  120. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)',
  121. svgSize: '0px'
  122. });
  123. // Inject custom spinner and message
  124. let initialMessage = `
  125. <div class="d-flex justify-content-center">
  126. <p class="mb-0 text-white">Please wait...</p>
  127. <div class="sk-wave m-0">
  128. <div class="sk-rect sk-wave-rect"></div>
  129. <div class="sk-rect sk-wave-rect"></div>
  130. <div class="sk-rect sk-wave-rect"></div>
  131. <div class="sk-rect sk-wave-rect"></div>
  132. <div class="sk-rect sk-wave-rect"></div>
  133. </div>
  134. </div>
  135. `;
  136. let notiflixBlock = document.querySelector('#section-block .notiflix-block');
  137. if (notiflixBlock) notiflixBlock.innerHTML = initialMessage;
  138. // remove the first block
  139. Block.remove(sectionId, 1000);
  140. // Timeout to start the second block
  141. multiMsg1 = setTimeout(() => {
  142. // Step 2: Second block with "Almost Done..." message
  143. Block.standard(sectionId, 'Almost Done...', {
  144. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)',
  145. messageFontSize: '15px',
  146. svgSize: '0px',
  147. messageColor: config.colors.white
  148. });
  149. // remove the second block
  150. Block.remove(sectionId, 1000);
  151. // Timeout to start the third block
  152. multiMsg2 = setTimeout(() => {
  153. // Step 3: Final block with "Success" message
  154. Block.standard(sectionId, {
  155. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)'
  156. });
  157. let initialMessage = `<div class="px-12 py-3 bg-success text-white">Success</div>`;
  158. let notiflixBlock = document.querySelector('#section-block .notiflix-block');
  159. if (notiflixBlock) notiflixBlock.innerHTML = initialMessage;
  160. multiMsg3 = setTimeout(() => {
  161. Block.remove(sectionId); // Remove the final block
  162. setTimeout(() => {
  163. sectionBtn.classList.remove('disabled');
  164. sectionBtnOverlay.classList.remove('disabled');
  165. sectionBtnSpinner.classList.remove('disabled');
  166. sectionBtnCustom.classList.remove('disabled');
  167. sectionBtnMultiple.classList.remove('disabled');
  168. }, 500);
  169. }, 1810); // Adjust the timeout for the final block
  170. }, 1810); // Adjust the timeout for the second block
  171. }, 1610); // Adjust the timeout for the first block
  172. });
  173. }
  174. // List of all button selectors
  175. const buttonSelectors = [
  176. '.btn-section-block',
  177. '.btn-section-block-overlay',
  178. '.btn-section-block-spinner',
  179. '.btn-section-block-custom',
  180. '.btn-section-block-multiple'
  181. ];
  182. // Select all buttons based on their individual classes
  183. const buttons = buttonSelectors.map(selector => document.querySelector(selector));
  184. // Add click event listener to each button
  185. buttons.forEach(button => {
  186. if (button) {
  187. button.addEventListener('click', () => {
  188. buttons.forEach(btn => {
  189. if (btn) {
  190. btn.classList.add('disabled');
  191. }
  192. });
  193. });
  194. }
  195. });
  196. if (removeBtn) {
  197. removeBtn.addEventListener('click', () => {
  198. setTimeout(() => {
  199. if (document.querySelector(`${sectionId} .notiflix-block`)) {
  200. Block.remove(sectionId);
  201. } else {
  202. alert('No active block to remove.');
  203. }
  204. }, 400);
  205. clearTimeout(multiMsg1);
  206. clearTimeout(multiMsg2);
  207. clearTimeout(multiMsg3);
  208. setTimeout(() => {
  209. sectionBtn.classList.remove('disabled');
  210. sectionBtnOverlay.classList.remove('disabled');
  211. sectionBtnSpinner.classList.remove('disabled');
  212. sectionBtnCustom.classList.remove('disabled');
  213. sectionBtnMultiple.classList.remove('disabled');
  214. }, 500);
  215. });
  216. }
  217. // Card Blocking
  218. // --------------------------------------------------------------------
  219. // Default
  220. if (cardSection && cardBtn) {
  221. cardBtn.addEventListener('click', () => {
  222. Block.circle(cardSectionId, {
  223. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)',
  224. svgSize: '40px',
  225. svgColor: config.colors.white
  226. });
  227. });
  228. }
  229. // Overlay Color
  230. if (cardSection && cardBtnOverlay) {
  231. cardBtnOverlay.addEventListener('click', () => {
  232. Block.standard(cardSectionId, {
  233. backgroundColor: 'rgba(' + window.Helpers.getCssVar('white-rgb') + ', 0.8)',
  234. svgSize: '0px'
  235. });
  236. const customSpinner = document.createElement('div');
  237. customSpinner.classList.add('spinner-border', 'text-primary');
  238. customSpinner.setAttribute('role', 'status');
  239. let notiflixBlock = document.querySelector('#card-block .notiflix-block');
  240. notiflixBlock.appendChild(customSpinner);
  241. });
  242. }
  243. // Custom Spinner
  244. if (cardSection && cardBtnSpinner) {
  245. cardBtnSpinner.addEventListener('click', () => {
  246. Block.standard(cardSectionId, {
  247. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)',
  248. svgSize: '0px'
  249. });
  250. let customSpinnerHTML = `
  251. <div class="sk-wave mx-auto">
  252. <div class="sk-rect sk-wave-rect"></div>
  253. <div class="sk-rect sk-wave-rect"></div>
  254. <div class="sk-rect sk-wave-rect"></div>
  255. <div class="sk-rect sk-wave-rect"></div>
  256. <div class="sk-rect sk-wave-rect"></div>
  257. </div>
  258. `;
  259. let notiflixBlock = document.querySelector('#card-block .notiflix-block');
  260. notiflixBlock.innerHTML = customSpinnerHTML;
  261. });
  262. }
  263. // Custom Message
  264. if (cardSection && cardBtnCustom) {
  265. cardBtnCustom.addEventListener('click', () => {
  266. Block.standard(cardSectionId, {
  267. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)',
  268. svgSize: '0px'
  269. });
  270. let customSpinnerHTML = `
  271. <div class="d-flex">
  272. <p class="mb-0 text-white">Please wait...</p>
  273. <div class="sk-wave m-0">
  274. <div class="sk-rect sk-wave-rect"></div>
  275. <div class="sk-rect sk-wave-rect"></div>
  276. <div class="sk-rect sk-wave-rect"></div>
  277. <div class="sk-rect sk-wave-rect"></div>
  278. <div class="sk-rect sk-wave-rect"></div>
  279. </div>
  280. </div>
  281. `;
  282. let notiflixBlock = document.querySelector('#card-block .notiflix-block');
  283. notiflixBlock.innerHTML = customSpinnerHTML;
  284. });
  285. }
  286. // Multiple Message
  287. let multiMsgCard1, multiMsgCard2, multiMsgCard3;
  288. if (cardSection && cardBtnMultiple) {
  289. cardBtnMultiple.addEventListener('click', () => {
  290. // Step 1: Initial block with spinner and "Please wait..." message
  291. Block.standard(cardSectionId, {
  292. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)',
  293. svgSize: '0px'
  294. });
  295. // Inject custom spinner and message
  296. let initialMessageCard = `
  297. <div class="d-flex justify-content-center">
  298. <p class="mb-0 text-white">Please wait...</p>
  299. <div class="sk-wave m-0">
  300. <div class="sk-rect sk-wave-rect"></div>
  301. <div class="sk-rect sk-wave-rect"></div>
  302. <div class="sk-rect sk-wave-rect"></div>
  303. <div class="sk-rect sk-wave-rect"></div>
  304. <div class="sk-rect sk-wave-rect"></div>
  305. </div>
  306. </div>
  307. `;
  308. let notiflixBlock = document.querySelector('#card-block .notiflix-block');
  309. if (notiflixBlock) notiflixBlock.innerHTML = initialMessageCard;
  310. // remove the first block
  311. Block.remove(cardSectionId, 1000);
  312. // Timeout to start the second block
  313. multiMsgCard1 = setTimeout(() => {
  314. // Step 2: Second block with "Almost Done..." message
  315. Block.standard(cardSectionId, 'Almost Done...', {
  316. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)',
  317. messageFontSize: '15px',
  318. svgSize: '0px',
  319. messageColor: config.colors.white
  320. });
  321. // remove the second block
  322. Block.remove(cardSectionId, 1000);
  323. // Timeout to start the third block
  324. multiMsgCard2 = setTimeout(() => {
  325. // Step 3: Final block with "Success" message
  326. Block.standard(cardSectionId, {
  327. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)'
  328. });
  329. let initialMessageCard2 = `<div class="px-12 py-3 bg-success text-white">Success</div>`;
  330. let notiflixBlock = document.querySelector('#card-block .notiflix-block');
  331. if (notiflixBlock) notiflixBlock.innerHTML = initialMessageCard2;
  332. multiMsgCard3 = setTimeout(() => {
  333. Block.remove(cardSectionId); // Remove the final block
  334. }, 1610); // Adjust the timeout for the final block
  335. }, 1610); // Adjust the timeout for the second block
  336. }, 1610); // Adjust the timeout for the first block
  337. });
  338. }
  339. // List of all button selectors
  340. const cardButtonSelectors = [
  341. '.btn-card-block',
  342. '.btn-card-block-overlay',
  343. '.btn-card-block-spinner',
  344. '.btn-card-block-custom',
  345. '.btn-card-block-multiple'
  346. ];
  347. // Select all buttons based on their individual classes
  348. const cardButtons = cardButtonSelectors.map(selector => document.querySelector(selector));
  349. // Add click event listener to each button
  350. cardButtons.forEach(button => {
  351. if (button) {
  352. button.addEventListener('click', () => {
  353. removeCardBtn.style.position = 'relative';
  354. removeCardBtn.style.pointerEvents = 'auto';
  355. removeCardBtn.style.zIndex = 1074;
  356. });
  357. }
  358. });
  359. if (removeCardBtn) {
  360. removeCardBtn.addEventListener('click', () => {
  361. setTimeout(() => {
  362. if (document.querySelector(`${cardSectionId} .notiflix-block`)) {
  363. Block.remove(cardSectionId);
  364. } else {
  365. alert('No active block to remove.');
  366. }
  367. }, 400);
  368. clearTimeout(multiMsgCard1);
  369. clearTimeout(multiMsgCard2);
  370. clearTimeout(multiMsgCard3);
  371. });
  372. }
  373. // Blocking with multiple options
  374. // --------------------------------------------------------------------
  375. // Default
  376. if (optionSection && optionBtn) {
  377. optionBtn.addEventListener('click', () => {
  378. Block.standard(optionSectionId, {
  379. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)',
  380. svgSize: '40px',
  381. svgColor: config.colors.white
  382. });
  383. });
  384. }
  385. // hourglass
  386. if (optionSection && optionBtnHourglass) {
  387. optionBtnHourglass.addEventListener('click', () => {
  388. Block.hourglass(optionSectionId, {
  389. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)',
  390. svgSize: '40px',
  391. svgColor: config.colors.white
  392. });
  393. });
  394. }
  395. // circle
  396. if (optionSection && optionBtnCircle) {
  397. optionBtnCircle.addEventListener('click', () => {
  398. Block.circle(optionSectionId, {
  399. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)',
  400. svgSize: '40px',
  401. svgColor: config.colors.white
  402. });
  403. });
  404. }
  405. // arrows
  406. if (optionSection && optionBtnArrows) {
  407. optionBtnArrows.addEventListener('click', () => {
  408. Block.arrows(optionSectionId, {
  409. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)',
  410. svgSize: '40px',
  411. svgColor: config.colors.white
  412. });
  413. });
  414. }
  415. // Dots
  416. if (optionSection && optionBtnDots) {
  417. optionBtnDots.addEventListener('click', () => {
  418. Block.dots(optionSectionId, {
  419. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)',
  420. svgSize: '40px',
  421. svgColor: config.colors.white
  422. });
  423. });
  424. }
  425. // Pulse
  426. if (optionSection && optionBtnPulse) {
  427. optionBtnPulse.addEventListener('click', () => {
  428. Block.pulse(optionSectionId, {
  429. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)',
  430. svgSize: '40px',
  431. svgColor: config.colors.white
  432. });
  433. });
  434. }
  435. // List of all button selectors
  436. const optionButtonSelectors = [
  437. '.btn-option-block',
  438. '.btn-option-block-overlay',
  439. '.btn-option-block-spinner',
  440. '.btn-option-block-custom',
  441. '.btn-option-block-multiple'
  442. ];
  443. // Select all buttons based on their individual classes
  444. const optionButtons = optionButtonSelectors.map(selector => document.querySelector(selector));
  445. // Add click event listener to each button
  446. optionButtons.forEach(button => {
  447. if (button) {
  448. button.addEventListener('click', () => {
  449. removeOptionBtn.style.position = 'relative';
  450. removeOptionBtn.style.pointerEvents = 'auto';
  451. removeOptionBtn.style.zIndex = 1074;
  452. });
  453. }
  454. });
  455. if (removeOptionBtn) {
  456. removeOptionBtn.addEventListener('click', () => {
  457. if (document.querySelector(`${optionSectionId} .notiflix-block`)) {
  458. Block.remove(optionSectionId);
  459. } else {
  460. alert('No active block to remove.');
  461. }
  462. });
  463. }
  464. // Page Blocking
  465. // --------------------------------------------------------------------
  466. // default
  467. if (pageBtn) {
  468. pageBtn.addEventListener('click', () => {
  469. Loading.circle({
  470. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)',
  471. svgSize: '40px',
  472. svgColor: config.colors.white
  473. });
  474. });
  475. }
  476. // Overlay Color
  477. if (pageBtnOverlay) {
  478. pageBtnOverlay.addEventListener('click', () => {
  479. Loading.standard({
  480. backgroundColor: 'rgba(' + window.Helpers.getCssVar('white-rgb') + ', 0.8)',
  481. svgSize: '0px'
  482. });
  483. const customSpinner = document.createElement('div');
  484. customSpinner.classList.add('spinner-border', 'text-primary');
  485. customSpinner.setAttribute('role', 'status');
  486. let notiflixBlock = document.querySelector('.notiflix-loading');
  487. notiflixBlock.appendChild(customSpinner);
  488. });
  489. }
  490. // Custom Spinner
  491. if (pageBtnSpinner) {
  492. pageBtnSpinner.addEventListener('click', () => {
  493. Loading.standard({
  494. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)',
  495. svgSize: '0px'
  496. });
  497. let customSpinnerHTML = `
  498. <div class="sk-wave mx-auto">
  499. <div class="sk-rect sk-wave-rect"></div>
  500. <div class="sk-rect sk-wave-rect"></div>
  501. <div class="sk-rect sk-wave-rect"></div>
  502. <div class="sk-rect sk-wave-rect"></div>
  503. <div class="sk-rect sk-wave-rect"></div>
  504. </div>
  505. `;
  506. let notiflixBlock = document.querySelector('.notiflix-loading');
  507. notiflixBlock.innerHTML = customSpinnerHTML;
  508. });
  509. }
  510. // Custom Message
  511. if (pageBtnCustom) {
  512. pageBtnCustom.addEventListener('click', () => {
  513. Loading.standard({
  514. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)',
  515. svgSize: '0px'
  516. });
  517. let customSpinnerHTML = `
  518. <div class="d-flex">
  519. <p class="mb-0 text-white">Please wait...</p>
  520. <div class="sk-wave m-0">
  521. <div class="sk-rect sk-wave-rect"></div>
  522. <div class="sk-rect sk-wave-rect"></div>
  523. <div class="sk-rect sk-wave-rect"></div>
  524. <div class="sk-rect sk-wave-rect"></div>
  525. <div class="sk-rect sk-wave-rect"></div>
  526. </div>
  527. </div>
  528. `;
  529. let notiflixBlock = document.querySelector('.notiflix-loading');
  530. notiflixBlock.innerHTML = customSpinnerHTML;
  531. });
  532. }
  533. // Multiple Message
  534. let multiMsgPage1, multiMsgPage2, multiMsgPage3;
  535. if (pageBtnMultiple) {
  536. pageBtnMultiple.addEventListener('click', () => {
  537. // Step 1: Initial block with spinner and "Please wait..." message
  538. Loading.standard({
  539. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)',
  540. svgSize: '0px'
  541. });
  542. // Inject custom spinner and message
  543. let initialMessage = `
  544. <div class="d-flex justify-content-center">
  545. <p class="mb-0 text-white">Please wait...</p>
  546. <div class="sk-wave m-0">
  547. <div class="sk-rect sk-wave-rect"></div>
  548. <div class="sk-rect sk-wave-rect"></div>
  549. <div class="sk-rect sk-wave-rect"></div>
  550. <div class="sk-rect sk-wave-rect"></div>
  551. <div class="sk-rect sk-wave-rect"></div>
  552. </div>
  553. </div>
  554. `;
  555. let notiflixBlock = document.querySelector('.notiflix-loading');
  556. if (notiflixBlock) notiflixBlock.innerHTML = initialMessage;
  557. // remove the first block
  558. Loading.remove(1000);
  559. // Timeout to start the second block
  560. multiMsgPage1 = setTimeout(() => {
  561. // Step 2: Second block with "Almost Done..." message
  562. Loading.standard('Almost Done...', {
  563. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)',
  564. messageFontSize: '15px',
  565. svgSize: '0px',
  566. messageColor: config.colors.white
  567. });
  568. // remove the second block
  569. Loading.remove(1000);
  570. // Timeout to start the third block
  571. multiMsgPage2 = setTimeout(() => {
  572. // Step 3: Final block with "Success" message
  573. Loading.standard({
  574. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)'
  575. });
  576. let initialMessage2 = `<div class="px-12 py-3 bg-success text-white">Success</div>`;
  577. let notiflixBlock = document.querySelector('.notiflix-loading');
  578. if (notiflixBlock) notiflixBlock.innerHTML = initialMessage2;
  579. multiMsgPage3 = setTimeout(() => {
  580. Loading.remove(); // Remove the final block
  581. }, 1610); // Adjust the timeout for the final block
  582. }, 1610); // Adjust the timeout for the second block
  583. }, 1610); // Adjust the timeout for the first block
  584. });
  585. }
  586. // List of all button selectors
  587. const pageButtonSelectors = [
  588. '.btn-page-block',
  589. '.btn-page-block-overlay',
  590. '.btn-page-block-spinner',
  591. '.btn-page-block-custom',
  592. '.btn-page-block-multiple'
  593. ];
  594. // Select all buttons based on their individual classes
  595. const pageButtons = pageButtonSelectors.map(selector => document.querySelector(selector));
  596. // Add click event listener to each button
  597. pageButtons.forEach(button => {
  598. if (button) {
  599. button.addEventListener('click', () => {
  600. removePageBtn.style.position = 'relative';
  601. removePageBtn.style.pointerEvents = 'auto';
  602. removePageBtn.style.zIndex = 9999;
  603. });
  604. }
  605. });
  606. if (removePageBtn) {
  607. removePageBtn.addEventListener('click', () => {
  608. if (document.querySelector(`.notiflix-loading`)) {
  609. Loading.remove();
  610. } else {
  611. alert('No active loading to remove.');
  612. }
  613. clearTimeout(multiMsgPage1);
  614. clearTimeout(multiMsgPage2);
  615. clearTimeout(multiMsgPage3);
  616. });
  617. }
  618. // Form Blocking
  619. // --------------------------------------------------------------------
  620. // Default
  621. if (formSection && formBtn) {
  622. formBtn.addEventListener('click', () => {
  623. Block.circle(formSectionClass, {
  624. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)',
  625. svgSize: '40px',
  626. svgColor: config.colors.white
  627. });
  628. });
  629. }
  630. // Overlay Color
  631. if (formSection && formBtnOverlay) {
  632. formBtnOverlay.addEventListener('click', () => {
  633. Block.standard(formSectionClass, {
  634. backgroundColor: 'rgba(' + window.Helpers.getCssVar('white-rgb') + ', 0.8)',
  635. svgSize: '0px'
  636. });
  637. let customSpinner = document.createElement('div');
  638. customSpinner.classList.add('spinner-border', 'text-primary');
  639. customSpinner.setAttribute('role', 'status');
  640. let notiflixBlock = document.querySelector('.form-block .notiflix-block');
  641. notiflixBlock.appendChild(customSpinner);
  642. });
  643. }
  644. // Custom Spinner
  645. if (formSection && formBtnSpinner) {
  646. formBtnSpinner.addEventListener('click', () => {
  647. Block.standard(formSectionClass, {
  648. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)',
  649. svgSize: '0px'
  650. });
  651. let customSpinnerHTML = `
  652. <div class="sk-wave mx-auto">
  653. <div class="sk-rect sk-wave-rect"></div>
  654. <div class="sk-rect sk-wave-rect"></div>
  655. <div class="sk-rect sk-wave-rect"></div>
  656. <div class="sk-rect sk-wave-rect"></div>
  657. <div class="sk-rect sk-wave-rect"></div>
  658. </div>
  659. `;
  660. let notiflixBlock = document.querySelector('.form-block .notiflix-block');
  661. notiflixBlock.innerHTML = customSpinnerHTML;
  662. });
  663. }
  664. // Custom Message
  665. if (formSection && formBtnCustom) {
  666. formBtnCustom.addEventListener('click', () => {
  667. Block.standard(formSectionClass, {
  668. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)',
  669. svgSize: '0px'
  670. });
  671. let customSpinnerHTML = `
  672. <div class="d-flex">
  673. <p class="mb-0 text-white">Please wait...</p>
  674. <div class="sk-wave m-0">
  675. <div class="sk-rect sk-wave-rect"></div>
  676. <div class="sk-rect sk-wave-rect"></div>
  677. <div class="sk-rect sk-wave-rect"></div>
  678. <div class="sk-rect sk-wave-rect"></div>
  679. <div class="sk-rect sk-wave-rect"></div>
  680. </div>
  681. </div>
  682. `;
  683. let notiflixBlock = document.querySelector('.form-block .notiflix-block');
  684. notiflixBlock.innerHTML = customSpinnerHTML;
  685. });
  686. }
  687. // Multiple Message
  688. let multiMsgForm1, multiMsgForm2, multiMsgForm3;
  689. if (formSection && formBtnMultiple) {
  690. formBtnMultiple.addEventListener('click', () => {
  691. // Step 1: Initial block with spinner and "Please wait..." message
  692. Block.standard(formSectionClass, {
  693. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)',
  694. svgSize: '0px'
  695. });
  696. // Inject custom spinner and message
  697. let initialMessage = `
  698. <div class="d-flex justify-content-center">
  699. <p class="mb-0 text-white">Please wait...</p>
  700. <div class="sk-wave m-0">
  701. <div class="sk-rect sk-wave-rect"></div>
  702. <div class="sk-rect sk-wave-rect"></div>
  703. <div class="sk-rect sk-wave-rect"></div>
  704. <div class="sk-rect sk-wave-rect"></div>
  705. <div class="sk-rect sk-wave-rect"></div>
  706. </div>
  707. </div>
  708. `;
  709. let notiflixBlock = document.querySelector('.form-block .notiflix-block');
  710. if (notiflixBlock) notiflixBlock.innerHTML = initialMessage;
  711. // remove the first block
  712. Block.remove(formSectionClass, 1000);
  713. // Timeout to start the second block
  714. multiMsgForm1 = setTimeout(() => {
  715. // Step 2: Second block with "Almost Done..." message
  716. Block.standard(formSectionClass, 'Almost Done...', {
  717. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)',
  718. messageFontSize: '15px',
  719. svgSize: '0px',
  720. messageColor: config.colors.white
  721. });
  722. // remove the second block
  723. Block.remove(formSectionClass, 1000);
  724. // Timeout to start the third block
  725. multiMsgForm2 = setTimeout(() => {
  726. // Step 3: Final block with "Success" message
  727. Block.standard(formSectionClass, {
  728. backgroundColor: 'rgba(' + window.Helpers.getCssVar('black-rgb') + ', 0.5)'
  729. });
  730. let initialMessage = `<div class="px-12 py-3 bg-success text-white">Success</div>`;
  731. let notiflixBlock = document.querySelector('.form-block .notiflix-block');
  732. if (notiflixBlock) notiflixBlock.innerHTML = initialMessage;
  733. multiMsgForm3 = setTimeout(() => {
  734. Block.remove(formSectionClass); // Remove the final block
  735. setTimeout(() => {
  736. formBtn.classList.remove('disabled');
  737. formBtnOverlay.classList.remove('disabled');
  738. formBtnSpinner.classList.remove('disabled');
  739. formBtnCustom.classList.remove('disabled');
  740. formBtnMultiple.classList.remove('disabled');
  741. }, 500);
  742. }, 1810); // Adjust the timeout for the final block
  743. }, 1810); // Adjust the timeout for the second block
  744. }, 1610); // Adjust the timeout for the first block
  745. });
  746. }
  747. // List of all button selectors
  748. const formButtonSelectors = [
  749. '.btn-form-block',
  750. '.btn-form-block-overlay',
  751. '.btn-form-block-spinner',
  752. '.btn-form-block-custom',
  753. '.btn-form-block-multiple'
  754. ];
  755. // Select all buttons based on their individual classes
  756. const formButtons = formButtonSelectors.map(selector => document.querySelector(selector));
  757. // Add click event listener to each button
  758. formButtons.forEach(button => {
  759. if (button) {
  760. button.addEventListener('click', () => {
  761. formButtons.forEach(btn => {
  762. if (btn) {
  763. btn.classList.add('disabled');
  764. }
  765. });
  766. });
  767. }
  768. });
  769. if (removeFormBtn) {
  770. removeFormBtn.addEventListener('click', () => {
  771. setTimeout(() => {
  772. if (document.querySelector(`${formSectionClass} .notiflix-block`)) {
  773. Block.remove(formSectionClass);
  774. } else {
  775. alert('No active block to remove.');
  776. }
  777. }, 450);
  778. clearTimeout(multiMsgForm1);
  779. clearTimeout(multiMsgForm2);
  780. clearTimeout(multiMsgForm3);
  781. setTimeout(() => {
  782. formBtn.classList.remove('disabled');
  783. formBtnOverlay.classList.remove('disabled');
  784. formBtnSpinner.classList.remove('disabled');
  785. formBtnCustom.classList.remove('disabled');
  786. formBtnMultiple.classList.remove('disabled');
  787. }, 500);
  788. });
  789. }
  790. });