forked from ILIAS-eLearning/ILIAS
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
22 changed files
with
215 additions
and
48 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
15 changes: 15 additions & 0 deletions
15
components/ILIAS/UI/resources/js/Dropdown/dist/dropdown.js
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,15 @@ | ||
/** | ||
* This file is part of ILIAS, a powerful learning management system | ||
* published by ILIAS open source e-Learning e.V. | ||
* | ||
* ILIAS is licensed with the GPL-3.0, | ||
* see https://www.gnu.org/licenses/gpl-3.0.en.html | ||
* You should have received a copy of said license along with the | ||
* source code, too. | ||
* | ||
* If this is not the case or you just want to try ILIAS, you'll find | ||
* us at: | ||
* https://www.ilias.de | ||
* https://github.com/ILIAS-eLearning | ||
*/ | ||
!function(t){"use strict";function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var i=e(t);class n{#t;#e;#i;#n;constructor(t){if(this.#e=t,this.#t=t.ownerDocument,this.#i=this.#e.querySelector(":scope > button"),null===this.#i)throw new Error("Dropdown: Expected exactly one button in dropdown element.",this.#e);if(this.#n=this.#e.querySelector(":scope > ul"),null===this.#n)throw new Error("Dropdown: Expected exactly one ul in dropdown element.",this.#e);this.#i.addEventListener("click",this.#s)}#o=t=>{27===t.which&&this.hide()};#s=t=>{t.stopPropagation(),this.show()};#h=()=>{this.hide()};show(){this.#n.style.display="block",this.#i.setAttribute("aria-expanded","true"),this.#t.addEventListener("keydown",this.#o),this.#t.addEventListener("click",this.#h),this.#i.removeEventListener("click",this.#s)}hide(){this.#n.style.display="none",this.#i.setAttribute("aria-expanded","false"),this.#t.removeEventListener("keydown",this.#o),this.#t.removeEventListener("click",this.#h),this.#i.addEventListener("click",this.#s)}}i.default.UI=i.default.UI||{},i.default.UI.dropdown={},i.default.UI.dropdown.init=function(t){return new n(t)}}(il); |
This file was deleted.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
components/ILIAS/UI/resources/js/Dropdown/rollup.config.js
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,42 @@ | ||
/** | ||
* This file is part of ILIAS, a powerful learning management system | ||
* published by ILIAS open source e-Learning e.V. | ||
* | ||
* ILIAS is licensed with the GPL-3.0, | ||
* see https://www.gnu.org/licenses/gpl-3.0.en.html | ||
* You should have received a copy of said license along with the | ||
* source code, too. | ||
* | ||
* If this is not the case or you just want to try ILIAS, you'll find | ||
* us at: | ||
* https://www.ilias.de | ||
* https://github.com/ILIAS-eLearning | ||
*/ | ||
|
||
import terser from '@rollup/plugin-terser'; | ||
import copyright from '../../../../../../scripts/Copyright-Checker/copyright'; | ||
import preserveCopyright from '../../../../../../scripts/Copyright-Checker/preserveCopyright'; | ||
|
||
export default { | ||
external: [ | ||
'document', | ||
'ilias', | ||
], | ||
input: './src/index.js', | ||
output: { | ||
file: './dist/dropdown.js', | ||
format: 'iife', | ||
banner: copyright, | ||
globals: { | ||
document: 'document', | ||
ilias: 'il', | ||
}, | ||
plugins: [ | ||
terser({ | ||
format: { | ||
comments: preserveCopyright, | ||
}, | ||
}), | ||
], | ||
}, | ||
}; |
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,96 @@ | ||
/** | ||
* This file is part of ILIAS, a powerful learning management system | ||
* published by ILIAS open source e-Learning e.V. | ||
* | ||
* ILIAS is licensed with the GPL-3.0, | ||
* see https://www.gnu.org/licenses/gpl-3.0.en.html | ||
* You should have received a copy of said license along with the | ||
* source code, too. | ||
* | ||
* If this is not the case or you just want to try ILIAS, you'll find | ||
* us at: | ||
* https://www.ilias.de | ||
* https://github.com/ILIAS-eLearning | ||
*/ | ||
|
||
export default class Dropdown { | ||
/** | ||
* @type {Document} | ||
*/ | ||
#document; | ||
|
||
/** | ||
* @type {HTMLElement} | ||
*/ | ||
#element; | ||
|
||
/** | ||
* @type {HTMLElement} | ||
*/ | ||
#button; | ||
|
||
/** | ||
* @type {HTMLElement} | ||
*/ | ||
#list; | ||
|
||
/** | ||
* @param {HTMLElement} element | ||
*/ | ||
constructor(element) { | ||
this.#element = element; | ||
this.#document = element.ownerDocument; | ||
|
||
this.#button = this.#element.querySelector(':scope > button'); | ||
if (this.#button === null) { | ||
throw new Error('Dropdown: Expected exactly one button in dropdown element.', this.#element); | ||
} | ||
|
||
this.#list = this.#element.querySelector(':scope > ul'); | ||
if (this.#list === null) { | ||
throw new Error('Dropdown: Expected exactly one ul in dropdown element.', this.#element); | ||
} | ||
|
||
this.#button.addEventListener('click', this.#showOnClick); | ||
} | ||
|
||
/** | ||
* @type {function(KeyboardEvent)} | ||
*/ | ||
#hideOnEscape = (/** @param {KeyboardEvent} event */ event) => { | ||
if (event.which === 27) { // ESCAPE | ||
this.hide(); | ||
} | ||
}; | ||
|
||
/** | ||
* @type {function(KeyboardEvent)} | ||
*/ | ||
#showOnClick = (/** @param {KeyboardEvent} event */event) => { | ||
event.stopPropagation(); | ||
this.show(); | ||
}; | ||
|
||
/** | ||
* @type {function()} | ||
*/ | ||
#hideOnClick = () => { | ||
this.hide(); | ||
}; | ||
|
||
show() { | ||
this.#list.style.display = 'block'; | ||
this.#button.setAttribute('aria-expanded', 'true'); | ||
this.#document.addEventListener('keydown', this.#hideOnEscape); | ||
this.#document.addEventListener('click', this.#hideOnClick); | ||
this.#button.removeEventListener('click', this.#showOnClick); | ||
} | ||
|
||
hide() { | ||
this.#list.style.display = 'none'; | ||
this.#button.setAttribute('aria-expanded', 'false'); | ||
this.#document.removeEventListener('keydown', this.#hideOnEscape); | ||
this.#document.removeEventListener('click', this.#hideOnClick); | ||
this.#button.addEventListener('click', this.#showOnClick); | ||
} | ||
} |
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,23 @@ | ||
/** | ||
* This file is part of ILIAS, a powerful learning management system | ||
* published by ILIAS open source e-Learning e.V. | ||
* | ||
* ILIAS is licensed with the GPL-3.0, | ||
* see https://www.gnu.org/licenses/gpl-3.0.en.html | ||
* You should have received a copy of said license along with the | ||
* source code, too. | ||
* | ||
* If this is not the case or you just want to try ILIAS, you'll find | ||
* us at: | ||
* https://www.ilias.de | ||
* https://github.com/ILIAS-eLearning | ||
*/ | ||
|
||
import il from 'ilias'; | ||
import Dropdown from './Dropdown'; | ||
|
||
il.UI = il.UI || {}; | ||
il.UI.dropdown = {}; | ||
il.UI.dropdown.init = function (htmlElement) { | ||
return new Dropdown(htmlElement); | ||
}; |
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
2 changes: 1 addition & 1 deletion
2
components/ILIAS/UI/src/templates/default/Dropdown/tpl.standard.html
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
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
Oops, something went wrong.