1441 |
ariadna |
1 |
define("core/local/collapsable_section/controls",["exports","core/local/collapsable_section/events","theme_boost/bootstrap/collapse"],(function(_exports,_events,_collapse){var obj;
|
|
|
2 |
/**
|
|
|
3 |
* The collapsable sections controls.
|
|
|
4 |
*
|
|
|
5 |
* @module core/local/collapsable_section/controls
|
|
|
6 |
* @copyright 2024 Ferran Recio <ferran@moodle.com>
|
|
|
7 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
8 |
*
|
|
|
9 |
* @example <caption>Example of controlling a collapsable section.</caption>
|
|
|
10 |
*
|
|
|
11 |
* import CollapsableSection from 'core/local/collapsable_section/controls';
|
|
|
12 |
*
|
|
|
13 |
* const section = CollapsableSection.instanceFromSelector('#MyCollapsableSection');
|
|
|
14 |
*
|
|
|
15 |
* // Use hide, show and toggle methods to control the section.
|
|
|
16 |
* section.hide();
|
|
|
17 |
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_collapse=(obj=_collapse)&&obj.__esModule?obj:{default:obj};let initialized=!1;return _exports.default=class{static instanceFromSelector(selector){const elements=document.querySelector(selector);if(!elements)throw new Error("No elements found with the selector: "+selector);return new this(elements)}static init(){initialized||(initialized=!0,document.addEventListener(_events.eventTypes.hiddenBsCollapse,(event=>{this.isCollapsableComponent(event.target)&&(0,_events.notifyCollapsableSectionHidden)(event.target)})),document.addEventListener(_events.eventTypes.shownBsCollapse,(event=>{this.isCollapsableComponent(event.target)&&(0,_events.notifyCollapsableSectionShown)(event.target)})))}static isCollapsableComponent(element){return element.hasAttribute("data-mdl-component")&&"core/local/collapsable_section"===element.getAttribute("data-mdl-component")}constructor(element){this.element=element}hide(){_collapse.default.getOrCreateInstance(this.element).hide()}show(){_collapse.default.getOrCreateInstance(this.element).show()}toggle(){_collapse.default.getOrCreateInstance(this.element).toggle()}isVisible(){return _collapse.default.getOrCreateInstance(this.element)._isShown()}},_exports.default}));
|
|
|
18 |
|
|
|
19 |
//# sourceMappingURL=controls.min.js.map
|