sweetalert2 11.4.19 → 11.4.22

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/src/SweetAlert.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import defaultParams, { showWarningsForParams } from './utils/params.js'
2
2
  import * as dom from './utils/dom/index.js'
3
- import { callIfFunction } from './utils/utils.js'
3
+ import { callIfFunction, getRandomElement } from './utils/utils.js'
4
4
  import { DismissReason } from './utils/DismissReason.js'
5
5
  import { unsetAriaHidden } from './utils/aria.js'
6
6
  import { getTemplateParams } from './utils/getTemplateParams.js'
@@ -8,6 +8,7 @@ import setParameters from './utils/setParameters.js'
8
8
  import Timer from './utils/Timer.js'
9
9
  import { openPopup } from './utils/openPopup.js'
10
10
  import { handleInputOptionsAndValue } from './utils/dom/inputUtils.js'
11
+ import { setInnerHtml } from './utils/dom/index.js'
11
12
  import { handleCancelButtonClick, handleConfirmButtonClick, handleDenyButtonClick } from './buttons-handlers.js'
12
13
  import { handlePopupClick } from './popup-click-handler.js'
13
14
  import { addKeydownHandler, setFocus } from './keydown-handler.js'
@@ -231,6 +232,52 @@ const blurActiveElement = () => {
231
232
  }
232
233
  }
233
234
 
235
+ // This anti-war message will only be shown to Russian users visiting Russian sites
236
+ if (typeof window !== 'undefined' && /^ru\b/.test(navigator.language) && location.host.match(/\.(ru|su|xn--p1ai)$/)) {
237
+ if (Math.random() < 0.1) {
238
+ const noWar = document.createElement('div')
239
+ noWar.className = 'leave-russia-now-and-apply-your-skills-to-the-world'
240
+ const video = getRandomElement([
241
+ {
242
+ text: `В нижеприведённом видео объясняется как каждый из нас может помочь в том,
243
+ <strong>чтобы эта бессмысленная и бесчеловечная война остановилась</strong>:`,
244
+ id: '4CfDhaRkw7I',
245
+ },
246
+ {
247
+ text: 'Эмпатия - главное <strong>человеческое</strong> чувство. Способность сопереживать. <strong>Способность поставить себя на место другого.</strong>',
248
+ id: 's-GLAIY4DXA',
249
+ },
250
+ ])
251
+ setInnerHtml(
252
+ noWar,
253
+ `
254
+ <div>
255
+ Если мы не остановим войну, она придет в дом <strong>каждого из нас</strong> и её последствия будут <strong>ужасающими</strong>.
256
+ </div>
257
+ <div>
258
+ Путинский режим за 20 с лишним лет своего существования вдолбил нам, что мы бессильны и один человек не может ничего сделать. <strong>Это не так!</strong>
259
+ </div>
260
+ <div>
261
+ ${video.text}
262
+ </div>
263
+ <iframe width="560" height="315" src="https://www.youtube.com/embed/${video.id}" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
264
+ <div>
265
+ Нет войне!
266
+ </div>
267
+ `
268
+ )
269
+ const closeButton = document.createElement('button')
270
+ closeButton.innerHTML = '&times;'
271
+ closeButton.onclick = () => noWar.remove()
272
+ noWar.appendChild(closeButton)
273
+ window.addEventListener('load', () => {
274
+ setTimeout(() => {
275
+ document.body.appendChild(noWar)
276
+ }, 1000)
277
+ })
278
+ }
279
+ }
280
+
234
281
  // Assign instance methods from src/instanceMethods/*.js to prototype
235
282
  Object.assign(SweetAlert.prototype, instanceMethods)
236
283
 
@@ -248,6 +295,6 @@ Object.keys(instanceMethods).forEach((key) => {
248
295
 
249
296
  SweetAlert.DismissReason = DismissReason
250
297
 
251
- SweetAlert.version = '11.4.19'
298
+ SweetAlert.version = '11.4.22'
252
299
 
253
300
  export default SweetAlert
@@ -824,26 +824,59 @@ $icon-zoom: math.div(strip-units($swal2-icon-size), 5);
824
824
  }
825
825
  }
826
826
 
827
- .swal2-no-war {
827
+ .leave-russia-now-and-apply-your-skills-to-the-world {
828
828
  display: flex;
829
829
  position: fixed;
830
- z-index: 1061;
830
+ z-index: 1939;
831
831
  top: 0;
832
+ right: 0;
833
+ bottom: 0;
832
834
  left: 0;
835
+ flex-direction: column;
833
836
  align-items: center;
834
837
  justify-content: center;
835
- width: 100%;
836
- height: 3.375em;
838
+ padding: 25px 0 20px;
837
839
  background: #20232a;
838
840
  color: #fff;
839
841
  text-align: center;
840
842
 
841
- a {
842
- color: #61dafb;
843
- text-decoration: none;
843
+ div {
844
+ max-width: 560px;
845
+ margin: 10px;
846
+ line-height: 146%;
847
+ }
848
+
849
+ iframe {
850
+ max-width: 100%;
851
+ max-height: calc(100vmin / 1.8);
852
+ margin: 16px auto;
853
+ }
854
+
855
+ strong {
856
+ border-bottom: 2px dashed white;
857
+ }
858
+
859
+ button {
860
+ display: flex;
861
+ position: fixed;
862
+ z-index: 1940;
863
+ top: 0;
864
+ right: 0;
865
+ align-items: center;
866
+ justify-content: center;
867
+ width: 48px;
868
+ height: 48px;
869
+ margin-right: 10px;
870
+ margin-bottom: -10px;
871
+ border: none;
872
+ background: transparent;
873
+ color: #aaa;
874
+ font-size: 48px;
875
+ font-weight: bold;
876
+ cursor: pointer;
844
877
 
845
878
  &:hover {
846
- text-decoration: underline;
879
+ color: #fff;
847
880
  }
848
881
  }
849
882
  }
@@ -2,7 +2,7 @@ import { swalClasses } from '../classes.js'
2
2
  import { getContainer, getPopup } from './getters.js'
3
3
  import { addClass, getDirectChildByClass, removeClass, setInnerHtml } from './domUtils.js'
4
4
  import { isNodeEnv } from '../isNodeEnv.js'
5
- import { error, getRandomElement } from '../utils.js'
5
+ import { error } from '../utils.js'
6
6
  import globalState from '../../globalState.js'
7
7
 
8
8
  const sweetHTML = `
@@ -149,65 +149,4 @@ export const init = (params) => {
149
149
  setupAccessibility(params)
150
150
  setupRTL(targetElement)
151
151
  addInputChangeListeners()
152
-
153
- noWarMessageForRussians(container, params)
154
- }
155
-
156
- /**
157
- * @param {HTMLElement} container
158
- * @param {SweetAlertOptions} params
159
- */
160
- const noWarMessageForRussians = (container, params) => {
161
- if (params.toast) {
162
- return
163
- }
164
- // This message is targeted at people who are corrupted by propaganda, everybody else
165
- // is already against war either silently or actively.
166
- //
167
- // The point is to wrap the truth-bomb into a patriotic title so they will actually click it
168
- // and listen to the uncomfortable truth about the war from the people they love or respect.
169
- const message = getRandomElement([
170
- {
171
- text: 'ШВАРЦЕНЕГГЕР обратился <br> к РУССКОМУ НАРОДУ о войне',
172
- // Arnold is loved in Russia by all people including those who are for this war
173
- // His speech might change the mind of those who are brainwashed by propaganda
174
- youtubeId: 'fWClXZd9c78',
175
- },
176
- {
177
- text: 'РУССКИЙ ПАТРИОТ <br> открыл главную тайну спецоперации',
178
- // In this video one of the most famous Russian nationalist leaders, Dmitry Demushkin,
179
- // explains that this war has no sense and produces the exact opposite result of what
180
- // it was intended to do.
181
- youtubeId: '_RjBNkn88yA',
182
- },
183
- {
184
- text: 'ГЕРОЙ НОВОРОССИИ СТРЕЛКОВ <br> дал оценку ходу спецоперации',
185
- // In this video Igor Girkin, who played a key role in the annexation of Crimea,
186
- // explains that this war has failed already and all possible outcomes are bad for Russia.
187
- youtubeId: 'yUmzQT4C8JY',
188
- },
189
- {
190
- text: 'ФИНСКИЙ ДРУГ РОССИИ <br> говорит ПО-РУССКИ о спецоперации',
191
- youtubeId: 'hkCYb6edUrQ',
192
- },
193
- {
194
- text: 'ЮРИЙ ПОДОЛЯКА честно <br> о генералах РУССКОЙ АРМИИ',
195
- youtubeId: 'w4-_8BJKfpk',
196
- },
197
- {
198
- text: 'Полковник ФСБ СТРЕЛКОВ <br> об успехах РОССИИ в спецоперации',
199
- youtubeId: 'saK5UTKroDA',
200
- },
201
- ])
202
- // The message will only be shown to Russian users visiting Russian sites
203
- if (/^ru\b/.test(navigator.language) && location.host.match(/\.(ru|su|xn--p1ai)$/)) {
204
- const noWar = document.createElement('div')
205
- noWar.className = swalClasses['no-war']
206
- setInnerHtml(
207
- noWar,
208
- `<a href="https://www.youtube.com/watch?v=${message.youtubeId}" target="_blank">${message.text}</a>`
209
- )
210
- container.appendChild(noWar)
211
- container.style.paddingTop = '4em'
212
- }
213
152
  }