# all files / src/js/lite/ui/ DropdownUI.js

6.82% Statements 3/44
0% Branches 0/6
8.33% Functions 1/12
4.65% Lines 2/43

    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
    661×

    2×

     (function(global){global.wrappers['/Users/lqez/Dev/summernote/src/js/lite/ui/DropdownUI.js']=[function(require,module,exports,__dirname,__filename){ "use strict";
    exports.__esModule = true;
    var DropdownUI = /** @class */ (function () {
        function DropdownUI($node, options) {
            this.$button = $node;
            this.options = $.extend({}, {
                target: options.container
            }, options);
            this.setEvent();
        }
        DropdownUI.prototype.setEvent = function () {
            var _this = this;
            this.$button.on('click', function (e) {
                _this.toggle();
                e.stopImmediatePropagation();
            });
        };
        DropdownUI.prototype.clear = function () {
            var $parent = $('.note-btn-group.open');
            $parent.find('.note-btn.active').removeClass('active');
            $parent.removeClass('open');
        };
        DropdownUI.prototype.show = function () {
            this.$button.addClass('active');
            this.$button.parent().addClass('open');
            var $dropdown = this.$button.next();
            var offset = $dropdown.offset();
            var width = $dropdown.outerWidth();
            var windowWidth = $(window).width();
            var targetMarginRight = parseFloat($(this.options.target).css('margin-right'));
            if (offset.left + width > windowWidth - targetMarginRight) {
                $dropdown.css('margin-left', windowWidth - targetMarginRight - (offset.left + width));
            }
            else {
                $dropdown.css('margin-left', '');
            }
        };
        DropdownUI.prototype.hide = function () {
            this.$button.removeClass('active');
            this.$button.parent().removeClass('open');
        };
        DropdownUI.prototype.toggle = function () {
            var isOpened = this.$button.parent().hasClass('open');
            this.clear();
            if (isOpened) {
                this.hide();
            }
            else {
                this.show();
            }
        };
        return DropdownUI;
    }());
    $(document).on('click', function (e) {
        if (!$(e.target).closest('.note-btn-group').length) {
            $('.note-btn-group.open').removeClass('open');
        }
    });
    $(document).on('click.note-dropdown-menu', function (e) {
        $(e.target).closest('.note-dropdown-menu').parent().removeClass('open');
    });
    exports["default"] = DropdownUI;

    },'src/js/lite/ui/DropdownUI.js',{}];})(this);
    //# sourceMappingURL=data:application/json;charset=utf-8;base64,