Commit bf38ed68 authored by yPhil's avatar yPhil
Browse files

killTab:

- if numberOfFeeds : dialog(), else kill() silently
parent 3996db45
......@@ -708,16 +708,12 @@ PTL.dialog = {
$dialog.dialog('open');
});
},
killTab: function($button) {
killTab: function($button, tabName, $selectedTab, $selectedPanel, numberOfFeeds) {
$('div#ptlDialogs').load('/static/templates/dialogs.html #questionDialog', function() {
const $dialog = $(this),
$tabs = $('#tabs'),
$a = $button.prev('a.ui-tabs-anchor'),
tabId = $a.attr('href'),
$selectedTab = $a.parent(),
$selectedPanel = $tabs.find(tabId),
$icon = $dialog.find('div#icon > i'),
selectedTabIndex = $tabs.tabs('option', 'active'),
previousTabIndex = selectedTabIndex === 0 ? 0 : selectedTabIndex - 1;
......@@ -765,10 +761,9 @@ PTL.dialog = {
.addClass('dangerous')
.text(PTL.tr('This action cannot be undone.'))
.next('h2').text(PTL.tr('Name'))
.next('p').text($a.text())
.next('p').text(tabName)
.next('h2').text(PTL.tr('Number of feeds'))
.next('p').text($selectedPanel.find('li.feed').length);
.next('p').text(numberOfFeeds);
}
});
......
......@@ -34,7 +34,23 @@ PTL.tab = {
});
$tabs.on("click", "i.tabCloser", function() {
PTL.dialog.killTab($(this));
const $tabs = $('#tabs'),
$a = $(this).prev('a.ui-tabs-anchor'),
tabName = $a.text(),
tabId = $a.attr('href'),
$selectedTab = $a.parent(),
$selectedPanel = $tabs.find(tabId),
numberOfFeeds = $selectedPanel.find('li.feed').length;
if (numberOfFeeds) {
PTL.dialog.killTab($(this), $a.text(), $selectedTab, $selectedPanel, numberOfFeeds);
} else {
$selectedTab.remove();
$selectedPanel.remove();
PTL.tab.saveTabs();
}
});
if (PTL.util.isMobile()) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment