all files / document-editor-container/helper/ line-spacing-helper.js

85.11% Statements 40/47
75% Branches 15/20
87.5% Functions 7/8
85.11% Lines 40/47
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     80×                                           274× 274× 264×   10×     10×                        
define(["require", "exports"], function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var LineSpacingHelper = (function () {
        function LineSpacingHelper() {
        }
        LineSpacingHelper.getLineSpacingItems = function (localObj) {
            return [
                { text: localObj.getConstant('Single') },
                { text: '1.15' },
                { text: '1.5' },
                { text: localObj.getConstant('Double') }
            ];
        };
        LineSpacingHelper.applyLineSpacing = function (documentEditor, text, appliedLineSpacing, localObj) {
            Eif (!documentEditor.isReadOnly && documentEditor.selection) {
                var lineSpacing = 0;
                switch (text) {
                    case localObj.getConstant('Single'):
                        lineSpacing = 1;
                        appliedLineSpacing.value = localObj.getConstant('Single');
                        break;
                    case '1.15':
                        lineSpacing = 1.15;
                        appliedLineSpacing.value = '1.15';
                        break;
                    case '1.5':
                        lineSpacing = 1.5;
                        appliedLineSpacing.value = '1.5';
                        break;
                    case localObj.getConstant('Double'):
                        lineSpacing = 2;
                        appliedLineSpacing.value = localObj.getConstant('Double');
                        break;
                }
                Eif (lineSpacing > 0) {
                    documentEditor.selection.paragraphFormat.lineSpacing = lineSpacing;
                }
                setTimeout(function () {
                    documentEditor.focusIn();
                }, 30);
            }
        };
        LineSpacingHelper.getCurrentLineSpacing = function (documentEditor, localObj) {
            var lineSpacing = documentEditor.selection.paragraphFormat.lineSpacing;
            if (lineSpacing === 1) {
                return localObj.getConstant('Single');
            }
            else Iif (lineSpacing === 1.15) {
                return '1.15';
            }
            else if (lineSpacing === 1.5) {
                return '1.5';
            }
            else if (lineSpacing === 2) {
                return localObj.getConstant('Double');
            }
            else {
                return '';
            }
        };
        LineSpacingHelper.customizeLineSpacingItem = function (args, appliedLineSpacing) {
            args.element.innerHTML = '<span></span>' + args.item.text;
            var span = args.element.children[0];
            if (args.item.text === appliedLineSpacing) {
                span.style.marginRight = '10px';
                span.setAttribute('class', 'e-de-selected-item e-icons e-de-linespacing');
            }
            else {
                span.style.marginRight = '25px';
                span.classList.remove('e-de-selected-item');
            }
        };
        return LineSpacingHelper;
    }());
    exports.LineSpacingHelper = LineSpacingHelper;
});