all files / progressbar/model/ annotation.js

91.67% Statements 44/48
57.14% Branches 8/14
100% Functions 7/7
91.67% Lines 44/48
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   19×   21× 21×       21×   21× 21× 21× 21×                 21×       21× 21× 21× 21× 21× 21× 21× 21× 21× 20×       21× 21× 21× 21×     18× 18× 18× 18× 18× 18× 18×   21×            
define(["require", "exports", "@syncfusion/ej2-base", "../utils/helper"], function (require, exports, ej2_base_1, helper_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var AnnotationBase = (function () {
        function AnnotationBase(control) {
            this.control = control;
        }
        AnnotationBase.prototype.render = function (annotation, index) {
            this.annotation = annotation;
            var childElement = ej2_base_1.createElement('div', {
                id: this.control.element.id + 'Annotation' + index,
                styles: 'position:absolute;z-index:1', innerHTML: annotation.content
            });
            return childElement;
        };
        AnnotationBase.prototype.processAnnotation = function (annotation, index, parentElement) {
            var location = new helper_1.ProgressLocation(0, 0);
            var annotationElement = this.render(annotation, index);
            Eif (annotationElement) {
                this.setElementStyle(location, annotationElement, parentElement);
            }
            else if (this.control.redraw) {
                helper_1.removeElement(annotationElement.id);
                if (this.control.isReact) {
                    this.control.clearTemplate();
                }
            }
        };
        AnnotationBase.prototype.setElementStyle = function (location, element, parentElement) {
            var argsData = {
                cancel: false, name: helper_1.annotationRender, content: element,
                location: location
            };
            this.control.trigger(helper_1.annotationRender, argsData);
            Eif (!argsData.cancel) {
                var result = this.Location(this.annotation.annotationRadius, this.annotation.annotationAngle);
                argsData.content.style.left = result.left + 'px';
                argsData.content.style.top = result.top + 'px';
                argsData.content.style.transform = 'translate(-50%, -50%)';
                argsData.content.setAttribute('aria-label', 'Annotation');
                parentElement.appendChild(argsData.content);
                if (this.control.isReact) {
                    this.control.renderReactTemplates();
                }
            }
        };
        AnnotationBase.prototype.Location = function (radius, angle) {
            var top;
            var left;
            var radius1 = parseFloat(radius);
            if (radius1 === 0 && angle === 0) {
                var rect = this.control.progressRect;
                left = rect.x + (rect.width / 2);
                top = rect.y + (rect.height / 2);
            }
            else {
                var degToRadFactor = Math.PI / 180;
                angle = angle - 90;
                angle = angle * degToRadFactor;
                var x = Math.round(this.control.progressSize.width / 2.25);
                var y = Math.round(this.control.progressSize.height / 2.25);
                left = (radius1 * Math.cos(angle)) + x;
                top = (radius1 * Math.sin(angle)) + y;
            }
            return {
                top: top, left: left
            };
        };
        return AnnotationBase;
    }());
    exports.AnnotationBase = AnnotationBase;
});