1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-30 19:30:25 +02:00

Tabs and JS plugin navigation (e.g. Preferences page) remember now the last active tab

This commit is contained in:
SecretR
2013-04-06 19:41:10 +03:00
parent cddde10962
commit c39333a6b2
2 changed files with 29 additions and 40 deletions

View File

@@ -27,35 +27,6 @@ include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE);
$e_sub_cat = 'prefs';
e107::lan('core','mailout','admin');
//FIXME temporary fix - need universal solution.
e107::js('inline',"
$(document).ready(function()
{
var hash = document.location.hash;
if(hash)
{
$('.plugin-navigation a').each(function(index) {
var ot = $(this).attr('href');
$(ot).hide();
$(this).closest('li').removeClass('active');
$(this).switchClass( 'link-active', 'link', 0 );
});
var button = '#eplug-nav-' + hash.replace('#', '') + '-prev-nav';
$(hash).show();
$(button).switchClass('link', 'link-active', 30 );
$(button).closest('li').addClass('active');
}
else
{
$('#core-prefs-main').show();
}
});
","jquery");
e107::js('inline',"
function disp(type)
{

View File

@@ -1,5 +1,19 @@
$(document).ready(function()
{
// Change hash when a tab changes
$('.nav-tabs a').on('shown', function (event) {
var hash = event.target.href.toString().split('#')[1], form = $(event.target).parents('form')[0];
window.location.hash = '/' + hash;
if(form) {
$(form).attr('action', $(form).attr('action').split('#')[0] + '#/' + hash);
}
});
// tabs hash
if(/^#\/\w+/.test(window.location.hash)) {
var hash = window.location.hash.substr(2);
if(hash.match('^tab')) $('.nav-tabs a[href=#' + hash + ']').tab('show');
}
$('.e-typeahead').each(function() {
@@ -259,24 +273,31 @@ $(document).ready(function()
// Admin Prefs Navigation
$(".plugin-navigation a").click(function () {
// alert(document.location.hash);
$(".plugin-navigation a").each(function(index) {
var ot = $(this).attr("href");
$(ot).hide();
$(ot).hide().removeClass('e-hideme');
$(this).closest("li").removeClass("active");
$(this).switchClass( "link-active", "link", 0 );
});
var id = $(this).attr("href");
var id = $(this).attr("href"), hash = id.substr(1), form = $('.admin-menu')[0]; // FIXME - a better way to detect the page form
$(this).switchClass( "link", "link-active", 30 );
$(this).closest("li").addClass("active");
$(id).show({
$(id).removeClass('e-hideme').show({
effect: "slide"
});
return false; //FIXME See admin/prefs navigation.
});
// 'remember' the active navigation pane
window.location.hash = 'nav-' + hash;
if(form) {
$(form).attr('action', $(form).attr('action').split('#')[0] + '#nav-' + hash);
}
return false; //FIXME See admin/prefs navigation.
});
// plugin navigation hash
if(/^#nav-+/.test(window.location.hash)) {
$("a[href='" + window.location.hash.replace('nav-', '') + "']").click();
}
// backend
$(".e-password").pwdMeter({
@@ -558,9 +579,6 @@ $(document).ready(function()
// Text-area AutoGrow
// $("textarea.e-autoheight").elastic();
})