all files / spinner/ spinner.js

100% Statements 342/342
96.4% Branches 107/111
100% Functions 44/44
100% Lines 342/342
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                   63× 63× 63× 63× 16×   63×     58× 58× 58× 58× 58× 56×     63× 63×   56× 56× 56× 56× 56×   41× 41× 41× 41×   42× 42× 42× 42× 42× 42×   15× 15× 15× 15×     35× 35×   75× 75× 75× 17×   75×   41× 41×   15× 15×   12× 12×       12× 12× 12× 12×   12× 12× 12× 12× 12× 12× 12× 12× 12× 96× 96× 96× 96× 96×     12× 12× 12× 12× 12× 12× 12× 96× 96× 96× 96× 96× 96×     96× 96× 96× 96× 96× 96× 3936× 3936× 3840× 1680×   2160× 96× 96× 96×   2064× 384× 384× 96×     1680× 1680×   3840× 3840×     96×   12× 12× 12× 96×   96×   96× 96× 71510× 71503× 71503× 71503× 1672×   71503×             58× 58× 58×   42×           74× 74× 74× 370×   74×   21× 21× 21× 21× 21× 21× 21× 21× 21× 21×   41× 41× 41× 41× 41× 41× 41×   63× 63× 63× 63× 63× 63× 63×   370× 370× 370× 370× 370× 370×   370× 370× 370× 370× 370× 370× 370× 105030× 105030× 105030× 104702×     328×     105030×   105030× 105030× 105030× 105030×       41× 41× 41× 41× 41× 41× 41× 41× 41× 41× 41× 41×   370× 370×   41× 41× 41×     411×   105071×   105030× 105030× 105030×   21× 21× 21× 21× 21× 21× 21× 21× 21× 21× 21× 21× 21× 21×   138× 138×         21× 21× 21×       21×   21×           21×             80× 80×   85×   85× 85× 85×   85× 80× 80×   78× 78× 78×   44× 44×   13× 13×     83× 83×                               25× 25× 16× 16× 16×     25× 25× 20×     20× 17× 17× 16× 16×                 17× 16×   17× 17× 17× 17× 17×   17×      
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_FAB_WIDTH = 30;
    var DEFT_BOOT_WIDTH = 30;
    var CLS_SHOWSPIN = 'e-spin-show';
    var CLS_HIDESPIN = 'e-spin-hide';
    var CLS_MATERIALSPIN = 'e-spin-material';
    var CLS_FABRICSPIN = 'e-spin-fabric';
    var CLS_BOOTSPIN = 'e-spin-bootstrap';
    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';
    /**
     * Create a spinner for the specified target element.
     * ```
     * E.g : createSpinner({ target: targetElement, width: '34px', label: 'Loading..' });
     * ```
     * @param args
     * @private
     */
    function createSpinner(args, internalCreateElement) {
        var radius;
        var makeElement = !ej2_base_1.isNullOrUndefined(internalCreateElement) ? internalCreateElement : ej2_base_1.createElement;
        var container = create_spinner_container(args.target, makeElement);
        if (!ej2_base_1.isNullOrUndefined(args.cssClass)) {
            container.wrap.classList.add(args.cssClass);
        }
        if (!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);
            if (!ej2_base_1.isNullOrUndefined(args.label)) {
                createLabel(container.inner_wrap, 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 = random_generator();
        globalTimeOut[uniqueID] = { timeOut: 0, type: 'Material', radius: radius };
        create_material_element(container, uniqueID, makeElement);
        mat_calculate_attributes(radius, container);
    }
    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 = random_generator();
        globalTimeOut[uniqueID] = { timeOut: 0, type: 'Fabric', radius: radius };
        create_fabric_element(container, uniqueID, CLS_FABRICSPIN, makeElement);
        fb_calculate_attributes(radius, container, CLS_FABRICSPIN);
    }
    function createHighContrastSpinner(container, radius, makeElement) {
        var uniqueID = random_generator();
        globalTimeOut[uniqueID] = { timeOut: 0, type: 'HighContrast', radius: radius };
        create_fabric_element(container, uniqueID, CLS_HIGHCONTRASTSPIN, makeElement);
        fb_calculate_attributes(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');
        if (!ej2_base_1.isNullOrUndefined(svg)) {
            innerContainer.removeChild(svg);
        }
        switch (theme) {
            case 'Material':
                createMaterialSpinner(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;
        }
    }
    function createBootstrapSpinner(innerContainer, radius, makeElement) {
        var uniqueID = random_generator();
        globalTimeOut[uniqueID] = { timeOut: 0, type: 'Bootstrap', radius: radius };
        create_bootstrap_element(innerContainer, uniqueID, makeElement);
        boot_calculate_attributes(innerContainer, radius);
    }
    function create_bootstrap_element(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 boot_calculate_attributes(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 Eif (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;
            boot_animate(start);
            function boot_animate(radius) {
                if (globalTimeOut[id].isAnimate) {
                    ++count;
                    circle.setAttribute('r', radius + '');
                    if (count >= series.length) {
                        count = 0;
                    }
                    globalTimeOut[id].timeOut = setTimeout(boot_animate.bind(null, series[count]), 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 = theme === 'Material' ? DEFT_MAT_WIDTH : theme === 'Fabric' ? DEFT_FAB_WIDTH : 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 random_generator() {
        var random = '';
        var combine = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
        for (var i = 0; i < 5; i++) {
            random += combine.charAt(Math.floor(Math.random() * combine.length));
        }
        return random;
    }
    function create_fabric_element(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 create_material_element(innerContainer, uniqueID, makeElement) {
        var svgMaterial = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
        svgMaterial.setAttribute('class', CLS_MATERIALSPIN);
        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 create_spinner_container(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, inner_wrap: 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);
        mat_animation(spinnerInfo);
        function mat_animation(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(mat_animation.bind(null, spinnerInfo), 1);
            }
            else {
                animateMaterial(spinnerInfo);
            }
        }
        function updatePath(value, container) {
            Eif ((!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')))) {
                var svg = container.querySelector('svg.e-spin-material');
                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 mat_calculate_attributes(radius, container) {
        var diameter = radius * 2;
        var svg = container.querySelector('svg.e-spin-material');
        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('stroke-width', strokeSize + '');
        path.setAttribute('d', drawArc(diameter, 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 fb_calculate_attributes(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 to show the Spinner.
     * @param container - Specify the target of the Spinner.
     * @private
     */
    function showSpinner(container) {
        showHideSpinner(container, false);
        container = null;
    }
    exports.showSpinner = showSpinner;
    function showHideSpinner(container, isHide) {
        var spinnerWrap = container.classList.contains(CLS_SPINWRAP) ? container :
            container.querySelector('.' + CLS_SPINWRAP);
        var inner = spinnerWrap.querySelector('.' + CLS_SPININWRAP);
        var spinCheck;
        spinCheck = isHide ? !spinnerWrap.classList.contains(CLS_SPINTEMPLATE) && !spinnerWrap.classList.contains(CLS_HIDESPIN) :
            !spinnerWrap.classList.contains(CLS_SPINTEMPLATE) && !spinnerWrap.classList.contains(CLS_SHOWSPIN);
        if (spinCheck) {
            var svgEle = spinnerWrap.querySelector('svg');
            if (ej2_base_1.isNullOrUndefined(svgEle)) {
                return;
            }
            var id = svgEle.getAttribute('id');
            globalTimeOut[id].isAnimate = !isHide;
            switch (globalTimeOut[id].type) {
                case 'Material':
                    isHide ? clearTimeout(globalTimeOut[id].timeOut) : startMatAnimate(inner, id, globalTimeOut[id].radius);
                    break;
                case 'Bootstrap':
                    isHide ? clearTimeout(globalTimeOut[id].timeOut) : animateBootstrap(inner);
                    break;
            }
        }
        isHide ? ej2_base_1.classList(spinnerWrap, [CLS_HIDESPIN], [CLS_SHOWSPIN]) : ej2_base_1.classList(spinnerWrap, [CLS_SHOWSPIN], [CLS_HIDESPIN]);
        container = null;
    }
    /**
     * Function to hide the Spinner.
     * @param container - Specify the target of the Spinner.
     * @private
     */
    function hideSpinner(container) {
        showHideSpinner(container, true);
        container = null;
    }
    exports.hideSpinner = hideSpinner;
    /**
     * Function to change the Spinners in a page globally from application end.
     * ```
     * E.g : setSpinner({ cssClass: 'custom-css'; type: 'Material' });
     * ```
     * @param args
     * @private
     */
    function setSpinner(args, internalCreateElement) {
        var makeElement = !ej2_base_1.isNullOrUndefined(internalCreateElement) ? internalCreateElement : ej2_base_1.createElement;
        if (args.template !== undefined) {
            spinTemplate = args.template;
            Eif (args.template !== undefined) {
                spinCSSClass = args.cssClass;
            }
        }
        var container = document.querySelectorAll('.' + CLS_SPINWRAP);
        for (var index = 0; index < container.length; index++) {
            ensureTemplate(args.template, container[index], 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);
    }
});