1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-11 00:54:49 +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

@@ -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();
})