Change saving active panel from js localStorage to via html #anker

This commit is contained in:
Jonny Tischbein 2018-11-24 00:44:11 +01:00
parent 62f09fdd57
commit 36aca259d5
2 changed files with 12 additions and 7 deletions

View File

@ -1163,6 +1163,7 @@ function admin_page_site_post(App $a)
$relay_scope = ((x($_POST,'relay_scope')) ? Strings::escapeTags(trim($_POST['relay_scope'])) : ''); $relay_scope = ((x($_POST,'relay_scope')) ? Strings::escapeTags(trim($_POST['relay_scope'])) : '');
$relay_server_tags = ((x($_POST,'relay_server_tags')) ? Strings::escapeTags(trim($_POST['relay_server_tags'])) : ''); $relay_server_tags = ((x($_POST,'relay_server_tags')) ? Strings::escapeTags(trim($_POST['relay_server_tags'])) : '');
$relay_user_tags = ((x($_POST,'relay_user_tags')) ? True : False); $relay_user_tags = ((x($_POST,'relay_user_tags')) ? True : False);
$active_panel = (defaults($_POST, 'active_panel', '') ? "#" . Strings::escapeTags(trim($_POST['active_panel'])) : '');
// Has the directory url changed? If yes, then resubmit the existing profiles there // Has the directory url changed? If yes, then resubmit the existing profiles there
if ($global_directory != Config::get('system', 'directory') && ($global_directory != '')) { if ($global_directory != Config::get('system', 'directory') && ($global_directory != '')) {
@ -1344,7 +1345,8 @@ function admin_page_site_post(App $a)
Config::set('system', 'rino_encrypt', $rino); Config::set('system', 'rino_encrypt', $rino);
info(L10n::t('Site settings updated.') . EOL); info(L10n::t('Site settings updated.') . EOL);
$a->internalRedirect('admin/site');
$a->internalRedirect('admin/site' . $active_panel);
return; // NOTREACHED return; // NOTREACHED
} }

View File

@ -40,13 +40,14 @@
}); });
$(function(){ $(function(){
$(".collapse").on('show.bs.collapse', function(e) { $(".collapse").on('show.bs.collapse', function(e) {
localStorage.setItem('activeTab', $(e.target).attr('id')); var id = $(e.target).attr('id');
$("input[name=active_panel]").val(id);
}); });
var activeTab = localStorage.getItem('activeTab'); var url = document.location.toString();
if (activeTab) { if ( url.match('#') ) {
$("#" + activeTab).collapse('show'); var element = '#'+url.split('#')[1];
window.scroll(0, $("#" + activeTab).offset().top - 120); $(element).addClass('in');
localStorage.removeItem('activeTab'); window.scroll(0, $(element).offset().top - 120);
} }
}); });
</script> </script>
@ -56,6 +57,7 @@
<h1>{{$title}} - {{$page}}</h1> <h1>{{$title}} - {{$page}}</h1>
<form action="{{$baseurl}}/admin/site" method="post"> <form action="{{$baseurl}}/admin/site" method="post">
<input type='hidden' name='form_security_token' value='{{$form_security_token}}'> <input type='hidden' name='form_security_token' value='{{$form_security_token}}'>
<input type='hidden' name='active_panel' value=''>
<div class="panel-group panel-group-settings" id="admin-settings" role="tablist" aria-multiselectable="true"> <div class="panel-group panel-group-settings" id="admin-settings" role="tablist" aria-multiselectable="true">
<!-- <!--
/* /*
@ -355,6 +357,7 @@
<input type='hidden' name='form_security_token' value='{{$form_security_token}}'> <input type='hidden' name='form_security_token' value='{{$form_security_token}}'>
{{include file="field_input.tpl" field=$relocate_url}} {{include file="field_input.tpl" field=$relocate_url}}
<input type="hidden" name="page_site" value="{{$submit|escape:'html'}}"> <input type="hidden" name="page_site" value="{{$submit|escape:'html'}}">
<input type='hidden' name='active_panel' value='admin-settings-relocate-collapse'>
<div class="panel-footer"> <div class="panel-footer">
<input type="submit" name="relocate" class="btn btn-primary" value="{{$relocate_button|escape:'html'}}"/> <input type="submit" name="relocate" class="btn btn-primary" value="{{$relocate_button|escape:'html'}}"/>
</div> </div>