Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 1... Línea 1...
1
/**
1
/**
2
 * --------------------------------------------------------------------------
2
 * --------------------------------------------------------------------------
3
 * Bootstrap (v4.6.2): popover.js
3
 * Bootstrap popover.js
4
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
4
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
5
 * --------------------------------------------------------------------------
5
 * --------------------------------------------------------------------------
6
 */
6
 */
Línea 7... Línea -...
7
 
-
 
8
import $ from 'jquery'
7
 
-
 
8
import Tooltip from './tooltip'
Línea 9... Línea 9...
9
import Tooltip from './tooltip'
9
import { defineJQueryPlugin } from './util/index'
10
 
10
 
11
/**
11
/**
Línea 12... Línea 12...
12
 * Constants
12
 * Constants
13
 */
-
 
14
 
-
 
15
const NAME = 'popover'
-
 
16
const VERSION = '4.6.2'
-
 
17
const DATA_KEY = 'bs.popover'
-
 
18
const EVENT_KEY = `.${DATA_KEY}`
-
 
19
const JQUERY_NO_CONFLICT = $.fn[NAME]
-
 
20
const CLASS_PREFIX = 'bs-popover'
-
 
21
const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g')
-
 
Línea 22... Línea 13...
22
 
13
 */
23
const CLASS_NAME_FADE = 'fade'
14
 
Línea 24... Línea 15...
24
const CLASS_NAME_SHOW = 'show'
15
const NAME = 'popover'
25
 
16
 
26
const SELECTOR_TITLE = '.popover-header'
-
 
27
const SELECTOR_CONTENT = '.popover-body'
-
 
28
 
17
const SELECTOR_TITLE = '.popover-header'
-
 
18
const SELECTOR_CONTENT = '.popover-body'
-
 
19
 
29
const Default = {
20
const Default = {
30
  ...Tooltip.Default,
21
  ...Tooltip.Default,
31
  placement: 'right',
22
  content: '',
32
  trigger: 'click',
23
  offset: [0, 8],
-
 
24
  placement: 'right',
-
 
25
  template: '<div class="popover" role="tooltip">' +
33
  content: '',
26
    '<div class="popover-arrow"></div>' +
Línea 34... Línea 27...
34
  template: '<div class="popover" role="tooltip">' +
27
    '<h3 class="popover-header"></h3>' +
35
              '<div class="arrow"></div>' +
28
    '<div class="popover-body"></div>' +
36
              '<h3 class="popover-header"></h3>' +
29
    '</div>',
37
              '<div class="popover-body"></div></div>'
-
 
38
}
-
 
39
 
-
 
40
const DefaultType = {
-
 
41
  ...Tooltip.DefaultType,
-
 
42
  content: '(string|element|function)'
-
 
43
}
-
 
44
 
-
 
45
const Event = {
-
 
46
  HIDE: `hide${EVENT_KEY}`,
-
 
47
  HIDDEN: `hidden${EVENT_KEY}`,
-
 
48
  SHOW: `show${EVENT_KEY}`,
-
 
49
  SHOWN: `shown${EVENT_KEY}`,
-
 
50
  INSERTED: `inserted${EVENT_KEY}`,
30
  trigger: 'click'
Línea 51... Línea 31...
51
  CLICK: `click${EVENT_KEY}`,
31
}
52
  FOCUSIN: `focusin${EVENT_KEY}`,
32
 
53
  FOCUSOUT: `focusout${EVENT_KEY}`,
33
const DefaultType = {
Línea 54... Línea 34...
54
  MOUSEENTER: `mouseenter${EVENT_KEY}`,
34
  ...Tooltip.DefaultType,
55
  MOUSELEAVE: `mouseleave${EVENT_KEY}`
35
  content: '(null|string|element|function)'
56
}
-
 
57
 
-
 
58
/**
-
 
59
 * Class definition
-
 
60
 */
36
}
61
 
37
 
62
class Popover extends Tooltip {
38
/**
Línea 63... Línea -...
63
  // Getters
-
 
64
  static get VERSION() {
-
 
65
    return VERSION
-
 
66
  }
-
 
67
 
-
 
68
  static get Default() {
-
 
69
    return Default
-
 
70
  }
-
 
71
 
-
 
72
  static get NAME() {
-
 
73
    return NAME
-
 
74
  }
-
 
75
 
-
 
76
  static get DATA_KEY() {
-
 
77
    return DATA_KEY
-
 
78
  }
-
 
79
 
39
 * Class definition
80
  static get Event() {
40
 */
81
    return Event
41
 
Línea 82... Línea -...
82
  }
-
 
83
 
42
class Popover extends Tooltip {
84
  static get EVENT_KEY() {
43
  // Getters
85
    return EVENT_KEY
-
 
86
  }
-
 
87
 
-
 
88
  static get DefaultType() {
-
 
89
    return DefaultType
44
  static get Default() {
Línea -... Línea 45...
-
 
45
    return Default
90
  }
46
  }
91
 
47
 
92
  // Overrides
-
 
93
  isWithContent() {
48
  static get DefaultType() {
Línea 94... Línea 49...
94
    return this.getTitle() || this._getContent()
49
    return DefaultType
95
  }
50
  }
96
 
-
 
97
  addAttachmentClass(attachment) {
51
 
98
    $(this.getTipElement()).addClass(`${CLASS_PREFIX}-${attachment}`)
52
  static get NAME() {
99
  }
53
    return NAME
100
 
-
 
101
  getTipElement() {
-
 
102
    this.tip = this.tip || $(this.config.template)[0]
54
  }
103
    return this.tip
-
 
104
  }
-
 
105
 
-
 
106
  setContent() {
-
 
107
    const $tip = $(this.getTipElement())
55
 
Línea 108... Línea -...
108
 
-
 
109
    // We use append for html objects to maintain js events
56
  // Overrides
110
    this.setElementContent($tip.find(SELECTOR_TITLE), this.getTitle())
57
  _isWithContent() {
111
    let content = this._getContent()
-
 
112
    if (typeof content === 'function') {
-
 
113
      content = content.call(this.element)
-
 
114
    }
-
 
115
 
-
 
116
    this.setElementContent($tip.find(SELECTOR_CONTENT), content)
-
 
117
 
-
 
118
    $tip.removeClass(`${CLASS_NAME_FADE} ${CLASS_NAME_SHOW}`)
-
 
119
  }
-
 
120
 
58
    return this._getTitle() || this._getContent()
Línea 121... Línea 59...
121
  // Private
59
  }
122
  _getContent() {
60
 
123
    return this.element.getAttribute('data-content') ||
61
  // Private
124
      this.config.content
-
 
125
  }
62
  _getContentForTemplate() {
Línea 126... Línea 63...
126
 
63
    return {
127
  _cleanTipClass() {
64
      [SELECTOR_TITLE]: this._getTitle(),
128
    const $tip = $(this.getTipElement())
65
      [SELECTOR_CONTENT]: this._getContent()
Línea 129... Línea 66...
129
    const tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX)
66
    }
130
    if (tabClass !== null && tabClass.length > 0) {
67
  }
131
      $tip.removeClass(tabClass.join(''))
-
 
132
    }
68
 
Línea 133... Línea -...
133
  }
-
 
134
 
-
 
135
  // Static
-
 
136
  static _jQueryInterface(config) {
-
 
137
    return this.each(function () {
-
 
138
      let data = $(this).data(DATA_KEY)
69
  _getContent() {
139
      const _config = typeof config === 'object' ? config : null
-
 
140
 
70
    return this._resolvePossibleFunction(this._config.content)
141
      if (!data && /dispose|hide/.test(config)) {
71
  }
142
        return
72
 
Línea 143... Línea 73...
143
      }
73
  // Static
144
 
74
  static jQueryInterface(config) {
145
      if (!data) {
75
    return this.each(function () {
Línea 146... Línea -...
146
        data = new Popover(this, _config)
-
 
147
        $(this).data(DATA_KEY, data)
76
      const data = Popover.getOrCreateInstance(this, config)
148
      }
-
 
149
 
-
 
150
      if (typeof config === 'string') {
-
 
151
        if (typeof data[config] === 'undefined') {
-
 
Línea 152... Línea 77...
152
          throw new TypeError(`No method named "${config}"`)
77