mirror of
https://github.com/YunoHost/SSOwat.git
synced 2024-09-03 20:06:27 +02:00
Clarify the various cases and pave the way to merging with global.js
This commit is contained in:
parent
2646db9ea2
commit
85d59c5e77
2 changed files with 41 additions and 3 deletions
|
@ -199,9 +199,34 @@ function make_element_draggable(id) {
|
|||
---------------------------------------------------------- */
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
// Don't do this in iframe
|
||||
if (window.self !== window.top) {return false;}
|
||||
// 3 different cases :
|
||||
// - this script is loaded from inside an app
|
||||
// - this script is loaded inside the portal, inside an iframe/overlay activated by clicking the portal button inside an app
|
||||
// - this script is loaded inside the "regular" portal when going to /yunohost/sso.
|
||||
|
||||
var in_app = ! document.body.classList.contains('ynh-user-portal');
|
||||
var in_overlay_iframe = (window.self === window.top);
|
||||
|
||||
if (in_app)
|
||||
{
|
||||
init_portal_button_and_overlay();
|
||||
}
|
||||
else
|
||||
{
|
||||
init_portal();
|
||||
if (in_overlay_iframe) { tweak_portal_when_in_iframe(); }
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// This function is called when ynhpanel.js is included in an app
|
||||
//
|
||||
// It will create the small yunohost "portal button" usually in the bottom
|
||||
// right corner and initialize the portal overlay, shown when clicking the
|
||||
// portal button meant to make it easier to switch between apps.
|
||||
//
|
||||
function init_portal_button_and_overlay()
|
||||
{
|
||||
// Set and store meta viewport
|
||||
var meta_viewport = document.querySelector('meta[name="viewport"]');
|
||||
if (meta_viewport === null) {
|
||||
|
@ -259,3 +284,16 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||
});
|
||||
|
||||
});
|
||||
|
||||
//
|
||||
// This function is called to initialize elements like the app tile colors and other things ...
|
||||
//
|
||||
function init_portal()
|
||||
{
|
||||
// Import stuff from global.js ...
|
||||
}
|
||||
|
||||
function tweak_portal_when_in_iframe()
|
||||
{
|
||||
// Import stuff from global.js ...
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<meta name="msapplication-TileColor" content="#41444f">
|
||||
<meta name="msapplication-TileImage" content="/mstile-144x144.png">
|
||||
</head>
|
||||
<body class="{{#connected}}logged{{/connected}}">
|
||||
<body class="ynh-user-portal {{#connected}}logged{{/connected}}">
|
||||
|
||||
<h1 id="logo" class="logo">
|
||||
<img src="assets/img/logo-ynh-white.svg"/><span class="element-invisible">Yunohost</span>
|
||||
|
|
Loading…
Reference in a new issue