-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update mmenu to 8.3.0, add columns, add polyfill option (#40)
- Loading branch information
1 parent
17b12cb
commit 3f49fc0
Showing
112 changed files
with
2,673 additions
and
1,244 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
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
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
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,17 +1,20 @@ | ||
<?php | ||
|
||
$GLOBALS['TL_CSS'][] = 'bundles/contaommenu/mmenu/mmenu.css|static'; | ||
$GLOBALS['TL_JAVASCRIPT'][] = 'bundles/contaommenu/mmenu/mmenu.js|static'; | ||
$GLOBALS['TL_CSS']['contao_dk_mmenu'] = 'bundles/contaommenu/mmenu/mmenu.css|static'; | ||
|
||
if ($this->options['polyfill']) { | ||
$GLOBALS['TL_JAVASCRIPT']['contao_dk_mmenu.polyfill'] = 'bundles/contaommenu/mmenu/mmenu.polyfills.js|static'; | ||
} | ||
$GLOBALS['TL_JAVASCRIPT']['contao_dk_mmenu'] = 'bundles/contaommenu/mmenu/mmenu.js|static'; | ||
if ($this->options['drag']['menu']['open']) { | ||
$GLOBALS['TL_JAVASCRIPT'][] = 'bundles/contaommenu/hammerjs/hammer.min.js|static'; | ||
$GLOBALS['TL_JAVASCRIPT']['contao_dk_mmenu.hammerjs'] = 'bundles/contaommenu/hammerjs/hammer.min.js|static'; | ||
} | ||
|
||
?> | ||
<script> | ||
document.addEventListener( | ||
"DOMContentLoaded", () => { | ||
new Mmenu('#<?= $this->elementId ?>', <?= json_encode($this->options) ?>, <?= json_encode($this->configuration) ?>); | ||
} | ||
); | ||
document.addEventListener( | ||
"DOMContentLoaded", () => { | ||
new Mmenu('#<?= $this->elementId ?>', <?= json_encode($this->options) ?>, <?= json_encode($this->configuration) ?>); | ||
}, | ||
); | ||
</script> |
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,132 @@ | ||
/** | ||
* Create an element with classname. | ||
* | ||
* @param {string} selector The nodeName and classnames for the element to create. | ||
* @return {HTMLElement} The created element. | ||
*/ | ||
export function create(selector) { | ||
var args = selector.split('.'); | ||
var elem = document.createElement(args.shift()); | ||
// IE11: | ||
args.forEach(function (classname) { | ||
elem.classList.add(classname); | ||
}); | ||
// Better browsers: | ||
// elem.classList.add(...args); | ||
return elem; | ||
} | ||
/** | ||
* Find all elements matching the selector. | ||
* Basically the same as element.querySelectorAll() but it returns an actuall array. | ||
* | ||
* @param {HTMLElement} element Element to search in. | ||
* @param {string} filter The filter to match. | ||
* @return {array} Array of elements that match the filter. | ||
*/ | ||
export function find(element, filter) { | ||
return Array.prototype.slice.call(element.querySelectorAll(filter)); | ||
} | ||
/** | ||
* Find all child elements matching the (optional) selector. | ||
* | ||
* @param {HTMLElement} element Element to search in. | ||
* @param {string} filter The filter to match. | ||
* @return {array} Array of child elements that match the filter. | ||
*/ | ||
export function children(element, filter) { | ||
var children = Array.prototype.slice.call(element.children); | ||
return filter ? children.filter(function (child) { return child.matches(filter); }) : children; | ||
} | ||
/** | ||
* Find text excluding text from within child elements. | ||
* @param {HTMLElement} element Element to search in. | ||
* @return {string} The text. | ||
*/ | ||
export function text(element) { | ||
return Array.prototype.slice | ||
.call(element.childNodes) | ||
.filter(function (child) { return child.nodeType == 3; }) | ||
.map(function (child) { return child.textContent; }) | ||
.join(' '); | ||
} | ||
/** | ||
* Find all preceding elements matching the selector. | ||
* | ||
* @param {HTMLElement} element Element to start searching from. | ||
* @param {string} filter The filter to match. | ||
* @return {array} Array of preceding elements that match the selector. | ||
*/ | ||
export function parents(element, filter) { | ||
/** Array of preceding elements that match the selector. */ | ||
var parents = []; | ||
/** Array of preceding elements that match the selector. */ | ||
var parent = element.parentElement; | ||
while (parent) { | ||
parents.push(parent); | ||
parent = parent.parentElement; | ||
} | ||
return filter ? parents.filter(function (parent) { return parent.matches(filter); }) : parents; | ||
} | ||
/** | ||
* Find all previous siblings matching the selecotr. | ||
* | ||
* @param {HTMLElement} element Element to start searching from. | ||
* @param {string} filter The filter to match. | ||
* @return {array} Array of previous siblings that match the selector. | ||
*/ | ||
export function prevAll(element, filter) { | ||
/** Array of previous siblings that match the selector. */ | ||
var previous = []; | ||
/** Current element in the loop */ | ||
var current = element.previousElementSibling; | ||
while (current) { | ||
if (!filter || current.matches(filter)) { | ||
previous.push(current); | ||
} | ||
current = current.previousElementSibling; | ||
} | ||
return previous; | ||
} | ||
/** | ||
* Get an element offset relative to the document. | ||
* | ||
* @param {HTMLElement} element Element to start measuring from. | ||
* @param {string} [direction=top] Offset top or left. | ||
* @return {number} The element offset relative to the document. | ||
*/ | ||
export function offset(element, direction) { | ||
return (element.getBoundingClientRect()[direction] + | ||
document.body[direction === 'left' ? 'scrollLeft' : 'scrollTop']); | ||
} | ||
/** | ||
* Filter out non-listitem listitems. | ||
* @param {array} listitems Elements to filter. | ||
* @return {array} The filtered set of listitems. | ||
*/ | ||
export function filterLI(listitems) { | ||
return listitems.filter(function (listitem) { return !listitem.matches('.mm-hidden'); }); | ||
} | ||
/** | ||
* Find anchors in listitems (excluding anchor that open a sub-panel). | ||
* @param {array} listitems Elements to filter. | ||
* @return {array} The found set of anchors. | ||
*/ | ||
export function filterLIA(listitems) { | ||
var anchors = []; | ||
filterLI(listitems).forEach(function (listitem) { | ||
anchors.push.apply(anchors, children(listitem, 'a.mm-listitem__text')); | ||
}); | ||
return anchors.filter(function (anchor) { return !anchor.matches('.mm-btn_next'); }); | ||
} | ||
/** | ||
* Refactor a classname on multiple elements. | ||
* @param {HTMLElement} element Element to refactor. | ||
* @param {string} oldClass Classname to remove. | ||
* @param {string} newClass Classname to add. | ||
*/ | ||
export function reClass(element, oldClass, newClass) { | ||
if (element.matches('.' + oldClass)) { | ||
element.classList.remove(oldClass); | ||
element.classList.add(newClass); | ||
} | ||
} |
Oops, something went wrong.