Skip to content

Commit

Permalink
UI/Metabar: engage/disengage more-button
Browse files Browse the repository at this point in the history
  • Loading branch information
nhaagen committed Sep 14, 2023
1 parent 35b053e commit d25d819
Show file tree
Hide file tree
Showing 10 changed files with 648 additions and 326 deletions.
20 changes: 12 additions & 8 deletions src/UI/Implementation/Component/MainControls/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected function renderToolEntry(
$this->trigger_signals[] = $trigger_signal;
$btn_removetool = $close_buttons[$entry_id]
->withAdditionalOnloadCode(
fn ($id) => "il.UI.maincontrols.mainbar.addPartIdAndEntry('$mb_id', 'remover', '$id', true);"
fn($id) => "il.UI.maincontrols.mainbar.addPartIdAndEntry('$mb_id', 'remover', '$id', true);"
)
->withOnClick($trigger_signal);

Expand Down Expand Up @@ -268,13 +268,16 @@ function ($id) use ($signals) {
$entry_signal = $signals['entry'];
$close_slates_signal = $signals['close_slates'];
return "
il.UI.maincontrols.metabar.registerSignals(
'$id',
il.UI.maincontrols.metabar.init('$id');
il.UI.maincontrols.metabar.get('$id').registerSignals(
'$entry_signal',
'$close_slates_signal',
);
il.UI.maincontrols.metabar.init();
$(window).resize(il.UI.maincontrols.metabar.init);
il.UI.maincontrols.metabar.get('$id').init();
window.addEventListener(
'resize',
()=>{il.UI.maincontrols.metabar.get('$id').init()}
);
";
}
);
Expand Down Expand Up @@ -321,13 +324,13 @@ protected function renderSystemInfo(
$close = $close->withOnClick($signal);
$tpl->setVariable('CLOSE_BUTTON', $default_renderer->render($close));
$tpl->setVariable('CLOSE_URI', (string) $component->getDismissAction());
$component = $component->withAdditionalOnLoadCode(fn ($id) => "$(document).on('$signal', function() { il.UI.maincontrols.system_info.close('$id'); });");
$component = $component->withAdditionalOnLoadCode(fn($id) => "$(document).on('$signal', function() { il.UI.maincontrols.system_info.close('$id'); });");
}

$more = $this->getUIFactory()->symbol()->glyph()->more("#");
$tpl->setVariable('MORE_BUTTON', $default_renderer->render($more));

$component = $component->withAdditionalOnLoadCode(fn ($id) => "il.UI.maincontrols.system_info.init('$id')");
$component = $component->withAdditionalOnLoadCode(fn($id) => "il.UI.maincontrols.system_info.init('$id')");

$id = $this->bindJavaScript($component);
$tpl->setVariable('ID', $id);
Expand Down Expand Up @@ -454,7 +457,8 @@ public function registerResources(ResourceRegistry $registry): void
{
parent::registerResources($registry);
$registry->register('./src/UI/templates/js/MainControls/dist/mainbar.js');
$registry->register('./src/UI/templates/js/MainControls/metabar.js');
//$registry->register('./src/UI/templates/js/MainControls/metabar.js');
$registry->register('./src/UI/templates/js/MainControls/dist/maincontrols.min.js');
$registry->register('./src/GlobalScreen/Client/dist/GS.js');
$registry->register('./src/UI/templates/js/MainControls/system_info.js');
}
Expand Down
14 changes: 10 additions & 4 deletions src/UI/Implementation/Component/MainControls/Slate/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected function getCombinedSlateContents(
$triggerer = $triggerer
->withOnClick($trigger_signal)
->withAdditionalOnLoadCode(
fn ($id) => "
fn($id) => "
il.UI.maincontrols.mainbar.addTriggerSignal('{$trigger_signal}');
il.UI.maincontrols.mainbar.addPartIdAndEntry('{$mb_id}', 'triggerer', '{$id}');
"
Expand Down Expand Up @@ -132,9 +132,15 @@ protected function renderSlate(

$component = $component->withAdditionalOnLoadCode(
function ($id) use ($slate_signals, $mb_id): string {
$js = "fn = il.UI.maincontrols.slate.onSignal;";
$js = "";
foreach ($slate_signals as $key => $signal) {
$js .= "$(document).on('{$signal}', function(event, signalData) { fn('{$key}', event, signalData, '{$id}'); return false;});";
$js .= "$(document).on('{$signal}', function(event, signalData) {
il.UI.maincontrols.slate.onSignal('{$key}',
event,
signalData,
'{$id}'
);
return false;});";
}

if ($mb_id) {
Expand Down Expand Up @@ -168,7 +174,7 @@ protected function renderNotificationSlate(
public function registerResources(\ILIAS\UI\Implementation\Render\ResourceRegistry $registry): void
{
parent::registerResources($registry);
$registry->register('./src/UI/templates/js/MainControls/slate.js');
$registry->register('./src/UI/templates/js/MainControls/dist/maincontrols.min.js');
}

/**
Expand Down
15 changes: 15 additions & 0 deletions src/UI/templates/js/MainControls/dist/maincontrols.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

216 changes: 0 additions & 216 deletions src/UI/templates/js/MainControls/metabar.js

This file was deleted.

58 changes: 51 additions & 7 deletions src/UI/templates/js/MainControls/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,51 @@
export default {
input: './src/mainbar.js',
output: {
file: './dist/mainbar.js',
format: 'es'
}
};
/**
* 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 '../../../../../CI/Copyright-Checker/copyright';
import preserveCopyright from '../../../../../CI/Copyright-Checker/preserveCopyright';

export default [
{
input: './src/mainbar.js',
output: {
file: './dist/mainbar.js',
format: 'es',
},
},

{
input: './src/maincontrols.js',
output: {
file: './dist/maincontrols.min.js',
format: 'iife',
banner: copyright,
plugins: [
terser({
format: {
comments: preserveCopyright,
},
}),
],
globals: {
il: 'il',
jquery: '$',
},
},
external: ['il', 'jquery'],
},

];
Loading

0 comments on commit d25d819

Please sign in to comment.