var tabs = {
"search":{
url:'r',
},
"tab-users":{
url:'u',
parentTabId:'search',
parentTabIndex:1
},
"keywords-results":{
url:'k',
parentTabId:'tab-users',
parentTabIndex:1,
criteriaIndex:0,
resultsIndex:1,
normaDetailIndex:2,
extraktDetailIndex:3,
elearningIndex:4,
askAuthorIndex:5,
flexiGrid:null,
flexiGridCurrentCriteria:null, //flexgrid
flexiGridWGColumn:true,
flexiGridWidth:800,
extraktDetailWidth:800,
currentPermaId:null
},
"wg-results":{
url:'w',
parentTabId:'search',
parentTabIndex:3,
criteriaIndex:0,
wgIndex:1,
resultsIndex:2,
normaDetailIndex:3,
extraktDetailIndex:4,
elearningIndex:5,
askAuthorIndex:6,
searchCountsUpdated:false,
flexiGrid:null,
flexiGridCurrentCriteria:null, //flexgrid
flexiGridWGColumn:false,
flexiGridWidth:830,
selectedWG:null,
extraktDetailWidth:830,
currentPermaId:null
},
"cat-results":{
url:'c',
parentTabId:'search',
parentTabIndex:2,
criteriaIndex:0,
resultsIndex:1,
normaDetailIndex:2,
extraktDetailIndex:3,
elearningIndex:4,
askAuthorIndex:5,
searchCountsUpdated:false,
flexiGrid:null,
flexiGridCurrentCriteria:null, //flexgrid
flexiGridWGColumn:true,
flexiGridWidth:830,
extraktDetailWidth:830,
currentPermaId:null
},
"spravce-results":{
url:'s',
parentTabId:'tab-users',
parentTabIndex:2,
criteriaIndex:0,
resultsIndex:1,
normaDetailIndex:2,
extraktDetailIndex:3,
elearningIndex:4,
askAuthorIndex:5,
flexiGrid:null,
flexiGridCurrentCriteria:null, //flexgrid
flexiGridWGColumn:true,
flexiGridWidth:800,
extraktDetailWidth:800,
currentPermaId:null
},
"fulltext-results":{
url:'f',
parentTabId:'search',
parentTabIndex:0,
criteriaIndex:0,
resultsIndex:0,
normaDetailIndex:1,
extraktDetailIndex:2,
elearningIndex:3,
askAuthorIndex:4,
flexiGrid:null,
flexiGridCurrentCriteria:null, //flexgrid
flexiGridWGColumn:true,
flexiGridWidth:830,
extraktDetailWidth:830,
currentPermaId:null
}
};
function ajaxErrorHandler(grid)
{
$.jGrowl("Při požadavku na server nastala chyba.");
$(grid).flexReload();
}
function getSelectedCats()
{
return $('#cat-tab-criteria input:checkbox:checked,input:radio:checked').map(function() { return $(this).attr("id"); }).get().join(",");
}
function getSelectedKeywords()
{
return $("#keywords-search").val();
}
function searchResultClick(tabId, permaId)
{
refreshNormaDetail(tabId, permaId);
refreshExtraktDetail(tabId, permaId);
changeTab(tabId,tabs[tabId].normaDetailIndex,permaId);
}
function updateCatSearchAllCounts() {
if (!tabs["cat-results"].searchCountsUpdated) {
$.getJSON("./normas_categories_countall.php",
function(data){
$.each(data.cats, function(i,cat){
$("#cat-cnt-" + cat.id).text(cat.count);
});
});
tabs["cat-results"].searchCountsUpdated = true;
}
}
function updateWGSearchAllCounts() {
if (!tabs["wg-results"].searchCountsUpdated) {
$.getJSON("./normas_wg_countall.php",
function(data){
$.each(data.wgs, function(i,wg){
$("#wg-cnt-" + wg.id).text(wg.count);
});
});
tabs["wg-results"].searchCountsUpdated = true;
}
}
function updateSearchResultsCount(tabId, criteria, serverScript) {
$("#"+tabId).tabs('option', 'disabled', [tabs[tabId].normaDetailIndex,
tabs[tabId].extraktDetailIndex,
tabs[tabId].elearningIndex,
tabs[tabId].askAuthorIndex]);
if (criteria) {
$.ajax({
type: "GET",
cache: false,
url: serverScript+'?lang=cz',
data: {'criteria':criteria, 'count':1},
dataType: "json",
success: function(data) {
if (data.count > 0) {
$("#"+tabId+"-count").text(data.count);
$("#"+tabId+"-count-container").show();
$("#"+tabId).tabs('enable', tabs[tabId].resultsIndex);
if (data.count > 4) {
$.jGrowl("Zvoleným kritériím nyní vyhovuje
"+data.count+"
výsledků.\n", { life: 10000, closerTemplate: '[ zavřít vše ]
' });
} else if (data.count > 1) {
$.jGrowl("Zvoleným kritériím nyní vyhovuje "+data.count+"
výsledků.\n", { life: 10000, closerTemplate: '[ zavřít vše ]
' });
} else {
$.jGrowl("Zvoleným kritériím nyní vyhovuje "+data.count+"
výsledků.\n", { life: 10000, closerTemplate: '[ zavřít vše ]
' });
}
} else {
$("#"+tabId+"-count-container").hide();
$("#"+tabId).tabs('option', 'disabled', [tabs[tabId].resultsIndex,
tabs[tabId].normaDetailIndex,
tabs[tabId].extraktDetailIndex,
tabs[tabId].elearningIndex,
tabs[tabId].askAuthorIndex]);
$.jGrowl("Zvoleným kritériím nevyhovuje žádný výsledek.\nRozšiřte svá kritéria.", { life: 10000, closerTemplate: '[ zavřít vše ]
' });
}
},
error: function(data) {
$.jGrowl("Error occured during request to server. Cannot display results.");
}
});
} else {
$("#"+tabId+"-count-container").hide();
}
}
function updateSearchResults(tabId, criteria, serverScript, clickHandler) {
if (!tabs[tabId].flexiGrid) {
columnModel = [
{display: 'ID', name : 'id', width : 20, sortable : false, align: 'center', hide : true},
{display: "Číslo", name : 'cislo', width : 95, sortable : true, align: 'left', process:clickHandler},
{display: "Název", name : 'nazev', width : tabs[tabId].flexiGridWidth-310+(tabs[tabId].flexiGridWGColumn?0:110), sortable : true, align: 'left', process:clickHandler}
];
if (tabs[tabId].flexiGridWGColumn) {
columnModel.push({display: "WG", name : 'wg', width : 180, sortable : true, align: 'left', process:clickHandler});
}
tabs[tabId].flexiGrid = $("#"+tabId+"-flex").flexigrid({
url: serverScript+'?lang=cz&criteria='+criteria,
dataType: 'json',
colModel : columnModel,
sortname: "cislo",
sortorder: "asc",
usepager: true,
procmsg: "Načítám data, prosím čekejte...",
errormsg: "Chyba ve spojení",
pagestat: "Zobrazuji od {from} do {to} z celkových {total} výsledků",
resizable: false, //resizable table
nomsg: "Žádné výsledky",
//title: 'Normy',
useRp: false, //use the results per page select box
rp: 15, // results per page
showTableToggleBtn: true,
singleSelect: true,
width: tabs[tabId].flexiGridWidth,
height: 400,
onError: ajaxErrorHandler
});
} else {
if (!tabs[tabId].flexiGridCurrentCriteria || tabs[tabId].flexiGridCurrentCriteria != criteria) {
tabs[tabId].flexiGrid.flexOptions({url: serverScript+'?lang=cz&criteria='+criteria}).flexReload();
tabs[tabId].flexiGridCurrentCriteria = criteria;
changeTab(tabId, tabs[tabId].resultsIndex); //select result list tab
}
}
}
$('div.criteria-header h3').live('click', function() {
return false; //suppress default event
});
function resetTabs()
{
$('#cat-results').tabs('option','disabled', [1,2,3,4,5]);
$("#fulltext-results").tabs('option','disabled', [1,2,3,4,5]);
$("#fulltext-results").tabs('enable', 0);
$("#keywords-results").tabs('option','disabled', [1,2,3,4,5]);
$("#spravce-results").tabs('option', 'disabled', [1,2,3,4,5]);
$("#wg-results").tabs('option', 'disabled', [1,2,3,4,5,6]);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
$(document).ready(function() {
$('a[rel*=facebox]').facebox();
$("#search").tabs();
$("#fulltext-results").tabs();
$("#keywords-results").tabs();
$("#spravce-results").tabs();
$("#tab-users").tabs();
$("#cat-results").tabs();
$("#wg-results").tabs();
//default tab selected
$("#tab-users").tabs('select', 1);
$("#search").tabs('select', 0);
$("#keywords-results").tabs('select', 0);
$("#spravce-results").tabs('select', 0);
$("#wg-results").tabs('select', 0);
//style all text input tags (IE7 does not support CSS selectors to do that in CSS)
$('input[type=text]').addClass('input-text');
//tooltip everything
$('#ps-secondaryNavigation a[title], #ps-content a[title],label[title]').tooltip({
track: true,
delay: 0,
showURL: false,
//showBody: " - ",
fade: 250
});
$("#search").bind('tabsselect', function(event, ui) {
if (ui.index == 2) { //categories
updateCatSearchAllCounts();
}
});
$("#cat-results-count-container").hide();
$('#cat-tab-criteria input:checkbox').change(function(){
updateSearchResultsCount('cat-results',getSelectedCats(),"./normas_categories.php");
});
$('#cat-results').bind('tabsselect', function(event, ui) {
if (ui.index == 1) updateSearchResults("cat-results",getSelectedCats(),"normas_categories.php",function(celDiv, id){
$(celDiv).click(function(){searchResultClick('cat-results',id);})});
return true;
});
$('a[rel*=CatShowResults]').click(function(){
changeTab("cat-results", tabs["cat-results"].resultsIndex); //select result list tab
return false;
});
/////////////////////////////////////
//FULLTEXT
//submit
$("#fulltext-search").keypress(function (e) {
//$.jGrowl(e.which);
if (e.which == 13) {
//$("#fulltext-results-list-items").load('./normas_fulltext.php?query='+$.URLEncode($("#fulltext-search").val()));
$.ajax({
type: "GET",
cache: false,
url: "./normas_fulltext.php?lang=cz",
data: {'query':$("#fulltext-search").val()},
dataType: "html",
success: function(data) {
$("#fulltext-results-list-items").html(data);
},
error: function(data) {
$.jGrowl("Error occured during server request. Extract cannot be displayed.");
}
});
}
});
//pagination
$('a.fulltext_page').live('click', function() {
$.ajax({
type: "GET",
cache: false,
url: "./normas_fulltext.php?lang=cz",
data: {'page':$(this).attr("rel"),'query':$("#fulltext-search").val()},
dataType: "html",
success: function(data) {
$("#fulltext-results-list-items").html(data);
},
error: function(data) {
$.jGrowl("Error occured during server request. Extract cannot be displayed.");
}
});
return false; //suppress default event
});
$("a.norma_item").live('click',function () {
id = $(this).attr("rel");
searchResultClick('fulltext-results',id);
return false; //suppress default event
});
$('#fulltext-results').bind('tabsselect', function(event, ui) {
if (ui.index != tabs["fulltext-results"].askAuthorIndex) {
if ($("#query").val()) { //is the question to extract author in draft status?
if (!confirm("Máte rozepsaný dotaz autorovi extraktu. Přejete si jej smazat?")) {
return false; //suppress select tab event
}
}
//disable detail tabs
setTimeout(function() {
$("#fulltext-search").focus();
}, 100); //async disable (may be currently active)
}
return true;
});
////////////////////////////////////////////////////////////////
//user
$('#tab-users h1').live('click',function () {
$(this).next().toggle();
// id = $(this).attr("rel");
// $('body').scrollTo('#tocitembody-' + id);
});
////////////////////////////////////////////////////////////////
//keywords
//$("#keywords-full-list").load('./keywords_list.php');
$("#keywords-search").val('');
$('a[rel*=keywords-full-list-toggle]').click(function(){
$("#keywords-full-list").toggleClass('hidden');
return false;
});
$("#keywords-results").bind('tabsselect', function(event, ui) {
if (ui.index == tabs["keywords-results"].resultsIndex) updateSearchResults("keywords-results",getSelectedKeywords(),"normas_keywords.php",function(celDiv,id){
$(celDiv).click(function(){searchResultClick('keywords-results',id);})});
return true;
});
$('a[rel*=KeywordsShowResults]').click(function(){
changeTab('keywords-results', tabs['keywords-results'].resultsIndex);
return false;
});
$("#keywords-search").tokenInput("./keywords.php", {
hintText: "Napiště klíčová slova",
noResultsText: "Nenalezeno žádné klíčové slovo",
searchingText: "Hledám...",
minChars: 2,
classes: {
tokenList: "token-input-list-facebook",
token: "token-input-token-facebook",
tokenDelete: "token-input-delete-token-facebook",
selectedToken: "token-input-selected-token-facebook",
highlightedToken: "token-input-highlighted-token-facebook",
dropdown: "token-input-dropdown-facebook",
dropdownItem: "token-input-dropdown-item-facebook",
dropdownItem2: "token-input-dropdown-item2-facebook",
selectedDropdownItem: "token-input-selected-dropdown-item-facebook",
inputToken: "token-input-input-token-facebook"
},
onChange: function(){updateSearchResultsCount('keywords-results',getSelectedKeywords(),"./normas_keywords.php");},
fullList: "#keywords-full-list",
fullListSource: './keywords_list.php'
});
$("#keywords-results-count-container").hide();
////////////////////////////////////////////////////////////////
//laik
$("#laik-a1,#laik-a2,#laik-a3,#laik-a4,#laik-a5,#laik-a6,#laik-a7,#laik-a8").hide();
$("#tab-laik a[rel*=q]").click(function(){
//$.jGrowl(this.next());
$(this).parent().next().toggle();
return false; //suppress event
});
$('a[rel*=extrakt]').click(function(){
$("#metodika").html('');
if ($("#extrakt-laik").html() == "") {
$("#extrakt-laik").html('');
} else {
$("#extrakt-laik").html('');
}
return false; //suppress default event
});
$('a[rel*=metodika]').click(function(){
$("#extrakt-laik").html('');
if ($("#metodika").html() == "") {
$("#metodika").html('');
} else {
$("#metodika").html('');
}
return false; //suppress default event
});
$('a[rel*=selecttab]').click(function(){
//$.jGrowl($(this).attr("href"));
changeTab('search',parseInt($(this).attr("href")));
//$("#search").tabs('select', parseInt($(this).attr("href")));
return false; //suppress default event
});
////////////////////////////////////////////////////////////////
//spravce
$("#s-1,#s-2,#s-3,#s-4,#s-5,#s-6,#s-7").hide();
$("#spravce-results-criteria a[rel*=q]").click(function(){
//$.jGrowl(this.next());
$(this).next().toggle();
return false; //suppress event
});
$("#spravce-results-criteria a[rel*=l]").click(function(){
//$.jGrowl($(this).attr("href"));
criteria = $(this).attr("href");
updateSearchResults("spravce-results",criteria,"normas_spravce.php",function(celDiv,id){
$(celDiv).click(function(){searchResultClick('spravce-results',id);})});
//updateSpravceSearchResults(criteria);
$("#spravce-results").tabs('enable', tabs["spravce-results"].resultsIndex); //select result list tab
changeTab('spravce-results',tabs["spravce-results"].resultsIndex);
return false; //suppress event
});
$("#spravce-results-count-container").hide();
///////////////////////////////////////////////////////
// WorkGroups
$('#wg-results-overview tr:odd').addClass('odd');
$('#wg-results-overview tr:even').addClass('even');
$('#wg-results-overviewl td:first').addClass('first');
$('#wg-results-overview a.wg').click(function() {
tabs['wg-results'].selectedWG = $(this).attr("rel");
$("#wg-results").tabs('option', 'disabled', [tabs['wg-results'].normaDetailIndex,
tabs['wg-results'].extraktDetailIndex,
tabs['wg-results'].elearningIndex,
tabs['wg-results'].askAuthorIndex]);
$("#wg-results").tabs('load', tabs["wg-results"].wgIndex);
$("#wg-results").tabs('enable', tabs["wg-results"].wgIndex);
if ($("#wg-cnt-" + tabs['wg-results'].selectedWG).text() > 0) { //count of normas for wg > 0
$("#wg-results").tabs('enable', tabs["wg-results"].resultsIndex); //enable norma list tab
} else {
$("#wg-results").tabs('option', 'disabled', [tabs['wg-results'].resultsIndex,
tabs['wg-results'].normaDetailIndex,
tabs['wg-results'].extraktDetailIndex,
tabs['wg-results'].elearningIndex,
tabs['wg-results'].askAuthorIndex]);
}
$("#wg-results").tabs('url', tabs["wg-results"].wgIndex, lang+'/wg-'+$(this).attr("rel")+'.html');
//setTimeout(function() {$("#wg-results").tabs('select', 1);}, 100);
setTimeout(function() {changeTab("wg-results",tabs["wg-results"].wgIndex);}, 100);
return false;
});
$("#wg-results").bind('tabsselect', function(event, ui) {
if (ui.index == tabs["wg-results"].resultsIndex) {
updateSearchResults("wg-results",tabs['wg-results'].selectedWG,"normas_wg.php",function(celDiv,id){
$(celDiv).click(function(){searchResultClick('wg-results',id);})});
}
return true;
});
$("#search").bind('tabsselect', function(event, ui) {
if (ui.index == 3) { //main wg tab
updateWGSearchAllCounts();
}
});
$("#ps-content").css("visibility","visible");
//$("#ps-content").fadeIn("fast");
resetTabs();
});
function getUrlFromTabId(tabId)
{
return tabs[tabId].url;
}
function isTabDisabled(tabId, idx)
{
return ($.inArray(idx, $("#"+tabId).tabs('option','disabled')) != -1);
}
function isTabPermalinked(tabId, idx)
{
return isTabNormaDetail(tabId, idx) || isTabExtraktDetail(tabId, idx);
}
function isTabActive(tabId, idx)
{
return $("#"+tabId).tabs("option","active") == idx;
}
function isTabNormaDetail(tabId, idx)
{
return tabs[tabId].normaDetailIndex == idx;
}
function isTabExtraktDetail(tabId, idx)
{
return tabs[tabId].extraktDetailIndex == idx;
}
function isTabActiveAndVisible(tabId, idx)
{
return (isTabActive(tabId, idx) &&
(!tabs[tabId].parentTabId ||
isTabActiveAndVisible(tabs[tabId].parentTabId,tabs[tabId].parentTabIndex)));
}
function isTabActiveAndVisibleUsingTarget(tabId, idx, targetTabId, targetIdx)
{
if (tabId == targetTabId) { //is it on the same level?
if (idx == targetIdx) { //target will be active
return true;
}
} else {
if (isTabActive(tabId, idx) &&
(!tabs[tabId].parentTabId ||
isTabActiveAndVisibleUsingTarget(tabs[tabId].parentTabId,
tabs[tabId].parentTabIndex,
targetTabId,
targetIdx))) {
return true;
}
}
return false;
}
function removePermalink(state)
{
delete state ['norma'];
}
function addPermalink(id, state)
{
state ['norma'] = id;
}
function refreshNormaDetail(tabId, permaId)
{
//console.log("refreshing "+tabId + " id "+ permaId);
$("#"+tabId).tabs('enable', tabs[tabId].normaDetailIndex);
$('#'+tabId).tabs('url',tabs[tabId].normaDetailIndex,'./norma_detail.php?lang=cz&id='+permaId);
}
function refreshExtraktDetail(tabId, permaId)
{
$('#'+tabId).tabs('url',tabs[tabId].extraktDetailIndex,'./extrakt_detail.php?lang=cz&id='+permaId+'&width='+tabs[tabId].extraktDetailWidth);
$.ajax({
type: "GET",
cache: false,
url: "./extrakt_count.php",
data: {'id':permaId},
dataType: "json",
success: function(data) {
if (data.count > 0) {
$('#'+tabId).tabs('url',tabs[tabId].extraktDetailIndex,'./extrakt_detail.php?lang=cz&id='+permaId+'&width='+tabs[tabId].extraktDetailWidth);
$('#'+tabId).tabs('enable', tabs[tabId].extraktDetailIndex);
$.getJSON("./author_count.php?id="+permaId, function(data){
if (data.count > 0) {
$('#'+tabId).tabs('url', tabs[tabId].askAuthorIndex,'./author_question.php?lang=cz&id='+permaId);
$('#'+tabId).tabs('enable', tabs[tabId].askAuthorIndex);
} else {
$('#'+tabId).tabs('option', 'disabled', [tabs[tabId].elearningIndex,
tabs[tabId].askAuthorIndex]);
}
});
} else {
$('#'+tabId).tabs('option', 'disabled', [tabs[tabId].extraktDetailIndex,
tabs[tabId].elearningIndex,
tabs[tabId].askAuthorIndex]);
}
},
error: function(data) {
$.jGrowl("Při požadavku na server nastala chyba. Extrakt nelze zobrazit.");
}
});
}
function changeTab(tabId, idx)
{
changeTab(tabId, idx, null);
}
function changeTab(tabId, idx, permaId)
{
var state = $.bbq.getState();
//console.log("[changeTab]tabId="+tabId+",idx="+idx+",permaId="+permaId);
if (isTabDisabled(tabId, idx)) { //requested tab is disabled
//state[ getUrlFromTabId(tabId) ] = idx;
$.bbq.removeState(getUrlFromTabId(tabId));
} else {
//console.log("cannot set " + tabId + " to " + idx);
//state [ getUrlFromTabId(tabId) ] = 0; //resetting to first one
state[ getUrlFromTabId(tabId) ] = idx;
}
//console.log("trying change " + tabId + " to " + idx);
if (isTabPermalinked(tabId, idx)) {
if (permaId) {
addPermalink(permaId, state);
if (tabs[tabId].currentPermaId != permaId) {
//console.log("[changeTab]updating permalink "+ tabId + " from " + tabs[tabId].currentPermaId +" to " + permaId);
tabs[tabId].currentPermaId = permaId;
}
} else {
addPermalink(tabs[tabId].currentPermaId, state);
}
} else {
removePermalink(state);
if (!permaId && !tabs[tabId].normaDetailIndex && !tabs[tabId].extraktDetailIndex) {
for(var tabId2 in tabs) {
if ((tabs[tabId2].normaDetailIndex &&
isTabActiveAndVisibleUsingTarget(tabId2,tabs[tabId2].normaDetailIndex,tabId,idx) &&
tabs[tabId2].currentPermaId) ||
(tabs[tabId2].extraktDetailIndex &&
isTabActiveAndVisibleUsingTarget(tabId2,tabs[tabId2].extraktDetailIndex,tabId,idx) &&
tabs[tabId2].currentPermaId))
{
//console.log("[changeTab]addding permalink "+ tabId2 + " to " + tabs[tabId2].currentPermaId);
//console.log(tabs);
addPermalink(tabs[tabId2].currentPermaId, state);
break;
}
}
}
}
$.bbq.pushState( state, 2 /* replace all */);
}
$(function() {
// The "tab widgets" to handle.
var mytabs = $('.tab');
// Enable tabs on all tab widgets. The `event` property must be overridden so
// that the tabs aren't changed on click, and any custom event name can be
// specified. Note that if you define a callback for the 'select' event, it
// will be executed for the selected tab whenever the hash changes.
mytabs.tabs({ event: 'change' });
$("#search ul.ui-tabs-nav a").click(function(e){
//console.log("TAB CLICK");
// Get the id of this tab widget.
var tabId = $(this).closest( '.ui-tabs' ).attr( 'id' ),
// Get the index of this tab.
idx = $(this).parent().prevAll().length;
if (!isTabDisabled(tabId, idx)) { //requested tab is not disabled
changeTab(tabId, idx);
} else {
return false; //ignore the click
}
});
// Bind an event to window.onhashchange that, when the history state changes,
// iterates over all tab widgets, changing the current tab as necessary.
$(window).bind( 'hashchange', function(e) {
//console.log('hashchange');
mytabs.each(function(){
var tabId = this.id;
var idx = $.bbq.getState( getUrlFromTabId(tabId), true ) || 0;
if (isTabDisabled(tabId, idx)) { //requested tab is disabled
var permaId = $.bbq.getState('norma');
if (permaId) {
//console.log("enabling " + tabId + " idx " + idx);
$("#"+tabId).tabs('enable', tabs[tabId].normaDetailIndex);
$("#"+tabId).tabs('enable', tabs[tabId].extraktDetailIndex);
refreshNormaDetail(tabId, permaId);
refreshExtraktDetail(tabId, permaId);
$("#"+tabId).tabs('select', idx);
tabs[tabId].currentPermaId = permaId;
} else {
//console.log("cannot set " + tabId + " to " + idx);
$.bbq.removeState(getUrlFromTabId(tabId));
}
} else {
if (isTabPermalinked(tabId, idx)) {
var permaId = $.bbq.getState('norma');
if (permaId) {
//console.log("access " + tabId + " idx " + idx);
if (isTabActiveAndVisible(tabId,idx)) {
//console.log("[hashchange]active and visible " + tabId + " idx " + idx);
refreshNormaDetail(tabId, permaId);
refreshExtraktDetail(tabId, permaId);
$("#"+tabId).tabs('load', idx); //load does not like when tab is not active
if (tabs[tabId].currentPermaId != permaId) {
//console.log("[hashchange]updating permalink "+ tabId + " from " + tabs[tabId].currentPermaId +" to " + permaId);
tabs[tabId].currentPermaId = permaId;
}
}
}
}
// Select the appropriate tab for this tab widget by triggering the custom
// event specified in the .tabs() init above (you could keep track of what
// tab each widget is on using .data, and only select a tab if it has
// changed).
$("#"+tabId).tabs('select', idx);
}
});
})
// Since the event is only triggered when the hash changes, we need to trigger
// the event now, to handle the hash the page may have loaded with.
$(window).trigger( 'hashchange' );
});