summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/commons/bootstrap.js
blob: e5e1cbb1e62a4746c61f62b611d0839abd61e031 (plain)
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
74
75
76
77
78
import $ from 'jquery';

// bootstrap jQuery plugins
import 'bootstrap';

// custom jQuery functions
$.fn.extend({
  disable() {
    return $(this)
      .prop('disabled', true)
      .addClass('disabled');
  },
  enable() {
    return $(this)
      .prop('disabled', false)
      .removeClass('disabled');
  },
});

/*
 Starting with bootstrap 4.3.1, bootstrap sanitizes html used for tooltips / popovers.
 This extends the default whitelists with more elements / attributes:
 https://getbootstrap.com/docs/4.3/getting-started/javascript/#sanitizer
 */
const whitelist = $.fn.tooltip.Constructor.Default.whiteList;

const inputAttributes = ['value', 'type'];

const dataAttributes = [
  'data-toggle',
  'data-placement',
  'data-container',
  'data-title',
  'data-class',
  'data-clipboard-text',
  'data-placement',
];

// Whitelisting data attributes
whitelist['*'] = [
  ...whitelist['*'],
  ...dataAttributes,
  'title',
  'width height',
  'abbr',
  'datetime',
  'name',
  'width',
  'height',
];

// Whitelist missing elements:
whitelist.label = ['for'];
whitelist.button = [...inputAttributes];
whitelist.input = [...inputAttributes];

whitelist.tt = [];
whitelist.samp = [];
whitelist.kbd = [];
whitelist.var = [];
whitelist.dfn = [];
whitelist.cite = [];
whitelist.big = [];
whitelist.address = [];
whitelist.dl = [];
whitelist.dt = [];
whitelist.dd = [];
whitelist.abbr = [];
whitelist.acronym = [];
whitelist.blockquote = [];
whitelist.del = [];
whitelist.ins = [];
whitelist['gl-emoji'] = [];

// Whitelisting SVG tags and attributes
whitelist.svg = ['viewBox'];
whitelist.use = ['xlink:href'];
whitelist.path = ['d'];