Completed
Push — master ( 36261e...adbdec )
by
unknown
14s queued 12s
created

popover.js ➔ _extends   B

Complexity

Conditions 6

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 9
dl 0
loc 16
rs 8.6666
c 0
b 0
f 0
1
/*!
2
  * Bootstrap popover.js v4.6.1 (https://getbootstrap.com/)
3
  * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
4
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
5
  */
6
(function (global, factory) {
7
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('./tooltip.js')) :
8
  typeof define === 'function' && define.amd ? define(['jquery', './tooltip'], factory) :
0 ignored issues
show
Bug introduced by
The variable define seems to be never declared. If this is a global, consider adding a /** global: define */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
9
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Popover = factory(global.jQuery, global.Tooltip));
0 ignored issues
show
Bug introduced by
The variable globalThis seems to be never declared. If this is a global, consider adding a /** global: globalThis */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Best Practice introduced by
If you intend to check if the variable self is declared in the current environment, consider using typeof self === "undefined" instead. This is safe if the variable is not actually declared.
Loading history...
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
10
})(this, (function ($, Tooltip) { 'use strict';
11
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
14
  var $__default = /*#__PURE__*/_interopDefaultLegacy($);
15
  var Tooltip__default = /*#__PURE__*/_interopDefaultLegacy(Tooltip);
16
17
  function _defineProperties(target, props) {
18
    for (var i = 0; i < props.length; i++) {
19
      var descriptor = props[i];
20
      descriptor.enumerable = descriptor.enumerable || false;
21
      descriptor.configurable = true;
22
      if ("value" in descriptor) descriptor.writable = true;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
23
      Object.defineProperty(target, descriptor.key, descriptor);
24
    }
25
  }
26
27
  function _createClass(Constructor, protoProps, staticProps) {
28
    if (protoProps) _defineProperties(Constructor.prototype, protoProps);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
29
    if (staticProps) _defineProperties(Constructor, staticProps);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
30
    return Constructor;
31
  }
32
33
  function _extends() {
34
    _extends = Object.assign || function (target) {
35
      for (var i = 1; i < arguments.length; i++) {
36
        var source = arguments[i];
37
0 ignored issues
show
Comprehensibility introduced by
It seems like you are trying to overwrite a function name here. _extends is already defined in line 36 as a function. While this will work, it can be very confusing.
Loading history...
38
        for (var key in source) {
39
          if (Object.prototype.hasOwnProperty.call(source, key)) {
40
            target[key] = source[key];
41
          }
0 ignored issues
show
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
Loading history...
42
        }
43
      }
44
45
      return target;
46
    };
47
48
    return _extends.apply(this, arguments);
49
  }
50
51
  function _inheritsLoose(subClass, superClass) {
52
    subClass.prototype = Object.create(superClass.prototype);
53
    subClass.prototype.constructor = subClass;
54
55
    _setPrototypeOf(subClass, superClass);
56
  }
57
58
  function _setPrototypeOf(o, p) {
59
    _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
60
      o.__proto__ = p;
61
      return o;
62
    };
63
64
    return _setPrototypeOf(o, p);
65
  }
66
67
  /**
68
   * Constants
69
   */
70
71
  var NAME = 'popover';
72
  var VERSION = '4.6.1';
73
  var DATA_KEY = 'bs.popover';
74
  var EVENT_KEY = "." + DATA_KEY;
75
  var JQUERY_NO_CONFLICT = $__default["default"].fn[NAME];
76
  var CLASS_PREFIX = 'bs-popover';
77
  var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g');
78
  var CLASS_NAME_FADE = 'fade';
79
  var CLASS_NAME_SHOW = 'show';
80
  var SELECTOR_TITLE = '.popover-header';
81
  var SELECTOR_CONTENT = '.popover-body';
82
83
  var Default = _extends({}, Tooltip__default["default"].Default, {
84
    placement: 'right',
85
    trigger: 'click',
86
    content: '',
87
    template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>'
88
  });
89
90
  var DefaultType = _extends({}, Tooltip__default["default"].DefaultType, {
91
    content: '(string|element|function)'
92
  });
93
94
  var Event = {
95
    HIDE: "hide" + EVENT_KEY,
96
    HIDDEN: "hidden" + EVENT_KEY,
97
    SHOW: "show" + EVENT_KEY,
98
    SHOWN: "shown" + EVENT_KEY,
99
    INSERTED: "inserted" + EVENT_KEY,
100
    CLICK: "click" + EVENT_KEY,
101
    FOCUSIN: "focusin" + EVENT_KEY,
102
    FOCUSOUT: "focusout" + EVENT_KEY,
103
    MOUSEENTER: "mouseenter" + EVENT_KEY,
104
    MOUSELEAVE: "mouseleave" + EVENT_KEY
105
  };
106
  /**
107
   * Class definition
108
   */
109
110
  var Popover = /*#__PURE__*/function (_Tooltip) {
111
    _inheritsLoose(Popover, _Tooltip);
112
113
    function Popover() {
114
      return _Tooltip.apply(this, arguments) || this;
115
    }
116
117
    var _proto = Popover.prototype;
118
119
    // Overrides
120
    _proto.isWithContent = function isWithContent() {
121
      return this.getTitle() || this._getContent();
122
    };
123
124
    _proto.addAttachmentClass = function addAttachmentClass(attachment) {
125
      $__default["default"](this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
126
    };
127
128
    _proto.getTipElement = function getTipElement() {
129
      this.tip = this.tip || $__default["default"](this.config.template)[0];
130
      return this.tip;
131
    };
132
133
    _proto.setContent = function setContent() {
134
      var $tip = $__default["default"](this.getTipElement()); // We use append for html objects to maintain js events
135
136
      this.setElementContent($tip.find(SELECTOR_TITLE), this.getTitle());
137
138
      var content = this._getContent();
139
140
      if (typeof content === 'function') {
141
        content = content.call(this.element);
142
      }
143
144
      this.setElementContent($tip.find(SELECTOR_CONTENT), content);
145
      $tip.removeClass(CLASS_NAME_FADE + " " + CLASS_NAME_SHOW);
146
    } // Private
147
    ;
148
149
    _proto._getContent = function _getContent() {
150
      return this.element.getAttribute('data-content') || this.config.content;
151
    };
152
153
    _proto._cleanTipClass = function _cleanTipClass() {
154
      var $tip = $__default["default"](this.getTipElement());
155
      var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
156
157
      if (tabClass !== null && tabClass.length > 0) {
158
        $tip.removeClass(tabClass.join(''));
159
      }
160
    } // Static
161
    ;
162
163
    Popover._jQueryInterface = function _jQueryInterface(config) {
164
      return this.each(function () {
165
        var data = $__default["default"](this).data(DATA_KEY);
166
167
        var _config = typeof config === 'object' ? config : null;
168
169
        if (!data && /dispose|hide/.test(config)) {
170
          return;
171
        }
172
173
        if (!data) {
174
          data = new Popover(this, _config);
175
          $__default["default"](this).data(DATA_KEY, data);
176
        }
177
178
        if (typeof config === 'string') {
179
          if (typeof data[config] === 'undefined') {
180
            throw new TypeError("No method named \"" + config + "\"");
181
          }
182
183
          data[config]();
184
        }
185
      });
186
    };
187
188
    _createClass(Popover, null, [{
189
      key: "VERSION",
190
      get: // Getters
191
      function get() {
192
        return VERSION;
193
      }
194
    }, {
195
      key: "Default",
196
      get: function get() {
197
        return Default;
198
      }
199
    }, {
200
      key: "NAME",
201
      get: function get() {
202
        return NAME;
203
      }
204
    }, {
205
      key: "DATA_KEY",
206
      get: function get() {
207
        return DATA_KEY;
208
      }
209
    }, {
210
      key: "Event",
211
      get: function get() {
212
        return Event;
213
      }
214
    }, {
215
      key: "EVENT_KEY",
216
      get: function get() {
217
        return EVENT_KEY;
218
      }
219
    }, {
220
      key: "DefaultType",
221
      get: function get() {
222
        return DefaultType;
223
      }
224
    }]);
225
226
    return Popover;
227
  }(Tooltip__default["default"]);
228
  /**
229
   * jQuery
230
   */
231
232
233
  $__default["default"].fn[NAME] = Popover._jQueryInterface;
234
  $__default["default"].fn[NAME].Constructor = Popover;
235
236
  $__default["default"].fn[NAME].noConflict = function () {
237
    $__default["default"].fn[NAME] = JQUERY_NO_CONFLICT;
238
    return Popover._jQueryInterface;
239
  };
240
241
  return Popover;
242
243
}));
244
//# sourceMappingURL=popover.js.map
245