1.9.2 - fix for bug #218

This commit is contained in:
karol@jagiello.it 2019-01-02 02:24:39 +01:00
parent cae1943bce
commit 24407009d3
13 changed files with 120 additions and 126 deletions

File diff suppressed because one or more lines are too long

View File

@ -631,11 +631,6 @@
"hint_explained_new_tab_settings": {
"message": "Кнопка [+] в панели инструментов Tree Tabs помещает новые вкладки в корень активной группы, если не установлено иначе."
},
"hint_explained_orphan_after_active_settings": {
"message": "Если для опции «Открывать вкладки-сироты» установлено значение «после активной вкладки», а активная вкладка не находится в активной группе, вкладка добавится к корню активной группы. Но только если боковая панель открыта."
},
"button_background": {
"message": "Цвет кнопок панели инструментов"

View File

@ -491,7 +491,6 @@ function OnMessageTabCreated(NewTab, activeTabId) {
if (opt.append_orphan_tab == "after_active" || opt.append_orphan_tab == "active_parent_top" || opt.append_orphan_tab == "active_parent_bottom") {
if (b.windows[NewTab.windowId] && b.windows[NewTab.windowId].activeTabId) {
if (b.tabs[activeTabId]) {
let ActiveTabSiblings = GetChildren(b.tabs, b.tabs[activeTabId].parent);

View File

@ -45,5 +45,5 @@
"description": "close tree"
}
},
"version": "1.9.1"
"version": "1.9.2"
}

View File

@ -169,7 +169,8 @@
<label class="label" id="options_midclick_tab"></label>
<select id="midclick_tab">
<option class="bg_opt_drop_down_menu" id="options_action_tab_none" value="nothing"></option>
<option class="bg_opt_drop_down_menu" id="options_action_tab_new" value="new_tab"></option>
<option class="bg_opt_drop_down_menu" id="options_action_tab_new_sibling" value="new_tab"></option>
<option class="bg_opt_drop_down_menu" id="options_action_tab_new_child" value="new_child_tab"></option>
<option class="bg_opt_drop_down_menu" id="options_action_tab_expand_collapse" value="expand_collapse"></option>
<option class="bg_opt_drop_down_menu" id="options_action_tab_close" value="close_tab"></option>
<option class="bg_opt_drop_down_menu" id="options_action_tab_undo_close" value="undo_close_tab"></option>
@ -182,7 +183,8 @@
<label class="label" id="options_dbclick_tab"></label>
<select id="dbclick_tab">
<option class="bg_opt_drop_down_menu" id="options_action_tab_none" value="nothing"></option>
<option class="bg_opt_drop_down_menu" id="options_action_tab_new" value="new_tab"></option>
<option class="bg_opt_drop_down_menu" id="options_action_tab_new_sibling" value="new_tab"></option>
<option class="bg_opt_drop_down_menu" id="options_action_tab_new_child" value="new_child_tab"></option>
<option class="bg_opt_drop_down_menu" id="options_action_tab_expand_collapse" value="expand_collapse"></option>
<option class="bg_opt_drop_down_menu" id="options_action_tab_close" value="close_tab"></option>
<option class="bg_opt_drop_down_menu" id="options_action_tab_undo_close" value="undo_close_tab"></option>
@ -253,7 +255,6 @@
<option class="bg_opt_drop_down_menu" id="options_append_orphan_tab_active_parent_bottom" value="active_parent_bottom"></option>
<option class="bg_opt_drop_down_menu" id="options_append_orphan_tab_as_child" value="as_child"></option>
</select>
<span style="position: relative; left: 6px; display:block; font-size:10px; color: #c71414;" class="hint_explanation" id="hint_explained_orphan_after_active_settings"></span>
</li>
@ -266,6 +267,7 @@
<label class="label" id="options_toolbar_new_tab"></label>
<select id="append_tab_from_toolbar">
<option class="bg_opt_drop_down_menu" id="options_toolbar_new_tab_as_regular_orphan" value="as_regular_orphan"></option>
<option class="bg_opt_drop_down_menu" id="options_toolbar_new_tab_as_regular_child" value="as_regular_child"></option>
<option class="bg_opt_drop_down_menu" id="options_toolbar_new_tab_root_of_group" value="group_root"></option>
</select>
</li>

View File

@ -386,8 +386,18 @@ function DOM_DropToTarget(p) { // Class: ("group", "tab", "folder"), DraggedTabN
}, 500);
}
function DOM_AppendToNode(Node, AppendNode) {
if (Node != null && AppendNode != null) AppendNode.appendChild(Node);
function DOM_PreppendToNode(Node, PreppendToNode) {
if (Node != null && PreppendToNode != null) {
if (PreppendToNode.childNodes.length > 0) {
PreppendToNode.parentNode.insertBefore(Node, PreppendToNode.childNodes[0]);
} else {
PreppendToNode.appendChild(Node);
}
}
}
function DOM_AppendToNode(Node, AppendToNode) {
if (Node != null && AppendToNode != null) AppendToNode.appendChild(Node);
}
function DOM_InsterBeforeNode(Node, BeforeNode) {

View File

@ -269,7 +269,7 @@ function Folders_ActionClickFolder(FolderNode, bgOption) {
let FolderId = Folders_AddNewFolder({ParentId: FolderNode.id});
Folders_ShowRenameFolderDialog(FolderId);
}
if (bgOption == "new_tab") Tabs_OpenNewTab(false, undefined, FolderNode.childNodes[1]);
if (bgOption == "new_tab") Tabs_OpenNewTab(false, undefined, FolderNode.id, (opt.append_child_tab === "bottom" ? true : false));
if (bgOption == "expand_collapse") DOM_EventExpandBox(FolderNode);
if (bgOption == "close_folder") Folders_RemoveFolder(FolderNode.id);
if (bgOption == "unload_folder") {

View File

@ -121,7 +121,9 @@ function Groups_SaveGroups() {
function Groups_AppendGroups(groups) {
Groups_AppendGroupToList("tab_list", labels.ungrouped_group, "", true);
for (var group in groups) {
Groups_AppendGroupToList(groups[group].id, groups[group].name, groups[group].font, true);
if (groups[group].id) {
Groups_AppendGroupToList(groups[group].id, groups[group].name, groups[group].font, true);
}
if (document.querySelectorAll(".group").length == Object.keys(groups).length) {
Groups_RearrangeGroupsButtons();
setTimeout(function() {Groups_RearrangeGroupsLists();}, 50);
@ -351,10 +353,8 @@ function Groups_GroupsToolbarToggle() {
function Groups_ActionClickGroup(Node, bgOption) {
if (bgOption == "new_tab") {
if (Node.id == "pin_list") Tabs_OpenNewTab(true, undefined, undefined);
if (Node.classList.contains("tab")) Tabs_OpenNewTab(false, Node);
if (Node.classList.contains("folder")) Tabs_OpenNewTab(false, undefined, Node.childNodes[1]);
if (Node.classList.contains("group")) Tabs_OpenNewTab(false, undefined, Node.childNodes[0]);
if (Node.id == "pin_list") Tabs_OpenNewTab(true, undefined, undefined, true);
if (Node.classList.contains("group")) Tabs_OpenNewTab(false, undefined, Node.id, true);
}
if (bgOption == "activate_previous_active") {
chrome.tabs.update(parseInt(tt.groups[tt.active_group].prev_active_tab), {active: true});

View File

@ -9,22 +9,22 @@ class Menu_ttMenu {
if (this.id == "menu_new_pin") { this.Menu.onmousedown = function(event) { if (event.which == 1) {
if (tt.menuItemNode.classList.contains("pin")) {
console.log(tt.menuItemNode)
Tabs_OpenNewTab(true, tt.menuItemNode, undefined);
Tabs_OpenNewTab(true, tt.menuItemNode.id, undefined, undefined);
} else {
Tabs_OpenNewTab(true, undefined, undefined);
Tabs_OpenNewTab(true, undefined, undefined, (opt.append_orphan_tab === "top" ? false : true));
}
}}}
if (this.id == "menu_new_tab") { this.Menu.onmousedown = function(event) { if (event.which == 1) {
if (tt.menuItemNode.classList.contains("folder")) {
Tabs_OpenNewTab(false, undefined, tt.menuItemNode.childNodes[1]);
Tabs_OpenNewTab(false, undefined, tt.menuItemNode.id, (opt.append_orphan_tab === "top" ? false : true));
} else {
if (tt.menuItemNode.classList.contains("pin")) {
Tabs_OpenNewTab(true, tt.menuItemNode, undefined);
Tabs_OpenNewTab(true, tt.menuItemNode.id, undefined, undefined);
} else {
if (tt.menuItemNode.classList.contains("tab")) {
Tabs_OpenNewTab(false, tt.menuItemNode, undefined);
Tabs_OpenNewTab(false, tt.menuItemNode.id, undefined, undefined);
} else {
Tabs_OpenNewTab(false, undefined, document.getElementById("°"+tt.active_group));
Tabs_OpenNewTab(false, undefined, tt.active_group, (opt.append_orphan_tab === "top" ? false : true));
}
}
}

View File

@ -28,15 +28,15 @@ class Tabs_ttTab {
}
DIV_children.onmousedown = function(event) {
if (event.target == this) {
if (event.which == 2 && event.target == this) {
if (event.which == 2 && event.target == this && opt.midclick_tab !== "close_tab") {
event.stopImmediatePropagation();
Groups_ActionClickGroup(this.parentNode, opt.midclick_group);
Tabs_ActionClickTab(this.parentNode, opt.midclick_tab);
}
if (event.which == 3) Menu_ShowFGlobalMenu(event);
}
}
DIV_children.ondblclick = function(event) {
if (event.target == this) Groups_ActionClickGroup(this.parentNode, opt.dbclick_group);
if (event.target == this) Tabs_ActionClickTab(this.parentNode, opt.dbclick_tab);
}
DIV_expand.onmousedown = function(event) {
if (tt.DOMmenu.style.top != "-1000px") Menu_HideMenus();
@ -74,17 +74,9 @@ class Tabs_ttTab {
if (tt.DOMmenu.style.top != "-1000px") {
Menu_HideMenus();
} else {
if (event.shiftKey || event.ctrlKey) {
DOM_Select(event, this.parentNode);
}
// let tabId = parseInt(this.parentNode.id);
// setTimeout(function() {
// if (tt.Dragging == false && !event.shiftKey && !event.ctrlKey && event.target.classList.contains("tab_header") && event.target.parentNode.classList.contains("selected") == false) {
// chrome.tabs.update(tabId, {active: true});
// }
// }, 90);
}
}
if (event.which == 2) {
@ -93,35 +85,14 @@ class Tabs_ttTab {
}
if (event.which == 3) Menu_ShowTabMenu(this.parentNode, event);
}
DIV_header.onclick = function(event) {
if (!event.shiftKey && !event.ctrlKey) {
DOM_Deselect();
// let tabId = parseInt(this.parentNode.id);
if (event.target.classList.contains("tab_header")) {
chrome.tabs.update(parseInt(this.parentNode.id), {active: true});
// , function(tab) {
// if (was_selected) tt.tab[tab.id].Node.classList.add("selected");
// });
}
}
}
// DIV_header.onmouseup = function(event) {
// event.stopImmediatePropagation();
// if (tt.DOMmenu.style.top != "-1000px") {
// Menu_HideMenus();
// } else {
// if (event.which == 1 && !event.shiftKey && !event.ctrlKey && event.target.classList.contains("tab_header")) {
// DOM_Deselect();
// chrome.tabs.update(parseInt(this.parentNode.id), {active: true});
// }
// }
// }
DIV_header.onmouseover = function(event) {
this.classList.add("tab_header_hover");
if (opt.never_show_close == false && opt.always_show_close == false) this.classList.add("close_show");
@ -263,7 +234,7 @@ class Tabs_ttTab {
}
}
if (p.Append == true && parent) parent.appendChild(DIV_Tab);
if ((p.Append == false || p.Append == undefined) && parent) {parent.prepend(DIV_Tab);}
if ((p.Append == false || p.Append == undefined) && parent) parent.prepend(DIV_Tab);
if (p.InsertAfterId) {
let After = document.getElementById(p.InsertAfterId);
if (After != null) {
@ -675,43 +646,13 @@ function Tabs_CloseTabs(tabsIds) {
}, 200);
}
function Tabs_OpenNewTab(pin, InsertAfterNode, AppendToNode) {
// if (pin) {
chrome.tabs.create({pinned: pin}, function(tab) {
// console.log(tt.tabs[tab.id])
let Retry = setInterval(function() {
if (tt.tabs[tab.id]) {
if (InsertAfterNode) {
DOM_InsterAfterNode(tt.tabs[tab.id].Node, InsertAfterNode);
}
if (AppendToNode) {
DOM_AppendToNode(tt.tabs[tab.id].Node, AppendToNode);
}
tt.schedule_update_data++;
clearInterval(Retry);
}
}, 10);
setTimeout(function() {
if (Retry) clearInterval(Retry);
}, 500);
if (!pin && opt.move_tabs_on_url_change == "from_empty") chrome.runtime.sendMessage({command: "remove_tab_from_empty_tabs", tabId: tab.id});
// if (InsertAfterNode && tt.tabs[tab.id]) {
// let parent = document.getElementById("#pin_list");
// if (parent != null && tt.tabs[tab.id]) parent.appendChild(tt.tabs[tab.id].Node);
// }
});
// } else {
// chrome.tabs.create({}, function(tab) {
// if (parentId) {
// let parent = document.getElementById("#°"+parentId);
// if (parent != null && tt.tabs[tab.id]) parent.appendChild(tt.tabs[tab.id].Node);
// tt.schedule_update_data++;
// }
// });
// }
function Tabs_OpenNewTab(pin, InsertAfterTabId, ParentId, Append) {
chrome.tabs.create({pinned: pin}, function(tab) {
tt.tabs[tab.id] = new Tabs_ttTab({tab: tab, ParentId: ParentId, InsertAfterId: InsertAfterTabId, Append: Append, Scroll: true});
if (!pin && opt.move_tabs_on_url_change == "from_empty") chrome.runtime.sendMessage({command: "remove_tab_from_empty_tabs", tabId: tab.id});
DOM_RefreshGUI();
tt.schedule_update_data++;
});
}
function Tabs_GetTabDepthInTree(Node) {
@ -735,7 +676,14 @@ function Tabs_GetTabDepthInTree(Node) {
}
function Tabs_ActionClickTab(TabNode, bgOption) {
if (bgOption == "new_tab") Tabs_OpenNewTab(TabNode.classList.contains("pin"), TabNode);
if (bgOption == "new_tab") {
let pin = TabNode.classList.contains("pin");
Tabs_OpenNewTab(pin, TabNode.id, undefined, undefined);
}
if (bgOption == "new_child_tab") {
let pin = TabNode.classList.contains("pin");
Tabs_OpenNewTab(pin, (pin ? TabNode.id : undefined), (pin ? undefined : TabNode.id), ((opt.append_child_tab === "bottom" || opt.append_child_tab === "after") ? true : false));
}
if (bgOption == "expand_collapse") DOM_EventExpandBox(TabNode);
if (bgOption == "close_tab") {
if ((TabNode.classList.contains("pin") && opt.allow_pin_close) || TabNode.classList.contains("tab")) Tabs_CloseTabs([parseInt(TabNode.id)]);
@ -769,16 +717,6 @@ function Tabs_SetActiveTab(tabId, switchToGroup) {
if (Tab.classList.contains("tab")) Groups_SetActiveTabInGroup(TabGroup[0].id, tabId);
if (switchToGroup) Groups_SetActiveGroup(TabGroup[0].id, false, false); // not going to scroll, because mostly it's going to change to a new active in group AFTER switch, so we are not going to scroll to previous active tab
}
// let selected = document.querySelectorAll(".selected");
// for (let s of selected) {
// s.classList.remove("selected");
// }
// let selected_not_in_group = document.querySelectorAll(".pin, #" + tt.active_group + " .tab");
// for (let s of selected_not_in_group) {
// DOM_SetClasses(s, [], ["active_tab", "selected", "selected_last", "selected_frozen", "selected_temporarly", "tab_header_hover"], []);
// }
let active_tabs = document.querySelectorAll(".pin.active_tab, #" + tt.active_group + " .active_tab");
for (let s of active_tabs) {
DOM_SetClasses(s, [], ["active_tab"], []);

View File

@ -223,8 +223,54 @@ function Toolbar_SetToolbarEvents(CleanPreviousBindings, BindButtons, BindToolba
if (s.id == "button_new") { // NEW TAB
s.onclick = function(event) {
if (event.which == 1) {
if (opt.append_tab_from_toolbar == "group_root") Tabs_OpenNewTab(false, undefined, document.getElementById("°"+tt.active_group));
if (opt.append_tab_from_toolbar == "as_regular_orphan") Tabs_OpenNewTab(false, undefined, undefined);
if (opt.append_tab_from_toolbar === "as_regular_orphan") {
if (opt.append_orphan_tab === "top" || opt.append_orphan_tab === "bottom") Tabs_OpenNewTab(false, undefined, tt.active_group, (opt.append_orphan_tab === "bottom" ? true : false));
if (opt.append_orphan_tab === "after_active") {
let activeTab = document.querySelector("#" + tt.active_group + " .active_tab");
if (activeTab != null) {
Tabs_OpenNewTab(false, activeTab.id, undefined, undefined);
} else {
activeTab = document.querySelector(".pin.active_tab");
if (activeTab != null) {
Tabs_OpenNewTab(true, activeTab.id, undefined, undefined);
} else {
Tabs_OpenNewTab(false, undefined, tt.active_group, true);
}
}
}
if (opt.append_orphan_tab === "active_parent_top" || opt.append_orphan_tab === "active_parent_bottom") {
let activeTab = document.querySelector("#" + tt.active_group + " .active_tab") != null ? document.querySelector("#" + tt.active_group + " .active_tab") : document.querySelector(".pin.active_tab") != null ? document.querySelector(".pin.active_tab") : null;
if (activeTab != null) {
Tabs_OpenNewTab(false, undefined, activeTab.parentNode.parentNode.id, (opt.append_orphan_tab === "active_parent_bottom" ? true : false));
} else {
Tabs_OpenNewTab(false, undefined, tt.active_group, true);
}
}
}
if (opt.append_tab_from_toolbar === "as_regular_child" || (opt.append_tab_from_toolbar === "as_regular_orphan" && opt.append_orphan_tab === "as_child")) {
if (opt.append_child_tab === "top" || opt.append_child_tab === "bottom") {
let activeTab = document.querySelector("#" + tt.active_group + " .active_tab");
if (activeTab != null) {
Tabs_OpenNewTab(false, undefined, activeTab.id, ((opt.append_child_tab === "bottom" || opt.append_child_tab === "after") ? true : false));
} else {
activeTab = document.querySelector(".pin.active_tab");
if (activeTab != null) {
Tabs_OpenNewTab(true, activeTab.id, undefined, undefined);
} else {
Tabs_OpenNewTab(false, undefined, tt.active_group, true);
}
}
}
if (opt.append_child_tab === "after") {
let activeTab = document.querySelector("#" + tt.active_group + " .active_tab") != null ? document.querySelector("#" + tt.active_group + " .active_tab") : document.querySelector(".pin.active_tab") != null ? document.querySelector(".pin.active_tab") : null;
if (activeTab != null) {
Tabs_OpenNewTab(false, activeTab.id, undefined, undefined);
} else {
Tabs_OpenNewTab(false, undefined, tt.active_group, true);
}
}
}
if (opt.append_tab_from_toolbar === "group_root") Tabs_OpenNewTab(false, undefined, tt.active_group, true);
}
}
s.onmousedown = function(event) {

View File

@ -132,21 +132,24 @@ function StartSidebarListeners() {
return;
}
if (message.command == "tab_created") {
if (message.InsertAfterId && document.querySelectorAll("#" + tt.active_group + " .tab").length == 0) {
message.InsertAfterId = undefined;
message.ParentId = tt.active_group;
if (opt.debug) Utils_log("chrome event: " + message.command + ", tabId: " + message.tabId);
if (tt.tabs[message.tabId] == undefined) {
if (message.InsertAfterId && document.querySelectorAll("#" + tt.active_group + " .tab").length == 0) {
message.InsertAfterId = undefined;
message.ParentId = tt.active_group;
}
tt.tabs[message.tabId] = new Tabs_ttTab({tab: message.tab, ParentId: message.ParentId, InsertAfterId: message.InsertAfterId, Append: message.Append, Scroll: true});
DOM_RefreshExpandStates();
setTimeout(function() {
DOM_RefreshCounters();
DOM_RefreshGUI();
}, 50);
if (opt.syncro_tabbar_tabs_order) {
let tabIds = Array.prototype.map.call(document.querySelectorAll(".pin, .tab"), function(s) {return parseInt(s.id);});
chrome.tabs.move(message.tab.id, {index: tabIds.indexOf(message.tab.id)});
}
setTimeout(function() {tt.schedule_update_data++;}, 2000);
}
tt.tabs[message.tabId] = new Tabs_ttTab({tab: message.tab, ParentId: message.ParentId, InsertAfterId: message.InsertAfterId, Append: message.Append, Scroll: true});
DOM_RefreshExpandStates();
setTimeout(function() {
DOM_RefreshCounters();
DOM_RefreshGUI();
}, 50);
if (opt.syncro_tabbar_tabs_order) {
let tabIds = Array.prototype.map.call(document.querySelectorAll(".pin, .tab"), function(s) {return parseInt(s.id);});
chrome.tabs.move(message.tab.id, {index: tabIds.indexOf(message.tab.id)});
}
setTimeout(function() {tt.schedule_update_data++;}, 2000);
return;
}
if (message.command == "tab_attached") {
@ -316,7 +319,7 @@ function Initialize() {
for (const tab of window.tabs) {
if (bgtabs[tab.id] && !tab.pinned) {
let TabParent = document.getElementById("°"+bgtabs[tab.id].parent);
if (TabParent != null && document.querySelector("[id='"+tab.id+"'] #°"+bgtabs[tab.id].parent) == null) {
if (TabParent != null && document.querySelector("[id='"+tab.id+"'] #°"+bgtabs[tab.id].parent) == null && (TabParent.parentNode.classList.contains("tab") || TabParent.parentNode.classList.contains("folder") || TabParent.parentNode.classList.contains("group"))) {
TabParent.appendChild(tt.tabs[tab.id].Node);
}
}

View File

@ -112,7 +112,8 @@ const english_base = {
"options_midclick_tab":"",
"options_dbclick_tab":"",
"options_action_tab_none":"",
"options_action_tab_new":"",
"options_action_tab_new_sibling":"",
"options_action_tab_new_child":"",
"options_action_tab_expand_collapse":"",
"options_action_tab_close":"",
"options_action_tab_reload":"",
@ -186,6 +187,7 @@ const english_base = {
"options_export_debug":"",
"options_print_debug":"",
"options_toolbar_look":"",
"options_toolbar_new_tab_as_regular_child":"",
"hint_orphan_tab":"",
"hint_ctrl_t":"",
"hint_from_pin":"",
@ -193,7 +195,6 @@ const english_base = {
"hint_from_external_link":"",
"hint_from_popup":"",
"hint_explained_new_tab_settings":"",
"hint_explained_orphan_after_active_settings":"",
"button_background":"",
"button_hover_background":"",
"button_on_background":"",
@ -356,7 +357,7 @@ let translator = {
let OriginalText = document.createElement("div");
OriginalText.classList = "original";
OriginalText.id = p.id;
OriginalText.innerHTML = textValue;
OriginalText.innerHTML = '"'+p.id+'" - '+textValue;
body.appendChild(OriginalText);
this.OriginalText = OriginalText;
let TextBox = document.createElement("textarea");