diff --git a/e107_admin/prefs.php b/e107_admin/prefs.php index d72d6fb7d..b699de494 100644 --- a/e107_admin/prefs.php +++ b/e107_admin/prefs.php @@ -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) { diff --git a/e107_web/js/core/admin.jquery.js b/e107_web/js/core/admin.jquery.js index 4d4729eef..07fa801a1 100644 --- a/e107_web/js/core/admin.jquery.js +++ b/e107_web/js/core/admin.jquery.js @@ -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(); - - - })