-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Grzegorz Bujański
committed
Feb 27, 2023
1 parent
d4120a5
commit e5a3fad
Showing
12 changed files
with
139 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
MDB5 | ||
Version: FREE 6.1.0 | ||
Version: FREE 6.2.0 | ||
|
||
Documentation: | ||
https://mdbootstrap.com/docs/standard/ | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import { getjQuery, onDOMContentLoaded } from '../mdb/util/index'; | ||
import EventHandler from '../mdb/dom/event-handler'; | ||
import SelectorEngine from '../mdb/dom/selector-engine'; | ||
import BSCollapse from '../bootstrap/mdb-prefix/collapse'; | ||
|
||
/** | ||
* ------------------------------------------------------------------------ | ||
* Constants | ||
* ------------------------------------------------------------------------ | ||
*/ | ||
|
||
const NAME = 'collapse'; | ||
const DATA_KEY = `mdb.${NAME}`; | ||
const EVENT_KEY = `.${DATA_KEY}`; | ||
|
||
const EVENT_SHOW_BS = 'show.bs.collapse'; | ||
const EVENT_SHOWN_BS = 'shown.bs.collapse'; | ||
const EVENT_HIDE_BS = 'hide.bs.collapse'; | ||
const EVENT_HIDDEN_BS = 'hidden.bs.collapse'; | ||
|
||
const EVENT_SHOW = `show${EVENT_KEY}`; | ||
const EVENT_SHOWN = `shown${EVENT_KEY}`; | ||
const EVENT_HIDE = `hide${EVENT_KEY}`; | ||
const EVENT_HIDDEN = `hidden${EVENT_KEY}`; | ||
|
||
const SELECTOR_DATA_TOGGLE = '[data-mdb-toggle="collapse"]'; | ||
|
||
class Collapse extends BSCollapse { | ||
constructor(element, data = {}) { | ||
super(element, data); | ||
|
||
this._init(); | ||
} | ||
|
||
dispose() { | ||
EventHandler.off(this._element, EVENT_SHOW_BS); | ||
EventHandler.off(this._element, EVENT_SHOWN_BS); | ||
EventHandler.off(this._element, EVENT_HIDE_BS); | ||
EventHandler.off(this._element, EVENT_HIDDEN_BS); | ||
|
||
super.dispose(); | ||
} | ||
|
||
// Getters | ||
static get NAME() { | ||
return NAME; | ||
} | ||
|
||
// Private | ||
_init() { | ||
this._bindShowEvent(); | ||
this._bindShownEvent(); | ||
this._bindHideEvent(); | ||
this._bindHiddenEvent(); | ||
} | ||
|
||
_bindShowEvent() { | ||
EventHandler.on(this._element, EVENT_SHOW_BS, () => { | ||
EventHandler.trigger(this._element, EVENT_SHOW); | ||
}); | ||
} | ||
|
||
_bindShownEvent() { | ||
EventHandler.on(this._element, EVENT_SHOWN_BS, () => { | ||
EventHandler.trigger(this._element, EVENT_SHOWN); | ||
}); | ||
} | ||
|
||
_bindHideEvent() { | ||
EventHandler.on(this._element, EVENT_HIDE_BS, () => { | ||
EventHandler.trigger(this._element, EVENT_HIDE); | ||
}); | ||
} | ||
|
||
_bindHiddenEvent() { | ||
EventHandler.on(this._element, EVENT_HIDDEN_BS, () => { | ||
EventHandler.trigger(this._element, EVENT_HIDDEN); | ||
}); | ||
} | ||
} | ||
|
||
/** | ||
* ------------------------------------------------------------------------ | ||
* Data Api implementation - auto initialization | ||
* ------------------------------------------------------------------------ | ||
*/ | ||
|
||
SelectorEngine.find(SELECTOR_DATA_TOGGLE).forEach((el) => { | ||
let instance = Collapse.getInstance(el); | ||
if (!instance) { | ||
instance = new Collapse(el, { toggle: false }); | ||
} | ||
}); | ||
|
||
/** | ||
* ------------------------------------------------------------------------ | ||
* jQuery | ||
* ------------------------------------------------------------------------ | ||
* add .rating to jQuery only if jQuery is present | ||
*/ | ||
onDOMContentLoaded(() => { | ||
const $ = getjQuery(); | ||
|
||
if ($) { | ||
const JQUERY_NO_CONFLICT = $.fn[NAME]; | ||
$.fn[NAME] = Collapse.jQueryInterface; | ||
$.fn[NAME].Constructor = Collapse; | ||
$.fn[NAME].noConflict = () => { | ||
$.fn[NAME] = JQUERY_NO_CONFLICT; | ||
return Collapse.jQueryInterface; | ||
}; | ||
} | ||
}); | ||
|
||
export default Collapse; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters