Code coverage report for src/js/base/module/AirPopover.js

# all files / src/js/base/module/ AirPopover.js

55.81% Statements 24/43
7.14% Branches 1/14
41.67% Functions 5/12
54.76% Lines 23/42

    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
    741×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    2×
    97×
    97×
    97×
    97×
    97×

    1×
    99×

    1×

    1×

    1×

    1×

    1×

    1×

     (function(global){global.wrappers['/Users/lqez/Dev/summernote/src/js/base/module/AirPopover.js']=[function(require,module,exports,__dirname,__filename){ "use strict";
    exports.__esModule = true;
    var jquery_1 = require("jquery");
    var env_1 = require("../core/env");
    var func_1 = require("../core/func");
    var lists_1 = require("../core/lists");
    var dom_1 = require("../core/dom");
    var AIR_MODE_POPOVER_X_OFFSET = 20;
    var AirPopover = /** @class */ (function () {
        function AirPopover(context) {
            var _this = this;
            this.context = context;
            this.ui = jquery_1["default"].summernote.ui;
            this.options = context.options;
            this.events = {
                'summernote.keyup summernote.mouseup summernote.scroll': function () {
                    _this.update();
                },
                'summernote.disable summernote.change summernote.dialog.shown': function () {
                    _this.hide();
                },
                'summernote.focusout': function (we, e) {
                    // [workaround] Firefox doesn't support relatedTarget on focusout
                    //  - Ignore hide action on focus out in FF.
                    if (env_1["default"].isFF) {
                        return;
                    }
                    if (!e.relatedTarget || !dom_1["default"].ancestor(e.relatedTarget, func_1["default"].eq(_this.$popover[0]))) {
                        _this.hide();
                    }
                }
            };
        }
        AirPopover.prototype.shouldInitialize = function () {
            return this.options.airMode && !lists_1["default"].isEmpty(this.options.popover.air);
        };
        AirPopover.prototype.initialize = function () {
            this.$popover = this.ui.popover({
                className: 'note-air-popover'
            }).render().appendTo(this.options.container);
            var $content = this.$popover.find('.popover-content');
            this.context.invoke('buttons.build', $content, this.options.popover.air);
        };
        AirPopover.prototype.destroy = function () {
            this.$popover.remove();
        };
        AirPopover.prototype.update = function () {
            var styleInfo = this.context.invoke('editor.currentStyle');
            if (styleInfo.range && !styleInfo.range.isCollapsed()) {
                var rect = lists_1["default"].last(styleInfo.range.getClientRects());
                if (rect) {
                    var bnd = func_1["default"].rect2bnd(rect);
                    this.$popover.css({
                        display: 'block',
                        left: Math.max(bnd.left + bnd.width / 2, 0) - AIR_MODE_POPOVER_X_OFFSET,
                        top: bnd.top + bnd.height
                    });
                    this.context.invoke('buttons.updateCurrentStyle', this.$popover);
                }
            }
            else {
                this.hide();
            }
        };
        AirPopover.prototype.hide = function () {
            this.$popover.hide();
        };
        return AirPopover;
    }());
    exports["default"] = AirPopover;

    },'src/js/base/module/AirPopover.js',{"jquery":"/Users/lqez/Dev/summernote/node_modules/jquery/dist/jquery.js","../core/env":"/Users/lqez/Dev/summernote/src/js/base/core/env.js","../core/func":"/Users/lqez/Dev/summernote/src/js/base/core/func.js","../core/lists":"/Users/lqez/Dev/summernote/src/js/base/core/lists.js","../core/dom":"/Users/lqez/Dev/summernote/src/js/base/core/dom.js"}];})(this);
    //# sourceMappingURL=data:application/json;charset=utf-8;base64,[encoded data, 5732 characters]