Completed
Push — dev5 ( 76b71a...013a5b )
by Ron
11:53
created

resources/js/template_files/tooltips.js   A

Complexity

Total Complexity 5
Complexity/F 1.67

Size

Lines of Code 33
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 16
mnd 2
bc 2
fnc 3
dl 0
loc 33
rs 10
bpm 0.6666
cpm 1.6666
noi 0
c 0
b 0
f 0
1
(function($) {
2
  'use strict';
3
4
  $(function() {
5
    /* Code for attribute data-custom-class for adding custom class to tooltip */
6
    if (typeof $.fn.tooltip.Constructor === 'undefined') {
7
      throw new Error('Bootstrap Tooltip must be included first!');
8
    }
9
10
    var Tooltip = $.fn.tooltip.Constructor;
11
12
    // add customClass option to Bootstrap Tooltip
13
    $.extend(Tooltip.Default, {
14
      customClass: ''
15
    });
16
17
    var _show = Tooltip.prototype.show;
18
19
    Tooltip.prototype.show = function() {
20
21
      // invoke parent method
22
      _show.apply(this, Array.prototype.slice.apply(arguments));
23
24
      if (this.config.customClass) {
25
        var tip = this.getTipElement();
26
        $(tip).addClass(this.config.customClass);
27
      }
28
29
    };
30
    $('[data-toggle="tooltip"]').tooltip();
31
32
  });
33
})(jQuery);