From ef57faa773d307de540b748f283e9ff95b6a7a69 Mon Sep 17 00:00:00 2001 From: "karol@jagiello.it" <1cyfraikilkaliter> Date: Wed, 4 Jul 2018 17:29:50 +0200 Subject: [PATCH] 1.7.1 - Firefox quick fix for bug 149, 150, 151 --- ..files_firefox/manifest.json | 2 +- background.js | 6 ++++ listeners_bg.js | 58 ++++++++++++++++++++--------------- manifest.json | 2 +- scripts/events.js | 1 + sidebar.html | 2 +- 6 files changed, 44 insertions(+), 27 deletions(-) diff --git a/..files_firefox/manifest.json b/..files_firefox/manifest.json index 661cf39..7d3afd3 100644 --- a/..files_firefox/manifest.json +++ b/..files_firefox/manifest.json @@ -48,5 +48,5 @@ "page": "options.html", "open_in_tab": true }, - "version": "1.7.0" + "version": "1.7.1" } \ No newline at end of file diff --git a/background.js b/background.js index eee9d98..e90a6e6 100644 --- a/background.js +++ b/background.js @@ -259,6 +259,12 @@ function QuantumLoadTabs(retry) { } else { QuantumAppendWinTTId(winId); } + + if (b.windows[winId].activeTabId == undefined) { // legacy + b.windows[winId].activeTabId = [0,0]; // legacy + } // legacy + + for (let tIndex = 0; tIndex < tabsCount; tIndex++) { let tab = w[winIndex].tabs[tIndex]; let tabIndex = tIndex; diff --git a/listeners_bg.js b/listeners_bg.js index 840e57f..e6a814b 100644 --- a/listeners_bg.js +++ b/listeners_bg.js @@ -488,6 +488,7 @@ function OnMessageTabCreated(tabId) { } else { if (opt.append_orphan_tab == "as_child" && opt.orphaned_tabs_to_ungrouped == false) { + // let atb = NewTab.active ? 0 : 1; NewTab.openerTabId = b.windows[NewTab.windowId].activeTabId[NewTab.active ? 0 : 1]; } @@ -623,34 +624,43 @@ function OnMessageTabCreated(tabId) { if (opt.append_orphan_tab == "after_active") { - let activeTabId = b.windows[NewTab.windowId].activeTabId[1] != NewTab.id ? b.windows[NewTab.windowId].activeTabId[1] : b.windows[NewTab.windowId].activeTabId[0]; - - // console.log(b.tabs[activeTabId].index); - if (b.tabs[activeTabId]) { - let ActiveSiblings = GetChildren(b.tabs[activeTabId].parent); - b.tabs[NewTab.id].parent = b.tabs[activeTabId].parent; - b.tabs[NewTab.id].index = b.tabs[activeTabId].index+1; - for (let i = ActiveSiblings.indexOf(activeTabId)+1; i < ActiveSiblings.length; i++) { // shift next siblings indexes - // let prev = b.tabs[ActiveSiblings[i]].index; - b.tabs[ActiveSiblings[i]].index += 1; - // console.log(prev + " " + b.tabs[ActiveSiblings[i]].index ); + if (b.windows[NewTab.windowId] && b.windows[NewTab.windowId].activeTabId) { + let activeTabId = b.windows[NewTab.windowId].activeTabId[1] != NewTab.id ? b.windows[NewTab.windowId].activeTabId[1] : b.windows[NewTab.windowId].activeTabId[0]; + + // console.log(b.tabs[activeTabId].index); + if (b.tabs[activeTabId]) { + let ActiveSiblings = GetChildren(b.tabs[activeTabId].parent); + b.tabs[NewTab.id].parent = b.tabs[activeTabId].parent; + b.tabs[NewTab.id].index = b.tabs[activeTabId].index+1; + for (let i = ActiveSiblings.indexOf(activeTabId)+1; i < ActiveSiblings.length; i++) { // shift next siblings indexes + // let prev = b.tabs[ActiveSiblings[i]].index; + b.tabs[ActiveSiblings[i]].index += 1; + // console.log(prev + " " + b.tabs[ActiveSiblings[i]].index ); + } + if (browserId == "F"){ + b.tabs[NewTab.id].parent_ttid = b.tabs[activeTabId].parent_ttid; + } + AfterId = activeTabId; + } else { // FAIL, no active tab! + let GroupTabs = GetChildren(b.windows[NewTab.windowId].active_group); + b.tabs[NewTab.id].parent = b.windows[NewTab.windowId].active_group; + if (browserId == "F"){ + b.tabs[NewTab.id].parent_ttid = ""; + } + if (GroupTabs.length > 0) { + b.tabs[NewTab.id].index = b.tabs[GroupTabs[GroupTabs.length-1]].index+1; + } else { + b.tabs[NewTab.id].index = 0; + } + ParentId = b.windows[NewTab.windowId].active_group; } - if (browserId == "F"){ - b.tabs[NewTab.id].parent_ttid = b.tabs[activeTabId].parent_ttid; - } - AfterId = activeTabId; - } else { // FAIL, no active tab! - let GroupTabs = GetChildren(b.windows[NewTab.windowId].active_group); - b.tabs[NewTab.id].parent = b.windows[NewTab.windowId].active_group; + } else { + b.tabs[NewTab.id].parent = "tab_list"; if (browserId == "F"){ b.tabs[NewTab.id].parent_ttid = ""; } - if (GroupTabs.length > 0) { - b.tabs[NewTab.id].index = b.tabs[GroupTabs[GroupTabs.length-1]].index+1; - } else { - b.tabs[NewTab.id].index = 0; - } - ParentId = b.windows[NewTab.windowId].active_group; + b.tabs[NewTab.id].index = NewTab.index; + ParentId = "tab_list"; } // console.log(b.tabs[NewTab.id].index); } diff --git a/manifest.json b/manifest.json index 661cf39..7d3afd3 100644 --- a/manifest.json +++ b/manifest.json @@ -48,5 +48,5 @@ "page": "options.html", "open_in_tab": true }, - "version": "1.7.0" + "version": "1.7.1" } \ No newline at end of file diff --git a/scripts/events.js b/scripts/events.js index b03c6b2..76580c9 100644 --- a/scripts/events.js +++ b/scripts/events.js @@ -29,6 +29,7 @@ function SetEvents() { document.oncontextmenu = function(event){ if (!event.ctrlKey && event.target.classList.contains("text_input") == false) { event.preventDefault(); + return false; } } document.body.onresize = function(event) { diff --git a/sidebar.html b/sidebar.html index 6e20670..494001d 100644 --- a/sidebar.html +++ b/sidebar.html @@ -32,7 +32,7 @@ -
+