Fixed action-buttons

This commit is contained in:
jose.gonzalez@pandorafms.com 2022-11-16 16:04:22 +01:00
parent 5478c14c21
commit 88766eb7cc
6 changed files with 91 additions and 30 deletions

View File

@ -913,7 +913,7 @@ if ($new_agent === false) {
__('Delete agent'),
'deleteAgent',
false,
'onClick=onClick="if (!confirm(\'"'.__('Are you sure?').'"\')) return false;\" href=\'index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente=\''.$id_agente,
'deleteAgentDialog('.$id_agente.')',
[
'icon' => 'delete',
'mode' => 'secondary',
@ -922,28 +922,24 @@ if ($new_agent === false) {
);
}
} else {
$submitButton = html_print_submit_button(
$submitButton = html_print_input_hidden('create_agent', 1);
$submitButton .= html_print_submit_button(
__('Create'),
'crtbutton',
false,
[ 'icon' => 'wand'],
true
);
$submitButton .= html_print_go_back_button(
'index.php?sec=gagente&sec2=godmode/agentes/modificar_agente',
['button_class' => ''],
true
);
$submitButton .= html_print_input_hidden('create_agent', 1);
}
html_print_div(
[
'class' => 'action-buttons',
'content' => $submitButton,
]
$submitButton .= html_print_go_back_button(
'index.php?sec=gagente&sec2=godmode/agentes/modificar_agente',
['button_class' => ''],
true
);
html_print_action_buttons($submitButton);
echo '</div></div>';
echo '</form>';
@ -965,6 +961,15 @@ ui_require_jquery_file('bgiframe');
}
}
function deleteAgentDialog($idAgente) {
confirmDialog({
title: "<?php echo __('Delete agent'); ?>",
message: "<?php echo __('This action is not reversible. Are you sure'); ?>",
onAccept: function() {
window.location.assign('index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente='+$idAgente);
}
});
}
//Use this function for change 3 icons when change the selectbox
function changeIcons() {
@ -1076,8 +1081,8 @@ ui_require_jquery_file('bgiframe');
paint_qrcode(
"<?php echo ui_get_full_url('mobile/index.php?page=agent&id='.$id_agente); ?>",
"#qr_code_agent_view",
256,
256
128,
128
);
}
$("#text-agente").prop('readonly', true);

View File

@ -956,17 +956,16 @@ if ($agents !== false) {
if ((bool) check_acl($config['id_user'], 0, 'AW') === true) {
// Create agent button.
echo '<form method="post" action="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente">';
html_print_div(
[
'class' => 'action-buttons',
'content' => html_print_submit_button(
__('Create agent'),
'crt-2',
false,
[ 'icon' => 'next' ],
true
),
]
html_print_action_buttons(
html_print_submit_button(
__('Create agent'),
'crt-2',
false,
[ 'icon' => 'next' ],
true
),
false,
'fixed_action_buttons'
);
echo '</form>';
}

View File

@ -3321,6 +3321,29 @@ function html_print_input_color($name, $value, $id='', $class=false, $return=fal
}
/**
* Action buttons.
*
* @param string $buttons Buttons for add.
* @param boolean $return Return.
* @param boolean $principal Principal Action buttons.
* @param string $class Special classes.
*
* @return mixed.
*/
function html_print_action_buttons(string $buttons, bool $return=false, bool $principal=true, string $class='fixed_action_buttons fixed_action_buttons_size')
{
return html_print_div(
[
'id' => ($principal === true) ? 'principal_action_buttons' : 'action_buttons_'.rand(),
'class' => 'action-buttons '.$class,
'content' => $buttons,
],
$return
);
}
/**
* Render an submit input button element.
*

View File

@ -30,7 +30,6 @@
}
.agent_qr {
width: 30%;
text-align: center;
box-sizing: border-box;
padding: 10px 0px;

View File

@ -9464,7 +9464,7 @@ button.ui-button.ui-widget.submit-cancel:active {
height: 40px;
border-top-right-radius: 8px;
border-bottom-right-radius: 8px;
margin-left: -59px;
margin-left: -56px;
border: 1px solid #c0ccdc;
background-color: #f6f7fb;
padding: 0 16px;
@ -9764,6 +9764,8 @@ tr.bring_next_field {
.fixed_action_buttons {
position: fixed;
padding: 0px;
bottom: 50px;
right: 10px;
}
.fixed_action_buttons_size {
width: 1064px;
}

View File

@ -1491,6 +1491,8 @@ require 'include/php_to_js_values.php';
?>
<script type="text/javascript" language="javascript">
// Handle the scroll.
$(document).ready(scrollFunction());
// When there are less than 5 rows, all rows must be white
var theme = "<?php echo $config['style']; ?>";
if (theme === 'pandora') {
@ -1505,6 +1507,10 @@ require 'include/php_to_js_values.php';
scrollFunction()
};
window.onresize = function() {
scrollFunction()
};
function scrollFunction() {
if (document.body.scrollTop > 400 || document.documentElement.scrollTop > 400) {
if (document.getElementById("top_btn")) {
@ -1515,6 +1521,33 @@ require 'include/php_to_js_values.php';
document.getElementById("top_btn").style.display = "none";
}
}
var separationHeight = 10;
// Position of the visible part of document.
var scrollTop = document.documentElement.scrollTop;
// Height of all document.
var scrollHeight = document.documentElement.scrollHeight;
// Height of visible window (browser).
var clientHeight = document.documentElement.clientHeight;
// Height of footer (Plus 10px).
var footerHeight = document.getElementById('foot').offsetHeight + separationHeight;
// Fixed action buttons element.
var actionButtons = document.getElementById('principal_action_buttons');
// Handle the position of principal_action_buttons.
if (actionButtons) {
var $bottom = '', $left = '';
if ((scrollHeight - clientHeight - scrollTop) < footerHeight) {
$bottom = 'bottom:'+(footerHeight - (scrollHeight - clientHeight - window.scrollY))+'px;';
} else {
$bottom = 'bottom:'+separationHeight+'px;';
}
if (actionButtons.classList.contains('fixed_action_buttons_size') === false) {
$left = 'left:'+(document.documentElement.offsetWidth - document.getElementById('principal_action_buttons').offsetWidth - 40)+'px;';
}
// Set the position of principal action buttons.
actionButtons.setAttribute('style', $left+$bottom);
}
}
// When the user clicks on the button, scroll to the top of the document.