Skip to content

Commit

Permalink
Merge pull request #505 from linkdd/main
Browse files Browse the repository at this point in the history
feat: Add options to `M.AutoInit()`
  • Loading branch information
wuda-io authored Nov 13, 2024
2 parents 0fc1800 + 4925385 commit b9c12ed
Show file tree
Hide file tree
Showing 7 changed files with 391 additions and 345 deletions.
2 changes: 1 addition & 1 deletion dist/css/materialize.min.css.map

Large diffs are not rendered by default.

39 changes: 20 additions & 19 deletions dist/js/materialize.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7508,8 +7508,9 @@ function Button(children = '') {
/**
* Automatically initialize components.
* @param context Root element to initialize. Defaults to `document.body`.
* @param options Options for each component.
*/
function AutoInit(context = document.body) {
function AutoInit(context = document.body, options) {
let registry = {
Autocomplete: context.querySelectorAll('.autocomplete:not(.no-autoinit)'),
Carousel: context.querySelectorAll('.carousel:not(.no-autoinit)'),
Expand All @@ -7530,24 +7531,24 @@ function AutoInit(context = document.body) {
Tooltip: context.querySelectorAll('.tooltipped:not(.no-autoinit)'),
FloatingActionButton: context.querySelectorAll('.fixed-action-btn:not(.no-autoinit)')
};
Autocomplete.init(registry.Autocomplete, {});
Carousel.init(registry.Carousel, {});
Chips.init(registry.Chips, {});
Collapsible.init(registry.Collapsible, {});
Datepicker.init(registry.Datepicker, {});
Dropdown.init(registry.Dropdown, {});
Materialbox.init(registry.Materialbox, {});
Modal.init(registry.Modal, {});
Parallax.init(registry.Parallax, {});
Pushpin.init(registry.Pushpin, {});
ScrollSpy.init(registry.ScrollSpy, {});
FormSelect.init(registry.FormSelect, {});
Sidenav.init(registry.Sidenav, {});
Tabs.init(registry.Tabs, {});
TapTarget.init(registry.TapTarget, {});
Timepicker.init(registry.Timepicker, {});
Tooltip.init(registry.Tooltip, {});
FloatingActionButton.init(registry.FloatingActionButton, {});
Autocomplete.init(registry.Autocomplete, options?.Autocomplete ?? {});
Carousel.init(registry.Carousel, options?.Carousel ?? {});
Chips.init(registry.Chips, options?.Chips ?? {});
Collapsible.init(registry.Collapsible, options?.Collapsible ?? {});
Datepicker.init(registry.Datepicker, options?.Datepicker ?? {});
Dropdown.init(registry.Dropdown, options?.Dropdown ?? {});
Materialbox.init(registry.Materialbox, options?.Materialbox ?? {});
Modal.init(registry.Modal, options?.Modal ?? {});
Parallax.init(registry.Parallax, options?.Parallax ?? {});
Pushpin.init(registry.Pushpin, options?.Pushpin ?? {});
ScrollSpy.init(registry.ScrollSpy, options?.ScrollSpy ?? {});
FormSelect.init(registry.FormSelect, options?.FormSelect ?? {});
Sidenav.init(registry.Sidenav, options?.Sidenav ?? {});
Tabs.init(registry.Tabs, options?.Tabs ?? {});
TapTarget.init(registry.TapTarget, options?.TapTarget ?? {});
Timepicker.init(registry.Timepicker, options?.Timepicker ?? {});
Tooltip.init(registry.Tooltip, options?.Tooltip ?? {});
FloatingActionButton.init(registry.FloatingActionButton, options?.FloatingActionButton ?? {});
}
// Init
if (typeof document !== 'undefined') {
Expand Down
Loading

0 comments on commit b9c12ed

Please sign in to comment.