Merge pull request #36543 from thersane-john/fix_webportal_iframe_dialog
FIX : WebPortal dialog for iframe
This commit is contained in:
commit
bc0a3ddca3
6 changed files with 208 additions and 25 deletions
56
htdocs/public/webportal/css/btn.css
Normal file
56
htdocs/public/webportal/css/btn.css
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
|
||||
/*
|
||||
* BUTTON With Low emphasis
|
||||
*/
|
||||
|
||||
button.btn-low-emphasis{
|
||||
text-align: center;
|
||||
display: inline-block;
|
||||
border: none;
|
||||
outline: none;
|
||||
cursor: pointer;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: auto;
|
||||
min-width: 1.5em;
|
||||
min-height: 1.5em;
|
||||
line-height: 1.5em;
|
||||
|
||||
overflow: visible;
|
||||
background: transparent;
|
||||
background-position: center; /* used for hover ripple effect */
|
||||
background-size: 0%;
|
||||
color: var(--colortextlink, inherit);
|
||||
font: inherit;
|
||||
line-height: normal;
|
||||
|
||||
/* Corrects font smoothing for webkit */
|
||||
-webkit-font-smoothing: inherit;
|
||||
-moz-osx-font-smoothing: inherit;
|
||||
|
||||
/* Corrects inability to style clickable input types in iOS */
|
||||
-webkit-appearance: none;
|
||||
|
||||
|
||||
transition: background 0.8s;/* used for hover ripple effect */
|
||||
background: transparent radial-gradient(circle, transparent 1%, hsla(var(--colortextlink-h),var(--colortextlink-s) ,var(--colortextlink-l) , 0.1) 1%, transparent 10%) center/15000%;
|
||||
}
|
||||
|
||||
button.btn-low-emphasis.--btn-icon{
|
||||
border-radius: 100%;
|
||||
}
|
||||
|
||||
button.btn-low-emphasis :is(.fa, .fas){
|
||||
color: var(--colortextlink, inherit);
|
||||
opacity: 0.4;
|
||||
}
|
||||
|
||||
button.btn-low-emphasis:is(:focus,:hover) :is(.fa, .fas){
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
button.btn-low-emphasis.--btn-icon:active {
|
||||
background-color: hsla(var(--colortextlink-h),var(--colortextlink-s) ,var(--colortextlink-l) , 0.1);
|
||||
background-size: 100%;
|
||||
transition: background 0s;/* used for hover ripple effect */
|
||||
}
|
||||
91
htdocs/public/webportal/css/dialog.css
Normal file
91
htdocs/public/webportal/css/dialog.css
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
/* Dialog container */
|
||||
.dialog-full-screen article {
|
||||
width: 80vw;
|
||||
max-width: 95vw;
|
||||
height: 90vh;
|
||||
max-height: 95vh;
|
||||
|
||||
position: fixed;
|
||||
margin: 0 auto;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: nowrap;
|
||||
justify-content: normal;
|
||||
align-items: normal;
|
||||
align-content: normal;
|
||||
}
|
||||
|
||||
.dialog-full-screen article:has(.dialog-header) {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
||||
.dialog-full-screen article .dialog-body {
|
||||
display: block;
|
||||
flex-grow: 2;
|
||||
flex-shrink: 1;
|
||||
flex-basis: auto;
|
||||
align-self: auto;
|
||||
order: 0;
|
||||
}
|
||||
|
||||
@media (min-width: 576px) {
|
||||
dialog.dialog-full-screen article {
|
||||
max-width: 95%;
|
||||
}
|
||||
}
|
||||
@media (min-width: 768px) {
|
||||
dialog.dialog-full-screen article {
|
||||
max-width: 95%;
|
||||
}
|
||||
}
|
||||
|
||||
/* Iframe */
|
||||
.dialog-iframe {
|
||||
border: none;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!* Header *!*/
|
||||
.dialog-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0.5em 1em;
|
||||
border-bottom: 1px solid rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.dialog-header-title-container {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.dialog-header-title {
|
||||
margin: 0;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.dialog-header-action-container {
|
||||
flex: 0 0 auto;
|
||||
white-space: nowrap;
|
||||
display: flex;
|
||||
flex-direction: row-reverse;
|
||||
gap: 0.5em;
|
||||
}
|
||||
|
||||
/* Header title */
|
||||
.dialog-header h2 {
|
||||
margin: 0;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
/* Close button */
|
||||
dialog article .dialog-header-btn.close {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
|
@ -99,6 +99,8 @@ if (empty($dolibarr_nocache)) {
|
|||
@import "badges.css";
|
||||
@import "title-buttons.css";
|
||||
@import "nav.css";
|
||||
@import "dialog.css";
|
||||
@import "btn.css";
|
||||
/**
|
||||
This file can overwrite default pico css
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -117,44 +117,60 @@ if (empty($conf->browser->layout) || $conf->browser->layout != 'phone') { ?>
|
|||
jQuery(document).ready(function () {
|
||||
jQuery(".modal_card").click(function (event) {
|
||||
console.log("We click on card link for element with href=" + $(this).attr('href'));
|
||||
modal_card($(this).attr('href'));
|
||||
const modalTitle = $(this).data('modal-title') || $(this).attr('title') || '';
|
||||
modal_card($(this).attr('href'), modalTitle);
|
||||
event.preventDefault();
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Function show modal card. It uses the "modal" function.
|
||||
* Show modal card using Pico.css modal system
|
||||
*
|
||||
* @param url Url
|
||||
* @param title Dialog box title
|
||||
* @return void
|
||||
* @see newpopup()
|
||||
* @param {string} url - URL to load in the iframe
|
||||
* @param {string} title - Modal title
|
||||
*/
|
||||
function modal_card(url, title) {
|
||||
console.log("modal_card A click was done: url=" + url);
|
||||
function modal_card(url, title = '') {
|
||||
console.log("modal_card called: url=" + url);
|
||||
|
||||
let width = "85%";
|
||||
let object_width = '100%';
|
||||
let height = ($(window).height() - 60) * 0.90;
|
||||
let object_height = '98%';
|
||||
let newElem = '<a href="#close" aria-label="Close" class="close" onClick="close_modal_card()"></a><iframe id="card-frame" title="' +
|
||||
title + '" width="' + object_width + '" height="' + object_height + '" src="' + url + '"></iframe>';
|
||||
const modal = document.getElementById('modalforcard'); // Pico.css modal container
|
||||
if (!modal) {
|
||||
console.error('Modal container not found');
|
||||
return;
|
||||
}
|
||||
|
||||
$('#modalforcard article').css('width', width).css('height', height).html(newElem);
|
||||
let modal = document.getElementById('modalforcard');
|
||||
// Insert structured modal content
|
||||
modal.querySelector('article').innerHTML = `
|
||||
<div class="dialog-header">
|
||||
<div class="dialog-header-title-container" >
|
||||
<h2 class="dialog-header-title">${title}</h2>
|
||||
</div>
|
||||
<div class="dialog-header-action-container" >
|
||||
<button class="dialog-header-btn dialog-close-btn btn-low-emphasis close"></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dialog-body">
|
||||
<iframe class="dialog-iframe" src="${url}" title="${title}"></iframe>
|
||||
</div>
|
||||
`;
|
||||
|
||||
// Add close button handler
|
||||
const closeBtn = modal.querySelector('.dialog-close-btn');
|
||||
if (closeBtn) {
|
||||
closeBtn.addEventListener('click', () => close_modal_card());
|
||||
}
|
||||
|
||||
// Open modal via Pico.css function
|
||||
openModal(modal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function close modal card. It uses the "modal" function.
|
||||
*
|
||||
* @return void
|
||||
* Close modal card using Pico.css modal system
|
||||
*/
|
||||
function close_modal_card() {
|
||||
console.log("close_modal_card A click was done");
|
||||
const modal = document.getElementById('modalforcard');
|
||||
if (!modal) return;
|
||||
|
||||
let modal = document.getElementById('modalforcard');
|
||||
closeModal(modal);
|
||||
}
|
||||
|
||||
|
|
@ -215,6 +231,7 @@ if (empty($conf->browser->layout) || $conf->browser->layout != 'phone') { ?>
|
|||
}
|
||||
|
||||
function show_preview(mode) {
|
||||
// TODO : rebuild dialog tpl show modal_card
|
||||
let newElem = '<a href="#close" aria-label="Close" class="close" data-target="modalforpopup" onClick="toggleModal(event)"></a><object name="objectpreview" data="' +
|
||||
file + '" type="' + type + '" width="' + object_width + '" height="' + object_height + '" param="noparam"></object>';
|
||||
if (mode == 'image' && showOriginalSizeButton) {
|
||||
|
|
@ -252,8 +269,8 @@ if (empty($conf->browser->layout) || $conf->browser->layout != 'phone') { ?>
|
|||
</script>
|
||||
|
||||
<!-- A div to allow modal popup by modal -->
|
||||
<dialog id="modalforcard"><article></article></dialog>
|
||||
<dialog id="modalforpopup"><article></article></dialog>
|
||||
<dialog id="modalforcard" class="dialog-full-screen" ><article></article></dialog>
|
||||
<dialog id="modalforpopup" class="dialog-popup" ><article></article></dialog>
|
||||
<?php } ?>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@
|
|||
/**
|
||||
* @var Context $context Object context for webportal
|
||||
* @var Translate $langs
|
||||
* @@var string[] $vars['body-class'] more CSS classes for body
|
||||
* @@var string[] $vars['body-theme'] theme css to apply default is custom
|
||||
*/
|
||||
|
||||
// Protection to avoid direct call of template
|
||||
|
|
@ -85,6 +87,18 @@ top_httphead();
|
|||
// Common dolibarr js functions
|
||||
$jQueryUIJSUrl = $context->rootUrl.'js/lib_head.js.php';
|
||||
print '<script src="'.$jQueryUIJSUrl.'"></script>'."\n";
|
||||
|
||||
$bodyAttributes = [
|
||||
'data-theme' => $vars['body-theme']??'custom',
|
||||
'data-controller' => $context->controller,
|
||||
];
|
||||
|
||||
if (!empty($vars['body-class'])) {
|
||||
$bodyAttributes['class'] = $vars['body-class'];
|
||||
}
|
||||
|
||||
$bodyCompiledAttributes = commonHtmlAttributeBuilder($bodyAttributes);
|
||||
|
||||
?>
|
||||
</head>
|
||||
<body data-theme="custom" data-controller="<?php print dol_escape_htmltag($context->controller); ?>">
|
||||
<body <?php print empty($bodyCompiledAttributes) ? '' : implode(' ', $bodyCompiledAttributes); ?> >
|
||||
|
|
|
|||
|
|
@ -47,7 +47,10 @@ abstract class AbstractCardController extends Controller
|
|||
return;
|
||||
}
|
||||
|
||||
$this->loadTemplate('header');
|
||||
$this->loadTemplate('header', [
|
||||
'body-class' => empty($this->formCard->modal) ? '' : '--is-modal'
|
||||
]);
|
||||
|
||||
if (empty($this->formCard->modal)) {
|
||||
$this->loadTemplate('menu');
|
||||
$this->loadTemplate('hero-header-banner');
|
||||
|
|
|
|||
Loading…
Reference in a new issue