1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597 | 1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
12×
12×
12×
12×
12×
2×
12×
12×
12×
12×
12×
12×
12×
12×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
12×
12×
1×
12×
12×
12×
12×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
12×
12×
12×
12×
12×
1×
1×
1×
1×
1×
12×
12×
12×
12×
12×
12×
12×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
| define(["require", "exports", "@syncfusion/ej2-base"], function (require, exports, ej2_base_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var globalTimeOut = {};
var spinTemplate = null;
var spinCSSClass = null;
var DEFT_MAT_WIDTH = 30;
var DEFT_MAT3_WIDTH = 30;
var DEFT_FAB_WIDTH = 30;
var DEFT_BOOT_WIDTH = 30;
var DEFT_BOOT4_WIDTH = 36;
var DEFT_FLUENT2_WIDTH = 30;
var CLS_SHOWSPIN = 'e-spin-show';
var CLS_HIDESPIN = 'e-spin-hide';
var CLS_MATERIALSPIN = 'e-spin-material';
var CLS_MATERIAL3SPIN = 'e-spin-material3';
var CLS_FABRICSPIN = 'e-spin-fabric';
var CLS_BOOTSPIN = 'e-spin-bootstrap';
var CLS_BOOT4SPIN = 'e-spin-bootstrap4';
var CLS_BOOT5SPIN = 'e-spin-bootstrap5';
var CLS_TAILWIND = 'e-spin-tailwind';
var CLS_FLUENT = 'e-spin-fluent';
var CLS_FLUENT2 = 'e-spin-fluent2';
var CLS_HIGHCONTRASTSPIN = 'e-spin-high-contrast';
var CLS_SPINWRAP = 'e-spinner-pane';
var CLS_SPININWRAP = 'e-spinner-inner';
var CLS_SPINCIRCLE = 'e-path-circle';
var CLS_SPINARC = 'e-path-arc';
var CLS_SPINLABEL = 'e-spin-label';
var CLS_SPINTEMPLATE = 'e-spin-template';
function Spinner(action, options, target, type) {
switch (action) {
case 'Create': {
var element = document.querySelector(options.target);
var args = {
type: type, target: element, cssClass: options.cssClass,
label: options.label, width: options.width
};
createSpinner(args);
break;
}
case 'Show':
showSpinner(document.querySelector(target));
break;
case 'Hide':
hideSpinner(document.querySelector(target));
break;
case 'Set': {
var setArgs = { cssClass: options.cssClass, type: type };
setSpinner(setArgs);
break;
}
}
}
exports.Spinner = Spinner;
function createSpinner(args, internalCreateElement) {
Iif (!args.target) {
return;
}
var radius;
var makeElement = !ej2_base_1.isNullOrUndefined(internalCreateElement) ? internalCreateElement : ej2_base_1.createElement;
var container = createSpinnerContainer(args.target, makeElement);
if (!ej2_base_1.isNullOrUndefined(args.cssClass)) {
container.wrap.classList.add(args.cssClass);
}
Iif (!ej2_base_1.isNullOrUndefined(args.template) || !ej2_base_1.isNullOrUndefined(spinTemplate)) {
var template = !ej2_base_1.isNullOrUndefined(args.template) ? args.template : spinTemplate;
container.wrap.classList.add(CLS_SPINTEMPLATE);
replaceContent(container.wrap, template, spinCSSClass);
}
else {
var theme = !ej2_base_1.isNullOrUndefined(args.type) ? args.type : getTheme(container.wrap);
var width = !ej2_base_1.isNullOrUndefined(args.width) ? args.width : undefined;
radius = calculateRadius(width, theme);
setTheme(theme, container.wrap, radius, makeElement);
Iif (!ej2_base_1.isNullOrUndefined(args.label)) {
createLabel(container.innerWrap, args.label, makeElement);
}
}
container.wrap.classList.add(CLS_HIDESPIN);
container = null;
}
exports.createSpinner = createSpinner;
function createLabel(container, label, makeElement) {
var labelEle = makeElement('div', {});
labelEle.classList.add(CLS_SPINLABEL);
labelEle.textContent = label;
container.appendChild(labelEle);
return labelEle;
}
function createMaterialSpinner(container, radius, makeElement) {
var uniqueID = randomGenerator();
globalTimeOut["" + uniqueID] = { timeOut: 0, type: 'Material', radius: radius };
createMaterialElement(container, uniqueID, makeElement, CLS_MATERIALSPIN);
matCalculateAttributes(radius, container, 'Material', CLS_MATERIALSPIN);
}
function createFluent2Spinner(container, radius, makeElement) {
var uniqueID = randomGenerator();
globalTimeOut["" + uniqueID] = { timeOut: 0, type: 'Fluent2', radius: radius };
createFabricElement(container, uniqueID, CLS_FLUENT2, makeElement);
fbCalculateAttributes(radius, container, CLS_FLUENT2);
}
function createMaterial3Spinner(container, radius, makeElement) {
var uniqueID = randomGenerator();
globalTimeOut["" + uniqueID] = { timeOut: 0, type: 'Material3', radius: radius };
createMaterialElement(container, uniqueID, makeElement, CLS_MATERIAL3SPIN);
matCalculateAttributes(radius, container, 'Material3', CLS_MATERIAL3SPIN);
}
function createBootstrap4Spinner(container, radius, makeElement) {
var uniqueID = randomGenerator();
globalTimeOut["" + uniqueID] = { timeOut: 0, type: 'Bootstrap4', radius: radius };
createMaterialElement(container, uniqueID, makeElement, CLS_BOOT4SPIN);
matCalculateAttributes(radius, container, 'Bootstrap4', CLS_BOOT4SPIN);
}
function createBootstrap5Spinner(container, radius, makeElement) {
var uniqueID = randomGenerator();
globalTimeOut["" + uniqueID] = { timeOut: 0, type: 'Bootstrap5', radius: radius };
createMaterialElement(container, uniqueID, makeElement, CLS_BOOT5SPIN);
matCalculateAttributes(radius, container, 'Bootstrap5', CLS_BOOT5SPIN);
}
function createTailwindSpinner(container, radius, makeElement) {
var uniqueID = randomGenerator();
globalTimeOut["" + uniqueID] = { timeOut: 0, type: 'Tailwind', radius: radius };
createFabricElement(container, uniqueID, CLS_TAILWIND, makeElement);
fbCalculateAttributes(radius, container, CLS_TAILWIND);
}
function createFluentSpinner(container, radius, makeElement) {
var uniqueID = randomGenerator();
globalTimeOut["" + uniqueID] = { timeOut: 0, type: 'Fluent', radius: radius };
createFabricElement(container, uniqueID, CLS_FLUENT, makeElement);
fbCalculateAttributes(radius, container, CLS_FLUENT);
}
function startMatAnimate(container, uniqueID, radius) {
var globalObject = {};
var timeOutVar = 0;
globalTimeOut["" + uniqueID].timeOut = 0;
globalObject["" + uniqueID] = globalVariables(uniqueID, radius, 0, 0);
var spinnerInfo = { uniqueID: uniqueID, container: container, globalInfo: globalObject, timeOutVar: timeOutVar };
animateMaterial(spinnerInfo);
}
function createFabricSpinner(container, radius, makeElement) {
var uniqueID = randomGenerator();
globalTimeOut["" + uniqueID] = { timeOut: 0, type: 'Fabric', radius: radius };
createFabricElement(container, uniqueID, CLS_FABRICSPIN, makeElement);
fbCalculateAttributes(radius, container, CLS_FABRICSPIN);
}
function createHighContrastSpinner(container, radius, makeElement) {
var uniqueID = randomGenerator();
globalTimeOut["" + uniqueID] = { timeOut: 0, type: 'HighContrast', radius: radius };
createFabricElement(container, uniqueID, CLS_HIGHCONTRASTSPIN, makeElement);
fbCalculateAttributes(radius, container, CLS_HIGHCONTRASTSPIN);
}
function getTheme(container) {
var theme = window.getComputedStyle(container, ':after').getPropertyValue('content');
return theme.replace(/['"]+/g, '');
}
function setTheme(theme, container, radius, makeElement) {
var innerContainer = container.querySelector('.' + CLS_SPININWRAP);
var svg = innerContainer.querySelector('svg');
Iif (!ej2_base_1.isNullOrUndefined(svg)) {
innerContainer.removeChild(svg);
}
switch (theme) {
case 'Material':
createMaterialSpinner(innerContainer, radius, makeElement);
break;
case 'Material3':
createMaterial3Spinner(innerContainer, radius, makeElement);
break;
case 'Fabric':
createFabricSpinner(innerContainer, radius, makeElement);
break;
case 'Bootstrap':
createBootstrapSpinner(innerContainer, radius, makeElement);
break;
case 'HighContrast':
createHighContrastSpinner(innerContainer, radius, makeElement);
break;
case 'Bootstrap4':
createBootstrap4Spinner(innerContainer, radius, makeElement);
break;
case 'Bootstrap5':
createBootstrap5Spinner(innerContainer, radius, makeElement);
break;
case 'Tailwind':
createTailwindSpinner(innerContainer, radius, makeElement);
break;
case 'Fluent':
createFluentSpinner(innerContainer, radius, makeElement);
break;
case 'Fluent2':
createFluent2Spinner(innerContainer, radius, makeElement);
break;
}
}
function createBootstrapSpinner(innerContainer, radius, makeElement) {
var uniqueID = randomGenerator();
globalTimeOut["" + uniqueID] = { timeOut: 0, type: 'Bootstrap', radius: radius };
createBootstrapElement(innerContainer, uniqueID, makeElement);
bootCalculateAttributes(innerContainer, radius);
}
function createBootstrapElement(innerContainer, uniqueID, makeElement) {
var svgBoot = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
var viewBoxValue = 64;
var trans = 32;
var defaultRadius = 2;
svgBoot.setAttribute('id', uniqueID);
svgBoot.setAttribute('class', CLS_BOOTSPIN);
svgBoot.setAttribute('viewBox', '0 0 ' + viewBoxValue + ' ' + viewBoxValue);
innerContainer.insertBefore(svgBoot, innerContainer.firstChild);
for (var item = 0; item <= 7; item++) {
var bootCircle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
bootCircle.setAttribute('class', CLS_SPINCIRCLE + '_' + item);
bootCircle.setAttribute('r', defaultRadius + '');
bootCircle.setAttribute('transform', 'translate(' + trans + ',' + trans + ')');
svgBoot.appendChild(bootCircle);
}
}
function bootCalculateAttributes(innerContainer, radius) {
var svg = innerContainer.querySelector('svg.e-spin-bootstrap');
svg.style.width = svg.style.height = radius + 'px';
var x = 0;
var y = 0;
var rad = 24;
var startArc = 90;
for (var item = 0; item <= 7; item++) {
var start = defineArcPoints(x, y, rad, startArc);
var circleEle = svg.querySelector('.' + CLS_SPINCIRCLE + '_' + item);
circleEle.setAttribute('cx', start.x + '');
circleEle.setAttribute('cy', start.y + '');
startArc = startArc >= 360 ? 0 : startArc;
startArc = startArc + 45;
}
}
function generateSeries(begin, stop) {
var series = [];
var start = begin;
var end = stop;
var increment = false;
var count = 1;
formSeries(start);
function formSeries(i) {
series.push(i);
if (i !== end || count === 1) {
if (i <= start && i > 1 && !increment) {
i = parseFloat((i - 0.2).toFixed(2));
}
else if (i === 1) {
i = 7;
i = parseFloat((i + 0.2).toFixed(2));
increment = true;
}
else if (i < 8 && increment) {
i = parseFloat((i + 0.2).toFixed(2));
if (i === 8) {
increment = false;
}
}
else if (i <= 8 && !increment) {
i = parseFloat((i - 0.2).toFixed(2));
}
++count;
formSeries(i);
}
}
return series;
}
function animateBootstrap(innerContainer) {
var svg = innerContainer.querySelector('svg.e-spin-bootstrap');
var id = svg.getAttribute('id');
for (var i = 1; i <= 8; i++) {
var circleEle = (innerContainer.getElementsByClassName('e-path-circle_' +
(i === 8 ? 0 : i))[0]);
rotation(circleEle, i, i, generateSeries(i, i), id);
}
function rotation(circle, start, end, series, id) {
var count = 0;
bootAnimate(start);
function bootAnimate(radius) {
if (globalTimeOut["" + id].isAnimate) {
++count;
circle.setAttribute('r', radius + '');
if (count >= series.length) {
count = 0;
}
globalTimeOut["" + id].timeOut = setTimeout(bootAnimate.bind(null, series[parseInt(count.toString(), 10)]), 18);
}
}
}
}
function replaceContent(container, template, cssClass) {
if (!ej2_base_1.isNullOrUndefined(cssClass)) {
container.classList.add(cssClass);
}
var inner = container.querySelector('.e-spinner-inner');
inner.innerHTML = template;
}
function calculateRadius(width, theme) {
var defaultSize;
switch (theme) {
case 'Material':
defaultSize = DEFT_MAT_WIDTH;
break;
case 'Material3':
defaultSize = DEFT_MAT3_WIDTH;
break;
case 'Fabric':
defaultSize = DEFT_FAB_WIDTH;
break;
case 'Fluent2':
defaultSize = DEFT_FLUENT2_WIDTH;
break;
case 'Bootstrap4':
defaultSize = DEFT_BOOT4_WIDTH;
break;
default:
defaultSize = DEFT_BOOT_WIDTH;
}
width = width ? parseFloat(width + '') : defaultSize;
return theme === 'Bootstrap' ? width : width / 2;
}
function globalVariables(id, radius, count, previousId) {
return {
radius: radius,
count: count,
previousId: previousId
};
}
function randomGenerator() {
var random = '';
var combine = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for (var i = 0; i < 5; i++) {
random += combine.charAt(Math.floor(Math.random() * combine.length));
}
return random;
}
function createFabricElement(innerCon, uniqueID, themeClass, makeElement) {
var svgFabric = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
svgFabric.setAttribute('id', uniqueID);
svgFabric.setAttribute('class', themeClass);
var fabricCirclePath = document.createElementNS('http://www.w3.org/2000/svg', 'path');
fabricCirclePath.setAttribute('class', CLS_SPINCIRCLE);
var fabricCircleArc = document.createElementNS('http://www.w3.org/2000/svg', 'path');
fabricCircleArc.setAttribute('class', CLS_SPINARC);
innerCon.insertBefore(svgFabric, innerCon.firstChild);
svgFabric.appendChild(fabricCirclePath);
svgFabric.appendChild(fabricCircleArc);
}
function createMaterialElement(innerContainer, uniqueID, makeElement, cls) {
var svgMaterial = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
svgMaterial.setAttribute('class', cls);
svgMaterial.setAttribute('id', uniqueID);
var matCirclePath = document.createElementNS('http://www.w3.org/2000/svg', 'path');
matCirclePath.setAttribute('class', CLS_SPINCIRCLE);
innerContainer.insertBefore(svgMaterial, innerContainer.firstChild);
svgMaterial.appendChild(matCirclePath);
}
function createSpinnerContainer(target, makeElement) {
var spinnerContainer = makeElement('div', {});
spinnerContainer.classList.add(CLS_SPINWRAP);
var spinnerInnerContainer = makeElement('div', {});
spinnerInnerContainer.classList.add(CLS_SPININWRAP);
target.appendChild(spinnerContainer);
spinnerContainer.appendChild(spinnerInnerContainer);
return { wrap: spinnerContainer, innerWrap: spinnerInnerContainer };
}
function animateMaterial(spinnerInfo) {
var start = 1;
var end = 149;
var duration = 1333;
var max = 75;
createCircle(start, end, easeAnimation, duration, spinnerInfo.globalInfo[spinnerInfo.uniqueID].count, max, spinnerInfo);
spinnerInfo.globalInfo[spinnerInfo.uniqueID].count = ++spinnerInfo.globalInfo[spinnerInfo.uniqueID].count % 4;
}
function createCircle(start, end, easing, duration, count, max, spinnerInfo) {
var id = ++spinnerInfo.globalInfo[spinnerInfo.uniqueID].previousId;
var startTime = new Date().getTime();
var change = end - start;
var diameter = getSize((spinnerInfo.globalInfo[spinnerInfo.uniqueID].radius * 2) + '');
var strokeSize = getStrokeSize(diameter);
var rotate = -90 * (spinnerInfo.globalInfo[spinnerInfo.uniqueID].count || 0);
matAnimation(spinnerInfo);
function matAnimation(spinnerInfo) {
var currentTime = Math.max(0, Math.min(new Date().getTime() - startTime, duration));
updatePath(easing(currentTime, start, change, duration), spinnerInfo.container);
if (id === spinnerInfo.globalInfo[spinnerInfo.uniqueID].previousId && currentTime < duration) {
globalTimeOut[spinnerInfo.uniqueID].timeOut = setTimeout(matAnimation.bind(null, spinnerInfo), 1);
}
else {
animateMaterial(spinnerInfo);
}
}
function updatePath(value, container) {
if (!ej2_base_1.isNullOrUndefined(container.querySelector('svg.e-spin-material')) || !ej2_base_1.isNullOrUndefined(container.querySelector('svg.e-spin-material3'))) {
var svg = void 0;
if (!ej2_base_1.isNullOrUndefined(container.querySelector('svg.e-spin-material')) && !ej2_base_1.isNullOrUndefined(container.querySelector('svg.e-spin-material').querySelector('path.e-path-circle'))) {
svg = container.querySelector('svg.e-spin-material');
}
else if (!ej2_base_1.isNullOrUndefined(container.querySelector('svg.e-spin-fluent2')) && !ej2_base_1.isNullOrUndefined(container.querySelector('svg.e-spin-fluent2').querySelector('path.e-path-circle'))) {
svg = container.querySelector('svg.e-spin-fluent2');
}
else if (!ej2_base_1.isNullOrUndefined(container.querySelector('svg.e-spin-material3')) && !ej2_base_1.isNullOrUndefined(container.querySelector('svg.e-spin-material3').querySelector('path.e-path-circle'))) {
svg = container.querySelector('svg.e-spin-material3');
}
if (!ej2_base_1.isNullOrUndefined(svg)) {
var path = svg.querySelector('path.e-path-circle');
path.setAttribute('stroke-dashoffset', getDashOffset(diameter, strokeSize, value, max) + '');
path.setAttribute('transform', 'rotate(' + (rotate) + ' ' + diameter / 2 + ' ' + diameter / 2 + ')');
}
}
}
}
function matCalculateAttributes(radius, container, type, cls) {
var diameter = radius * 2;
var svg = container.querySelector('svg.' + cls);
var path = svg.querySelector('path.e-path-circle');
var strokeSize = getStrokeSize(diameter);
var transformOrigin = (diameter / 2) + 'px';
svg.setAttribute('viewBox', '0 0 ' + diameter + ' ' + diameter);
svg.style.width = svg.style.height = diameter + 'px';
svg.style.transformOrigin = transformOrigin + ' ' + transformOrigin + ' ' + transformOrigin;
path.setAttribute('d', drawArc(diameter, strokeSize));
if (type === 'Material' || type === 'Material3') {
path.setAttribute('stroke-width', strokeSize + '');
path.setAttribute('stroke-dasharray', ((diameter - strokeSize) * Math.PI * 0.75) + '');
path.setAttribute('stroke-dashoffset', getDashOffset(diameter, strokeSize, 1, 75) + '');
}
}
function getSize(value) {
var parsed = parseFloat(value);
return parsed;
}
function drawArc(diameter, strokeSize) {
var radius = diameter / 2;
var offset = strokeSize / 2;
return 'M' + radius + ',' + offset
+ 'A' + (radius - offset) + ',' + (radius - offset) + ' 0 1 1 ' + offset + ',' + radius;
}
function getStrokeSize(diameter) {
return 10 / 100 * diameter;
}
function getDashOffset(diameter, strokeSize, value, max) {
return (diameter - strokeSize) * Math.PI * ((3 * (max) / 100) - (value / 100));
}
function easeAnimation(current, start, change, duration) {
var timestamp = (current /= duration) * current;
var timecount = timestamp * current;
return start + change * (6 * timecount * timestamp + -15 * timestamp * timestamp + 10 * timecount);
}
function fbCalculateAttributes(radius, innerConainer, trgClass) {
var centerX = radius;
var centerY = radius;
var diameter = radius * 2;
var startArc = 315;
var endArc = 45;
var svg = innerConainer.querySelector('.' + trgClass);
var circle = svg.querySelector('.e-path-circle');
var path = svg.querySelector('.e-path-arc');
var transformOrigin = (diameter / 2) + 'px';
circle.setAttribute('d', defineCircle(centerX, centerY, radius));
path.setAttribute('d', defineArc(centerX, centerY, radius, startArc, endArc));
svg.setAttribute('viewBox', '0 0 ' + diameter + ' ' + diameter);
svg.style.transformOrigin = transformOrigin + ' ' + transformOrigin + ' ' + transformOrigin;
svg.style.width = svg.style.height = diameter + 'px';
}
function defineArcPoints(centerX, centerY, radius, angle) {
var radians = (angle - 90) * Math.PI / 180.0;
return {
x: centerX + (radius * Math.cos(radians)),
y: centerY + (radius * Math.sin(radians))
};
}
function defineArc(x, y, radius, startArc, endArc) {
var start = defineArcPoints(x, y, radius, endArc);
var end = defineArcPoints(x, y, radius, startArc);
var d = [
'M', start.x, start.y,
'A', radius, radius, 0, 0, 0, end.x, end.y
].join(' ');
return d;
}
function defineCircle(x, y, radius) {
var d = [
'M', x, y,
'm', -radius, 0,
'a', radius, radius, 0, 1, 0, radius * 2, 0,
'a', radius, radius, 0, 1, 0, -radius * 2, 0
].join(' ');
return d;
}
function showSpinner(container) {
showHideSpinner(container, false);
container = null;
}
exports.showSpinner = showSpinner;
function showHideSpinner(container, isHide) {
var spinnerWrap;
Eif (container) {
spinnerWrap = container.classList.contains(CLS_SPINWRAP) ? container :
container.querySelector('.' + CLS_SPINWRAP);
}
Eif (container && spinnerWrap) {
var inner = spinnerWrap.querySelector('.' + CLS_SPININWRAP);
var spinCheck = isHide ? !spinnerWrap.classList.contains(CLS_SPINTEMPLATE) &&
!spinnerWrap.classList.contains(CLS_HIDESPIN) :
!spinnerWrap.classList.contains(CLS_SPINTEMPLATE) && !spinnerWrap.classList.contains(CLS_SHOWSPIN);
Eif (spinCheck) {
var svgEle = spinnerWrap.querySelector('svg');
Eif (ej2_base_1.isNullOrUndefined(svgEle)) {
return;
}
var id = svgEle.getAttribute('id');
globalTimeOut["" + id].isAnimate = !isHide;
switch (globalTimeOut["" + id].type) {
case 'Material':
case 'Material3':
case 'Fluent2':
if (isHide) {
clearTimeout(globalTimeOut["" + id].timeOut);
}
else {
startMatAnimate(inner, id, globalTimeOut["" + id].radius);
}
break;
case 'Bootstrap':
if (isHide) {
clearTimeout(globalTimeOut["" + id].timeOut);
}
else {
animateBootstrap(inner);
}
break;
}
}
if (isHide) {
ej2_base_1.classList(spinnerWrap, [CLS_HIDESPIN], [CLS_SHOWSPIN]);
}
else {
ej2_base_1.classList(spinnerWrap, [CLS_SHOWSPIN], [CLS_HIDESPIN]);
}
container = null;
}
}
function hideSpinner(container) {
showHideSpinner(container, true);
container = null;
}
exports.hideSpinner = hideSpinner;
function setSpinner(args, internalCreateElement) {
var makeElement = !ej2_base_1.isNullOrUndefined(internalCreateElement) ? internalCreateElement : ej2_base_1.createElement;
if (args.template !== undefined) {
spinTemplate = args.template;
if (args.template !== undefined) {
spinCSSClass = args.cssClass;
}
}
var container = document.querySelectorAll('.' + CLS_SPINWRAP);
for (var index = 0; index < container.length; index++) {
ensureTemplate(args.template, container[parseInt(index.toString(), 10)], args.type, args.cssClass, makeElement);
}
}
exports.setSpinner = setSpinner;
function ensureTemplate(template, container, theme, cssClass, makeEle) {
if (ej2_base_1.isNullOrUndefined(template) && !container.classList.contains(CLS_SPINTEMPLATE)) {
replaceTheme(container, theme, cssClass, makeEle);
if (container.classList.contains(CLS_SHOWSPIN)) {
container.classList.remove(CLS_SHOWSPIN);
showSpinner(container);
}
else {
container.classList.remove(CLS_HIDESPIN);
hideSpinner(container);
}
}
else {
spinTemplate = template;
if (!ej2_base_1.isNullOrUndefined(cssClass)) {
spinCSSClass = cssClass;
}
}
}
function replaceTheme(container, theme, cssClass, makeEle) {
if (!ej2_base_1.isNullOrUndefined(cssClass)) {
container.classList.add(cssClass);
}
var svgElement = container.querySelector('svg');
var radius = theme === 'Bootstrap' ? parseFloat(svgElement.style.height) : parseFloat(svgElement.style.height) / 2;
var classNames = svgElement.getAttribute('class');
var svgClassList = classNames.split(/\s/);
if (svgClassList.indexOf('e-spin-material') >= 0) {
var id = svgElement.getAttribute('id');
clearTimeout(globalTimeOut["" + id].timeOut);
}
setTheme(theme, container, radius, makeEle);
}
});
|