Permalink
Browse files

remove useless iife

  • Loading branch information...
Johann-S committed Sep 26, 2018
1 parent 02c4444 commit 7c7a1706c348fcb5290a63d9249e0c8e4b6ebbcf
Showing with 3,053 additions and 3,095 deletions.
  1. +129 −133 js/src/alert.js
  2. +128 −132 js/src/button.js
  3. +408 −412 js/src/carousel.js
  4. +305 −309 js/src/collapse.js
  5. +383 −386 js/src/dropdown.js
  6. +2 −2 js/src/index.js
  7. +439 −443 js/src/modal.js
  8. +138 −142 js/src/popover.js
  9. +261 −265 js/src/scrollspy.js
  10. +194 −198 js/src/tab.js
  11. +555 −559 js/src/tooltip.js
  12. +111 −114 js/src/util.js
View
@@ -8,176 +8,172 @@ import Util from './util'
* --------------------------------------------------------------------------
*/
const Alert = (($) => {
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'alert'
const VERSION = '4.1.3'
const DATA_KEY = 'bs.alert'
const EVENT_KEY = `.${DATA_KEY}`
const DATA_API_KEY = '.data-api'
const JQUERY_NO_CONFLICT = $.fn[NAME]
const Selector = {
DISMISS : '[data-dismiss="alert"]'
}
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'alert'
const VERSION = '4.1.3'
const DATA_KEY = 'bs.alert'
const EVENT_KEY = `.${DATA_KEY}`
const DATA_API_KEY = '.data-api'
const JQUERY_NO_CONFLICT = $.fn[NAME]
const Selector = {
DISMISS : '[data-dismiss="alert"]'
}
const Event = {
CLOSE : `close${EVENT_KEY}`,
CLOSED : `closed${EVENT_KEY}`,
CLICK_DATA_API : `click${EVENT_KEY}${DATA_API_KEY}`
}
const ClassName = {
ALERT : 'alert',
FADE : 'fade',
SHOW : 'show'
}
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
const Event = {
CLOSE : `close${EVENT_KEY}`,
CLOSED : `closed${EVENT_KEY}`,
CLICK_DATA_API : `click${EVENT_KEY}${DATA_API_KEY}`
class Alert {
constructor(element) {
this._element = element
}
const ClassName = {
ALERT : 'alert',
FADE : 'fade',
SHOW : 'show'
// Getters
static get VERSION() {
return VERSION
}
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
// Public
class Alert {
constructor(element) {
this._element = element
close(element) {
let rootElement = this._element
if (element) {
rootElement = this._getRootElement(element)
}
// Getters
const customEvent = this._triggerCloseEvent(rootElement)
static get VERSION() {
return VERSION
if (customEvent.isDefaultPrevented()) {
return
}
// Public
this._removeElement(rootElement)
}
close(element) {
let rootElement = this._element
if (element) {
rootElement = this._getRootElement(element)
}
dispose() {
$.removeData(this._element, DATA_KEY)
this._element = null
}
const customEvent = this._triggerCloseEvent(rootElement)
// Private
if (customEvent.isDefaultPrevented()) {
return
}
_getRootElement(element) {
const selector = Util.getSelectorFromElement(element)
let parent = false
this._removeElement(rootElement)
if (selector) {
parent = document.querySelector(selector)
}
dispose() {
$.removeData(this._element, DATA_KEY)
this._element = null
if (!parent) {
parent = $(element).closest(`.${ClassName.ALERT}`)[0]
}
// Private
_getRootElement(element) {
const selector = Util.getSelectorFromElement(element)
let parent = false
if (selector) {
parent = document.querySelector(selector)
}
return parent
}
if (!parent) {
parent = $(element).closest(`.${ClassName.ALERT}`)[0]
}
_triggerCloseEvent(element) {
const closeEvent = $.Event(Event.CLOSE)
return parent
}
$(element).trigger(closeEvent)
return closeEvent
}
_triggerCloseEvent(element) {
const closeEvent = $.Event(Event.CLOSE)
_removeElement(element) {
$(element).removeClass(ClassName.SHOW)
$(element).trigger(closeEvent)
return closeEvent
if (!$(element).hasClass(ClassName.FADE)) {
this._destroyElement(element)
return
}
_removeElement(element) {
$(element).removeClass(ClassName.SHOW)
const transitionDuration = Util.getTransitionDurationFromElement(element)
if (!$(element).hasClass(ClassName.FADE)) {
this._destroyElement(element)
return
}
$(element)
.one(Util.TRANSITION_END, (event) => this._destroyElement(element, event))
.emulateTransitionEnd(transitionDuration)
}
const transitionDuration = Util.getTransitionDurationFromElement(element)
_destroyElement(element) {
$(element)
.detach()
.trigger(Event.CLOSED)
.remove()
}
$(element)
.one(Util.TRANSITION_END, (event) => this._destroyElement(element, event))
.emulateTransitionEnd(transitionDuration)
}
// Static
_destroyElement(element) {
$(element)
.detach()
.trigger(Event.CLOSED)
.remove()
}
static _jQueryInterface(config) {
return this.each(function () {
const $element = $(this)
let data = $element.data(DATA_KEY)
// Static
if (!data) {
data = new Alert(this)
$element.data(DATA_KEY, data)
}
static _jQueryInterface(config) {
return this.each(function () {
const $element = $(this)
let data = $element.data(DATA_KEY)
if (config === 'close') {
data[config](this)
}
})
}
if (!data) {
data = new Alert(this)
$element.data(DATA_KEY, data)
}
static _handleDismiss(alertInstance) {
return function (event) {
if (event) {
event.preventDefault()
}
if (config === 'close') {
data[config](this)
}
})
alertInstance.close(this)
}
}
}
static _handleDismiss(alertInstance) {
return function (event) {
if (event) {
event.preventDefault()
}
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
alertInstance.close(this)
}
}
}
$(document).on(
Event.CLICK_DATA_API,
Selector.DISMISS,
Alert._handleDismiss(new Alert())
)
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
$(document).on(
Event.CLICK_DATA_API,
Selector.DISMISS,
Alert._handleDismiss(new Alert())
)
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = Alert._jQueryInterface
$.fn[NAME].Constructor = Alert
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT
return Alert._jQueryInterface
}
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
return Alert
})($)
$.fn[NAME] = Alert._jQueryInterface
$.fn[NAME].Constructor = Alert
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT
return Alert._jQueryInterface
}
export default Alert
Oops, something went wrong.

0 comments on commit 7c7a170

Please sign in to comment.