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

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

80.49% Statements 33/41
16.67% Branches 1/6
100% Functions 12/12
80% Lines 32/40

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

    66×

    8×

    1×
    99×

    1×
    97×

    97×
    97×

    97×
    97×

    1×
    2×

    1×

    66×
    66×
    66×

    1×
    74×

    1×

    1×

     (function(global){global.wrappers['/Users/lqez/Dev/summernote/src/js/base/module/LinkPopover.js']=[function(require,module,exports,__dirname,__filename){ "use strict";
    exports.__esModule = true;
    var jquery_1 = require("jquery");
    var lists_1 = require("../core/lists");
    var dom_1 = require("../core/dom");
    var LinkPopover = /** @class */ (function () {
        function LinkPopover(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.change summernote.scroll': function () {
                    _this.update();
                },
                'summernote.disable summernote.dialog.shown': function () {
                    _this.hide();
                }
            };
        }
        LinkPopover.prototype.shouldInitialize = function () {
            return !lists_1["default"].isEmpty(this.options.popover.link);
        };
        LinkPopover.prototype.initialize = function () {
            this.$popover = this.ui.popover({
                className: 'note-link-popover',
                callback: function ($node) {
                    var $content = $node.find('.popover-content,.note-popover-content');
                    $content.prepend('<span><a target="_blank"></a>&nbsp;</span>');
                }
            }).render().appendTo(this.options.container);
            var $content = this.$popover.find('.popover-content,.note-popover-content');
            this.context.invoke('buttons.build', $content, this.options.popover.link);
        };
        LinkPopover.prototype.destroy = function () {
            this.$popover.remove();
        };
        LinkPopover.prototype.update = function () {
            // Prevent focusing on editable when invoke('code') is executed
            Eif (!this.context.invoke('editor.hasFocus')) {
                this.hide();
                return;
            }
            var rng = this.context.invoke('editor.getLastRange');
            if (rng.isCollapsed() && rng.isOnAnchor()) {
                var anchor = dom_1["default"].ancestor(rng.sc, dom_1["default"].isAnchor);
                var href = jquery_1["default"](anchor).attr('href');
                this.$popover.find('a').attr('href', href).html(href);
                var pos = dom_1["default"].posFromPlaceholder(anchor);
                this.$popover.css({
                    display: 'block',
                    left: pos.left,
                    top: pos.top
                });
            }
            else {
                this.hide();
            }
        };
        LinkPopover.prototype.hide = function () {
            this.$popover.hide();
        };
        return LinkPopover;
    }());
    exports["default"] = LinkPopover;

    },'src/js/base/module/LinkPopover.js',{"jquery":"/Users/lqez/Dev/summernote/node_modules/jquery/dist/jquery.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, 5244 characters]