all files / rich-text-editor/actions/ full-screen.js

94.25% Statements 82/87
89.09% Branches 49/55
100% Functions 12/12
94.25% Lines 82/87
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   1833× 1833×   29× 29×   25×   29×     29× 29× 28×           28× 28× 27×   23× 23×   27× 27× 27× 26×   26×   26×           27× 27×         25× 25×   18×   25×     25× 12×           12× 12× 12× 12× 12× 12×   12× 11×   11×         11×     12× 12×         27×     27× 29× 27× 27×           621× 621×     13× 13× 13×     1833× 1833×   1832× 1832×   1832×     1832×     1832× 1832× 17×   1832×        
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-popups", "../base/constant", "../base/classes", "@syncfusion/ej2-base"], function (require, exports, ej2_base_1, ej2_popups_1, events, classes, ej2_base_2) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var FullScreen = (function () {
        function FullScreen(parent) {
            this.parent = parent;
            this.addEventListener();
        }
        FullScreen.prototype.showFullScreen = function (event) {
            var _this = this;
            if (this.parent.toolbarSettings.enable === true && this.parent.editorMode !== 'Markdown'
                && !ej2_base_1.isNullOrUndefined(this.parent.quickToolbarModule)) {
                this.parent.quickToolbarModule.hideQuickToolbars();
            }
            Iif (this.parent.showTooltip && !ej2_base_1.isNullOrUndefined(document.querySelector('.e-tooltip-wrap'))) {
                this.parent.notify(events.destroyTooltip, { args: event });
            }
            this.scrollableParent = ej2_popups_1.getScrollableParent(this.parent.element);
            if (!this.parent.element.classList.contains(classes.CLS_FULL_SCREEN)) {
                var evenArgs = {
                    cancel: false,
                    requestType: 'Maximize',
                    targetItem: 'Maximize',
                    args: event
                };
                this.parent.trigger(events.actionBegin, evenArgs, function (beginEventArgs) {
                    if (!beginEventArgs.cancel) {
                        if (_this.parent.toolbarSettings.enableFloating &&
                            !_this.parent.inlineMode.enable && _this.parent.toolbarSettings.enable) {
                            _this.parent.getToolbarElement().style.width = '100%';
                            _this.parent.getToolbarElement().style.top = '0px';
                        }
                        _this.parent.element.classList.add(classes.CLS_FULL_SCREEN);
                        _this.toggleParentOverflow(true);
                        if (_this.parent.toolbarModule) {
                            if (!_this.parent.getBaseToolbarObject().toolbarObj.items[0].properties) {
                                _this.parent.getBaseToolbarObject().toolbarObj.removeItems(0);
                            }
                            if (ej2_base_1.Browser.isDevice) {
                                _this.parent.toolbarModule.removeFixedTBarClass();
                            }
                            _this.parent.toolbarModule.updateItem({
                                targetItem: 'Maximize',
                                updateItem: 'Minimize',
                                baseToolbar: _this.parent.getBaseToolbarObject()
                            });
                        }
                        _this.parent.refreshUI();
                        _this.parent.trigger(events.actionComplete, { requestType: 'Maximize', targetItem: 'Maximize', args: event });
                    }
                });
            }
        };
        FullScreen.prototype.hideFullScreen = function (event) {
            var _this = this;
            if (this.parent.toolbarSettings.enable === true && this.parent.editorMode !== 'Markdown'
                && !ej2_base_1.isNullOrUndefined(this.parent.quickToolbarModule)) {
                this.parent.quickToolbarModule.hideQuickToolbars();
            }
            Iif (this.parent.showTooltip && !ej2_base_1.isNullOrUndefined(document.querySelector('.e-tooltip-wrap'))) {
                this.parent.notify(events.destroyTooltip, { args: event });
            }
            if (this.parent.element.classList.contains(classes.CLS_FULL_SCREEN)) {
                var evenArgs = {
                    cancel: false,
                    requestType: 'Minimize',
                    targetItem: 'Minimize',
                    args: event
                };
                this.parent.trigger(events.actionBegin, evenArgs, function (beginEventArgs) {
                    Eif (!beginEventArgs.cancel) {
                        _this.parent.element.classList.remove(classes.CLS_FULL_SCREEN);
                        var elem = document.querySelectorAll('.e-rte-overflow');
                        for (var i = 0; i < elem.length; i++) {
                            ej2_base_2.removeClass([elem[i]], ['e-rte-overflow']);
                        }
                        if (_this.parent.toolbarModule) {
                            if (!_this.parent.getBaseToolbarObject().toolbarObj.items[0].properties) {
                                _this.parent.getBaseToolbarObject().toolbarObj.removeItems(0);
                            }
                            _this.parent.toolbarModule.updateItem({
                                targetItem: 'Minimize',
                                updateItem: 'Maximize',
                                baseToolbar: _this.parent.getBaseToolbarObject()
                            });
                            if (ej2_base_1.Browser.isDevice && _this.parent.inlineMode.enable) {
                                _this.parent.toolbarModule.addFixedTBarClass();
                            }
                        }
                        _this.parent.refreshUI();
                        _this.parent.trigger(events.actionComplete, { requestType: 'Minimize', targetItem: 'Minimize', args: event });
                    }
                });
            }
        };
        FullScreen.prototype.toggleParentOverflow = function (isAdd) {
            Iif (ej2_base_1.isNullOrUndefined(this.scrollableParent)) {
                return;
            }
            for (var i = 0; i < this.scrollableParent.length; i++) {
                if (this.scrollableParent[i].nodeName === '#document') {
                    var elem = document.querySelector('body');
                    ej2_base_2.addClass([elem], ['e-rte-overflow']);
                }
                else {
                    var elem = this.scrollableParent[i];
                    ej2_base_2.addClass([elem], ['e-rte-overflow']);
                }
            }
        };
        FullScreen.prototype.onKeyDown = function (event) {
            var originalEvent = event.args;
            switch (originalEvent.action) {
                case 'full-screen':
                    this.showFullScreen(event.args);
                    originalEvent.preventDefault();
                    break;
                case 'escape':
                    this.hideFullScreen(event.args);
                    originalEvent.preventDefault();
                    break;
            }
        };
        FullScreen.prototype.addEventListener = function () {
            this.parent.on(events.keyDown, this.onKeyDown, this);
            this.parent.on(events.destroy, this.destroy, this);
        };
        FullScreen.prototype.removeEventListener = function () {
            this.parent.off(events.keyDown, this.onKeyDown);
            this.parent.off(events.destroy, this.destroy);
        };
        FullScreen.prototype.destroy = function () {
            Iif (ej2_base_1.isNullOrUndefined(this.parent)) {
                return;
            }
            Iif (this.parent.element.classList.contains(classes.CLS_FULL_SCREEN)) {
                this.toggleParentOverflow(false);
            }
            var elem = document.querySelectorAll('.e-rte-overflow');
            for (var i = 0; i < elem.length; i++) {
                ej2_base_2.removeClass([elem[i]], ['e-rte-overflow']);
            }
            this.removeEventListener();
        };
        return FullScreen;
    }());
    exports.FullScreen = FullScreen;
});