1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-27 22:09:04 +02:00

Comply to the new rules.

This commit is contained in:
XhmikosR
2017-12-16 14:00:38 +02:00
parent 6d336502c7
commit 80d0943b95
32 changed files with 1798 additions and 1760 deletions

View File

@@ -1,7 +1,6 @@
import $ from 'jquery'
import Tooltip from './tooltip'
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.0.0-beta.3): popover.js
@@ -10,8 +9,6 @@ import Tooltip from './tooltip'
*/
const Popover = (($) => {
/**
* ------------------------------------------------------------------------
* Constants
@@ -31,10 +28,10 @@ const Popover = (($) => {
placement : 'right',
trigger : 'click',
content : '',
template : '<div class="popover" role="tooltip">'
+ '<div class="arrow"></div>'
+ '<h3 class="popover-header"></h3>'
+ '<div class="popover-body"></div></div>'
template : '<div class="popover" role="tooltip">' +
'<div class="arrow"></div>' +
'<h3 class="popover-header"></h3>' +
'<div class="popover-body"></div></div>'
}
const DefaultType = {
@@ -65,7 +62,6 @@ const Popover = (($) => {
MOUSELEAVE : `mouseleave${EVENT_KEY}`
}
/**
* ------------------------------------------------------------------------
* Class Definition
@@ -73,9 +69,7 @@ const Popover = (($) => {
*/
class Popover extends Tooltip {
// getters
// Getters
static get VERSION() {
return VERSION
@@ -105,8 +99,7 @@ const Popover = (($) => {
return DefaultType
}
// overrides
// Overrides
isWithContent() {
return this.getTitle() || this._getContent()
@@ -124,7 +117,7 @@ const Popover = (($) => {
setContent() {
const $tip = $(this.getTipElement())
// we use append for html objects to maintain js events
// We use append for html objects to maintain js events
this.setElementContent($tip.find(Selector.TITLE), this.getTitle())
let content = this._getContent()
if (typeof content === 'function') {
@@ -135,11 +128,11 @@ const Popover = (($) => {
$tip.removeClass(`${ClassName.FADE} ${ClassName.SHOW}`)
}
// private
// Private
_getContent() {
return this.element.getAttribute('data-content')
|| this.config.content
return this.element.getAttribute('data-content') ||
this.config.content
}
_cleanTipClass() {
@@ -150,12 +143,11 @@ const Popover = (($) => {
}
}
// static
// Static
static _jQueryInterface(config) {
return this.each(function () {
let data = $(this).data(DATA_KEY)
let data = $(this).data(DATA_KEY)
const _config = typeof config === 'object' ? config : null
if (!data && /destroy|hide/.test(config)) {
@@ -169,7 +161,7 @@ const Popover = (($) => {
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new Error(`No method named "${config}"`)
throw new TypeError(`No method named "${config}"`)
}
data[config]()
}
@@ -177,22 +169,20 @@ const Popover = (($) => {
}
}
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = Popover._jQueryInterface
$.fn[NAME] = Popover._jQueryInterface
$.fn[NAME].Constructor = Popover
$.fn[NAME].noConflict = function () {
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT
return Popover._jQueryInterface
}
return Popover
})($)
export default Popover