38 lines
1.3 KiB
JavaScript
38 lines
1.3 KiB
JavaScript
wpj.windowUtils = {
|
|
getDefaultTab: function (type) {
|
|
return localStorage.getItem('defaultTab-' + type);
|
|
},
|
|
initDefaultTab: function (type) {
|
|
if ($('[data-tab]').length > 1) {
|
|
$('#setDefaultTab').closest('li').show();
|
|
if (wpj.windowUtils.getDefaultTab(type)) {
|
|
switchTab(wpj.windowUtils.getDefaultTab(type));
|
|
}
|
|
wpj.windowUtils.pinDefaultTab(type);
|
|
}
|
|
},
|
|
pinDefaultTab: function (type) {
|
|
$('li [data-tab] .pin').addClass('hidden');
|
|
const defaultTab = wpj.windowUtils.getDefaultTab(type);
|
|
if (defaultTab) {
|
|
$('[href="#' + defaultTab + '"]').find('.pin').removeClass('hidden');
|
|
$('#setDefaultTab').html('<span class="glyphicon fc icons_unpin"></span>Zrušit výchozí záložku');
|
|
} else {
|
|
$('#setDefaultTab').html('<span class="glyphicon fc icons_pin"></span>Nastavit jako výchozí záložku');
|
|
}
|
|
},
|
|
setDefaultTab: function (type) {
|
|
if (wpj.windowUtils.getDefaultTab(type)) {
|
|
localStorage.removeItem('defaultTab-' + type);
|
|
} else {
|
|
const activeTab = $('li.active [data-tab]');
|
|
if (activeTab) {
|
|
localStorage.setItem('defaultTab-' + type, activeTab.attr('href').substr(1));
|
|
}
|
|
}
|
|
wpj.windowUtils.pinDefaultTab(type);
|
|
|
|
return false;
|
|
}
|
|
};
|