Return to previous tab (Content & Settings)

- Return to previously active tab after deleting content
- Return to previously active tab after saving settings
This commit is contained in:
Guillaume 2019-01-26 23:12:31 +01:00 committed by GitHub
parent b245ac0028
commit 1e2d279e6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 17 deletions

View File

@ -20,7 +20,7 @@ checkRole(array('admin'));
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
editSettings($_POST);
Redirect::page('settings');
Redirect::page('settings'.$_POST['hash']);
}
// ============================================================================

View File

@ -166,7 +166,7 @@ function table($type) {
?>
<!-- TABS -->
<ul class="nav nav-tabs" role="tablist">
<ul class="nav nav-tabs" role="tablist" onclick="hash=event.target.hash">
<li class="nav-item">
<a class="nav-link active" id="pages-tab" data-toggle="tab" href="#pages" role="tab"><?php $L->p('Pages') ?></a>
</li>
@ -279,15 +279,17 @@ $(document).ready(function() {
'type': 'hidden',
'name': 'type',
'value': 'delete'
}))));
}).append(jQuery('<input>', {
'type': 'hidden',
'name': 'hash',
'value': hash
})))));
form.hide().appendTo("body").submit();
});
// Open the tab defined in the URL
$('a[href="'+ window.location.hash +'"]').tab('show');
window.scrollTo(0);
});
</script>
<script>
// Open the tab defined in the URL
const anchor = window.location.hash;
$(`a[href="${anchor}"]`).tab('show');
</script>

View File

@ -12,7 +12,7 @@
<!-- TABS -->
<nav class="mb-3">
<div class="nav nav-tabs" id="nav-tab" role="tablist">
<div class="nav nav-tabs" id="nav-tab" role="tablist" onclick="document.getElementById('jshash').value=event.target.hash">
<a class="nav-item nav-link active" id="nav-general-tab" data-toggle="tab" href="#general" role="tab" aria-controls="nav-general" aria-selected="false"><?php $L->p('General') ?></a>
<a class="nav-item nav-link" id="nav-advanced-tab" data-toggle="tab" href="#advanced" role="tab" aria-controls="nav-advanced" aria-selected="false"><?php $L->p('Advanced') ?></a>
<a class="nav-item nav-link" id="nav-seo-tab" data-toggle="tab" href="#seo" role="tab" aria-controls="nav-seo" aria-selected="false"><?php $L->p('SEO') ?></a>
@ -41,6 +41,12 @@
'name'=>'pageNotFound',
'value'=>$site->pageNotFound()
));
// Current tab
echo Bootstrap::formInputHidden(array(
'name'=>'hash',
'value'=>'#general'
));
?>
<!-- General tab -->
@ -345,6 +351,9 @@
}
});
// Open the tab defined in the URL
$('a[href="'+ window.location.hash +'"]').tab('show');
window.scrollTo(0);
});
</script>
@ -537,9 +546,3 @@
</div>
<?php echo Bootstrap::formClose(); ?>
<script>
// Open the tab defined in the URL
const anchor = window.location.hash;
$(`a[href="${anchor}"]`).tab('show');
</script>