mirror of
https://github.com/YunoHost/SSOwat.git
synced 2024-09-03 20:06:27 +02:00
Improve style and semantic
This commit is contained in:
parent
7734d248c5
commit
c62471703b
1 changed files with 34 additions and 38 deletions
|
@ -118,7 +118,7 @@ window.eventPreventDefault = function(event) {
|
||||||
http://jsfiddle.net/tovic/Xcb8d/light/
|
http://jsfiddle.net/tovic/Xcb8d/light/
|
||||||
-------------------------- */
|
-------------------------- */
|
||||||
|
|
||||||
var dragg = function(id) {
|
function make_element_draggable(id) {
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
this.elem = document.getElementById(id),
|
this.elem = document.getElementById(id),
|
||||||
|
@ -222,52 +222,48 @@ domReady(function(){
|
||||||
meta_viewport = document.querySelector('meta[name="viewport"]');
|
meta_viewport = document.querySelector('meta[name="viewport"]');
|
||||||
meta_viewport_content = meta_viewport.getAttribute('content');
|
meta_viewport_content = meta_viewport.getAttribute('content');
|
||||||
|
|
||||||
|
// Inject portal button
|
||||||
|
var portalButton = document.createElement('a');
|
||||||
|
portalButton.setAttribute('id', 'ynh-overlay-switch');
|
||||||
|
portalButton.setAttribute('href', '/yunohost/sso/');
|
||||||
|
portalButton.setAttribute('class', 'disableAjax');
|
||||||
|
document.body.insertBefore(portalButton, null);
|
||||||
|
// Make portal button draggable, for user convenience
|
||||||
|
make_element_draggable('ynh-overlay-switch');
|
||||||
|
|
||||||
// Create portal link
|
// Prepare and inject the portal overlay (what is activated when clicking on the portal button)
|
||||||
var portal = document.createElement('a');
|
var portalOverlay = document.createElement('iframe');
|
||||||
portal.setAttribute('id', 'ynh-overlay-switch');
|
portalOverlay.src = "/yunohost/sso/info.html";
|
||||||
portal.setAttribute('href', '/yunohost/sso/');
|
portalOverlay.setAttribute("id","ynh-overlay");
|
||||||
portal.setAttribute('class', 'disableAjax');
|
portalOverlay.setAttribute("style","visibility: hidden;"); // make sure the overlay is invisible already when loading it
|
||||||
document.body.insertBefore(portal, null);
|
document.body.insertBefore(portalOverlay, null);
|
||||||
|
|
||||||
// Portal link is draggable, for user convenience
|
// Inject portal stylesheet
|
||||||
dragg('ynh-overlay-switch');
|
// (we need it for the portal button to be displayed correctly)
|
||||||
|
|
||||||
|
|
||||||
// Create overlay element
|
|
||||||
var overlay = document.createElement('iframe');
|
|
||||||
overlay.src = "/yunohost/sso/info.html";
|
|
||||||
overlay.setAttribute("id","ynh-overlay");
|
|
||||||
overlay.setAttribute("style","visibility: hidden;"); // make sure the overlay is invisible already when loading it
|
|
||||||
|
|
||||||
document.body.insertBefore(overlay, null);
|
|
||||||
|
|
||||||
// Add portal stylesheet
|
|
||||||
// FIXME : check we really need to do this ... imho it's included directly in the html iframe ?
|
|
||||||
var portalStyle = document.createElement("link");
|
var portalStyle = document.createElement("link");
|
||||||
portalStyle.setAttribute("rel", "stylesheet");
|
portalStyle.setAttribute("rel", "stylesheet");
|
||||||
portalStyle.setAttribute("type", "text/css");
|
portalStyle.setAttribute("type", "text/css");
|
||||||
portalStyle.setAttribute("href", '/ynhpanel.css');
|
portalStyle.setAttribute("href", '/ynhpanel.css');
|
||||||
document.getElementsByTagName("head")[0].insertBefore(portalStyle, null);
|
document.getElementsByTagName("head")[0].insertBefore(portalStyle, null);
|
||||||
|
|
||||||
// Bind YNH Button
|
// Bind portal button
|
||||||
window.addEvent(portal, 'click', function(e){
|
window.addEvent(portalButton, 'click', function(e){
|
||||||
// Prevent default click
|
// Prevent default click
|
||||||
window.eventPreventDefault(e);
|
window.eventPreventDefault(e);
|
||||||
// Toggle overlay on YNHPortal button click
|
// Toggle overlay on YNHPortal button click
|
||||||
Element.toggleClass(overlay, 'visible');
|
Element.toggleClass(portalOverlay, 'visible');
|
||||||
Element.toggleClass(portal, 'visible');
|
Element.toggleClass(portalButton, 'visible');
|
||||||
Element.toggleClass(document.querySelector('html'), 'ynh-panel-active');
|
Element.toggleClass(document.querySelector('html'), 'ynh-panel-active');
|
||||||
Element.toggleClass(overlay, 'ynh-active');
|
Element.toggleClass(portalOverlay, 'ynh-active');
|
||||||
|
|
||||||
if(overlay.classList.contains('ynh-active')) {
|
if (portalOverlay.classList.contains('ynh-active')) {
|
||||||
meta_viewport.setAttribute('content', meta_viewport_content);
|
meta_viewport.setAttribute('content', meta_viewport_content);
|
||||||
Element.addClass(overlay, 'ynh-fadeIn');
|
Element.addClass(portalOverlay, 'ynh-fadeIn');
|
||||||
Element.removeClass(overlay, 'ynh-fadeOut');
|
Element.removeClass(portalOverlay, 'ynh-fadeOut');
|
||||||
}else {
|
} else {
|
||||||
meta_viewport.setAttribute('content', "width=device-width");
|
meta_viewport.setAttribute('content', "width=device-width");
|
||||||
Element.removeClass(overlay, 'ynh-fadeIn');
|
Element.removeClass(portalOverlay, 'ynh-fadeIn');
|
||||||
Element.addClass(overlay, 'ynh-fadeOut');
|
Element.addClass(portalOverlay, 'ynh-fadeOut');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue